Advertisement
Guest User

Untitled

a guest
Dec 12th, 2012
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. def ruby_file?(file)
  2. !!file.readlines[0].match(/#!.*ruby/) || File.extname(file.path) == ".rb"
  3. end
  4.  
  5. def bash_file?(file)
  6. !!file.readlines[0].match(/#!.*bash/) || File.extname(file.path) == ".sh"
  7. end
  8.  
  9. def valid?(file_name)
  10. system('ruby', '-c', file_name)
  11. end
  12.  
  13. def valid?(file_name)
  14. system('bash', '-n', file_name)
  15. end
  16.  
  17. Dir["**/*"].each do |file_name|
  18. file = File.new file_name
  19. next if file.binmode? || !ruby_file?(file) # || !bash_file?(file)
  20. puts "#{file_name}: #{valid? file_name}"
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement