asset_cloud 2.2.4 → 2.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/probots.yml +2 -0
- data/.travis.yml +2 -4
- data/README.rdoc +1 -1
- data/asset_cloud.gemspec +5 -6
- data/dev.yml +11 -0
- data/lib/asset_cloud.rb +1 -1
- data/lib/asset_cloud/base.rb +11 -12
- data/lib/asset_cloud/buckets/s3_bucket.rb +2 -2
- data/lib/asset_cloud/callbacks.rb +35 -25
- data/lib/asset_cloud/validations.rb +8 -9
- data/spec/remote_s3_bucket_spec.rb +9 -0
- metadata +6 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 893b7f80adf628a9de0991dce7f9febe75c5a72766dc30c2493d9d38c6f229c0
|
4
|
+
data.tar.gz: 668804b41b67252ef633ad568d2faeb79499fd97817b12686e4c0b8344a8aec1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c25c855f466f47cfbc425f603e43c1e29d12398c24d65fd75be116c3bbf7f71127637c30092e077133c514404f9bfe3ed9af56baacf2044407076f99dcb83195
|
7
|
+
data.tar.gz: 1e22a454de1001f1c696d5880134a4a91bf5abd33fe3490d6202fc0e2d698d6a2c1314c3bfb2019924a0e6a90c39bf622f9bfca9818a6f1f4cca692759443d02
|
data/.github/probots.yml
ADDED
data/.travis.yml
CHANGED
data/README.rdoc
CHANGED
data/asset_cloud.gemspec
CHANGED
@@ -2,12 +2,14 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{asset_cloud}
|
5
|
-
s.version = "2.2.
|
5
|
+
s.version = "2.2.5"
|
6
6
|
|
7
7
|
s.authors = %w(Shopify)
|
8
8
|
s.summary = %q{An abstraction layer around arbitrary and diverse asset stores.}
|
9
9
|
s.description = %q{An abstraction layer around arbitrary and diverse asset stores.}
|
10
10
|
|
11
|
+
s.required_ruby_version = '>= 2.2.0'
|
12
|
+
|
11
13
|
s.email = %q{developers@shopify.com}
|
12
14
|
s.homepage = %q{http://github.com/Shopify/asset_cloud}
|
13
15
|
s.require_paths = %w(lib)
|
@@ -16,13 +18,10 @@ Gem::Specification.new do |s|
|
|
16
18
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
19
|
|
18
20
|
s.add_dependency 'activesupport'
|
19
|
-
s.add_dependency 'class_inheritable_attributes'
|
20
21
|
|
21
22
|
s.add_development_dependency 'rspec'
|
22
23
|
s.add_development_dependency 'rake'
|
23
24
|
s.add_development_dependency 'mocha'
|
24
|
-
|
25
|
-
|
26
|
-
s.add_development_dependency 'pry-byebug'
|
27
|
-
end
|
25
|
+
s.add_development_dependency 'pry'
|
26
|
+
s.add_development_dependency 'pry-byebug'
|
28
27
|
end
|
data/dev.yml
ADDED
data/lib/asset_cloud.rb
CHANGED
data/lib/asset_cloud/base.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'uri'
|
2
|
-
require 'class_inheritable_attributes'
|
3
2
|
|
4
3
|
module AssetCloud
|
5
4
|
|
@@ -33,16 +32,16 @@ module AssetCloud
|
|
33
32
|
attr_accessor :url, :root
|
34
33
|
|
35
34
|
class_attribute :root_bucket_class
|
36
|
-
self.root_bucket_class = 'AssetCloud::FileSystemBucket'
|
35
|
+
self.root_bucket_class = 'AssetCloud::FileSystemBucket'.freeze
|
37
36
|
class_attribute :root_asset_class
|
38
|
-
self.root_asset_class = 'AssetCloud::Asset'
|
37
|
+
self.root_asset_class = 'AssetCloud::Asset'.freeze
|
39
38
|
|
40
|
-
|
41
|
-
self.bucket_classes = {}
|
42
|
-
|
43
|
-
self.asset_classes = {}
|
44
|
-
|
45
|
-
self.asset_extension_classes = {}
|
39
|
+
class_attribute :bucket_classes
|
40
|
+
self.bucket_classes = {}.freeze
|
41
|
+
class_attribute :asset_classes
|
42
|
+
self.asset_classes = {}.freeze
|
43
|
+
class_attribute :asset_extension_classes
|
44
|
+
self.asset_extension_classes = {}.freeze
|
46
45
|
|
47
46
|
def self.bucket(*args)
|
48
47
|
asset_class = if args.last.is_a? Hash
|
@@ -56,8 +55,8 @@ module AssetCloud
|
|
56
55
|
end
|
57
56
|
|
58
57
|
if bucket_name = args.first
|
59
|
-
self.bucket_classes
|
60
|
-
self.asset_classes
|
58
|
+
self.bucket_classes = bucket_classes.merge(bucket_name.to_sym => bucket_class).freeze
|
59
|
+
self.asset_classes = asset_classes.merge(bucket_name.to_sym => asset_class).freeze if asset_class
|
61
60
|
else
|
62
61
|
self.root_bucket_class = bucket_class
|
63
62
|
if asset_class
|
@@ -75,7 +74,7 @@ module AssetCloud
|
|
75
74
|
|
76
75
|
args.each do |klass|
|
77
76
|
klass = convert_to_class_name_if_possible(klass)
|
78
|
-
self.asset_extension_classes
|
77
|
+
self.asset_extension_classes = asset_extension_classes.merge(klass => opts).freeze
|
79
78
|
end
|
80
79
|
end
|
81
80
|
|
@@ -11,8 +11,8 @@ module AssetCloud
|
|
11
11
|
objects.map { |o| cloud[relative_key(o.key)] }
|
12
12
|
end
|
13
13
|
|
14
|
-
def read(key)
|
15
|
-
cloud.s3_bucket(key).objects[absolute_key(key)].read
|
14
|
+
def read(key, options = {})
|
15
|
+
cloud.s3_bucket(key).objects[absolute_key(key)].read(options)
|
16
16
|
rescue ::AWS::Errors::Base
|
17
17
|
raise AssetCloud::AssetNotFoundError, key
|
18
18
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'class_inheritable_attributes'
|
2
|
-
|
3
1
|
module AssetCloud
|
4
2
|
module Callbacks
|
5
3
|
extend ActiveSupport::Concern
|
@@ -7,29 +5,41 @@ module AssetCloud
|
|
7
5
|
module ClassMethods
|
8
6
|
def callback_methods(*symbols)
|
9
7
|
symbols.each do |method|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
8
|
+
define_callbacks(method)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def define_callbacks(method)
|
13
|
+
before = :"before_#{method}"
|
14
|
+
after = :"after_#{method}"
|
15
|
+
extension_module.send(:define_method, method) do |*args, &block|
|
16
|
+
result = nil
|
17
|
+
if execute_callbacks(before, args)
|
18
|
+
result = super(*args, &block)
|
19
|
+
execute_callbacks(after, args)
|
20
|
+
end
|
21
|
+
result
|
22
|
+
end
|
23
|
+
|
24
|
+
define_singleton_method(before) do |*callbacks, &block|
|
25
|
+
callbacks << block if block_given?
|
26
|
+
write_inheritable_array(before, callbacks)
|
27
|
+
end
|
28
|
+
|
29
|
+
define_singleton_method(after) do |*callbacks, &block|
|
30
|
+
callbacks << block if block_given?
|
31
|
+
write_inheritable_array(after, callbacks)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def extension_module
|
38
|
+
@extension_module ||= begin
|
39
|
+
mod = Module.new
|
40
|
+
self.const_set(:AssetCloudCallbacks, mod)
|
41
|
+
prepend(mod)
|
42
|
+
mod
|
33
43
|
end
|
34
44
|
end
|
35
45
|
end
|
@@ -1,11 +1,15 @@
|
|
1
1
|
module AssetCloud
|
2
2
|
module Validations
|
3
3
|
def self.included(base)
|
4
|
-
base.
|
5
|
-
base.
|
6
|
-
|
4
|
+
base.send(:alias_method, :store_without_validation, :store)
|
5
|
+
base.extend(ClassMethods)
|
6
|
+
base.prepend(PrependedMethods)
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
+
module PrependedMethods
|
10
|
+
def store
|
11
|
+
validate
|
12
|
+
errors.empty? ? super : false
|
9
13
|
end
|
10
14
|
end
|
11
15
|
|
@@ -16,11 +20,6 @@ module AssetCloud
|
|
16
20
|
end
|
17
21
|
end
|
18
22
|
|
19
|
-
def store_with_validation
|
20
|
-
validate
|
21
|
-
errors.empty? ? store_without_validation : false
|
22
|
-
end
|
23
|
-
|
24
23
|
def errors
|
25
24
|
@errors ||= []
|
26
25
|
end
|
@@ -66,4 +66,13 @@ describe 'Remote test for AssetCloud::S3Bucket', if: ENV['AWS_ACCESS_KEY_ID'] &
|
|
66
66
|
data = @bucket.read(key)
|
67
67
|
data.should == value
|
68
68
|
end
|
69
|
+
|
70
|
+
it "#reads first bytes when passed options" do
|
71
|
+
value = 'hello world'
|
72
|
+
key = 'tmp/new_file.txt'
|
73
|
+
options = {range: 0...5}
|
74
|
+
@bucket.write(key, value)
|
75
|
+
data = @bucket.read(key, options)
|
76
|
+
data.should == 'hello'
|
77
|
+
end
|
69
78
|
end
|
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.5
|
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: 2019-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: class_inheritable_attributes
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rspec
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,6 +100,7 @@ executables: []
|
|
114
100
|
extensions: []
|
115
101
|
extra_rdoc_files: []
|
116
102
|
files:
|
103
|
+
- ".github/probots.yml"
|
117
104
|
- ".gitignore"
|
118
105
|
- ".travis.yml"
|
119
106
|
- Gemfile
|
@@ -122,6 +109,7 @@ files:
|
|
122
109
|
- README.rdoc
|
123
110
|
- Rakefile
|
124
111
|
- asset_cloud.gemspec
|
112
|
+
- dev.yml
|
125
113
|
- lib/asset_cloud.rb
|
126
114
|
- lib/asset_cloud/asset.rb
|
127
115
|
- lib/asset_cloud/asset_extension.rb
|
@@ -170,7 +158,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
158
|
requirements:
|
171
159
|
- - ">="
|
172
160
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
161
|
+
version: 2.2.0
|
174
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
163
|
requirements:
|
176
164
|
- - ">="
|
@@ -178,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
166
|
version: '0'
|
179
167
|
requirements: []
|
180
168
|
rubyforge_project:
|
181
|
-
rubygems_version: 2.
|
169
|
+
rubygems_version: 2.7.6
|
182
170
|
signing_key:
|
183
171
|
specification_version: 4
|
184
172
|
summary: An abstraction layer around arbitrary and diverse asset stores.
|