Guest User

Untitled

a guest
Jun 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. require 'find'
  2. require 'fileutils'
  3.  
  4. $to_list = ['ruby', 'eruby', 'eruby-rails', 'html', 'javascript', 'javascript=jquery', 'ruby-rails', 'ruby-rails-rjs', 'ruby-rspec']
  5.  
  6. def in_list?(name)
  7. $to_list.any? { |el| name =~ /#{el}/ }
  8. end
  9.  
  10. def snippet?(name)
  11. name =~ /(\/.+\.snippet$)/
  12. end
  13.  
  14. Find.find(ARGV[0]) do |f|
  15. if File.directory?(f) && in_list?(f)
  16. puts f.upcase
  17. (f.length + 3).times { print "=" }
  18. puts ""
  19. end
  20. if File.file?(f) && in_list?(f) && snippet?(f)
  21. f =~ /(\w+)\.snippet$/
  22. puts $1
  23. ($1.length + 3).times { print "=" }
  24. puts ""
  25. File.open(f).each_line { |line| puts line }
  26. puts "\n"
  27. end
  28. end
Add Comment
Please, Sign In to add comment