sprite-factory 1.6.2 → 1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +36 -2
- data/RELEASE_NOTES.md +9 -0
- data/Rakefile +3 -0
- data/bin/sf +6 -4
- data/lib/sprite_factory.rb +7 -5
- data/lib/sprite_factory/library/rmagick.rb +1 -1
- data/lib/sprite_factory/runner.rb +28 -13
- data/test/images/glob/excluded1.png +0 -0
- data/test/images/glob/excluded2.png +0 -0
- data/test/images/glob/included1.png +0 -0
- data/test/images/glob/included2.png +0 -0
- data/test/images/glob/included3.png +0 -0
- data/test/images/names/Ends With Bang!.png +0 -0
- data/test/images/names/Has & Ampersand.png +0 -0
- data/test/images/names/Odd.Period.png +0 -0
- data/test/images/reference/glob.css +20 -0
- data/test/images/reference/glob.png +0 -0
- data/test/images/reference/sanitized.css +20 -0
- data/test/images/reference/sanitized.custom.css +20 -0
- data/test/images/reference/sanitized.custom.png +0 -0
- data/test/images/reference/sanitized.png +0 -0
- data/test/integration_test.rb +20 -0
- data/test/runner_test.rb +9 -9
- data/test/test_case.rb +7 -5
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8eaae33fa1ece6b170c111201b49c9c43aedf9a
|
4
|
+
data.tar.gz: 61a3998645237d26ded4d57c98970182ed1b9a85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b2b7092d6c87cde70180776c04a6e0fa6ec10f6c12244b8163f1749634875ed871274101f70449b830d3ee4451c58fe9de18cead42059aea204d673d941eb1
|
7
|
+
data.tar.gz: e2145ffe3b32229049d3ab9929e4c3f3da8e65b2417f731cb58913760a4075179881f9941c60b63fc5660a7dac7db14e949ef79418f3d919e01865f96e839867
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Sprite Factory (v1.
|
1
|
+
Sprite Factory (v1.7)
|
2
2
|
=======================
|
3
3
|
|
4
4
|
The sprite factory is a ruby library that can be used to generate
|
@@ -98,6 +98,7 @@ Much of the behavior can be customized by overriding the following options:
|
|
98
98
|
- `:height` - fix height of each sprite to a specific size
|
99
99
|
- `:nocss` - suppress generation of output stylesheet (`run!` returns css content as a string instead)
|
100
100
|
- `:nocomments` - suppress generation of comments in output stylesheet
|
101
|
+
- `:sanitizer` - strip non-word characters from image filenames when generating css selectors
|
101
102
|
|
102
103
|
Options can be passed as command line arguments to the `sf` script:
|
103
104
|
|
@@ -183,7 +184,6 @@ image filename. For example:
|
|
183
184
|
div.example div.foo span.icon_alert { ... first file ... }
|
184
185
|
div.example div.bar span.icon_alert { ... second file ... }
|
185
186
|
|
186
|
-
|
187
187
|
If you want to specify a psuedo class such as `:hover` for some of your images, the library will also
|
188
188
|
map '--' (double dash) to a colon ':' in any source image filename. For example:
|
189
189
|
|
@@ -199,6 +199,40 @@ map '--' (double dash) to a colon ':' in any source image filename. For example:
|
|
199
199
|
span.icon_alert { ... first file ... }
|
200
200
|
span.icon_alert:hover { ... second file ... }
|
201
201
|
|
202
|
+
Sanitizing the CSS Selector
|
203
|
+
===========================
|
204
|
+
|
205
|
+
If your image filenames contain non-word characters that would otherwise invalidate your css selector you
|
206
|
+
can sanitize these characters using the `:sanitizer` option. For example:
|
207
|
+
|
208
|
+
images/icons/has & ampersand.png
|
209
|
+
images/icons/odd.period.png
|
210
|
+
images/icons/ends with bang!.png
|
211
|
+
|
212
|
+
... when run with:
|
213
|
+
|
214
|
+
SpriteFactory.run!('images/icons', :sanitizer => true)
|
215
|
+
|
216
|
+
... will generate:
|
217
|
+
|
218
|
+
span.icon_hasampersand { ... first file ... }
|
219
|
+
span.icon_oddperiod { ... second file ... }
|
220
|
+
span.icon_endswithbang { ... third file ... }
|
221
|
+
|
222
|
+
If you want **full control** over the filename-to-selector sanitization process you can provide a custom `:sanitizer`. For example:
|
223
|
+
|
224
|
+
images/icons/foo.png
|
225
|
+
images/icons/bar.png
|
226
|
+
|
227
|
+
... when run with:
|
228
|
+
|
229
|
+
SpriteFactory.run!('images/icons', :sanitizer => lamda { |name| name.reverse }) # pointless, but amusing
|
230
|
+
|
231
|
+
... will generate
|
232
|
+
|
233
|
+
span.icon_oof { ... first file ... }
|
234
|
+
span.icon_rab { ... second file ... }
|
235
|
+
|
202
236
|
Customizing the CSS Image Url
|
203
237
|
=============================
|
204
238
|
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
August 15th 2015 - v1.7
|
2
|
+
-----------------------
|
3
|
+
|
4
|
+
* added `sanitizer` option to give more control over converting non-standard filenames to css selectors (hattip to @MentalPower)
|
5
|
+
* rename `directory_separator` option to simpler `separator`
|
6
|
+
* switch to minitest
|
7
|
+
* replace deprecated require 'RMagick' with require 'rmagick' (courtesy of @warrenguy)
|
8
|
+
* added `:glob` option to override default globbing behavior (courtsey of @jdlich)
|
9
|
+
|
1
10
|
January 17th 2015 - v1.6.2
|
2
11
|
--------------------------
|
3
12
|
|
data/Rakefile
CHANGED
@@ -47,6 +47,9 @@ task :reference do
|
|
47
47
|
regenerate.call('test/images/irregular', :output => 'test/images/irregular.sassy', :selector => 'img.sassy_', :style => :sass)
|
48
48
|
|
49
49
|
regenerate.call('test/images/hover', :output => 'test/images/hover', :selector => 'div.hover ', :style => :css)
|
50
|
+
regenerate.call('test/images/glob', :output => 'test/images/glob', :glob => "included*")
|
51
|
+
regenerate.call('test/images/names', :output => 'test/images/sanitized', :sanitizer => true)
|
52
|
+
regenerate.call('test/images/names', :output => 'test/images/sanitized.custom', :sanitizer => lambda {|name| name.gsub(/[^\w]/, '_').downcase })
|
50
53
|
|
51
54
|
regenerate.call('test/images/custom', :output => 'test/images/custom') do |images|
|
52
55
|
rules = []
|
data/bin/sf
CHANGED
@@ -29,7 +29,9 @@ output_style_help = "specify output location for generated stylesheet ( default:
|
|
29
29
|
pngcrush_help = "use pngcrush to optimize generated image"
|
30
30
|
padding_help = "add padding to each sprite"
|
31
31
|
margin_help = "add margin to each sprite"
|
32
|
+
glob_help = "specify glob pattern used to find images ( default: '*' )"
|
32
33
|
nocomments_help = "suppress comments in generated stylesheet"
|
34
|
+
sanitizer_help = "strip non-word characters out of filenames when converting to css selector"
|
33
35
|
|
34
36
|
op.on("--layout [ORIENTATION]", layout_help) {|value| options[:layout] = value }
|
35
37
|
op.on("--style [STYLE]", style_help) {|value| options[:style] = value }
|
@@ -39,9 +41,11 @@ op.on("--cssurl [CSSURL]", cssurl_help) {|value| options[:cssur
|
|
39
41
|
op.on("--output-image [PATH]", output_image_help) {|value| options[:output_image] = value }
|
40
42
|
op.on("--output-style [PATH]", output_style_help) {|value| options[:output_style] = value }
|
41
43
|
op.on("--pngcrush", pngcrush_help) {|value| options[:pngcrush] = value }
|
42
|
-
op.on("--padding
|
43
|
-
op.on("--margin
|
44
|
+
op.on("--padding [PIXELS]", padding_help) {|value| options[:padding] = value.to_i }
|
45
|
+
op.on("--margin [PIXELS]", margin_help) {|value| options[:margin] = value.to_i }
|
46
|
+
op.on("--glob [PATTERN]", glob_help) {|value| options[:glob] = value }
|
44
47
|
op.on("--nocomments", nocomments_help) {|value| options[:nocomments] = true }
|
48
|
+
op.on("--sanitizer", sanitizer_help) {|value| options[:sanitizer] = true }
|
45
49
|
|
46
50
|
begin
|
47
51
|
op.parse!(ARGV)
|
@@ -51,5 +55,3 @@ rescue Exception => ex
|
|
51
55
|
puts ex.message
|
52
56
|
exit
|
53
57
|
end
|
54
|
-
|
55
|
-
|
data/lib/sprite_factory.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module SpriteFactory
|
2
|
-
|
2
|
+
|
3
3
|
#----------------------------------------------------------------------------
|
4
4
|
|
5
|
-
VERSION = "1.
|
5
|
+
VERSION = "1.7"
|
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,7 +27,9 @@ module SpriteFactory
|
|
27
27
|
attr_accessor :cssurl
|
28
28
|
attr_accessor :pngcrush
|
29
29
|
attr_accessor :nocomments
|
30
|
-
attr_accessor :
|
30
|
+
attr_accessor :separator
|
31
|
+
attr_accessor :glob
|
32
|
+
attr_accessor :sanitizer
|
31
33
|
end
|
32
34
|
|
33
35
|
#----------------------------------------------------------------------------
|
@@ -51,7 +53,7 @@ module SpriteFactory
|
|
51
53
|
end
|
52
54
|
|
53
55
|
end
|
54
|
-
|
56
|
+
|
55
57
|
#----------------------------------------------------------------------------
|
56
58
|
|
57
59
|
module Library # abstract module for using various image libraries
|
@@ -67,7 +69,7 @@ module SpriteFactory
|
|
67
69
|
def self.chunkypng
|
68
70
|
ChunkyPng
|
69
71
|
end
|
70
|
-
|
72
|
+
|
71
73
|
def self.image_magick
|
72
74
|
ImageMagick
|
73
75
|
end
|
@@ -12,7 +12,7 @@ module SpriteFactory
|
|
12
12
|
|
13
13
|
attr :input
|
14
14
|
attr :config
|
15
|
-
|
15
|
+
|
16
16
|
def initialize(input, config = {})
|
17
17
|
@input = input.to_s[-1] == "/" ? input[0...-1] : input # gracefully ignore trailing slash on input directory name
|
18
18
|
@config = config
|
@@ -24,9 +24,11 @@ module SpriteFactory
|
|
24
24
|
@config[:report] ||= SpriteFactory.report
|
25
25
|
@config[:pngcrush] ||= SpriteFactory.pngcrush
|
26
26
|
@config[:nocomments] ||= SpriteFactory.nocomments
|
27
|
-
@config[:
|
27
|
+
@config[:separator] ||= SpriteFactory.separator || '_'
|
28
|
+
@config[:glob] ||= SpriteFactory.glob || '*'
|
29
|
+
@config[:sanitizer] ||= SpriteFactory.sanitizer
|
28
30
|
end
|
29
|
-
|
31
|
+
|
30
32
|
#----------------------------------------------------------------------------
|
31
33
|
|
32
34
|
def run!(&block)
|
@@ -76,7 +78,7 @@ module SpriteFactory
|
|
76
78
|
end
|
77
79
|
|
78
80
|
#----------------------------------------------------------------------------
|
79
|
-
|
81
|
+
|
80
82
|
private
|
81
83
|
|
82
84
|
def selector
|
@@ -139,8 +141,12 @@ module SpriteFactory
|
|
139
141
|
config[:nocomments] # set true if you dont want any comments in the output style file
|
140
142
|
end
|
141
143
|
|
142
|
-
def
|
143
|
-
config[:
|
144
|
+
def separator
|
145
|
+
config[:separator]
|
146
|
+
end
|
147
|
+
|
148
|
+
def sanitizer
|
149
|
+
config[:sanitizer]
|
144
150
|
end
|
145
151
|
|
146
152
|
def custom_style_file
|
@@ -166,7 +172,7 @@ module SpriteFactory
|
|
166
172
|
def image_files
|
167
173
|
return [] if input.nil?
|
168
174
|
valid_extensions = library::VALID_EXTENSIONS
|
169
|
-
expansions = Array(valid_extensions).map{|ext| File.join(input, "**", "
|
175
|
+
expansions = Array(valid_extensions).map{|ext| File.join(input, "**", "#{config[:glob]}.#{ext}")}
|
170
176
|
SpriteFactory.find_files(*expansions)
|
171
177
|
end
|
172
178
|
|
@@ -181,22 +187,31 @@ module SpriteFactory
|
|
181
187
|
|
182
188
|
images = library.load(image_files)
|
183
189
|
images.each do |i|
|
184
|
-
i[:name], i[:ext] =
|
190
|
+
i[:name], i[:ext] = extract_image_filename(i[:filename], input_path)
|
185
191
|
raise RuntimeError, "image #{i[:name]} does not fit within a fixed width of #{width}" if width && (width < i[:width])
|
186
192
|
raise RuntimeError, "image #{i[:name]} does not fit within a fixed height of #{height}" if height && (height < i[:height])
|
187
193
|
end
|
188
194
|
images.sort_by {|i| [image_name_without_pseudo_class(i), image_pseudo_class_priority(i)] }
|
189
195
|
end
|
190
196
|
|
191
|
-
def
|
192
|
-
name = Pathname.new(filename).relative_path_from(input_path).to_s.gsub(File::SEPARATOR,
|
193
|
-
name = name.gsub('--', ':')
|
194
|
-
name = name.gsub('__', ' ')
|
197
|
+
def extract_image_filename(filename, input_path)
|
198
|
+
name = Pathname.new(filename).relative_path_from(input_path).to_s.gsub(File::SEPARATOR, separator)
|
195
199
|
ext = File.extname(name)
|
196
200
|
name = name[0...-ext.length] unless ext.empty?
|
201
|
+
name = sanitize_image_filename(name)
|
197
202
|
[name, ext]
|
198
203
|
end
|
199
204
|
|
205
|
+
def sanitize_image_filename(name)
|
206
|
+
if sanitizer.is_a?(Proc)
|
207
|
+
sanitizer.call(name) # custom sanitizer
|
208
|
+
elsif sanitizer
|
209
|
+
name.gsub(/[^\w-]/, '') # (opt-in) clean all non-word characters
|
210
|
+
else
|
211
|
+
name.gsub('--', ':').gsub('__', ' ') # legacy behavior
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
200
215
|
def image_name_without_pseudo_class(image)
|
201
216
|
image[:name].split(':').first
|
202
217
|
end
|
@@ -249,7 +264,7 @@ module SpriteFactory
|
|
249
264
|
if SUPPORTS_PNGCRUSH && config[:pngcrush]
|
250
265
|
crushed = "#{image}.crushed"
|
251
266
|
system('pngcrush', '-q', '-rem alla', '-reduce', '-brute', image, crushed)
|
252
|
-
FileUtils.mv(crushed, image)
|
267
|
+
FileUtils.mv(crushed, image)
|
253
268
|
end
|
254
269
|
end
|
255
270
|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Creating a sprite from following images:
|
4
|
+
|
5
|
+
test/images/glob/included1.png (64x64)
|
6
|
+
test/images/glob/included2.png (64x64)
|
7
|
+
test/images/glob/included3.png (64x64)
|
8
|
+
|
9
|
+
Output files:
|
10
|
+
test/images/glob.png
|
11
|
+
test/images/glob.css
|
12
|
+
|
13
|
+
Output size:
|
14
|
+
192x64
|
15
|
+
|
16
|
+
|
17
|
+
*/
|
18
|
+
img.included1 { width: 64px; height: 64px; background: url(glob.png) 0px 0px no-repeat; }
|
19
|
+
img.included2 { width: 64px; height: 64px; background: url(glob.png) -64px 0px no-repeat; }
|
20
|
+
img.included3 { width: 64px; height: 64px; background: url(glob.png) -128px 0px no-repeat; }
|
Binary file
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Creating a sprite from following images:
|
4
|
+
|
5
|
+
test/images/names/Ends With Bang!.png (64x64)
|
6
|
+
test/images/names/Has & Ampersand.png (64x64)
|
7
|
+
test/images/names/Odd.Period.png (64x64)
|
8
|
+
|
9
|
+
Output files:
|
10
|
+
test/images/sanitized.png
|
11
|
+
test/images/sanitized.css
|
12
|
+
|
13
|
+
Output size:
|
14
|
+
192x64
|
15
|
+
|
16
|
+
|
17
|
+
*/
|
18
|
+
img.EndsWithBang { width: 64px; height: 64px; background: url(sanitized.png) 0px 0px no-repeat; }
|
19
|
+
img.HasAmpersand { width: 64px; height: 64px; background: url(sanitized.png) -64px 0px no-repeat; }
|
20
|
+
img.OddPeriod { width: 64px; height: 64px; background: url(sanitized.png) -128px 0px no-repeat; }
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Creating a sprite from following images:
|
4
|
+
|
5
|
+
test/images/names/Ends With Bang!.png (64x64)
|
6
|
+
test/images/names/Has & Ampersand.png (64x64)
|
7
|
+
test/images/names/Odd.Period.png (64x64)
|
8
|
+
|
9
|
+
Output files:
|
10
|
+
test/images/sanitized.custom.png
|
11
|
+
test/images/sanitized.custom.css
|
12
|
+
|
13
|
+
Output size:
|
14
|
+
192x64
|
15
|
+
|
16
|
+
|
17
|
+
*/
|
18
|
+
img.ends_with_bang_ { width: 64px; height: 64px; background: url(sanitized.custom.png) 0px 0px no-repeat; }
|
19
|
+
img.has___ampersand { width: 64px; height: 64px; background: url(sanitized.custom.png) -64px 0px no-repeat; }
|
20
|
+
img.odd_period { width: 64px; height: 64px; background: url(sanitized.custom.png) -128px 0px no-repeat; }
|
Binary file
|
Binary file
|
data/test/integration_test.rb
CHANGED
@@ -142,6 +142,26 @@ module SpriteFactory
|
|
142
142
|
|
143
143
|
#----------------------------------------------------------------------------
|
144
144
|
|
145
|
+
def test_generate_with_custom_glob
|
146
|
+
integration_test(GLOB_PATH, :glob => 'included*')
|
147
|
+
end
|
148
|
+
|
149
|
+
#----------------------------------------------------------------------------
|
150
|
+
|
151
|
+
def test_generate_with_sanitizer
|
152
|
+
integration_test(NAMES_PATH, :output => output_path('sanitized'),
|
153
|
+
:sanitizer => true)
|
154
|
+
end
|
155
|
+
|
156
|
+
#----------------------------------------------------------------------------
|
157
|
+
|
158
|
+
def test_generate_with_custom_sanitizer
|
159
|
+
integration_test(NAMES_PATH, :output => output_path('sanitized.custom'),
|
160
|
+
:sanitizer => lambda {|name| name.gsub(/[^\w]/, '_').downcase })
|
161
|
+
end
|
162
|
+
|
163
|
+
#----------------------------------------------------------------------------
|
164
|
+
|
145
165
|
def test_generate_sprite_with_nocss
|
146
166
|
input = REGULAR_PATH
|
147
167
|
output = File.basename(REGULAR_PATH)
|
data/test/runner_test.rb
CHANGED
@@ -18,7 +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(
|
21
|
+
assert_equal(SEPARATOR, r.separator)
|
22
22
|
|
23
23
|
r = Runner.new(IRREGULAR_PATH)
|
24
24
|
assert_equal(IRREGULAR_PATH, r.input)
|
@@ -29,9 +29,9 @@ module SpriteFactory
|
|
29
29
|
assert_equal(:horizontal, r.layout_name)
|
30
30
|
assert_equal(:css, r.style_name)
|
31
31
|
assert_equal(:rmagick, r.library_name)
|
32
|
-
assert_equal(
|
32
|
+
assert_equal(SEPARATOR, r.separator)
|
33
33
|
|
34
|
-
r = Runner.new(IRREGULAR_PATH, :
|
34
|
+
r = Runner.new(IRREGULAR_PATH, :separator => '.')
|
35
35
|
assert_equal(IRREGULAR_PATH, r.input)
|
36
36
|
assert_equal(IRREGULAR_PATH, r.output)
|
37
37
|
assert_equal(IRREGULAR_PATH + ".png", r.output_image_file)
|
@@ -40,7 +40,7 @@ module SpriteFactory
|
|
40
40
|
assert_equal(:horizontal, r.layout_name)
|
41
41
|
assert_equal(:css, r.style_name)
|
42
42
|
assert_equal(:rmagick, r.library_name)
|
43
|
-
assert_equal('.',
|
43
|
+
assert_equal('.', r.separator)
|
44
44
|
|
45
45
|
r = Runner.new(REGULAR_PATH, :output => IRREGULAR_PATH)
|
46
46
|
assert_equal(REGULAR_PATH, r.input)
|
@@ -51,7 +51,7 @@ module SpriteFactory
|
|
51
51
|
assert_equal(:horizontal, r.layout_name)
|
52
52
|
assert_equal(:css, r.style_name)
|
53
53
|
assert_equal(:rmagick, r.library_name)
|
54
|
-
assert_equal(
|
54
|
+
assert_equal(SEPARATOR, r.separator)
|
55
55
|
|
56
56
|
r = Runner.new(REGULAR_PATH, :output_image => "foo.png", :output_style => "bar.css.sass.erb")
|
57
57
|
assert_equal(REGULAR_PATH, r.input)
|
@@ -62,7 +62,7 @@ module SpriteFactory
|
|
62
62
|
assert_equal(:horizontal, r.layout_name)
|
63
63
|
assert_equal(:css, r.style_name)
|
64
64
|
assert_equal(:rmagick, r.library_name)
|
65
|
-
assert_equal(
|
65
|
+
assert_equal(SEPARATOR, r.separator)
|
66
66
|
|
67
67
|
r = Runner.new(REGULAR_PATH, :layout => :vertical, :library => :chunkypng, :style => :sass)
|
68
68
|
assert_equal(REGULAR_PATH, r.input)
|
@@ -73,7 +73,7 @@ module SpriteFactory
|
|
73
73
|
assert_equal(:vertical, r.layout_name)
|
74
74
|
assert_equal(:sass, r.style_name)
|
75
75
|
assert_equal(:chunkypng, r.library_name)
|
76
|
-
assert_equal(
|
76
|
+
assert_equal(SEPARATOR, r.separator)
|
77
77
|
|
78
78
|
end
|
79
79
|
|
@@ -239,10 +239,10 @@ module SpriteFactory
|
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
242
|
-
def
|
242
|
+
def test_use_specified_separator
|
243
243
|
Runner.publicize_methods do
|
244
244
|
expected = %w(england.amy england.bob france.bob usa.amy usa.bob)
|
245
|
-
actual = Runner.new(SUBFOLDERS_PATH, :
|
245
|
+
actual = Runner.new(SUBFOLDERS_PATH, :separator => '.').load_images.map{|i| i[:name]}
|
246
246
|
assert_equal(expected, actual)
|
247
247
|
end
|
248
248
|
end
|
data/test/test_case.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.expand_path('../lib/sprite_factory', File.dirname(__FILE__))
|
2
|
-
require '
|
2
|
+
require 'minitest/autorun'
|
3
3
|
|
4
4
|
module SpriteFactory
|
5
|
-
class TestCase < Test
|
5
|
+
class TestCase < Minitest::Test
|
6
6
|
|
7
7
|
#----------------------------------------------------------------------------
|
8
8
|
|
@@ -16,6 +16,8 @@ module SpriteFactory
|
|
16
16
|
EMPTY_PATH = 'test/images/empty'
|
17
17
|
SUBFOLDERS_PATH = 'test/images/subfolders'
|
18
18
|
HOVER_PATH = 'test/images/hover'
|
19
|
+
GLOB_PATH = 'test/images/glob'
|
20
|
+
NAMES_PATH = 'test/images/names'
|
19
21
|
|
20
22
|
REGULAR = SpriteFactory.find_files(File.join(REGULAR_PATH, '*.png'))
|
21
23
|
IRREGULAR = SpriteFactory.find_files(File.join(IRREGULAR_PATH, '*.png'))
|
@@ -36,7 +38,7 @@ module SpriteFactory
|
|
36
38
|
{ :filename => IRREGULAR[4], :width => 46, :height => 25 }
|
37
39
|
]
|
38
40
|
|
39
|
-
|
41
|
+
SEPARATOR = '_'
|
40
42
|
|
41
43
|
def output_path(name)
|
42
44
|
File.join(IMAGES_PATH, name)
|
@@ -80,14 +82,14 @@ module SpriteFactory
|
|
80
82
|
#----------------------------------------------------------------------------
|
81
83
|
|
82
84
|
def assert_runtime_error(msg = nil)
|
83
|
-
e =
|
85
|
+
e = assert_raises RuntimeError do
|
84
86
|
yield
|
85
87
|
end
|
86
88
|
assert_match(msg, e.message) if msg
|
87
89
|
end
|
88
90
|
|
89
91
|
def assert_not_implemented(msg = nil)
|
90
|
-
e =
|
92
|
+
e = assert_raises NotImplementedError do
|
91
93
|
yield
|
92
94
|
end
|
93
95
|
assert_match(msg, e.message) if msg
|
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.
|
4
|
+
version: '1.7'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Gordon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rmagick
|
@@ -76,6 +76,11 @@ files:
|
|
76
76
|
- test/images/formats/spies.jpg
|
77
77
|
- test/images/formats/stackoverflow.ico
|
78
78
|
- test/images/formats/thief.png
|
79
|
+
- test/images/glob/excluded1.png
|
80
|
+
- test/images/glob/excluded2.png
|
81
|
+
- test/images/glob/included1.png
|
82
|
+
- test/images/glob/included2.png
|
83
|
+
- test/images/glob/included3.png
|
79
84
|
- test/images/hover/div.bar__img.icon--active.png
|
80
85
|
- test/images/hover/div.bar__img.icon--focus.png
|
81
86
|
- test/images/hover/div.bar__img.icon--hover.png
|
@@ -94,10 +99,15 @@ files:
|
|
94
99
|
- test/images/irregular/irregular4.png
|
95
100
|
- test/images/irregular/irregular5.png
|
96
101
|
- test/images/irregular/readme.txt
|
102
|
+
- test/images/names/Ends With Bang!.png
|
103
|
+
- test/images/names/Has & Ampersand.png
|
104
|
+
- test/images/names/Odd.Period.png
|
97
105
|
- test/images/reference/custom.css
|
98
106
|
- test/images/reference/custom.png
|
99
107
|
- test/images/reference/formats.css
|
100
108
|
- test/images/reference/formats.png
|
109
|
+
- test/images/reference/glob.css
|
110
|
+
- test/images/reference/glob.png
|
101
111
|
- test/images/reference/hover.css
|
102
112
|
- test/images/reference/hover.png
|
103
113
|
- test/images/reference/index.html
|
@@ -140,6 +150,10 @@ files:
|
|
140
150
|
- test/images/reference/regular.vertical.css
|
141
151
|
- test/images/reference/regular.vertical.png
|
142
152
|
- test/images/reference/s.gif
|
153
|
+
- test/images/reference/sanitized.css
|
154
|
+
- test/images/reference/sanitized.custom.css
|
155
|
+
- test/images/reference/sanitized.custom.png
|
156
|
+
- test/images/reference/sanitized.png
|
143
157
|
- test/images/reference/subfolders.css
|
144
158
|
- test/images/reference/subfolders.png
|
145
159
|
- test/images/regular/regular1.PNG
|
@@ -181,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
195
|
version: '0'
|
182
196
|
requirements: []
|
183
197
|
rubyforge_project:
|
184
|
-
rubygems_version: 2.
|
198
|
+
rubygems_version: 2.4.5
|
185
199
|
signing_key:
|
186
200
|
specification_version: 4
|
187
201
|
summary: Automatic CSS sprite generator
|