vacuum 0.3.0 → 0.3.1

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.
data/README.md CHANGED
@@ -1,24 +1,28 @@
1
1
  # Vacuum
2
2
 
3
- [![travis][1]][2]
3
+ [![Build Status][1]][2]
4
4
 
5
- Vacuum is a thin Ruby wrapper to the [Amazon Product Advertising API][3].
5
+ Vacuum is a Ruby wrapper to the [Amazon Product Advertising API][4].
6
6
 
7
- ![vacuum][4]
7
+ ![vacuum][3]
8
+
9
+ ## Usage
8
10
 
9
11
  ```ruby
10
- request = Vacuum.new
12
+ req = Vacuum.new
13
+
14
+ req.configure key: 'foo',
15
+ secret: 'secret',
16
+ tag: 'biz-val'
11
17
 
12
- request.configure key: 'foo',
13
- secret: 'secret',
14
- tag: 'foo-bar'
18
+ params = { 'Operation' => 'ItemSearch',
19
+ 'SearchIndex' => 'Books',
20
+ 'Keywords' => 'Architecture' }
15
21
 
16
- request.get query: { 'Operation' => 'ItemSearch',
17
- 'SearchIndex' => 'Books',
18
- 'Keywords' => 'Architecture' }
22
+ req.get query: params # XPath is your friend.
19
23
  ```
20
24
 
21
25
  [1]: https://secure.travis-ci.org/hakanensari/vacuum.png
22
26
  [2]: http://travis-ci.org/hakanensari/vacuum
23
- [3]: https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html
24
- [4]: http://f.cl.ly/items/2k2X0e2u0G3k1c260D2u/vacuum.png
27
+ [3]: http://f.cl.ly/items/2k2X0e2u0G3k1c260D2u/vacuum.png
28
+ [4]: https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html
@@ -5,8 +5,8 @@ module Vacuum
5
5
  class Request
6
6
  include Jeff
7
7
 
8
- BadLocale = Class.new ArgumentError
9
- MissingTag = Class.new ArgumentError
8
+ BadLocale = Class.new(ArgumentError)
9
+ MissingTag = Class.new(ArgumentError)
10
10
 
11
11
  # A list of Amazon Product Advertising API hosts.
12
12
  HOSTS = {
@@ -25,7 +25,7 @@ module Vacuum
25
25
  'Service' => 'AWSECommerceService',
26
26
  'Version' => '2011-08-01'
27
27
 
28
- # Creates a new request for given locale and credentials.
28
+ # Create a new request for given locale.
29
29
  #
30
30
  # locale - The String Product Advertising API locale (default: US).
31
31
  #
@@ -35,25 +35,19 @@ module Vacuum
35
35
  self.endpoint = "http://#{host}/onca/xml"
36
36
  end
37
37
 
38
- # Configures the Amazon Product Advertising API request.
38
+ # Configure the Amazon Product Advertising API request.
39
39
  #
40
40
  # credentials - The Hash credentials of the API endpoint.
41
41
  # :key - The String Amazon Web Services (AWS) key.
42
42
  # :secret - The String AWS secret.
43
43
  # :tag - The String Associate Tag.
44
44
  #
45
- # Yields self.
46
- #
47
45
  # Returns nothing.
48
- def configure(credentials, &blk)
49
- if block_given?
50
- yield self
51
- else
52
- credentials.each { |key, val| self.send "#{key}=", val }
53
- end
46
+ def configure(credentials)
47
+ credentials.each { |key, val| self.send("#{key}=", val) }
54
48
  end
55
49
 
56
- # Gets the String Associate Tag.
50
+ # Get the String Associate Tag.
57
51
  #
58
52
  # Raises a Missing Tag error if Associate Tag is missing.
59
53
  def tag
@@ -62,5 +56,19 @@ module Vacuum
62
56
 
63
57
  # Sets the String Associate Tag.
64
58
  attr_writer :tag
59
+
60
+ # Build a URL.
61
+ #
62
+ # params - A Hash of Amazon Product Advertising query params.
63
+ #
64
+ # Returns the built URL String.
65
+ def url(params)
66
+ opts = {
67
+ :method => :get,
68
+ :query => params
69
+ }
70
+
71
+ [endpoint, build_options(opts).fetch(:query)].join('?')
72
+ end
65
73
  end
66
74
  end
@@ -1,3 +1,3 @@
1
1
  module Vacuum
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
metadata CHANGED
@@ -1,48 +1,48 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vacuum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
4
  prerelease:
5
+ version: 0.3.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Hakan Ensari
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-06 00:00:00.000000000 Z
12
+ date: 2013-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: jeff
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
15
+ version_requirements: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 0.4.0
19
+ version: 0.6.0
20
+ none: false
21
+ name: jeff
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
24
+ requirement: !ruby/object:Gem::Requirement
26
25
  requirements:
27
26
  - - ~>
28
27
  - !ruby/object:Gem::Version
29
- version: 0.4.0
30
- - !ruby/object:Gem::Dependency
31
- name: rake
32
- requirement: !ruby/object:Gem::Requirement
28
+ version: 0.6.0
33
29
  none: false
30
+ - !ruby/object:Gem::Dependency
31
+ version_requirements: !ruby/object:Gem::Requirement
34
32
  requirements:
35
33
  - - ! '>='
36
34
  - !ruby/object:Gem::Version
37
35
  version: '0'
36
+ none: false
37
+ name: rake
38
38
  type: :development
39
39
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
40
+ requirement: !ruby/object:Gem::Requirement
42
41
  requirements:
43
42
  - - ! '>='
44
43
  - !ruby/object:Gem::Version
45
44
  version: '0'
45
+ none: false
46
46
  description: A wrapper to the Amazon Product Advertising API
47
47
  email:
48
48
  - hakan.ensari@papercavalier.com
@@ -55,7 +55,6 @@ files:
55
55
  - lib/vacuum.rb
56
56
  - LICENSE
57
57
  - README.md
58
- - test/request_test.rb
59
58
  homepage: https://github.com/hakanensari/vacuum
60
59
  licenses: []
61
60
  post_install_message:
@@ -63,23 +62,21 @@ rdoc_options: []
63
62
  require_paths:
64
63
  - lib
65
64
  required_ruby_version: !ruby/object:Gem::Requirement
66
- none: false
67
65
  requirements:
68
66
  - - ! '>='
69
67
  - !ruby/object:Gem::Version
70
68
  version: '1.9'
71
- required_rubygems_version: !ruby/object:Gem::Requirement
72
69
  none: false
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
71
  requirements:
74
72
  - - ! '>='
75
73
  - !ruby/object:Gem::Version
76
74
  version: '0'
75
+ none: false
77
76
  requirements: []
78
77
  rubyforge_project:
79
78
  rubygems_version: 1.8.23
80
79
  signing_key:
81
80
  specification_version: 3
82
81
  summary: Amazon Product Advertising in Ruby
83
- test_files:
84
- - test/request_test.rb
85
- has_rdoc:
82
+ test_files: []
data/test/request_test.rb DELETED
@@ -1,18 +0,0 @@
1
- require 'minitest/autorun'
2
- require_relative '../lib/vacuum'
3
-
4
- module Vacuum
5
- describe Request do
6
- it 'requires a valid locale' do
7
- -> { Request.new('foo') }.must_raise Request::BadLocale
8
- end
9
-
10
- it 'requires an Associate Tag' do
11
- -> { Request.new('US').tag }.must_raise Request::MissingTag
12
- end
13
-
14
- it 'defaults to the US endpoint' do
15
- Request.new.endpoint.must_equal 'http://ecs.amazonaws.com/onca/xml'
16
- end
17
- end
18
- end