sprite-factory 1.7 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/RELEASE_NOTES.md +5 -0
- data/lib/sprite_factory.rb +2 -2
- data/lib/sprite_factory/runner.rb +14 -1
- data/test/images/custom/custom.css +0 -0
- data/test/images/custom/running.png +0 -0
- data/test/images/custom/stopped.png +0 -0
- data/test/images/formats/thief.png +0 -0
- 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/hover/div.bar__img.icon--active.png +0 -0
- data/test/images/hover/div.bar__img.icon--focus.png +0 -0
- data/test/images/hover/div.bar__img.icon--hover.png +0 -0
- data/test/images/hover/div.bar__img.icon--link.png +0 -0
- data/test/images/hover/div.bar__img.icon--visited.png +0 -0
- data/test/images/hover/div.bar__img.icon.png +0 -0
- data/test/images/hover/div.foo__img.icon--active.png +0 -0
- data/test/images/hover/div.foo__img.icon--focus.png +0 -0
- data/test/images/hover/div.foo__img.icon--hover.png +0 -0
- data/test/images/hover/div.foo__img.icon--link.png +0 -0
- data/test/images/hover/div.foo__img.icon--visited.png +0 -0
- data/test/images/hover/div.foo__img.icon.png +0 -0
- data/test/images/irregular/irregular1.png +0 -0
- data/test/images/irregular/irregular2.png +0 -0
- data/test/images/irregular/irregular3.png +0 -0
- data/test/images/irregular/irregular4.png +0 -0
- data/test/images/irregular/irregular5.png +0 -0
- data/test/images/names/Odd.Period.png +0 -0
- data/test/images/reference/irregular.filtered.css +20 -0
- data/test/images/reference/irregular.filtered.png +0 -0
- data/test/images/reference/regular.filtered.css +20 -0
- data/test/images/reference/regular.filtered.png +0 -0
- data/test/images/subfolders/england/amy.png +0 -0
- data/test/images/subfolders/england/bob.png +0 -0
- data/test/images/subfolders/france/bob.png +0 -0
- data/test/images/subfolders/usa/amy.png +0 -0
- data/test/images/subfolders/usa/bob.png +0 -0
- data/test/integration_test.rb +12 -0
- data/test/runner_test.rb +27 -3
- data/test/test_case.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb0f2314f328570697404a534cda489ed35c3c43
|
4
|
+
data.tar.gz: ad014967a8ecb4679f66e9f46ac4de2bf8c8d9ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce72a68481f25969e2eb9b4295176af0f4981ba67df6cc3d76a61aeb04bb9623d718a1dff078baf25173ec026c4c5514da000d759d0a95dbf19a0a4bc2e461e2
|
7
|
+
data.tar.gz: fb87c0cd93acd937fa422a76992dc3f4261f41609acd19efd72384946d2e14093cad27d8e5f1bb9ba0497be4b48661317dc41567ec1c3a3d8d50dc80debc6b35
|
data/README.md
CHANGED
data/RELEASE_NOTES.md
CHANGED
data/lib/sprite_factory.rb
CHANGED
@@ -2,7 +2,7 @@ module SpriteFactory
|
|
2
2
|
|
3
3
|
#----------------------------------------------------------------------------
|
4
4
|
|
5
|
-
VERSION = "1.7"
|
5
|
+
VERSION = "1.7.1"
|
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__)
|
@@ -30,6 +30,7 @@ module SpriteFactory
|
|
30
30
|
attr_accessor :separator
|
31
31
|
attr_accessor :glob
|
32
32
|
attr_accessor :sanitizer
|
33
|
+
attr_accessor :exclude
|
33
34
|
end
|
34
35
|
|
35
36
|
#----------------------------------------------------------------------------
|
@@ -85,4 +86,3 @@ module SpriteFactory
|
|
85
86
|
#----------------------------------------------------------------------------
|
86
87
|
|
87
88
|
end
|
88
|
-
|
@@ -27,6 +27,7 @@ module SpriteFactory
|
|
27
27
|
@config[:separator] ||= SpriteFactory.separator || '_'
|
28
28
|
@config[:glob] ||= SpriteFactory.glob || '*'
|
29
29
|
@config[:sanitizer] ||= SpriteFactory.sanitizer
|
30
|
+
@config[:exclude] ||= SpriteFactory.exclude || []
|
30
31
|
end
|
31
32
|
|
32
33
|
#----------------------------------------------------------------------------
|
@@ -149,6 +150,14 @@ module SpriteFactory
|
|
149
150
|
config[:sanitizer]
|
150
151
|
end
|
151
152
|
|
153
|
+
def exclude
|
154
|
+
config[:exclude]
|
155
|
+
end
|
156
|
+
|
157
|
+
def exclude?(file)
|
158
|
+
Array(exclude).any? { |name| file.include?(name) }
|
159
|
+
end
|
160
|
+
|
152
161
|
def custom_style_file
|
153
162
|
File.join(input, File.basename(input) + ".#{style_name}")
|
154
163
|
end
|
@@ -169,11 +178,15 @@ module SpriteFactory
|
|
169
178
|
end
|
170
179
|
end
|
171
180
|
|
181
|
+
#----------------------------------------------------------------------------
|
182
|
+
|
172
183
|
def image_files
|
173
184
|
return [] if input.nil?
|
174
185
|
valid_extensions = library::VALID_EXTENSIONS
|
175
186
|
expansions = Array(valid_extensions).map{|ext| File.join(input, "**", "#{config[:glob]}.#{ext}")}
|
176
|
-
SpriteFactory.find_files(*expansions)
|
187
|
+
files = SpriteFactory.find_files(*expansions)
|
188
|
+
files = files.reject{ |file| exclude?(file) }
|
189
|
+
files
|
177
190
|
end
|
178
191
|
|
179
192
|
#----------------------------------------------------------------------------
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Creating a sprite from following images:
|
4
|
+
|
5
|
+
test/images/irregular/irregular2.png (16x16)
|
6
|
+
test/images/irregular/irregular3.png (48x48)
|
7
|
+
test/images/irregular/irregular4.png (34x14)
|
8
|
+
|
9
|
+
Output files:
|
10
|
+
test/images/irregular.filtered.png
|
11
|
+
test/images/irregular.filtered.css
|
12
|
+
|
13
|
+
Output size:
|
14
|
+
98x48
|
15
|
+
|
16
|
+
|
17
|
+
*/
|
18
|
+
img.filtered_irregular2 { width: 16px; height: 16px; background: url(irregular.filtered.png) 0px -16px no-repeat; }
|
19
|
+
img.filtered_irregular3 { width: 48px; height: 48px; background: url(irregular.filtered.png) -16px 0px no-repeat; }
|
20
|
+
img.filtered_irregular4 { width: 34px; height: 14px; background: url(irregular.filtered.png) -64px -17px no-repeat; }
|
Binary file
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Creating a sprite from following images:
|
4
|
+
|
5
|
+
test/images/regular/regular2.PNG (64x64)
|
6
|
+
test/images/regular/regular3.PNG (64x64)
|
7
|
+
test/images/regular/regular4.PNG (64x64)
|
8
|
+
|
9
|
+
Output files:
|
10
|
+
test/images/regular.filtered.png
|
11
|
+
test/images/regular.filtered.css
|
12
|
+
|
13
|
+
Output size:
|
14
|
+
192x64
|
15
|
+
|
16
|
+
|
17
|
+
*/
|
18
|
+
img.filtered_regular2 { width: 64px; height: 64px; background: url(regular.filtered.png) 0px 0px no-repeat; }
|
19
|
+
img.filtered_regular3 { width: 64px; height: 64px; background: url(regular.filtered.png) -64px 0px no-repeat; }
|
20
|
+
img.filtered_regular4 { width: 64px; height: 64px; background: url(regular.filtered.png) -128px 0px no-repeat; }
|
Binary file
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/integration_test.rb
CHANGED
@@ -60,6 +60,12 @@ module SpriteFactory
|
|
60
60
|
:nocomments => true)
|
61
61
|
end
|
62
62
|
|
63
|
+
def test_generate_regular_sprite_with_exclude_array
|
64
|
+
integration_test(REGULAR_PATH, :output => output_path('regular.filtered'),
|
65
|
+
:selector => 'img.filtered_',
|
66
|
+
:exclude => ['regular1.PNG', 'regular5.PNG'])
|
67
|
+
end
|
68
|
+
|
63
69
|
#----------------------------------------------------------------------------
|
64
70
|
|
65
71
|
def test_generate_irregular_sprite
|
@@ -111,6 +117,12 @@ module SpriteFactory
|
|
111
117
|
:style => :sass)
|
112
118
|
end
|
113
119
|
|
120
|
+
def test_generate_irregular_sprite_with_exclude_array
|
121
|
+
integration_test(IRREGULAR_PATH, :output => output_path('irregular.filtered'),
|
122
|
+
:selector => 'img.filtered_',
|
123
|
+
:exclude => ['irregular1.png', 'irregular5.png'])
|
124
|
+
end
|
125
|
+
|
114
126
|
#----------------------------------------------------------------------------
|
115
127
|
|
116
128
|
def test_generate_custom_sprite
|
data/test/runner_test.rb
CHANGED
@@ -19,6 +19,7 @@ module SpriteFactory
|
|
19
19
|
assert_equal(:css, r.style_name)
|
20
20
|
assert_equal(:rmagick, r.library_name)
|
21
21
|
assert_equal(SEPARATOR, r.separator)
|
22
|
+
assert_equal([], r.exclude)
|
22
23
|
|
23
24
|
r = Runner.new(IRREGULAR_PATH)
|
24
25
|
assert_equal(IRREGULAR_PATH, r.input)
|
@@ -30,6 +31,7 @@ module SpriteFactory
|
|
30
31
|
assert_equal(:css, r.style_name)
|
31
32
|
assert_equal(:rmagick, r.library_name)
|
32
33
|
assert_equal(SEPARATOR, r.separator)
|
34
|
+
assert_equal([], r.exclude)
|
33
35
|
|
34
36
|
r = Runner.new(IRREGULAR_PATH, :separator => '.')
|
35
37
|
assert_equal(IRREGULAR_PATH, r.input)
|
@@ -52,6 +54,19 @@ module SpriteFactory
|
|
52
54
|
assert_equal(:css, r.style_name)
|
53
55
|
assert_equal(:rmagick, r.library_name)
|
54
56
|
assert_equal(SEPARATOR, r.separator)
|
57
|
+
assert_equal([], r.exclude)
|
58
|
+
|
59
|
+
r = Runner.new(REGULAR_PATH, :exclude => ['foo.png'])
|
60
|
+
assert_equal(REGULAR_PATH, r.input)
|
61
|
+
assert_equal(REGULAR_PATH, r.output)
|
62
|
+
assert_equal(REGULAR_PATH + ".png", r.output_image_file)
|
63
|
+
assert_equal(REGULAR_PATH + ".css", r.output_style_file)
|
64
|
+
assert_equal(REGULAR, r.image_files)
|
65
|
+
assert_equal(:horizontal, r.layout_name)
|
66
|
+
assert_equal(:css, r.style_name)
|
67
|
+
assert_equal(:rmagick, r.library_name)
|
68
|
+
assert_equal(SEPARATOR, r.separator)
|
69
|
+
assert_equal(['foo.png'], r.exclude)
|
55
70
|
|
56
71
|
r = Runner.new(REGULAR_PATH, :output_image => "foo.png", :output_style => "bar.css.sass.erb")
|
57
72
|
assert_equal(REGULAR_PATH, r.input)
|
@@ -63,6 +78,7 @@ module SpriteFactory
|
|
63
78
|
assert_equal(:css, r.style_name)
|
64
79
|
assert_equal(:rmagick, r.library_name)
|
65
80
|
assert_equal(SEPARATOR, r.separator)
|
81
|
+
assert_equal([], r.exclude)
|
66
82
|
|
67
83
|
r = Runner.new(REGULAR_PATH, :layout => :vertical, :library => :chunkypng, :style => :sass)
|
68
84
|
assert_equal(REGULAR_PATH, r.input)
|
@@ -74,9 +90,8 @@ module SpriteFactory
|
|
74
90
|
assert_equal(:sass, r.style_name)
|
75
91
|
assert_equal(:chunkypng, r.library_name)
|
76
92
|
assert_equal(SEPARATOR, r.separator)
|
77
|
-
|
78
|
-
end
|
79
|
-
|
93
|
+
assert_equal([], r.exclude)
|
94
|
+
end
|
80
95
|
end
|
81
96
|
|
82
97
|
#----------------------------------------------------------------------------
|
@@ -202,6 +217,15 @@ module SpriteFactory
|
|
202
217
|
|
203
218
|
#----------------------------------------------------------------------------
|
204
219
|
|
220
|
+
def test_images_are_filtered_correctly
|
221
|
+
Runner.publicize_methods do
|
222
|
+
expected = REGULAR_INFO.map{ |i| i[:filename] }
|
223
|
+
excluded = expected.pop(2)
|
224
|
+
actual = Runner.new(REGULAR_PATH, :exclude => excluded).image_files
|
225
|
+
assert_equal(expected, actual)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
205
229
|
def test_images_are_sorted_in_classname_order
|
206
230
|
Runner.publicize_methods do
|
207
231
|
expected = [
|
data/test/test_case.rb
CHANGED
@@ -107,7 +107,7 @@ module SpriteFactory
|
|
107
107
|
actual_image = Magick::Image.read(actual)[0]
|
108
108
|
expected_image = Magick::Image.read(expected)[0]
|
109
109
|
img, val = expected_image.compare_channel(actual_image, Magick::MeanAbsoluteErrorMetric)
|
110
|
-
|
110
|
+
assert_in_delta(0.0, val, 1e-7, "generated image does not match pregenerated reference:\n actual: #{actual}\n expected: #{expected}\n expected: #{expected}")
|
111
111
|
end
|
112
112
|
|
113
113
|
def assert_reference_style(name)
|
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:
|
4
|
+
version: 1.7.1
|
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-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rmagick
|
@@ -112,6 +112,8 @@ files:
|
|
112
112
|
- test/images/reference/hover.png
|
113
113
|
- test/images/reference/index.html
|
114
114
|
- test/images/reference/irregular.css
|
115
|
+
- test/images/reference/irregular.filtered.css
|
116
|
+
- test/images/reference/irregular.filtered.png
|
115
117
|
- test/images/reference/irregular.fixed.css
|
116
118
|
- test/images/reference/irregular.fixed.png
|
117
119
|
- test/images/reference/irregular.horizontal.css
|
@@ -131,6 +133,8 @@ files:
|
|
131
133
|
- test/images/reference/regular.css
|
132
134
|
- test/images/reference/regular.custom.css
|
133
135
|
- test/images/reference/regular.custom.png
|
136
|
+
- test/images/reference/regular.filtered.css
|
137
|
+
- test/images/reference/regular.filtered.png
|
134
138
|
- test/images/reference/regular.fixed.css
|
135
139
|
- test/images/reference/regular.fixed.png
|
136
140
|
- test/images/reference/regular.horizontal.css
|