Log the creation or unchanged status of sprites during compilation.

This commit is contained in:
Chris Eppstein 2011-09-19 07:28:29 -07:00
parent 5fd2c14d06
commit cd907d17a7
3 changed files with 11 additions and 1 deletions

View File

@ -15,6 +15,8 @@ module Compass
self.sass_options.update(sass_opts)
self.sass_options[:cache_location] ||= determine_cache_location
self.sass_options[:importer] = self.importer = Sass::Importers::Filesystem.new(from)
self.sass_options[:compass] ||= {}
self.sass_options[:compass][:logger] = self.logger
self.staleness_checker = Sass::Plugin::StalenessChecker.new(sass_options)
end

View File

@ -68,7 +68,7 @@ module Compass::SassExtensions::Functions::Sprites
end
Sass::Script::Functions.declare :sprite_file, [:map, :sprite]
# Returns voolean if sprite has a parent
# Returns boolean if sprite has a parent
def sprite_does_not_have_parent(map, sprite)
sprite = convert_sprite_name(sprite)
verify_map map

View File

@ -46,6 +46,10 @@ module Compass
File.join(Compass.configuration.generated_images_path, "#{path}-s#{uniqueness_hash}.png")
end
def relativize(path)
Pathname.new(path).relative_path_from(Pathname.new(Dir.pwd)).to_s
end
# Generate a sprite image if necessary
def generate
if generation_required?
@ -55,11 +59,14 @@ module Compass
engine.construct_sprite
Compass.configuration.run_sprite_generated(engine.canvas)
save!
else
options[:compass][:logger].record(:unchanged, relativize(filename))
end
end
def cleanup_old_sprites
Dir[File.join(Compass.configuration.images_path, "#{path}-*.png")].each do |file|
options[:compass][:logger].record(:remove, relativize(file))
FileUtils.rm file
end
end
@ -89,6 +96,7 @@ module Compass
def save!
FileUtils.mkdir_p(File.dirname(filename))
saved = engine.save(filename)
options[:compass][:logger].record(:create, relativize(filename))
Compass.configuration.run_sprite_saved(filename)
saved
end