ruby 1.8 KB

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