vacuum 3.1.0 → 3.2.0

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
  SHA256:
3
- metadata.gz: 93d495272c66aa409a35266354596c893f93dc94f909290143909a3ed3552f8a
4
- data.tar.gz: '0812a94c0f3254302468caa19b852e31f7e7e4650166721ed45d49f071db5303'
3
+ metadata.gz: e7930ac186979f816a0d138d66b3a2a560d6237f7a30ee05a93a09f5e6cf4722
4
+ data.tar.gz: 7bf258d4f95d9714ca6957240b1070e1394fcb017828d3d23116a6ffa6a7eed1
5
5
  SHA512:
6
- metadata.gz: 473700d6b71e5c6c3228f64fa2e6b78c4efc7d191211a686fb14ec8426f59fa68a6c626c742e1282cd08db8df9e6a0e6ce30b3f43b991908d96fe179cc8c37fd
7
- data.tar.gz: 43f66d7d7a0dc877a9e197006d5aa869e14b699f86554181e79794ec2bbe92846e9a2f73b320228f5c552eb8d9e278736284d947a08995e358162f444e299dbc
6
+ metadata.gz: ba541939522a687a4f1fd800232c7f71db4d5d8c87ecf6979d8111f86f27fa8fbb3fba9aca098bb6c8ace24d75e10fef7d6916c69904896312f72d2e41742e17
7
+ data.tar.gz: 016a3f3248f2470bfeee5bfc0b4245fed9ea00fba3217056c3f4d65a6c2c4dca92bd0f43687b87a0188c53ddf7e3da74de37ee1e2912fd8dce824b567a971cea
data/README.md CHANGED
@@ -98,14 +98,25 @@ response.dig('ItemsResult', 'Items')
98
98
 
99
99
  ### Troubleshooting
100
100
 
101
- In addition to the response payload, the following attributes help you introspect a request.
101
+ In addition to the response payload, the following attributes may help you introspect an executed request.
102
102
 
103
103
  ```ruby
104
- request.body
105
- request.headers
106
- request.url
104
+ operation = request.operation
105
+ operation.body
106
+ operation.headers
107
+ operation.url
107
108
  ```
108
109
 
110
+ ### Bring your parser
111
+ You can extend Vacuum with a custom parser. Just swap the original with a class or module that responds to `.parse`.
112
+
113
+ ```ruby
114
+ response.parser = MyParser
115
+ response.parse
116
+ ```
117
+
118
+ If no custom parser is set, `Vacuum::Response#parse` delegates to `#to_h`.
119
+
109
120
  ### VCR
110
121
 
111
122
  If you are using [VCR](https://github.com/vcr/vcr) to test an app that accesses the API, you can use the custom VCR matcher of Vacuum to stub requests.
@@ -9,7 +9,6 @@ module Vacuum
9
9
  # Amazon locale
10
10
  class NotFound < KeyError; end
11
11
 
12
- # @!visibility private
13
12
  HOSTS_AND_REGIONS = {
14
13
  au: ['webservices.amazon.com.au', 'us-west-2'],
15
14
  br: ['webservices.amazon.com.br', 'us-east-1'],
@@ -26,6 +25,7 @@ module Vacuum
26
25
  gb: ['webservices.amazon.co.uk', 'eu-west-1'],
27
26
  us: ['webservices.amazon.com', 'us-east-1']
28
27
  }.freeze
28
+ private_constant :HOSTS_AND_REGIONS
29
29
 
30
30
  # @return [String]
31
31
  attr_reader :host, :region, :access_key, :secret_key, :partner_tag,
@@ -16,6 +16,22 @@ module Vacuum
16
16
  # @see https://ruby-doc.org/core/Hash.html#method-i-dig
17
17
  def_delegator :to_h, :dig
18
18
 
19
+ class << self
20
+ attr_accessor :parser
21
+ end
22
+
23
+ def_delegator :to_h, :dig
24
+
25
+ attr_writer :parser
26
+
27
+ def parser
28
+ @parser || self.class.parser
29
+ end
30
+
31
+ def parse
32
+ parser ? parser.parse(body) : to_h
33
+ end
34
+
19
35
  # Casts body to Hash
20
36
  # @return [Hash]
21
37
  def to_h
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vacuum
4
- VERSION = '3.1.0'
4
+ VERSION = '3.2.0'
5
5
  end
@@ -11,6 +11,10 @@ module Vacuum
11
11
  @response = Response.new(mock)
12
12
  end
13
13
 
14
+ def test_parse
15
+ assert @response.parse
16
+ end
17
+
14
18
  def test_cast_to_hash
15
19
  assert_kind_of Hash, @response.to_h
16
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vacuum
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hakan Ensari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-10 00:00:00.000000000 Z
11
+ date: 2019-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sigv4
@@ -141,7 +141,6 @@ files:
141
141
  - test/cassettes/vacuum.yml
142
142
  - test/integration_helper.rb
143
143
  - test/locales.rb
144
- - test/locales.yml
145
144
  - test/locales.yml.example
146
145
  - test/vacuum/test_locale.rb
147
146
  - test/vacuum/test_operation.rb
@@ -178,5 +177,4 @@ test_files:
178
177
  - test/cassettes/vacuum.yml
179
178
  - test/integration_helper.rb
180
179
  - test/locales.rb
181
- - test/locales.yml
182
180
  - test/locales.yml.example
@@ -1,28 +0,0 @@
1
- - :marketplace: CA
2
- :access_key: AKIAIWQTVHVWCQA5THXQ
3
- :secret_key: VOhSIqIY1wF5selhhJYJGVnIET9k5q0J8QjTX38i
4
- :partner_tag: adabo00-20
5
- - :marketplace: ES
6
- :access_key: AKIAJJF26BJLZLSJLFBQ
7
- :secret_key: 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
8
- :partner_tag: adabo00-21
9
- - :marketplace: DE
10
- :access_key: AKIAJGN5UNM43HHV5MZA
11
- :secret_key: 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
12
- :partner_tag: adabo23-21
13
- - :marketplace: FR
14
- :access_key: AKIAJDNYBNMN23YBFK3A
15
- :secret_key: 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
16
- :partner_tag: adabo-21
17
- - :marketplace: IT
18
- :access_key: AKIAJVBAH4XJHK6YF46Q
19
- :secret_key: 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
20
- :partner_tag: adabo0c-21
21
- - :marketplace: GB
22
- :access_key: AKIAJPAXMP45DOQJPHJQ
23
- :secret_key: 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
24
- :partner_tag: adabo21-21
25
- - :marketplace: US
26
- :access_key: AKIAIWQTVHVWCQA5THXQ
27
- :secret_key: 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
28
- :partner_tag: adabo-20