ruby 1.9 KB

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