vacuum 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,27 +15,33 @@ module Vacuum
15
15
  #
16
16
  # Returns a Vacuum::Response::ProductAdvertising.
17
17
  def look_up(*item_ids)
18
- given_params = item_ids.last.is_a?(Hash) ? item_ids.pop : {}
18
+ given = item_ids.last.is_a?(Hash) ? item_ids.pop : {}
19
19
 
20
- params =
20
+ params = begin
21
21
  case item_ids.size
22
22
  when 1..10
23
23
  {
24
24
  'Operation' => 'ItemLookup',
25
25
  'ItemId' => item_ids
26
- }.merge given_params
26
+ }.merge given
27
27
  when 11..20
28
28
  default = {
29
- 'Operation' => 'ItemLookup',
29
+ 'Operation' => 'ItemLookup',
30
30
  'ItemLookup.1.ItemId' => item_ids.shift(10),
31
31
  'ItemLookup.2.ItemId' => item_ids
32
32
  }
33
- given_params.reduce(default) do |a, (k, v)|
33
+
34
+ if version = given.delete('Version') || given.delete(:version)
35
+ default['Version'] = version
36
+ end
37
+
38
+ given.reduce(default) do |a, (k, v)|
34
39
  a.merge "ItemLookup.Shared.#{Utils.camelize k.to_s}" => v
35
40
  end
36
41
  else
37
42
  raise ArgumentError, "Can't look up #{item_ids.size} items"
38
43
  end
44
+ end
39
45
  build! params
40
46
 
41
47
  get!
@@ -1,3 +1,3 @@
1
1
  module Vacuum
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
@@ -48,19 +48,25 @@ module Vacuum
48
48
 
49
49
  context 'given 11 to to 20 items' do
50
50
  before do
51
- request.look_up *((1..20).to_a << { :foo => 'bar' })
51
+ request.look_up *((1..20).to_a << {
52
+ :foo => 'bar',
53
+ :version => 'baz'
54
+ })
52
55
  end
53
56
 
54
57
  it 'builds a multi-batch query' do
55
- first_batch = parameters['ItemLookup.1.ItemId'].split(',')
56
- first_batch.should =~ (1..10).map(&:to_s)
57
- second_batch = parameters['ItemLookup.2.ItemId'].split(',')
58
- second_batch.should =~ (11..20).map(&:to_s)
58
+ first = parameters['ItemLookup.1.ItemId'].split(',')
59
+ second = parameters['ItemLookup.2.ItemId'].split(',')
60
+ (first + second).should =~ (1..20).map(&:to_s)
59
61
  end
60
62
 
61
63
  it 'takes parameters' do
62
64
  parameters['ItemLookup.Shared.Foo'].should eql 'bar'
63
65
  end
66
+
67
+ it 'overrides version' do
68
+ parameters['Version'].should eql 'baz'
69
+ end
64
70
  end
65
71
 
66
72
  context 'given over 20 items' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vacuum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-04 00:00:00.000000000 Z
12
+ date: 2012-04-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70156392348820 !ruby/object:Gem::Requirement
16
+ requirement: &70295025564860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.9'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70156392348820
24
+ version_requirements: *70295025564860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70156392348380 !ruby/object:Gem::Requirement
27
+ requirement: &70295025564460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.9'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70156392348380
35
+ version_requirements: *70295025564460
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: addressable
38
- requirement: &70156392347700 !ruby/object:Gem::Requirement
38
+ requirement: &70295025563720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '2.2'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70156392347700
46
+ version_requirements: *70295025563720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: faraday
49
- requirement: &70156392347120 !ruby/object:Gem::Requirement
49
+ requirement: &70295025563140 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.7.6
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70156392347120
57
+ version_requirements: *70295025563140
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: nokogiri
60
- requirement: &70156392346540 !ruby/object:Gem::Requirement
60
+ requirement: &70295025562560 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '1.5'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70156392346540
68
+ version_requirements: *70295025562560
69
69
  description: ! 'Vacuum is a wrapper to various Amazon Web Services (AWS) APIs, including
70
70
 
71
71
  Product Advertising and Marketplace Web Services (MWS).