asset_cloud 2.2.1 → 2.2.2
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 +4 -4
- data/.travis.yml +2 -0
- data/History.md +4 -0
- data/asset_cloud.gemspec +1 -1
- data/lib/asset_cloud/base.rb +8 -2
- data/spec/base_spec.rb +16 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c234877222854a009ce8f3cd01cc47e3827ce575
|
4
|
+
data.tar.gz: d0cfa40ee942e449c59b9bb6f2b362a7565e9ed1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71784bf57b3a79dd4cbe76a6d5921617ae368a62871e3289f9a50bef1273901d985c0553fa8868f742a1959f39c578f1b8e33f64c6625fae686e1ceb629fac1b
|
7
|
+
data.tar.gz: b520683f21e5fafacac076b20fee73d08744589b9631e5176d1e48edf9744d24b0e3bd6f5693f850b99e68a9abd0bf2ce256ed50c6831a3287ce99c22a5498ea
|
data/.travis.yml
CHANGED
data/History.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Asset Cloud Version History
|
2
2
|
|
3
|
+
## Version 2.2.2, 2016-02-11
|
4
|
+
|
5
|
+
* Allow asset_class to be a proc which determines the class to use within a bucket (https://github.com/Shopify/asset_cloud/pull/15)
|
6
|
+
|
3
7
|
## Version 2.2.0, 2015-03-17
|
4
8
|
|
5
9
|
* Reduce the limitations on filenames so as not to catch valid filenames. (https://github.com/Shopify/asset_cloud/pull/12)
|
data/asset_cloud.gemspec
CHANGED
data/lib/asset_cloud/base.rb
CHANGED
@@ -60,7 +60,10 @@ module AssetCloud
|
|
60
60
|
self.asset_classes[bucket_name.to_sym] = asset_class if asset_class
|
61
61
|
else
|
62
62
|
self.root_bucket_class = bucket_class
|
63
|
-
|
63
|
+
if asset_class
|
64
|
+
raise ArgumentError, 'asset_class on the root bucket cannot be a proc' if asset_class.is_a?(Proc)
|
65
|
+
self.root_asset_class = asset_class
|
66
|
+
end
|
64
67
|
end
|
65
68
|
end
|
66
69
|
|
@@ -216,7 +219,10 @@ module AssetCloud
|
|
216
219
|
end
|
217
220
|
|
218
221
|
def asset_class_for(key)
|
219
|
-
klass = self.class.asset_classes[bucket_symbol_for_key(key)]
|
222
|
+
klass = self.class.asset_classes[bucket_symbol_for_key(key)]
|
223
|
+
klass = klass.call(key) if klass.is_a?(Proc)
|
224
|
+
klass ||= self.class.root_asset_class
|
225
|
+
|
220
226
|
constantize_if_necessary(klass)
|
221
227
|
end
|
222
228
|
|
data/spec/base_spec.rb
CHANGED
@@ -3,10 +3,15 @@ require 'spec_helper'
|
|
3
3
|
class SpecialAsset < AssetCloud::Asset
|
4
4
|
end
|
5
5
|
|
6
|
-
class
|
7
|
-
bucket :special, AssetCloud::MemoryBucket, :asset_class => SpecialAsset
|
6
|
+
class LiquidAsset < AssetCloud::Asset
|
8
7
|
end
|
9
8
|
|
9
|
+
class BasicCloud < AssetCloud::Base
|
10
|
+
bucket :special, AssetCloud::MemoryBucket, asset_class: SpecialAsset
|
11
|
+
bucket :conditional, AssetCloud::MemoryBucket, asset_class: Proc.new {|key|
|
12
|
+
LiquidAsset if key.ends_with?('.liquid')
|
13
|
+
}
|
14
|
+
end
|
10
15
|
|
11
16
|
describe BasicCloud do
|
12
17
|
directory = File.dirname(__FILE__) + '/files'
|
@@ -177,6 +182,15 @@ describe BasicCloud do
|
|
177
182
|
@fs.build('assets/foo').should be_instance_of(AssetCloud::Asset)
|
178
183
|
@fs.build('special/foo').should be_instance_of(SpecialAsset)
|
179
184
|
end
|
185
|
+
|
186
|
+
it "should allow specifying a proc that determines the class to use, using the default bucket when returning nil" do
|
187
|
+
@fs.build('conditional/default.js').should be_instance_of(AssetCloud::Asset)
|
188
|
+
@fs.build('conditional/better.liquid').should be_instance_of(LiquidAsset)
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should raise " do
|
192
|
+
expect { BasicCloud.bucket(AssetCloud::MemoryBucket, asset_class: Proc.new {}) }.to(raise_error(ArgumentError))
|
193
|
+
end
|
180
194
|
end
|
181
195
|
|
182
196
|
describe "MATCH_BUCKET" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asset_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|