spritely 1.2.0 → 1.2.1

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: 55045aef9a86227f8a36323391b7e3e310feb6ef
4
- data.tar.gz: c0fca28f4f25ad8010743f7ac402d42582101d1d
3
+ metadata.gz: a0ea70f1bb477a8c0c5e1e2def759600d00ef83c
4
+ data.tar.gz: e10782b4a0356ed81a5976856c3661c6b2e4e42f
5
5
  SHA512:
6
- metadata.gz: a842ca5a5e5b4fea18f01b5e389bff09fa1666d3a86a7c284fdf8f62143eb36ad60031b593d16b5f97dfd2d0c58485262993eb358771818cf1a3359622dee89c
7
- data.tar.gz: f964e9e738031bb14e61d516cb836a152812002ca0d396809ac4d772f31d1343c763c457f174ccc9dad065865a3838e578d0b5edaf345cb3e26f3d1797b623d0
6
+ metadata.gz: e0c772fc0b8a55757dab249c179f6070493d85065a96924193453b5648a7a544717a04ca49c3fcc3e20dd169374ceafa92e591056dfa85cf05198c5d1bea28ce
7
+ data.tar.gz: 770515f3cc9b52726adde50e09f62cf1230e250ab4476d2dfa7cc05d8c6a9f5114c85fb2d1002d1e4c719640a0fd3af9261ffc64bb9366508e49b76dce404806
@@ -19,7 +19,7 @@ module Spritely
19
19
  end
20
20
 
21
21
  def cache_key
22
- files.collect { |file| Digest::MD5.file(file) }.join
22
+ files.flat_map { |file_path| [Digest::MD5.hexdigest(file_path), Digest::MD5.file(file_path)] }.join
23
23
  end
24
24
  alias_method :to_s, :cache_key
25
25
 
@@ -1,3 +1,3 @@
1
1
  module Spritely
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -43,4 +43,26 @@ describe 'Precompilation', :integration do
43
43
  sprite_files = Dir.glob(File.join('public', 'assets', 'sprites', 'application-*.png'))
44
44
  expect(sprite_files.length).to eq(2)
45
45
  end
46
+
47
+ context 'a file is renamed multiple times' do
48
+ before do
49
+ compile_assets
50
+ FileUtils.mv 'app/assets/images/application/fool.png', 'app/assets/images/application/ffool.png'
51
+ compile_assets
52
+ FileUtils.mv 'app/assets/images/application/ffool.png', 'app/assets/images/application/afool.png'
53
+ compile_assets
54
+ end
55
+
56
+ it 'should end up with 2 different versions of the sprite' do
57
+ sprite_files = Dir.glob(File.join('public', 'assets', 'sprites', 'application-*.png'))
58
+ expect(sprite_files.length).to eq(2)
59
+ end
60
+
61
+ it 'should generate the correct sprite after all of the file-moving' do
62
+ runner %~Rails.application.assets["sprites/application.png"].write_to("compiled-sprite.png")~
63
+ compiled_sprite = ChunkyPNG::Image.from_file('compiled-sprite.png')
64
+ correct_sprite = ChunkyPNG::Image.from_file(File.join(__dir__, '..', 'fixtures', 'correct-renamed-sprite.png'))
65
+ expect(compiled_sprite).to eq(correct_sprite)
66
+ end
67
+ end
46
68
  end
@@ -72,12 +72,14 @@ describe Spritely::Collection do
72
72
 
73
73
  describe '#cache_key' do
74
74
  before do
75
- allow(Digest::MD5).to receive(:file).with('file-1.png').and_return('foo')
76
- allow(Digest::MD5).to receive(:file).with('file-2.png').and_return('bar')
75
+ allow(Digest::MD5).to receive(:hexdigest).with('file-1.png').and_return('foo1')
76
+ allow(Digest::MD5).to receive(:hexdigest).with('file-2.png').and_return('bar1')
77
+ allow(Digest::MD5).to receive(:file).with('file-1.png').and_return('foo2')
78
+ allow(Digest::MD5).to receive(:file).with('file-2.png').and_return('bar2')
77
79
  end
78
80
 
79
- its(:cache_key) { should eq('foobar') }
80
- its(:to_s) { should eq('foobar') }
81
+ its(:cache_key) { should eq('foo1foo2bar1bar2') }
82
+ its(:to_s) { should eq('foo1foo2bar1bar2') }
81
83
  end
82
84
 
83
85
  describe '#position!' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spritely
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Robbin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-20 00:00:00.000000000 Z
11
+ date: 2016-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chunky_png
@@ -184,6 +184,7 @@ files:
184
184
  - lib/spritely/sprockets/transformer.rb
185
185
  - lib/spritely/version.rb
186
186
  - spec/fixtures/correct-empty-sprite.png
187
+ - spec/fixtures/correct-renamed-sprite.png
187
188
  - spec/fixtures/correct-sprite.png
188
189
  - spec/fixtures/correct-weird-sprite.png
189
190
  - spec/fixtures/rails-app-changes/app/assets/images/application/dropdown-arrow.png
@@ -234,13 +235,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
235
  version: '0'
235
236
  requirements: []
236
237
  rubyforge_project:
237
- rubygems_version: 2.5.1
238
+ rubygems_version: 2.5.2
238
239
  signing_key:
239
240
  specification_version: 4
240
241
  summary: Hooks into the Sprockets asset packaging system to allow you to easily generate
241
242
  sprite maps
242
243
  test_files:
243
244
  - spec/fixtures/correct-empty-sprite.png
245
+ - spec/fixtures/correct-renamed-sprite.png
244
246
  - spec/fixtures/correct-sprite.png
245
247
  - spec/fixtures/correct-weird-sprite.png
246
248
  - spec/fixtures/rails-app/app/assets/images/application/background.png