spritely 0.3.0 → 0.3.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: 721132518267e110bd80c304728233e7205ee17b
4
- data.tar.gz: 409be4e94f2e8c211e2c2ec409f0bb4d54f2f37b
3
+ metadata.gz: 1aeabc56574aebd3b05f381fe8ae100158ab1fa7
4
+ data.tar.gz: 6248f29cfd68142d27dc5037669ad7720d043996
5
5
  SHA512:
6
- metadata.gz: 5140489bc42620192ebe3ca36fe6311baee5aece73a290d3a928345805b62745d93ed9bc8d667f135cda859502a9d143780771d453ce9dfa2713a905f0d883aa
7
- data.tar.gz: 3eba0c2c8d580440ead81d95d9b0f893cf3f52247e2de139924b96dfddd405fa1759e0565ea6ed3bcac84f3b0d0d4640e90fb91cef485734fc8ea4711dd47249
6
+ metadata.gz: 99d976b70aea6b8d0d16bc8e08d0e0184dbc0d7581efe79825894d1b4490fc56b68c4a42fd08c80eccf0fb07bff30c095a6b919edda7246e0f4d1b2fb948db7a
7
+ data.tar.gz: c3019d1f01e9b4ff07a3780b211d6cbbd5fdaddcc63d2c36b6daa33a7bb6b952c12e31fb888e135f9eaa37c8d732786913802611ed401fbe667ab1df22f5aa79
@@ -1,17 +1,20 @@
1
1
  require 'sprockets/manifest'
2
- require 'active_support/core_ext/module/aliasing'
3
2
 
4
- module Sprockets
3
+ module Spritely
5
4
  # In order to hook into Sprockets' asset compilation appropriately, we must
6
5
  # chain our own implementation of `compile`. Our extension calls up to the
7
6
  # original, and then performs the same action on the generated sprite images,
8
7
  # forcing the sprites to be part of the compiled asset manifest.
9
- class Manifest
10
- def compile_with_sprites(*args)
11
- compile_without_sprites(*args)
12
- compile_without_sprites(*Dir.glob(Spritely.directory.join('*.png')))
8
+ module Sprockets
9
+ module Manifest
10
+ def compile(*args)
11
+ super
12
+ super(*Dir.glob(Spritely.directory.join('*.png')))
13
+ end
13
14
  end
14
15
 
15
- alias_method_chain :compile, :sprites
16
+ # TODO: Once we drop support for Ruby 2.0, stop using `send`.
17
+ # `Module#prepend` was made public in Ruby 2.1.
18
+ ::Sprockets::Manifest.send(:prepend, Manifest)
16
19
  end
17
20
  end
@@ -1,3 +1,3 @@
1
1
  module Spritely
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/lib/spritely.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require 'sass'
2
+ require 'sprockets/rails/version'
3
+ require 'sprockets/railtie'
2
4
  require 'sprockets/version'
3
5
  require 'spritely/sass_functions'
4
6
  require 'spritely/sprockets/manifest'
@@ -7,7 +9,11 @@ require 'spritely/adapters/sprockets_3'
7
9
 
8
10
  module Spritely
9
11
  def self.environment
10
- ::Rails.application.assets
12
+ if sprockets_rails_version == 3
13
+ ::Rails.application.assets || ::Sprockets::Railtie.build_environment(::Rails.application)
14
+ else
15
+ ::Rails.application.assets
16
+ end
11
17
  end
12
18
 
13
19
  def self.directory
@@ -19,7 +25,11 @@ module Spritely
19
25
  end
20
26
 
21
27
  def self.sprockets_version
22
- Gem::Version.new(Sprockets::VERSION).segments.first
28
+ Gem::Version.new(::Sprockets::VERSION).segments.first
29
+ end
30
+
31
+ def self.sprockets_rails_version
32
+ Gem::Version.new(::Sprockets::Rails::VERSION).segments.first
23
33
  end
24
34
 
25
35
  def self.sprockets_adapter
@@ -2,9 +2,25 @@ require 'spec_helper'
2
2
 
3
3
  describe Spritely do
4
4
  describe '.environment' do
5
- before { stub_const('::Rails', double(application: double(assets: 'assets environment'))) }
5
+ let(:application) { double(assets: 'assets environment') }
6
+
7
+ before { stub_const('::Rails', double(application: application)) }
6
8
 
7
9
  its(:environment) { should eq('assets environment') }
10
+
11
+ context 'sprockets-rails version 3' do
12
+ before { stub_const('Sprockets::Rails::VERSION', '3.0.0') }
13
+
14
+ its(:environment) { should eq('assets environment') }
15
+
16
+ context 'the Rails application assets environment is nil' do
17
+ let(:application) { double(assets: nil) }
18
+
19
+ before { allow(::Sprockets::Railtie).to receive(:build_environment).with(application).and_return('new assets environment') }
20
+
21
+ its(:environment) { should eq('new assets environment') }
22
+ end
23
+ end
8
24
  end
9
25
 
10
26
  describe '.directory' do
@@ -17,6 +17,7 @@ module RailsAppHelpers
17
17
  Bundler.with_clean_env do
18
18
  File.open('Gemfile', 'a') do |f|
19
19
  f.write("gem 'spritely', path: '#{__dir__}/../../'\n")
20
+ f.write("gem 'sprockets-rails', '#{Sprockets::Rails::VERSION}'\n")
20
21
  f.write("gem 'sprockets', '#{Sprockets::VERSION}'")
21
22
  end
22
23
  %x(bundle install)
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.3.0
4
+ version: 0.3.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: 2015-11-17 00:00:00.000000000 Z
11
+ date: 2015-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chunky_png
@@ -219,7 +219,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - ">="
221
221
  - !ruby/object:Gem::Version
222
- version: '0'
222
+ version: 2.0.0
223
223
  required_rubygems_version: !ruby/object:Gem::Requirement
224
224
  requirements:
225
225
  - - ">="
@@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
227
  version: '0'
228
228
  requirements: []
229
229
  rubyforge_project:
230
- rubygems_version: 2.4.5.1
230
+ rubygems_version: 2.5.1
231
231
  signing_key:
232
232
  specification_version: 4
233
233
  summary: Hooks into the Rails asset pipeline to allow you to easily generate sprite