Refactor loggin within sprites
Handle missing logger instance more elegantly and centralize relativizing and quiet mode checking. Closes GH-84.
This commit is contained in:
parent
9b56dc6169
commit
fecc98219d
@ -60,13 +60,13 @@ module Compass
|
|||||||
Compass.configuration.run_sprite_generated(engine.canvas)
|
Compass.configuration.run_sprite_generated(engine.canvas)
|
||||||
save!
|
save!
|
||||||
else
|
else
|
||||||
options[:compass][:logger].record(:unchanged, relativize(filename)) unless options[:quiet]
|
log :unchanged, filename
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleanup_old_sprites
|
def cleanup_old_sprites
|
||||||
Dir[File.join(Compass.configuration.images_path, "#{path}-*.png")].each do |file|
|
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
|
FileUtils.rm file
|
||||||
Compass.configuration.run_sprite_removed(file)
|
Compass.configuration.run_sprite_removed(file)
|
||||||
end
|
end
|
||||||
@ -98,7 +98,7 @@ module Compass
|
|||||||
def save!
|
def save!
|
||||||
FileUtils.mkdir_p(File.dirname(filename))
|
FileUtils.mkdir_p(File.dirname(filename))
|
||||||
saved = engine.save(filename)
|
saved = engine.save(filename)
|
||||||
options[:compass][:logger].record(:create, relativize(filename)) unless options[:quiet]
|
log :create, filename
|
||||||
Compass.configuration.run_sprite_saved(filename)
|
Compass.configuration.run_sprite_saved(filename)
|
||||||
saved
|
saved
|
||||||
end
|
end
|
||||||
@ -126,6 +126,11 @@ module Compass
|
|||||||
[width, height]
|
[width, height]
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user