spritely 0.0.3 → 0.0.4

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: 8713d85420999dd80091c7851846907da9bf01d7
4
- data.tar.gz: 255c099a89c000d9102a68791695ccdab45b5b52
3
+ metadata.gz: b90bec681ab9efe494b5e246a9e7b036bd9e5998
4
+ data.tar.gz: 424ccf4da0ca02416f9f9f7cb9a63ec86ab1fe89
5
5
  SHA512:
6
- metadata.gz: ec919488acf8b9c8718f3309031eed246f063b35848aa6695c2b08b4b7c83645fbdaaf0f4151574335c23da137c82643724aa479db994bba35a9e88edf1279e4
7
- data.tar.gz: ceecec6dd9287f29c9dd9847deec20c6c625ce39532069f560c2b5b84199871e22e764e0d2a79dac745ae08293b6a585c8860f5d57bcb74c8ec8bc089a3ae12c
6
+ metadata.gz: 4e836ffa7fd997b44b44d0f81d71373a581f1dab757c9c2e3aa006d74096a524bb6853ebd3b273d44fe801153c9c0fd8fa64dd307d37261bc8cdc6304e659ea1
7
+ data.tar.gz: 63ffcfa28376d8bbd936dcfda0063677112e2b9b772ab56abf86600f5db41ee05ad8564f316b41a1f7e55dc38c4d749ba4f424fa3343cc29726417aeb4504411
@@ -3,7 +3,12 @@ require 'spritely/sprite_map'
3
3
  module Spritely
4
4
  module SassFunctions
5
5
  def spritely_map(glob, kwargs = {})
6
- SpriteMap.create(glob.value, kwargs)
6
+ SpriteMap.create(glob.value, kwargs).tap do |sprite_map|
7
+ sprite_map.files.each do |file|
8
+ sprockets_context.depend_on(file)
9
+ sprockets_context.depend_on_asset(file)
10
+ end
11
+ end
7
12
  end
8
13
 
9
14
  ::Sass::Script::Functions.declare :spritely_map, [:glob], var_kwargs: true
@@ -51,8 +51,6 @@ module Spritely
51
51
  !File.exist?(filename) || Cache.busted?(filename, cache_key)
52
52
  end
53
53
 
54
- private
55
-
56
54
  def files
57
55
  Spritely.environment.paths.flat_map { |path| Dir.glob(File.join(path, glob)) }
58
56
  end
@@ -1,3 +1,3 @@
1
1
  module Spritely
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -4,7 +4,7 @@ require 'active_support/core_ext/string'
4
4
  describe 'Precompilation', :integration do
5
5
  it 'should create the sprite in the right location' do
6
6
  render_asset('sprites.css')
7
- expect(File.exist?(File.join('app', 'assets', 'images', 'sprites', 'application.png'))).to be_true
7
+ expect(File.exist?(File.join('app', 'assets', 'images', 'sprites', 'application.png'))).to be_truthy
8
8
  end
9
9
 
10
10
  it 'should compile the correct-looking sprite file' do
@@ -17,13 +17,13 @@ describe 'Precompilation', :integration do
17
17
  it 'should compile all of the assets necessary' do
18
18
  compile_assets
19
19
  sprite_files = Dir.glob(File.join('public', 'assets', 'sprites', 'application-*.png'))
20
- expect(sprite_files).to have(1).item
20
+ expect(sprite_files.length).to eq(1)
21
21
  end
22
22
 
23
23
  it 'should compile all of the assets necessary when sprites have been pre-generated' do
24
24
  render_asset('sprites.css')
25
25
  compile_assets
26
26
  sprite_files = Dir.glob(File.join('public', 'assets', 'sprites', 'application-*.png'))
27
- expect(sprite_files).to have(1).item
27
+ expect(sprite_files.length).to eq(1)
28
28
  end
29
29
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rspec'
2
+ require 'rspec/its'
2
3
  require 'spritely'
3
4
 
4
5
  require 'pry-byebug'
@@ -9,7 +10,6 @@ RSpec.configure do |config|
9
10
  config.expect_with :rspec do |c|
10
11
  c.syntax = :expect
11
12
  end
12
- config.treat_symbols_as_metadata_keys_with_true_values = true
13
13
 
14
14
  config.include RailsAppHelpers, :integration
15
15
  config.around(:each, :integration) { |example| within_rails_app(&example) }
@@ -3,6 +3,7 @@ require 'spec_helper'
3
3
  describe Spritely::SassFunctions do
4
4
  class SpriteMapDouble < Sass::Script::Literal
5
5
  def name; 'test'; end
6
+ def files; []; end
6
7
  end
7
8
 
8
9
  let(:sprite_map) { SpriteMapDouble.new }
@@ -7,7 +7,8 @@ describe Spritely::SpriteMap do
7
7
  subject { Spritely::SpriteMap.new('test/*.png', options_hash) }
8
8
 
9
9
  before do
10
- Spritely.stub(:directory).and_return(File)
10
+ allow(Spritely).to receive_message_chain(:environment, :paths).and_return(["#{__dir__}/../fixtures"])
11
+ allow(Spritely).to receive(:directory).and_return(File)
11
12
  allow(Spritely::Options).to receive(:new).with(options_hash).and_return(options_object)
12
13
  end
13
14
 
@@ -38,10 +39,7 @@ describe Spritely::SpriteMap do
38
39
  describe '#collection' do
39
40
  let(:collection) { double(find: 'find value', width: 'width value', height: 'height value', images: 'images value') }
40
41
 
41
- before do
42
- Spritely.stub_chain(:environment, :paths).and_return(["#{__dir__}/../fixtures"])
43
- allow(Spritely::Collection).to receive(:create).with(["#{__dir__}/../fixtures/test/foo.png"], options_object).and_return(collection)
44
- end
42
+ before { allow(Spritely::Collection).to receive(:create).with(["#{__dir__}/../fixtures/test/foo.png"], options_object).and_return(collection) }
45
43
 
46
44
  its(:collection) { should eq(collection) }
47
45
 
@@ -65,7 +63,7 @@ describe Spritely::SpriteMap do
65
63
 
66
64
  before { allow(File).to receive(:exist?).with('test.png').and_return(file_exists) }
67
65
 
68
- its(:needs_generation?) { should be_true }
66
+ its(:needs_generation?) { should be_truthy }
69
67
 
70
68
  context 'the sprite file already exists' do
71
69
  let(:file_exists) { true }
@@ -75,7 +73,12 @@ describe Spritely::SpriteMap do
75
73
  allow(Spritely::Cache).to receive(:busted?).with('test.png', 'value').and_return(true)
76
74
  end
77
75
 
78
- its(:needs_generation?) { should be_true }
76
+ its(:needs_generation?) { should be_truthy }
79
77
  end
80
78
  end
79
+
80
+ describe '#files' do
81
+ its('files.length') { should eq(1) }
82
+ its('files.first') { should match(/\.\.\/fixtures\/test\/foo\.png$/) }
83
+ end
81
84
  end
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: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Robbin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-27 00:00:00.000000000 Z
11
+ date: 2014-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chunky_png
@@ -102,6 +102,20 @@ dependencies:
102
102
  version: '0'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: rspec
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '3.0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '3.0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: rspec-its
105
119
  requirement: !ruby/object:Gem::Requirement
106
120
  requirements:
107
121
  - - ">="