spriteful 0.4.0 → 0.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 802e42a6470b82654aa1aef0398511151437a540
4
- data.tar.gz: 888a1faf83d9554a7c1800d5a7d52e1c2bbd2191
3
+ metadata.gz: e63c0a3ac0ace8a37960c2b007802938effb9f73
4
+ data.tar.gz: bbd2d4e865227dd3b68f4bec64c4f6c15df03b96
5
5
  SHA512:
6
- metadata.gz: 2addb4c415b658ca915c4ac3a7fafd81a534a7441e87f0c6bc2cb4bb2f91684cf4f4ccabde938540b7b27112510a94a52d5c25f979beeff2097122217f35253f
7
- data.tar.gz: e46289ac393de4033677556bf2642b708349c39f4f60fddf27fd8b608b7a88ddda0b802f8cc47c78eaf6174d9a28f50b1b336fa035091415867c114fa6272226
6
+ metadata.gz: 7dd122c7267b3926e351f245ee9907998f8ba01b0a168508a7de6d2a2f825ee0d0b199395cdddf93e1e774d6ef2051a1caa4117f2eff258faa793b8385362418
7
+ data.tar.gz: aa6b33f88f21060952d4afc531ec578728c7c7784c1334550bb3fc95ce249a8c5d41ab72ff4691c9d9b14e82fbc8166f7913a383198cab5242d2b94bccadd2bc
data/README.md CHANGED
@@ -180,6 +180,7 @@ If you are using SVG images, the embedded SVG as data URI will be optimized with
180
180
 
181
181
  * `--stylesheets` (`-s`) - Directory to save the generated stylesheet(s), instead of copying them to the clipboard.
182
182
  * `--destination` (`-d`) - Directory to save the generated image(s).
183
+ * `--name` (`-n`) - Name of generated sprite.
183
184
  * `--rails` (`-r`) - Forces rails specific settings, see [Spriteful and Rails](#spriteful-and-rails) for more info.
184
185
  * `--format` (`-f`) - Format to generate the sprite(s) stylesheet(s). Either "css" or "scss".
185
186
  * `--template` (`-t`) - The path for a custom Stylesheet template.
@@ -12,6 +12,7 @@ module Spriteful
12
12
  class_option :format, aliases: '-f', banner: 'FORMAT', type: :string, desc: 'Format to generate the sprite(s) stylesheet(s). Either "css" or "scss".', default: 'css'
13
13
  class_option :stylesheets, aliases: '-s', banner: 'STYLESHEETS_DIR', type: :string, desc: 'Directory to save the generated stylesheet(s), instead of copying them to the clipboard.', default: Dir.pwd
14
14
  class_option :destination, aliases: '-d', banner: 'DESTINATION_DIR', type: :string, desc: 'Destination directory to save the combined image(s).', default: Dir.pwd
15
+ class_option :name, aliases: '-n', banner: 'SPRITE_NAME', type: :string, desc: 'Name of generated sprite.'
15
16
  class_option :root, aliases: '-r', banner: 'ROOT_DIR', type: :string, desc: 'Root folder from where your static files will be served.'
16
17
  class_option :template, aliases: '-t', banner: 'TEMPLATE', type: :string, desc: 'Custom template file in ERB format to be used instead of the default.'
17
18
 
@@ -135,7 +136,8 @@ module Spriteful
135
136
  {
136
137
  horizontal: options.horizontal?,
137
138
  spacing: options.spacing,
138
- optimize: options.optimize
139
+ optimize: options.optimize,
140
+ name: options.name
139
141
  }
140
142
  end
141
143
 
@@ -51,7 +51,7 @@ module Spriteful
51
51
  @spacing = options[:spacing] || 0
52
52
  @optimize = options[:optimize]
53
53
 
54
- @name = File.basename(source_dir)
54
+ @name = options[:name] || File.basename(source_dir)
55
55
  @filename = "#{name}.png"
56
56
  @path = File.expand_path(File.join(destination, @filename))
57
57
  @list = Magick::ImageList.new(*sources) { self.background_color = 'none' }
@@ -1,3 +1,3 @@
1
1
  module Spriteful
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -52,6 +52,11 @@ describe Spriteful::Sprite do
52
52
  sprite = Spriteful::Sprite.new(source, destination)
53
53
  expect(sprite.filename).to eq('simple.png')
54
54
  end
55
+
56
+ it 'returns the name option if it is present' do
57
+ sprite = Spriteful::Sprite.new(source, destination, name: 'foo')
58
+ expect(sprite.filename).to eq('foo.png')
59
+ end
55
60
  end
56
61
 
57
62
  describe '#combine!' do
@@ -16,6 +16,16 @@ describe Spriteful::Stylesheet do
16
16
  expect(output).to match(/.simple.red \{/)
17
17
  end
18
18
 
19
+ it 'uses the custom name of the sprite' do
20
+ sprite = Spriteful::Sprite.new(source, destination, name: 'foo')
21
+ stylesheet = Spriteful::Stylesheet.new(sprite, destination, format: 'css')
22
+ output = stylesheet.render
23
+
24
+ expect(output).to match(/.foo \{/)
25
+ expect(output).to match(/.foo.blue \{/)
26
+ expect(output).to match(/.foo.red \{/)
27
+ end
28
+
19
29
  it 'renders the SCSS format' do
20
30
  sprite = Spriteful::Sprite.new(source, destination)
21
31
  stylesheet = Spriteful::Stylesheet.new(sprite, destination, format: 'scss')
@@ -26,6 +36,16 @@ describe Spriteful::Stylesheet do
26
36
  expect(output).to match(/%simple-sprite-red \{/)
27
37
  end
28
38
 
39
+ it 'uses the custom name of the sprite for SCSS format' do
40
+ sprite = Spriteful::Sprite.new(source, destination, name: 'foo')
41
+ stylesheet = Spriteful::Stylesheet.new(sprite, destination, format: 'scss')
42
+ output = stylesheet.render
43
+
44
+ expect(output).to match(/%foo-sprite \{/)
45
+ expect(output).to match(/%foo-sprite-blue \{/)
46
+ expect(output).to match(/%foo-sprite-red \{/)
47
+ end
48
+
29
49
  it 'renders the SCSS format using mixin' do
30
50
  sprite = Spriteful::Sprite.new(source, destination)
31
51
  stylesheet = Spriteful::Stylesheet.new(sprite, destination, format: 'scss', mixin: true)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spriteful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Mazza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-07 00:00:00.000000000 Z
11
+ date: 2014-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project:
168
- rubygems_version: 2.2.2
168
+ rubygems_version: 2.4.2
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: ''
@@ -180,3 +180,4 @@ test_files:
180
180
  - spec/sprite_spec.rb
181
181
  - spec/spriteful/template_spec.rb
182
182
  - spec/stylesheet_spec.rb
183
+ has_rdoc: