xref: /freebsd/contrib/file/magic/Magdir/ruby (revision 5ffd83dbcc34f10e07f6d3e968ae6365869615f4)
1
2#------------------------------------------------------------------------------
3# $File: ruby,v 1.10 2019/07/21 09:40:17 christos Exp $
4# ruby:  file(1) magic for Ruby scripting language
5# URL:  https://www.ruby-lang.org/
6# From: Reuben Thomas <rrt@sc3d.org>
7
8# Ruby scripts
90	search/1/w	#!\ /usr/bin/ruby				Ruby script text executable
10!:strength + 15
11!:mime text/x-ruby
120	search/1/w	#!\ /usr/local/bin/ruby	Ruby script text executable
13!:strength + 15
14!:mime text/x-ruby
150	search/1	#!/usr/bin/env\ ruby				Ruby script text executable
16!:strength + 15
17!:mime text/x-ruby
180	search/1	#!\ /usr/bin/env\ ruby			Ruby script text executable
19!:strength + 15
20!:mime text/x-ruby
21
22# What looks like ruby, but does not have a shebang
23# (modules and such)
24# From: Lubomir Rintel <lkundrak@v3.sk>
250	search/8192	require
26>0	regex		\^[[:space:]]*require[[:space:]]'[A-Za-z_/.]+'
27>>0	regex		def\ [a-z]|\ do$
28>>>&0	regex		\^[[:space:]]*end([[:space:]]+[;#].*)?$		Ruby script text
29!:strength + 30
30!:mime	text/x-ruby
310	regex		\^[[:space:]]*(class|module)[[:space:]][A-Z]
32>0	regex		(modul|includ)e\ [A-Z]|def\ [a-z]
33>>&0	regex		\^[[:space:]]*end([[:space:]]+[;#].*)?$		Ruby script text
34!:strength + 30
35!:mime	text/x-ruby
36# Classes with no modules or defs, beats simple ASCII
370	regex		\^[[:space:]]*(class|module)[[:space:]][A-Z]
38>&0	regex	\^[[:space:]]*end([[:space:]]+[;#if].*)?$		Ruby script text
39!:strength + 10
40!:mime	text/x-ruby
41# Looks for function definition to balance python magic
42# def name (args)
43# end
440	search/8192	def\
45>0	regex		\^[[:space:]]*def\ [a-z]|def\ [[:alpha:]]+::[a-z]
46>>&0	regex		\^[[:space:]]*end([[:space:]]+[;#].*)?$		Ruby script text
47!:strength + 10
48!:mime	text/x-ruby
49
500	search/8192	require
51>0	regex		\^[[:space:]]*require[[:space:]]'[A-Za-z_/.]+'	Ruby script text
52!:mime	text/x-ruby
530	search/8192	include
54>0 regex 	\^[[:space:]]*include\ ([A-Z]+[a-z]*(::))+	Ruby script text
55!:mime	text/x-ruby
56