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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c59ff21099481c73d18d20f5d12267538bfe5537
4
- data.tar.gz: b0b9d91f667a39da9848609af1e44d2f087b71bc
2
+ SHA256:
3
+ metadata.gz: 893b7f80adf628a9de0991dce7f9febe75c5a72766dc30c2493d9d38c6f229c0
4
+ data.tar.gz: 668804b41b67252ef633ad568d2faeb79499fd97817b12686e4c0b8344a8aec1
5
5
  SHA512:
6
- metadata.gz: e468ea841dcfc001541a7b117335e435c9500c464cde5a7239d73bd0340c8400401906f442d8e3ac22aeaa50d3afd3120b3a30e8a09ceb4f4289445a1419a5d9
7
- data.tar.gz: 41818a6fa8cbddfb504baf4c8e9a7866e320901487744c1d926f1bbedbedb4ec96b8ef8384293d048aa443da33b21c5c42f6b74079dc7c39ad5e199520436ea8
6
+ metadata.gz: c25c855f466f47cfbc425f603e43c1e29d12398c24d65fd75be116c3bbf7f71127637c30092e077133c514404f9bfe3ed9af56baacf2044407076f99dcb83195
7
+ data.tar.gz: 1e22a454de1001f1c696d5880134a4a91bf5abd33fe3490d6202fc0e2d698d6a2c1314c3bfb2019924a0e6a90c39bf622f9bfca9818a6f1f4cca692759443d02
@@ -0,0 +1,2 @@
1
+ enabled:
2
+ - cla
@@ -2,7 +2,5 @@ language: ruby
2
2
  before_install:
3
3
  - gem install bundler
4
4
  rvm:
5
- - '1.9.3'
6
- - '2.0'
7
- - '2.1'
8
- - 2.1.2
5
+ - '2.2'
6
+ - '2.3'
@@ -12,7 +12,7 @@ An abstraction layer around arbitrary and diverse asset stores.
12
12
 
13
13
  == Testing
14
14
 
15
- bundle exec rake spec
15
+ dev test
16
16
 
17
17
  With S3 Remote test:
18
18
 
@@ -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.4"
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
- if RUBY_VERSION >= "2.0.0"
25
- s.add_development_dependency 'pry'
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
@@ -0,0 +1,11 @@
1
+ name: asset-cloud
2
+
3
+ up:
4
+ - ruby:
5
+ version: 2.3.3
6
+ - bundler
7
+
8
+ commands:
9
+ test:
10
+ desc: "run test suite"
11
+ run: bundle exec rake spec
@@ -13,7 +13,7 @@ require 'asset_cloud/buckets/memory_bucket'
13
13
  require 'asset_cloud/buckets/versioned_memory_bucket'
14
14
  require 'asset_cloud/base'
15
15
 
16
- #S3
16
+ # S3
17
17
  require 'asset_cloud/buckets/s3_bucket'
18
18
 
19
19
  # Extensions
@@ -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
- class_inheritable_hash :bucket_classes
41
- self.bucket_classes = {}
42
- class_inheritable_hash :asset_classes
43
- self.asset_classes = {}
44
- class_inheritable_hash :asset_extension_classes
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[bucket_name.to_sym] = bucket_class
60
- self.asset_classes[bucket_name.to_sym] = asset_class if asset_class
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[klass] = opts
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
- code = <<-"end_eval"
11
- def self.before_#{method}(*callbacks, &block)
12
- callbacks << block if block_given?
13
- write_inheritable_array(:before_#{method}, callbacks)
14
- end
15
-
16
- def self.after_#{method}(*callbacks, &block)
17
- callbacks << block if block_given?
18
- write_inheritable_array(:after_#{method}, callbacks)
19
- end
20
-
21
- def #{method}_with_callbacks(*args)
22
- if execute_callbacks(:before_#{method}, args)
23
- result = #{method}_without_callbacks(*args)
24
- execute_callbacks(:after_#{method}, args)
25
- end
26
- result
27
- end
28
-
29
- alias_method_chain :#{method}, 'callbacks'
30
- end_eval
31
-
32
- self.class_eval code, __FILE__, __LINE__
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.extend ClassMethods
5
- base.class_eval do
6
- include AssetCloud::Callbacks
4
+ base.send(:alias_method, :store_without_validation, :store)
5
+ base.extend(ClassMethods)
6
+ base.prepend(PrependedMethods)
7
+ end
7
8
 
8
- alias_method_chain :store, :validation
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
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: 2016-02-16 00:00:00.000000000 Z
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: '0'
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.2.3
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.