sprite_generator 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/sprite_generator.rb +6 -6
  2. metadata +1 -1
@@ -42,7 +42,8 @@ class SpriteGenerator
42
42
  @root = root || ''
43
43
  @output = output
44
44
  @delimiter = options[:delimiter] || '-'
45
- @analyzed = find_files_for_mode(options[:distribution] || :smart)
45
+ @distribution = (options[:distribution] || :smart).to_sym
46
+ @analyzed = find_files_for_mode
46
47
  @template = Liquid::Template.parse(options[:template] || '')
47
48
  @sprite_location = options[:sprite_location] || @output
48
49
  @background = options[:background] || '#FFFFFF00'
@@ -73,7 +74,6 @@ protected
73
74
  value = @analyzed[key]
74
75
 
75
76
  context['top'] = 0
76
- puts "basename: %s" % key
77
77
  context['basename'] = key
78
78
  context['overall'] = @images.length
79
79
  if value.size > 1
@@ -189,7 +189,7 @@ protected
189
189
  new_context['full_filename'] = context['filenames'].shift
190
190
  new_context['filename'] = File.basename(new_context['full_filename'])
191
191
  new_context['file_basename'] = File.basename(new_context['full_filename'], '.*')
192
- new_context['variation_name'] = new_context['file_basename'].gsub("#{new_context['basename']}#{@delimiter}", '')
192
+ new_context['variation_name'] = new_context['file_basename'].gsub(/^#{new_context['basename']}#{@delimiter}/, '')
193
193
  css << build_css(new_context.dup)
194
194
 
195
195
  new_context['top'] += @tile ? @tile.rows : new_context['height']
@@ -213,8 +213,8 @@ protected
213
213
 
214
214
 
215
215
  # put filenames in format for each mode
216
- def find_files_for_mode(mode)
217
- case mode.to_sym
216
+ def find_files_for_mode
217
+ case @distribution
218
218
  when :smart
219
219
  smart_distribution
220
220
  when :horizontal
@@ -250,7 +250,7 @@ protected
250
250
  def vertical_distribution
251
251
  @files.inject(Hash.new{|hash, key| hash[key] = Array.new;}) do |h, file|
252
252
  basename = File.basename(file)
253
- h['all'] << file
253
+ h['__all__'] << file
254
254
  h
255
255
  end
256
256
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprite_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcel Scherf