Skip to content

Instantly share code, notes, and snippets.

@dcadenas
Created June 30, 2009 21:01
Show Gist options
  • Save dcadenas/138424 to your computer and use it in GitHub Desktop.
Save dcadenas/138424 to your computer and use it in GitHub Desktop.
#!/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