Skip to content

Instantly share code, notes, and snippets.

@boldfacedesign
Created April 8, 2014 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boldfacedesign/10109132 to your computer and use it in GitHub Desktop.
Save boldfacedesign/10109132 to your computer and use it in GitHub Desktop.
Compass sprite cleaner function (Ruby)
module Compass::SassExtensions::Functions::Sprites
def sprite_url(map)
verify_map(map, "sprite-url")
map.generate
generated_image_url(Sass::Script::String.new(map.name_and_hash))
end
end
module Compass::SassExtensions::Sprites::SpriteMethods
def name_and_hash
"sprite-#{path}.png"
end
def cleanup_old_sprites
Dir[File.join(::Compass.configuration.generated_images_path, "sprite-#{path}.png")].each do |file|
log :remove, file
FileUtils.rm file
::Compass.configuration.run_sprite_removed(file)
end
end
end
module Compass
class << SpriteImporter
def find_all_sprite_map_files(path)
glob = "sprite-*{#{self::VALID_EXTENSIONS.join(",")}}"
Dir.glob(File.join(path, "**", glob))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment