sprite-factory 1.6.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3869041a63a98b286f265b18d7248c3c398ba33
4
- data.tar.gz: 3d2d321ea52948892ecde2f0662489e963e4d90a
3
+ metadata.gz: 097ca4bb60eba921f4f50b9aa01f4637f76aac8d
4
+ data.tar.gz: f4270a2b011d8abe87e92ad99146766aad37eee8
5
5
  SHA512:
6
- metadata.gz: 96dfd8bf61c580fcc4508d28c308192d7bdaff6fa00bf015b9dacf1e5f5f71778228c3d6b698477838c018bca68011e1bf4f75189d5817531d9523da3adf74b5
7
- data.tar.gz: a1801ebe861de312bf212c1a5a5d95fbe0f2696620bc0c2e8819a5e8f237f0df3de031eb5d245a31f92db167d016a66c6218e72a6b257ccc38918b805d87fb68
6
+ metadata.gz: b23043b30ce92ee88cc2450fa88934ae7e26f2bc9e62ddc7f0bbf77fa9c6e5858816bacd55da3ff2e4d2d303c9f11548cfe8e99d0d89fe6eb093584248744f63
7
+ data.tar.gz: 4fb30bc756f357ace50ea35ec3a584c2e0b33daee1a5d5ab0d54901be2cdb9ba04490ee6d8840e93d05b2a8fd09f3d0073423e370b7192307007183d20bbc7cc
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011, 2012, 2013, 2014 Jake Gordon and contributors
1
+ Copyright (c) 2011, 2012, 2013, 2014, 2015, Jake Gordon and contributors
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Sprite Factory (v1.6.1)
1
+ Sprite Factory (v1.6.2)
2
2
  =======================
3
3
 
4
4
  The sprite factory is a ruby library that can be used to generate
data/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,9 @@
1
+ January 17th 2015 - v1.6.2
2
+ --------------------------
3
+
4
+ * replace deprecated Magick::MaxRGB with Magick::QuantumRange (courtesy of @kenmicles)
5
+ * add option to override default directory separator (courtesy of @cotampanie)
6
+
1
7
  August 8th 2014 - v1.6.1
2
8
  ------------------------
3
9
 
@@ -2,7 +2,7 @@ module SpriteFactory
2
2
 
3
3
  #----------------------------------------------------------------------------
4
4
 
5
- VERSION = "1.6.1"
5
+ VERSION = "1.6.2"
6
6
  SUMMARY = "Automatic CSS sprite generator"
7
7
  DESCRIPTION = "Combines individual images from a directory into a single sprite image file and creates an appropriate CSS stylesheet"
8
8
  LIB = File.dirname(__FILE__)
@@ -27,6 +27,7 @@ module SpriteFactory
27
27
  attr_accessor :cssurl
28
28
  attr_accessor :pngcrush
29
29
  attr_accessor :nocomments
30
+ attr_accessor :directory_separator
30
31
  end
31
32
 
32
33
  #----------------------------------------------------------------------------
@@ -20,7 +20,7 @@ module SpriteFactory
20
20
 
21
21
  def self.create(filename, images, width, height)
22
22
  target = Magick::Image.new(width,height)
23
- target.opacity = Magick::MaxRGB
23
+ target.opacity = Magick::QuantumRange
24
24
  images.each do |image|
25
25
  target.composite!(image[:image], image[:x], image[:y], Magick::SrcOverCompositeOp)
26
26
  end
@@ -24,12 +24,12 @@ module SpriteFactory
24
24
  @config[:report] ||= SpriteFactory.report
25
25
  @config[:pngcrush] ||= SpriteFactory.pngcrush
26
26
  @config[:nocomments] ||= SpriteFactory.nocomments
27
+ @config[:directory_separator] ||= SpriteFactory.directory_separator || '_'
27
28
  end
28
29
 
29
30
  #----------------------------------------------------------------------------
30
31
 
31
32
  def run!(&block)
32
-
33
33
  raise RuntimeError, "unknown layout #{layout_name}" if !Layout.respond_to?(layout_name)
34
34
  raise RuntimeError, "unknown style #{style_name}" if !Style.respond_to?(style_name)
35
35
  raise RuntimeError, "unknown library #{library_name}" if !Library.respond_to?(library_name)
@@ -139,6 +139,10 @@ module SpriteFactory
139
139
  config[:nocomments] # set true if you dont want any comments in the output style file
140
140
  end
141
141
 
142
+ def directory_separator
143
+ config[:directory_separator]
144
+ end
145
+
142
146
  def custom_style_file
143
147
  File.join(input, File.basename(input) + ".#{style_name}")
144
148
  end
@@ -174,6 +178,7 @@ module SpriteFactory
174
178
 
175
179
  def load_images
176
180
  input_path = Pathname.new(input)
181
+
177
182
  images = library.load(image_files)
178
183
  images.each do |i|
179
184
  i[:name], i[:ext] = map_image_filename(i[:filename], input_path)
@@ -184,7 +189,7 @@ module SpriteFactory
184
189
  end
185
190
 
186
191
  def map_image_filename(filename, input_path)
187
- name = Pathname.new(filename).relative_path_from(input_path).to_s.gsub(File::SEPARATOR, "_")
192
+ name = Pathname.new(filename).relative_path_from(input_path).to_s.gsub(File::SEPARATOR, directory_separator)
188
193
  name = name.gsub('--', ':')
189
194
  name = name.gsub('__', ' ')
190
195
  ext = File.extname(name)
data/test/runner_test.rb CHANGED
@@ -18,6 +18,7 @@ module SpriteFactory
18
18
  assert_equal(:horizontal, r.layout_name)
19
19
  assert_equal(:css, r.style_name)
20
20
  assert_equal(:rmagick, r.library_name)
21
+ assert_equal(DIRECTORY_SEPARATOR, r.directory_separator)
21
22
 
22
23
  r = Runner.new(IRREGULAR_PATH)
23
24
  assert_equal(IRREGULAR_PATH, r.input)
@@ -28,6 +29,18 @@ module SpriteFactory
28
29
  assert_equal(:horizontal, r.layout_name)
29
30
  assert_equal(:css, r.style_name)
30
31
  assert_equal(:rmagick, r.library_name)
32
+ assert_equal(DIRECTORY_SEPARATOR, r.directory_separator)
33
+
34
+ r = Runner.new(IRREGULAR_PATH, :directory_separator => '.')
35
+ assert_equal(IRREGULAR_PATH, r.input)
36
+ assert_equal(IRREGULAR_PATH, r.output)
37
+ assert_equal(IRREGULAR_PATH + ".png", r.output_image_file)
38
+ assert_equal(IRREGULAR_PATH + ".css", r.output_style_file)
39
+ assert_equal(IRREGULAR, r.image_files)
40
+ assert_equal(:horizontal, r.layout_name)
41
+ assert_equal(:css, r.style_name)
42
+ assert_equal(:rmagick, r.library_name)
43
+ assert_equal('.', r.directory_separator)
31
44
 
32
45
  r = Runner.new(REGULAR_PATH, :output => IRREGULAR_PATH)
33
46
  assert_equal(REGULAR_PATH, r.input)
@@ -38,6 +51,7 @@ module SpriteFactory
38
51
  assert_equal(:horizontal, r.layout_name)
39
52
  assert_equal(:css, r.style_name)
40
53
  assert_equal(:rmagick, r.library_name)
54
+ assert_equal(DIRECTORY_SEPARATOR, r.directory_separator)
41
55
 
42
56
  r = Runner.new(REGULAR_PATH, :output_image => "foo.png", :output_style => "bar.css.sass.erb")
43
57
  assert_equal(REGULAR_PATH, r.input)
@@ -48,6 +62,7 @@ module SpriteFactory
48
62
  assert_equal(:horizontal, r.layout_name)
49
63
  assert_equal(:css, r.style_name)
50
64
  assert_equal(:rmagick, r.library_name)
65
+ assert_equal(DIRECTORY_SEPARATOR, r.directory_separator)
51
66
 
52
67
  r = Runner.new(REGULAR_PATH, :layout => :vertical, :library => :chunkypng, :style => :sass)
53
68
  assert_equal(REGULAR_PATH, r.input)
@@ -58,6 +73,7 @@ module SpriteFactory
58
73
  assert_equal(:vertical, r.layout_name)
59
74
  assert_equal(:sass, r.style_name)
60
75
  assert_equal(:chunkypng, r.library_name)
76
+ assert_equal(DIRECTORY_SEPARATOR, r.directory_separator)
61
77
 
62
78
  end
63
79
 
@@ -223,6 +239,14 @@ module SpriteFactory
223
239
  end
224
240
  end
225
241
 
242
+ def test_use_specified_directory_separator
243
+ Runner.publicize_methods do
244
+ expected = %w(england.amy england.bob france.bob usa.amy usa.bob)
245
+ actual = Runner.new(SUBFOLDERS_PATH, :directory_separator => '.').load_images.map{|i| i[:name]}
246
+ assert_equal(expected, actual)
247
+ end
248
+ end
249
+
226
250
  #----------------------------------------------------------------------------
227
251
 
228
252
  end
data/test/test_case.rb CHANGED
@@ -36,6 +36,8 @@ module SpriteFactory
36
36
  { :filename => IRREGULAR[4], :width => 46, :height => 25 }
37
37
  ]
38
38
 
39
+ DIRECTORY_SEPARATOR = '_'
40
+
39
41
  def output_path(name)
40
42
  File.join(IMAGES_PATH, name)
41
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprite-factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Gordon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-08 00:00:00.000000000 Z
11
+ date: 2015-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rmagick