1 2#------------------------------------------------------------------------------ 3# $File: ruby,v 1.7 2017/08/14 13:39:18 christos Exp $ 4# ruby: file(1) magic for Ruby scripting language 5# URL: http://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 regex \^[[:space:]]*require[[:space:]]'[A-Za-z_/]+' 26>0 regex def\ [a-z]|\ do$ 27>>&0 regex \^[[:space:]]*end([[:space:]]+[;#].*)?$ Ruby script text 28!:strength + 30 29!:mime text/x-ruby 300 regex \^[[:space:]]*(class|module)[[:space:]][A-Z] 31>0 regex (modul|includ)e\ [A-Z]|def\ [a-z] 32>>&0 regex \^[[:space:]]*end([[:space:]]+[;#].*)?$ Ruby script text 33!:strength + 30 34!:mime text/x-ruby 35# Classes with no modules or defs, beats simple ASCII 360 regex \^[[:space:]]*(class|module)[[:space:]][A-Z] 37>&0 regex \^[[:space:]]*end([[:space:]]+[;#if].*)?$ Ruby script text 38!:strength + 10 39!:mime text/x-ruby 40# Looks for function definition to balance python magic 41# def name (args) 42# end 430 regex \^[[:space:]]*def\ [a-z]|def\ [[:alpha:]]+::[a-z] 44>&0 regex \^[[:space:]]*end([[:space:]]+[;#].*)?$ Ruby script text 45!:strength + 10 46!:mime text/x-ruby 47 480 regex \^[[:space:]]*require[[:space:]]'[A-Za-z_/]+' Ruby script text 49!:mime text/x-ruby 500 regex \^[[:space:]]*include\ ([A-Z]+[a-z]*(::))+ Ruby script text 51!:mime text/x-ruby 52