branchable_cdn_assets-middleman 0.8.0 → 0.8.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: 3ae86e989e0f3fbc272aa429e13dfde3ff1a5c24
4
- data.tar.gz: 55987dcadb5b29af7a9bb464de9c97ff2f35f212
3
+ metadata.gz: 99ca71123259f6e204e0198b4f36ad5267dc0a4e
4
+ data.tar.gz: 2d3970a00b3bd71c0d76f9e73b69ae5684e023be
5
5
  SHA512:
6
- metadata.gz: 85e65c9d9a90ae327b5cf6a3442bf2cdbdb123d1139e1afe218ca0b3c63e5c653aa3e779afc12b1490d6ab0d49e0b409f827c8c55ff629f31242bbd95070d460
7
- data.tar.gz: 2ac4a337fc0e61c5df01f9dc9401676918604d0774a6c7999a016d86b8a0b66c6ebdd1289bb7013df8166ad3a315069ae4ffe23efa98844710c16f92a893d9f4
6
+ metadata.gz: d0a8957936305371b89d0f603a43400de77d963fb9d80edb98dbdbc62c153a0cf36460b0ba8b4b1d3380d9a3754dd8283cca4fe8efa87ee2830aaa072fb9390f
7
+ data.tar.gz: 8aec9a0e94ba141da4056c7bf291830bdad1cabd2b5eae30fb8c4cd62824b44487304fadad8ec5a23c96e3083e613b8dbd3cf0bbba2bd697c25e70ef42d3ae78
@@ -17,6 +17,9 @@ module BranchableCDNAssets
17
17
  if defined?(::Sass::Script::Functions)
18
18
  ::Sass::Script::Functions.send :include, SassHelpers
19
19
  end
20
+ if defined?(::SassC::Script::Functions)
21
+ ::SassC::Script::Functions.send :include, SassHelpers
22
+ end
20
23
  end
21
24
 
22
25
  def manipulate_resource_list resources
@@ -19,7 +19,7 @@ module BranchableCDNAssets
19
19
 
20
20
  # check for file in sitemap on each extension
21
21
  sitemap_candidates = []
22
- if environment != :build
22
+ if !build?
23
23
  extensions[:cdn_assets].each do |k, inst|
24
24
  next if cdn && inst.id != cdn
25
25
 
@@ -33,7 +33,7 @@ module BranchableCDNAssets
33
33
  extensions[:cdn_assets].each do |k, inst|
34
34
  next if cdn && inst.id != cdn
35
35
 
36
- location = (environment == :build) ? :remote : :all;
36
+ location = build? ? :remote : :all;
37
37
  file = inst.file_manager.find(real_path, location)
38
38
 
39
39
  file_manager_candidates.push [file, ext_trail].join('') if file && file != :local
@@ -66,10 +66,20 @@ module BranchableCDNAssets
66
66
 
67
67
  def cdn_asset_path( path, cdn=nil )
68
68
  cdn = cdn.value if cdn.respond_to?(:value) # have to force cdn to a string if not nil
69
- file = options[:custom][:middleman_context].cdn_asset_url( path.value, cdn )
69
+ file = application_context.cdn_asset_url( path.value, cdn )
70
70
  ::Sass::Script::String.new file, :string
71
71
  end
72
72
 
73
+ # TODO: add a test that exercises this code
74
+ #
75
+ def application_context
76
+ if options.key?(:custom)
77
+ options[:custom][:middleman_context]
78
+ elsif options.key?(:sprockets)
79
+ options[:sprockets][:context]
80
+ end
81
+ end
82
+
73
83
  end
74
84
 
75
85
  class MultipleCDNError < StandardError
@@ -1,5 +1,5 @@
1
1
  module BranchableCDNAssets
2
2
  module Middleman
3
- VERSION = '0.8.0' unless defined?(BranchableCDNAssets::Middleman::VERSION)
3
+ VERSION = '0.8.1' unless defined?(BranchableCDNAssets::Middleman::VERSION)
4
4
  end
5
5
  end
@@ -58,7 +58,7 @@ describe BranchableCDNAssets::Middleman::Helpers do
58
58
 
59
59
  context "when building" do
60
60
  it "returns remote url" do
61
- @mm.config[:environment] = :build
61
+ @mm.config[:mode] = :build
62
62
 
63
63
  allow( Asgit ).to receive(:current_branch).and_return('some_branch')
64
64
  expect( @context.cdn_asset_url('image_all') ).to eq "http://staging.com/some_branch/image_all"
@@ -185,6 +185,13 @@ describe BranchableCDNAssets::Middleman::Helpers do
185
185
  source = 'body { background: url( cdn_asset_url("image_path", "cdn2") ); }'
186
186
  Sass.compile( source, {custom: {middleman_context: @context}} )
187
187
  end
188
+
189
+ it "is called with SassC as well" do
190
+ expect( @context ).to receive(:cdn_asset_url).with('image_path', 'cdn2')
191
+
192
+ source = 'body { background: url( cdn_asset_url("image_path", "cdn2") ); }'
193
+ SassC::Engine.new(source, {custom: {middleman_context: @context}}).render
194
+ end
188
195
  end
189
196
  end
190
197
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: branchable_cdn_assets-middleman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Sloan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-11 00:00:00.000000000 Z
11
+ date: 2016-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman