aws-sdk-resources 2.0.5.pre → 2.0.6.pre

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
2
  SHA1:
3
- metadata.gz: 3e1e6e86eb9aa98442dcbab93409180ec65e777b
4
- data.tar.gz: 3c8c32a3c19405c47760f70afc003ad57a47aa11
3
+ metadata.gz: 1836c23ab216964624f76b4e9d5897c005cdb922
4
+ data.tar.gz: a4c93137ebb9ed5f7a2a5b241e934602f5212a94
5
5
  SHA512:
6
- metadata.gz: 5e887aa6735dc952bb1f893b1f0cafa82e9e0ed17b0a92833d29c87f9b11c52e40f82e735c384eb9b58ac48a420acb6f5e0e4580172735945c236b34873534d8
7
- data.tar.gz: f05ec991a3384228fc0e7bb8bdc711af18c705f937b839d42ed02a8df38c440bb25afd3662e2f2750348486bfc5738b4ab105ce75a421d496f650496026b8ce3
6
+ metadata.gz: 62c9ab0d1fac25872ddbbc823f8f4c770886fb589c201142a63063e45402eb3b23cce44aea07c082366ce1f5d5175ee2d2ed86a5833b53059b3e326f589cf1c0
7
+ data.tar.gz: 58b60ec8a12570d5c087e0c7a4bd0593deb7a0dc80cb4a8726aed4ec48fcefd33ea693a3829d47fdb54cf399dbdcfd292dcbccc72b69b3e967e3ec45648ef4b2
@@ -34,7 +34,7 @@ module Aws
34
34
  when nil then Resources::Definition.new({})
35
35
  when Resources::Definition then definition
36
36
  when Hash then Resources::Definition.new(definition)
37
- when String then Resources::Definition.new(Aws.load_json(definition), source_path: definition)
37
+ when String, Pathname then Resources::Definition.new(Aws.load_json(definition), source_path: definition.to_s)
38
38
  else raise ArgumentError, "invalid resource definition #{definition}"
39
39
  end
40
40
  end
@@ -1,5 +1,3 @@
1
- require 'jamespath'
2
-
3
1
  module Aws
4
2
  module Resources
5
3
 
@@ -50,9 +48,9 @@ module Aws
50
48
  def build_batch(identifier_map, options, &block)
51
49
  resources = (0...resource_count(identifier_map)).collect do |n|
52
50
  identifiers = @sources.each.with_object({}) do |source, identifiers|
53
- identifiers[source.target] = source.plural? ?
54
- identifier_map[source.target][n] :
55
- identifier_map[source.target]
51
+ value = identifier_map[source.target]
52
+ value = value[n] if source.plural?
53
+ identifiers[source.target] = value
56
54
  end
57
55
  resource = build_one(identifiers, options)
58
56
  yield(resource) if block_given?
@@ -1,4 +1,4 @@
1
- require 'jamespath'
1
+ require 'jmespath'
2
2
 
3
3
  module Aws
4
4
  module Resources
@@ -82,7 +82,7 @@ module Aws
82
82
 
83
83
  # @option [required, Resource] :resource
84
84
  def extract(options)
85
- Jamespath.search(source, resource(options).data)
85
+ JMESPath.search(source, resource(options).data)
86
86
  end
87
87
 
88
88
  private
@@ -100,7 +100,8 @@ module Aws
100
100
 
101
101
  # @option [required, Seahorse::Client::Response] :response
102
102
  def extract(options)
103
- response(options).context.params[source.to_sym]
103
+ params = response(options).context.params
104
+ JMESPath.search(source, params)
104
105
  end
105
106
 
106
107
  private
@@ -120,7 +121,7 @@ module Aws
120
121
  if source == '$'
121
122
  response(options).data
122
123
  else
123
- Jamespath.search(source, response(options).data)
124
+ JMESPath.search(source, response(options).data)
124
125
  end
125
126
  end
126
127
 
@@ -1,4 +1,4 @@
1
- require 'jamespath'
1
+ require 'jmespath'
2
2
 
3
3
  module Aws
4
4
  module Resources
@@ -74,7 +74,7 @@ module Aws
74
74
  private
75
75
 
76
76
  def extract(resp)
77
- @path == '$' ? resp.data : Jamespath.search(@path, resp.data)
77
+ @path == '$' ? resp.data : JMESPath.search(@path, resp.data)
78
78
  end
79
79
 
80
80
  end
@@ -274,7 +274,7 @@ module Aws
274
274
  resp = resource.client.wait_until(@waiter_name, params)
275
275
 
276
276
  resource_opts = resource.identifiers.dup
277
- resource_opts[:data] = Jamespath.search(@path, resp.data) if @path
277
+ resource_opts[:data] = JMESPath.search(@path, resp.data) if @path
278
278
  resource_opts[:client] = resource.client
279
279
  resource.class.new(resource_opts)
280
280
  end
@@ -26,9 +26,9 @@ module Aws
26
26
 
27
27
  def computed_params(options)
28
28
  params_hash = {}
29
- Array(options[:resource]).each do |resource|
29
+ Array(options[:resource]).each.with_index do |resource, n|
30
30
  @params.each do |param|
31
- param.apply(params_hash, options.merge(resource: resource))
31
+ param.apply(params_hash, options.merge(resource: resource, n: n))
32
32
  end
33
33
  end
34
34
  params_hash
@@ -55,9 +55,10 @@ module Aws
55
55
  def initialize(target)
56
56
  @target = target.to_s
57
57
  @steps = []
58
- @target.scan(/\w+|\[\]/) do |step|
58
+ @target.scan(/\w+|\[\]|\[\*\]|\[[0-9]+\]/) do |step|
59
59
  case step
60
- when /\d+/ then @steps += [:array, step.to_i]
60
+ when /\[\d+\]/ then @steps += [:array, step[1..-2].to_i]
61
+ when /\[\*\]/ then @steps += [:array, :n]
61
62
  when '[]' then @steps += [:array, -1]
62
63
  else @steps += [:hash, step.to_sym]
63
64
  end
@@ -72,23 +73,25 @@ module Aws
72
73
  # @param [Hash] params
73
74
  # @param [Object] value
74
75
  # @return [Hash] Returns the modified params hash.
75
- def apply(params, value)
76
+ def apply(params, value, n = nil)
76
77
  if @final == -1
77
- build_context(params) << value
78
+ build_context(params, n) << value
78
79
  else
79
- build_context(params)[@final] = value
80
+ build_context(params, n)[@final] = value
80
81
  end
81
82
  params
82
83
  end
83
84
 
84
85
  private
85
86
 
86
- def build_context(params)
87
+ def build_context(params, n)
87
88
  @steps.each_slice(2).inject(params) do |context, (key, type)|
88
89
  entry = type == :array ? [] : {}
89
90
  if key == -1
90
91
  context << entry
91
92
  entry
93
+ elsif key == :n
94
+ context[n] ||= entry
92
95
  else
93
96
  context[key] ||= entry
94
97
  end
@@ -113,7 +116,7 @@ module Aws
113
116
  # @option [requried, Resource] :resource
114
117
  def apply(params_hash, options)
115
118
  value = options[:resource].identifiers[identifier_name]
116
- super(params_hash, value)
119
+ super(params_hash, value, options[:n])
117
120
  end
118
121
 
119
122
  # @api private
@@ -139,7 +142,7 @@ module Aws
139
142
  # @option [requried, Resource] :resource
140
143
  def apply(params_hash, options)
141
144
  value = options[:resource].data[member_name.to_sym]
142
- super(params_hash, value)
145
+ super(params_hash, value, options[:n])
143
146
  end
144
147
 
145
148
  # @api private
@@ -163,7 +166,7 @@ module Aws
163
166
 
164
167
  # @param [Hash] params_hash
165
168
  def apply(params_hash, options = {})
166
- super(params_hash, value)
169
+ super(params_hash, value, options[:n])
167
170
  end
168
171
 
169
172
  # @api private
@@ -187,7 +190,7 @@ module Aws
187
190
 
188
191
  # @param [Hash] params_hash
189
192
  def apply(params_hash, options = {})
190
- super(params_hash, value)
193
+ super(params_hash, value, options[:n])
191
194
  end
192
195
 
193
196
  # @api private
@@ -211,7 +214,7 @@ module Aws
211
214
 
212
215
  # @param [Hash] params_hash
213
216
  def apply(params_hash, options = {})
214
- super(params_hash, value)
217
+ super(params_hash, value, options[:n])
215
218
  end
216
219
 
217
220
  # @api private
@@ -1,7 +1,9 @@
1
1
  module Aws
2
2
  module S3
3
3
 
4
+ require 'aws-sdk-resources/services/s3/bucket'
4
5
  require 'aws-sdk-resources/services/s3/object'
6
+ require 'aws-sdk-resources/services/s3/multipart_upload'
5
7
 
6
8
  autoload :FilePart, 'aws-sdk-resources/services/s3/file_part'
7
9
  autoload :FileUploader, 'aws-sdk-resources/services/s3/file_uploader'
@@ -0,0 +1,31 @@
1
+ module Aws
2
+ module S3
3
+ class Bucket
4
+
5
+ # Deletes all objects and versioned objects from this bucket
6
+ #
7
+ # @example
8
+ #
9
+ # bucket.clear!
10
+ #
11
+ # @return [void]
12
+ def clear!
13
+ object_versions.delete
14
+ end
15
+
16
+ # Deletes all objects and versioned objects from this bucket and
17
+ # then deletes the bucket.
18
+ #
19
+ # @example
20
+ #
21
+ # bucket.delete!
22
+ #
23
+ # @return [void]
24
+ def delete!
25
+ clear!
26
+ delete
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,40 @@
1
+ module Aws
2
+ module S3
3
+ class MultipartUpload
4
+
5
+ alias_method :basic_complete, :complete
6
+
7
+ # Completes the MultipartUpload.
8
+ #
9
+ # To complete a multipart upload, a list of part numbers and their
10
+ # ETags is required.
11
+ #
12
+ # upload.complete(multipart_upload: { parts: part_list })
13
+ #
14
+ # You can pass `:compute_parts => true` and the {Client#list_parts}
15
+ # method will be called to generate the part list.
16
+ #
17
+ # upload.complete(compute_parts: true)
18
+ #
19
+ # @option options [Boolean] :compute_parts (false) When `true`,
20
+ # the {Client#list_parts} method will be called to determine
21
+ # the list of required part numbers and their ETags.
22
+ #
23
+ def complete(options = {})
24
+ if options.delete(:compute_parts)
25
+ options[:multipart_upload] = { parts: compute_parts }
26
+ end
27
+ basic_complete(options)
28
+ end
29
+
30
+ private
31
+
32
+ def compute_parts
33
+ parts.sort_by(&:part_number).each.with_object([]) do |part, part_list|
34
+ part_list << { part_number: part.part_number, etag: part.etag }
35
+ end
36
+ end
37
+
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5.pre
4
+ version: 2.0.6.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-23 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.5
19
+ version: 2.0.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.5
26
+ version: 2.0.6
27
27
  description: Provides resource-oriented abstractions for AWS.
28
28
  email:
29
29
  executables: []
@@ -51,9 +51,11 @@ files:
51
51
  - lib/aws-sdk-resources/request.rb
52
52
  - lib/aws-sdk-resources/request_params.rb
53
53
  - lib/aws-sdk-resources/resource.rb
54
+ - lib/aws-sdk-resources/services/s3/bucket.rb
54
55
  - lib/aws-sdk-resources/services/s3/file_part.rb
55
56
  - lib/aws-sdk-resources/services/s3/file_uploader.rb
56
57
  - lib/aws-sdk-resources/services/s3/multipart_file_uploader.rb
58
+ - lib/aws-sdk-resources/services/s3/multipart_upload.rb
57
59
  - lib/aws-sdk-resources/services/s3/multipart_upload_error.rb
58
60
  - lib/aws-sdk-resources/services/s3/object.rb
59
61
  - lib/aws-sdk-resources/services/s3.rb