From fecc98219d05104a13f66be78bc2ca9d048ab369 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Mon, 26 Sep 2011 09:00:51 -0700 Subject: [PATCH] Refactor loggin within sprites Handle missing logger instance more elegantly and centralize relativizing and quiet mode checking. Closes GH-84. --- lib/compass/sass_extensions/sprites/sprite_methods.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/compass/sass_extensions/sprites/sprite_methods.rb b/lib/compass/sass_extensions/sprites/sprite_methods.rb index 52458b00..95e5dda8 100644 --- a/lib/compass/sass_extensions/sprites/sprite_methods.rb +++ b/lib/compass/sass_extensions/sprites/sprite_methods.rb @@ -60,13 +60,13 @@ module Compass Compass.configuration.run_sprite_generated(engine.canvas) save! else - options[:compass][:logger].record(:unchanged, relativize(filename)) unless options[:quiet] + log :unchanged, 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)) unless options[:quiet] + log :remove, file FileUtils.rm file Compass.configuration.run_sprite_removed(file) end @@ -98,7 +98,7 @@ module Compass def save! FileUtils.mkdir_p(File.dirname(filename)) saved = engine.save(filename) - options[:compass][:logger].record(:create, relativize(filename)) unless options[:quiet] + log :create, filename Compass.configuration.run_sprite_saved(filename) saved end @@ -126,6 +126,11 @@ module Compass [width, height] end + def log(action, filename, *extra) + if options[:compass] && options[:compass][:logger] && !options[:quiet] + options[:compass][:logger].record(action, relativize(filename), *extra) + end + end end end end