Created
April 7, 2014 08:42
-
-
Save xarimanx/10016782 to your computer and use it in GitHub Desktop.
# check that all assets have the correct encoding # https://gist.github.com/1301199
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# check that all assets have the correct encoding | |
# https://gist.github.com/1301199 | |
namespace :assets do | |
desc "Check that all assets have valid encoding" | |
task :check => :environment do | |
paths = ["app/assets", "lib/assets", "vendor/assets"] | |
extensions = ["js", "coffee", "css", "scss"] | |
paths.each do |path| | |
dir_path = Rails.root + path | |
if File.exists?(dir_path) | |
dir_files = File.join(dir_path, "**") | |
Dir.glob(dir_files + "/**.{#{extensions.join(',')}}").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 "Invalid encoding: #{ file }" | |
else | |
puts "Valid: #{ file }" | |
end | |
end | |
end # end Dir.glob | |
end #end File.exists | |
end # end paths.each | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment