lib/rails_sprite/sprite_util.rb in rails-sprite-0.0.6 vs lib/rails_sprite/sprite_util.rb in rails-sprite-0.0.7
- old
+ new
@@ -4,11 +4,11 @@
class SpriteUtil
attr_reader :root_path, :scope_name, :recipe_path, :file_extend,
:spacing, :image_to_folder, :image_source_folder,
:stylesheet_to, :image_to_file_path, :css_class_prefix, :css_class_shared,
:image_scope_name, :stylesheet_scope_name,
- :css_extend, :file_extend_name
+ :css_extend, :file_extend_name, :zoom
#
# :css_extend => "",
# :root_path => '.',
# :scope_name => "rails_xxx",
@@ -49,10 +49,12 @@
@scope_str = scope_name.chomp('/').gsub('/', '-')
@recipe_str = recipe_path.chomp('/').gsub('/', '-')
@css_class_shared = options.fetch(:css_class_shared, "rs-#{@scope_str}")
@css_class_prefix = options.fetch(:css_class_prefix, "rs-#{@scope_str}-#{@recipe_str}-")
+
+ @zoom = options.fetch(:zoom, 1).to_i
end
def perform
file_infos = []
@@ -69,13 +71,11 @@
Dir.entries( image_source_folder ).each do |file_name|
if file_name != '.' && file_name != '..' && file_name.end_with?(file_extend)
file_path = "#{image_source_folder}/#{file_name}"
- if ::File.file?( file_path )
- # puts "#{file_path}"
-
+ if ::File.file?(file_path)
file_name_split = file_name.split('.')
file_name_split.pop
file_purename = file_name_split.join('.')
file_info = {
@@ -88,11 +88,11 @@
)
file_info[:x] = x
file_info[:y] = y
- y += ( spacing + file_info[:height] )
+ y += (spacing + file_info[:height])
max_w = [max_w, file_info[:width]].max
max_h = y
file_infos << file_info
@@ -116,9 +116,10 @@
RailsSprite::Library::RMagick
end
def _composite_css file_infos
stylesheet_generator.generate(
+ :zoom => zoom,
:css_class_shared => css_class_shared,
:css_class_prefix => css_class_prefix,
:file_infos => file_infos,
:image_scope_name => image_scope_name,
:css_extend => css_extend,