Created
June 30, 2009 21:01
-
-
Save dcadenas/138424 to your computer and use it in GitHub Desktop.
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
#!/usr/local/bin/ruby | |
missing_images = {} | |
grep_regexp = %q|/images[^\"\']*\....| | |
reference_and_image_paths = IO.popen('grep -ro "' + grep_regexp + '" app/views public/stylesheets').readlines | |
reference_and_image_paths.each do |reference_and_image_path| | |
reference, image_path = reference_and_image_path.split(":") | |
if image_path | |
image_path.gsub!(/^\//, 'public/').strip! | |
unless File.exists?(image_path) | |
(missing_images[image_path] ||= []) << reference | |
end | |
end | |
end | |
if missing_images.empty? | |
puts "All referenced images (#{missing_images.size}) exist" | |
else | |
puts "Missing images (#{missing_images.size}):\n" | |
missing_images.each do |missing_image, references| | |
puts missing_image | |
puts " Referenced in:" | |
references.each do |reference| | |
puts " #{reference}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment