xref: /freebsd-12.1/contrib/file/magic/Magdir/ruby (revision 40427cca)
1b6cee71dSXin LI
2b6cee71dSXin LI#------------------------------------------------------------------------------
3*40427ccaSGordon Tetlow# $File: ruby,v 1.7 2017/08/14 13:39:18 christos Exp $
4b6cee71dSXin LI# ruby:  file(1) magic for Ruby scripting language
5b6cee71dSXin LI# URL:  http://www.ruby-lang.org/
6b6cee71dSXin LI# From: Reuben Thomas <[email protected]>
7b6cee71dSXin LI
8b6cee71dSXin LI# Ruby scripts
9b6cee71dSXin LI0	search/1/w	#!\ /usr/bin/ruby				Ruby script text executable
10a5d223e6SXin LI!:strength + 15
11b6cee71dSXin LI!:mime text/x-ruby
12b6cee71dSXin LI0	search/1/w	#!\ /usr/local/bin/ruby	Ruby script text executable
13a5d223e6SXin LI!:strength + 15
14b6cee71dSXin LI!:mime text/x-ruby
15b6cee71dSXin LI0	search/1	#!/usr/bin/env\ ruby				Ruby script text executable
16a5d223e6SXin LI!:strength + 15
17b6cee71dSXin LI!:mime text/x-ruby
18b6cee71dSXin LI0	search/1	#!\ /usr/bin/env\ ruby			Ruby script text executable
19a5d223e6SXin LI!:strength + 15
20b6cee71dSXin LI!:mime text/x-ruby
21b6cee71dSXin LI
22b6cee71dSXin LI# What looks like ruby, but does not have a shebang
23b6cee71dSXin LI# (modules and such)
24b6cee71dSXin LI# From: Lubomir Rintel <[email protected]>
25*40427ccaSGordon Tetlow0	regex		\^[[:space:]]*require[[:space:]]'[A-Za-z_/]+'
26*40427ccaSGordon Tetlow>0	regex		def\ [a-z]|\ do$
27*40427ccaSGordon Tetlow>>&0	regex		\^[[:space:]]*end([[:space:]]+[;#].*)?$		Ruby script text
28*40427ccaSGordon Tetlow!:strength + 30
29b6cee71dSXin LI!:mime	text/x-ruby
30*40427ccaSGordon Tetlow0	regex		\^[[:space:]]*(class|module)[[:space:]][A-Z]
31b6cee71dSXin LI>0	regex		(modul|includ)e\ [A-Z]|def\ [a-z]
32*40427ccaSGordon Tetlow>>&0	regex		\^[[:space:]]*end([[:space:]]+[;#].*)?$		Ruby script text
33*40427ccaSGordon Tetlow!:strength + 30
34*40427ccaSGordon Tetlow!:mime	text/x-ruby
35*40427ccaSGordon Tetlow# Classes with no modules or defs, beats simple ASCII
36*40427ccaSGordon Tetlow0	regex		\^[[:space:]]*(class|module)[[:space:]][A-Z]
37*40427ccaSGordon Tetlow>&0	regex	\^[[:space:]]*end([[:space:]]+[;#if].*)?$		Ruby script text
38*40427ccaSGordon Tetlow!:strength + 10
39*40427ccaSGordon Tetlow!:mime	text/x-ruby
40*40427ccaSGordon Tetlow# Looks for function definition to balance python magic
41*40427ccaSGordon Tetlow# def name (args)
42*40427ccaSGordon Tetlow# end
43*40427ccaSGordon Tetlow0	regex		\^[[:space:]]*def\ [a-z]|def\ [[:alpha:]]+::[a-z]
44*40427ccaSGordon Tetlow>&0	regex		\^[[:space:]]*end([[:space:]]+[;#].*)?$		Ruby script text
45*40427ccaSGordon Tetlow!:strength + 10
46*40427ccaSGordon Tetlow!:mime	text/x-ruby
47*40427ccaSGordon Tetlow
48*40427ccaSGordon Tetlow0	regex		\^[[:space:]]*require[[:space:]]'[A-Za-z_/]+'	Ruby script text
49*40427ccaSGordon Tetlow!:mime	text/x-ruby
50*40427ccaSGordon Tetlow0 regex 	\^[[:space:]]*include\ ([A-Z]+[a-z]*(::))+	Ruby script text
51b6cee71dSXin LI!:mime	text/x-ruby
52