Guest User

Untitled

a guest
Jan 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. namespace :assets do
  2.  
  3. task :check => :environment do
  4. paths = ["app/assets", "lib/assets", "vendor/assets"]
  5.  
  6. paths.each do |path|
  7. dir_path = Rails.root + path
  8.  
  9. if File.exists?(dir_path)
  10. dir_files = File.join(dir_path, "**")
  11.  
  12. Dir.glob(dir_files + "/**.{js,css}").each do |file|
  13.  
  14. # make sure we're not trying to process a directory
  15. unless File.directory?(file)
  16. # read the file and check its encoding
  17. data = File.read(file)
  18. unless data.valid_encoding?
  19. puts "#{ file } does not have valid encoding!"
  20. encodings = []
  21. for enc in Encoding.name_list
  22. if data.dup.force_encoding(enc).valid_encoding?
  23. encodings << enc
  24. end
  25. end
  26. puts " (it could be one of #{encodings})" unless encodings.empty?
  27. end
  28. end
  29.  
  30. end # end Dir.glob
  31.  
  32. end #end File.exists
  33. end # end paths.each
  34.  
  35. end
  36.  
  37. end
Add Comment
Please, Sign In to add comment