the-architect-sprite_generator 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -106,10 +106,17 @@ protected
106
106
  context['images'] = image_list
107
107
  context['filenames'] = value
108
108
  else
109
- image = Image.read(value.flatten.first){ self.background_color = background }
109
+
110
+ filename = value.flatten.first
111
+ image = Image.read(filename){ self.background_color = background }
112
+
110
113
  context['variations'] = 0
111
114
  context['variation_name'] = ''
112
115
  context['variation_number'] = 0
116
+ context['full_filename'] = filename
117
+ context['file_basename'] = File.basename(filename, '.*')
118
+ context['variation_name'] = context['file_basename'].gsub(/^#{context['basename']}#{@delimiter}/, '')
119
+
113
120
  context['type'] = :image
114
121
 
115
122
  if tile
@@ -18,6 +18,13 @@ class SpriteGeneratorTest < Test::Unit::TestCase
18
18
  Dir.glob('test/output/*').each{|f| File.delete f }
19
19
  end
20
20
 
21
+ def test_should_set_correct_context_for_images_without_variations
22
+ template = %q{ {{file_basename}} }
23
+ generator = SpriteGenerator.new(@all_images_path, @output, nil, { :template => template, :delimiter => '_' })
24
+ css = generator.create
25
+ assert css.include?('emoticon-evilgrin')
26
+ end
27
+
21
28
 
22
29
  def test_should_create_correct_context
23
30
  template = %q{
@@ -35,8 +42,8 @@ class SpriteGeneratorTest < Test::Unit::TestCase
35
42
  variation_number: {{variation_number}}
36
43
  variation_name: {{variation_name}}
37
44
  }
38
- @generator = SpriteGenerator.new(@all_images_path, @output, nil, {:template => template})
39
- css = @generator.create
45
+ generator = SpriteGenerator.new(@all_images_path, @output, nil, {:template => template})
46
+ css = generator.create
40
47
  assert css.include?('basename: emoticon-evilgrin')
41
48
  assert css.include?('variation_name: evilgrin')
42
49
  assert css.include?('file_basename: emoticon-evilgrin')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the-architect-sprite_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcel Scherf
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-21 00:00:00 -07:00
12
+ date: 2009-04-22 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency