Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check asset encoding for valid UTF-8
namespace :assets do
task :check => :environment do
paths = ["app/assets", "lib/assets", "vendor/assets"]
paths.each do |path|
dir_path = Rails.root + path
if File.exists?(dir_path)
dir_files = File.join(dir_path, "**")
Dir.glob(dir_files + "/**.{js,css}").each do |file|
# make sure we're not trying to process a directory
unless File.directory?(file)
# read the file and check its encoding
data = File.read(file)
unless data.valid_encoding?
puts "#{ file } does not have valid encoding!"
end
end
end # end Dir.glob
end #end File.exists
end # end paths.each
end
end
@coliver

This comment has been minimized.

Copy link

commented Nov 17, 2011

This helped me out. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.