vacuum 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +11 -113
- data/lib/vacuum/request.rb +66 -0
- data/lib/vacuum/version.rb +1 -1
- data/lib/vacuum.rb +5 -38
- data/test/request_test.rb +18 -0
- metadata +24 -96
- data/lib/vacuum/endpoint/base.rb +0 -58
- data/lib/vacuum/endpoint/mws.rb +0 -59
- data/lib/vacuum/endpoint/product_advertising.rb +0 -34
- data/lib/vacuum/mws.rb +0 -8
- data/lib/vacuum/product_advertising.rb +0 -7
- data/lib/vacuum/request/base.rb +0 -109
- data/lib/vacuum/request/mws.rb +0 -24
- data/lib/vacuum/request/product_advertising.rb +0 -101
- data/lib/vacuum/request/signature/authentication.rb +0 -32
- data/lib/vacuum/request/signature/builder.rb +0 -70
- data/lib/vacuum/request/utils.rb +0 -24
- data/lib/vacuum/response/base.rb +0 -57
- data/lib/vacuum/response/mws.rb +0 -7
- data/lib/vacuum/response/product_advertising.rb +0 -19
- data/lib/vacuum/response/utils.rb +0 -48
- data/spec/fixtures/product_advertising +0 -1
- data/spec/spec_helper.rb +0 -15
- data/spec/support/shared_examples/endpoint.rb +0 -43
- data/spec/support/shared_examples/request.rb +0 -142
- data/spec/support/shared_examples/response.rb +0 -51
- data/spec/vacuum/endpoint/base_spec.rb +0 -19
- data/spec/vacuum/endpoint/mws_spec.rb +0 -47
- data/spec/vacuum/endpoint/product_advertising_spec.rb +0 -25
- data/spec/vacuum/request/base_spec.rb +0 -22
- data/spec/vacuum/request/mws_spec.rb +0 -26
- data/spec/vacuum/request/product_advertising_spec.rb +0 -118
- data/spec/vacuum/request/signature/authentication_spec.rb +0 -30
- data/spec/vacuum/request/signature/builder_spec.rb +0 -76
- data/spec/vacuum/request/utils_spec.rb +0 -23
- data/spec/vacuum/response/base_spec.rb +0 -38
- data/spec/vacuum/response/product_advertising_spec.rb +0 -57
- data/spec/vacuum/response/utils_spec.rb +0 -42
data/lib/vacuum/request/base.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
module Vacuum
|
2
|
-
module Request
|
3
|
-
# An Amazon Web Services (AWS) API request.
|
4
|
-
class Base
|
5
|
-
# Returns the AWS API Endpoint.
|
6
|
-
attr :endpoint
|
7
|
-
|
8
|
-
# Creates a new request for given locale and credentials.
|
9
|
-
#
|
10
|
-
# Yields the AWS API endpoint if a block is given.
|
11
|
-
def initialize(&blk)
|
12
|
-
@parameters = {}
|
13
|
-
@endpoint = Endpoint.const_get(class_basename).new
|
14
|
-
|
15
|
-
configure &blk if block_given?
|
16
|
-
end
|
17
|
-
|
18
|
-
# Adds given parameters to the request.
|
19
|
-
#
|
20
|
-
# hsh - A Hash of parameter key and value pairs.
|
21
|
-
#
|
22
|
-
# Returns self.
|
23
|
-
def build(hsh)
|
24
|
-
hsh.each do |k, v|
|
25
|
-
k = Utils.camelize k.to_s if k.is_a? Symbol
|
26
|
-
@parameters[k] = v.is_a?(Array) ? v.join(',') : v.to_s
|
27
|
-
end
|
28
|
-
|
29
|
-
self
|
30
|
-
end
|
31
|
-
|
32
|
-
# Resets the request to the given parameters.
|
33
|
-
#
|
34
|
-
# hsh - A Hash of parameter key and value pairs.
|
35
|
-
#
|
36
|
-
# Returns self.
|
37
|
-
def build!(hsh = {})
|
38
|
-
@parameters = {}
|
39
|
-
build hsh
|
40
|
-
end
|
41
|
-
|
42
|
-
# Yields the AWS API Endpoint.
|
43
|
-
#
|
44
|
-
# Returns nothing.
|
45
|
-
def configure(&blk)
|
46
|
-
yield @endpoint
|
47
|
-
end
|
48
|
-
|
49
|
-
# Returns a Faraday::Connection.
|
50
|
-
#
|
51
|
-
# Yields a Faraday::Builder to configure the connection if a block is
|
52
|
-
# given.
|
53
|
-
def connection
|
54
|
-
@connection ||= Faraday.new do |builder|
|
55
|
-
builder.use Signature::Authentication, endpoint.secret
|
56
|
-
|
57
|
-
yield builder if block_given?
|
58
|
-
|
59
|
-
unless builder.handlers.any? { |h| h.name.include? ':Adapter:' }
|
60
|
-
builder.adapter Faraday.default_adapter
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Performs the AWS API request.
|
66
|
-
#
|
67
|
-
# Returns a Vacuum::Response::Base or a subclass thereof.
|
68
|
-
def get
|
69
|
-
res = connection.get url
|
70
|
-
Response.const_get(class_basename).new res.body, res.status
|
71
|
-
end
|
72
|
-
|
73
|
-
# Performs the AWS API request.
|
74
|
-
#
|
75
|
-
# Raises a Bad Response if the response is not valid.
|
76
|
-
#
|
77
|
-
# Returns a Vacuum::Response::Base or a subclass thereof.
|
78
|
-
def get!
|
79
|
-
unless (res = get).valid?
|
80
|
-
raise BadResponse, "#{res.code} #{res['Code'].first}"
|
81
|
-
end
|
82
|
-
|
83
|
-
res
|
84
|
-
end
|
85
|
-
|
86
|
-
# Returns the Hash parameters of the AWS API request.
|
87
|
-
def parameters
|
88
|
-
default_parameters.merge @parameters
|
89
|
-
end
|
90
|
-
|
91
|
-
# Raises a Not Implemented Error.
|
92
|
-
#
|
93
|
-
# When implemented, this should return an Addressable::URI.
|
94
|
-
def url
|
95
|
-
raise NotImplementedError
|
96
|
-
end
|
97
|
-
|
98
|
-
private
|
99
|
-
|
100
|
-
def class_basename
|
101
|
-
self.class.name.split('::').last
|
102
|
-
end
|
103
|
-
|
104
|
-
def default_parameters
|
105
|
-
{ 'AWSAccessKeyId' => endpoint.key }
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
data/lib/vacuum/request/mws.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module Vacuum
|
2
|
-
module Request
|
3
|
-
# A Marketplace Web Services (MWS) API request.
|
4
|
-
class MWS < Base
|
5
|
-
# Returns the Addressable::URI URL of the MWS API request.
|
6
|
-
def url
|
7
|
-
Addressable::URI.new :scheme => 'https',
|
8
|
-
:host => endpoint.host,
|
9
|
-
:path => endpoint.path,
|
10
|
-
:query_values => parameters
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def default_parameters
|
16
|
-
super.merge 'MarketplaceId' => endpoint.marketplace,
|
17
|
-
'SellerId' => endpoint.seller,
|
18
|
-
'Service' => 'AWSECommerceService',
|
19
|
-
'SignatureMethod' => 'HmacSHA256',
|
20
|
-
'SignatureVersion' => 2
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
module Vacuum
|
2
|
-
module Request
|
3
|
-
# A Product Advertising API request.
|
4
|
-
class ProductAdvertising < Base
|
5
|
-
# Looks up attributes of up to twenty items.
|
6
|
-
#
|
7
|
-
# item_ids - Splat Array of item IDs. The last element may optionally
|
8
|
-
# specify a Hash of parameter key and value pairs.
|
9
|
-
#
|
10
|
-
# Examples
|
11
|
-
#
|
12
|
-
# request.find '0679753354', response_group: 'Images'
|
13
|
-
#
|
14
|
-
# Raises a Bad Response if response is not valid.
|
15
|
-
#
|
16
|
-
# Returns a Vacuum::Response::ProductAdvertising.
|
17
|
-
def look_up(*item_ids)
|
18
|
-
given = item_ids.last.is_a?(Hash) ? item_ids.pop : {}
|
19
|
-
|
20
|
-
params = begin
|
21
|
-
case item_ids.size
|
22
|
-
when 1..10
|
23
|
-
{
|
24
|
-
'Operation' => 'ItemLookup',
|
25
|
-
'ItemId' => item_ids
|
26
|
-
}.merge given
|
27
|
-
when 11..20
|
28
|
-
default = {
|
29
|
-
'Operation' => 'ItemLookup',
|
30
|
-
'ItemLookup.1.ItemId' => item_ids.shift(10),
|
31
|
-
'ItemLookup.2.ItemId' => item_ids
|
32
|
-
}
|
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)|
|
39
|
-
a.merge "ItemLookup.Shared.#{Utils.camelize k.to_s}" => v
|
40
|
-
end
|
41
|
-
else
|
42
|
-
raise ArgumentError, "Can't look up #{item_ids.size} items"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
build! params
|
46
|
-
|
47
|
-
get!
|
48
|
-
end
|
49
|
-
|
50
|
-
# Searches for items that satisfy the given criteria, including one or
|
51
|
-
# more search indices.
|
52
|
-
#
|
53
|
-
# index - Symbol search index
|
54
|
-
# query_or_params - String keyword query or Hash of parameter key and
|
55
|
-
# value pairs.
|
56
|
-
#
|
57
|
-
# Examples
|
58
|
-
#
|
59
|
-
# # Search the entire Amazon catalog for Deleuze.
|
60
|
-
# request.search :all, 'Deleuze'
|
61
|
-
#
|
62
|
-
# # Search books for non-fiction titles authored by Deleuze and sort
|
63
|
-
# # results by relevance.
|
64
|
-
# request.search :books, power: 'author:lacan and not fiction',
|
65
|
-
# sort: 'relevancerank'
|
66
|
-
#
|
67
|
-
# Raises a Bad Response if response is not valid.
|
68
|
-
#
|
69
|
-
# Returns a Vacuum::Response::ProductAdvertising.
|
70
|
-
def search(index, query_or_params = nil)
|
71
|
-
params = case query_or_params
|
72
|
-
when String
|
73
|
-
{ 'Keywords' => query_or_params }
|
74
|
-
else
|
75
|
-
query_or_params
|
76
|
-
end
|
77
|
-
build! params.merge! 'Operation' => 'ItemSearch',
|
78
|
-
'SearchIndex' => Utils.camelize(index.to_s)
|
79
|
-
|
80
|
-
get!
|
81
|
-
end
|
82
|
-
|
83
|
-
# Returns the Addressable::URI URL of the Product Advertising API
|
84
|
-
# request.
|
85
|
-
def url
|
86
|
-
Addressable::URI.new :scheme => 'http',
|
87
|
-
:host => endpoint.host,
|
88
|
-
:path => '/onca/xml',
|
89
|
-
:query_values => parameters
|
90
|
-
end
|
91
|
-
|
92
|
-
private
|
93
|
-
|
94
|
-
def default_parameters
|
95
|
-
super.merge 'AssociateTag' => endpoint.tag,
|
96
|
-
'Service' => 'AWSECommerceService',
|
97
|
-
'Version' => '2011-08-01'
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module Vacuum
|
2
|
-
module Request
|
3
|
-
module Signature
|
4
|
-
# Internal: Middleware that signs REST requests to various Amazon API
|
5
|
-
# endpoints.
|
6
|
-
class Authentication < Faraday::Middleware
|
7
|
-
# Initializes the middleware.
|
8
|
-
#
|
9
|
-
# app - An Object that responds to `call` and returns a
|
10
|
-
# Faraday::Response.
|
11
|
-
# secret - The String Amazon AWS access secret key.
|
12
|
-
def initialize(app, secret)
|
13
|
-
@secret = secret
|
14
|
-
super app
|
15
|
-
end
|
16
|
-
|
17
|
-
# Signs the request.
|
18
|
-
#
|
19
|
-
# env - A Hash that contains info about the request.
|
20
|
-
#
|
21
|
-
# Returns an Object that responds to `call` and returns a
|
22
|
-
# Faraday::Response.
|
23
|
-
def call(env)
|
24
|
-
builder = Builder.new env, @secret
|
25
|
-
builder.timestamp.sort_query.sign
|
26
|
-
|
27
|
-
@app.call builder.env
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
module Vacuum
|
2
|
-
module Request
|
3
|
-
module Signature
|
4
|
-
# Internal: Signs a request to an Amazon API with an HMAC-SHA256
|
5
|
-
# signature.
|
6
|
-
class Builder
|
7
|
-
# Returns a Hash that contains info about the request.
|
8
|
-
attr :env
|
9
|
-
|
10
|
-
# Returns the String Amazon AWS access secret key.
|
11
|
-
attr :secret
|
12
|
-
|
13
|
-
# Initializes a new Builder.
|
14
|
-
#
|
15
|
-
# env - A Hash that contains info about the request.
|
16
|
-
def initialize(env, secret)
|
17
|
-
env[:url] = Addressable::URI.parse env[:url]
|
18
|
-
@env, @secret = env, secret
|
19
|
-
end
|
20
|
-
|
21
|
-
# Returns the String name of the HTTP method used by the request.
|
22
|
-
def method
|
23
|
-
env[:method].to_s.upcase
|
24
|
-
end
|
25
|
-
|
26
|
-
# Signs the request.
|
27
|
-
#
|
28
|
-
# Returns self.
|
29
|
-
def sign
|
30
|
-
url.query = url.query.to_s + "&Signature=#{Utils.encode signature}"
|
31
|
-
self
|
32
|
-
end
|
33
|
-
|
34
|
-
# Returns a String signature.
|
35
|
-
def signature
|
36
|
-
sha256 = OpenSSL::Digest::SHA256.new
|
37
|
-
hash = OpenSSL::HMAC.digest sha256, secret, string_to_sign
|
38
|
-
|
39
|
-
Base64.encode64(hash).chomp
|
40
|
-
end
|
41
|
-
|
42
|
-
# Sorts the URL query values of the request.
|
43
|
-
#
|
44
|
-
# Returns self.
|
45
|
-
def sort_query
|
46
|
-
url.query_values = url.query_values
|
47
|
-
self
|
48
|
-
end
|
49
|
-
|
50
|
-
# Returns a String to sign based on pseudo-grammar specified by Amazon.
|
51
|
-
def string_to_sign
|
52
|
-
[method, url.host, url.path, url.query].join "\n"
|
53
|
-
end
|
54
|
-
|
55
|
-
# Timestamps the request.
|
56
|
-
#
|
57
|
-
# Returns self.
|
58
|
-
def timestamp
|
59
|
-
url.query = url.query.to_s + "&Timestamp=#{Utils.encode Time.now.utc.iso8601}"
|
60
|
-
self
|
61
|
-
end
|
62
|
-
|
63
|
-
# Returns the Addressable::URI URL of the request.
|
64
|
-
def url
|
65
|
-
env[:url]
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
data/lib/vacuum/request/utils.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module Vacuum
|
2
|
-
module Request
|
3
|
-
module Utils
|
4
|
-
# Camelizes a value.
|
5
|
-
#
|
6
|
-
# val - A String value.
|
7
|
-
#
|
8
|
-
# Returns an upper-camelcased String.
|
9
|
-
def self.camelize(val)
|
10
|
-
val.split('_').map(&:capitalize).join
|
11
|
-
end
|
12
|
-
|
13
|
-
# Percent encodes a URI component.
|
14
|
-
#
|
15
|
-
# component - The String URI component to encode.
|
16
|
-
#
|
17
|
-
# Returns the String encoded component.
|
18
|
-
def self.encode(component)
|
19
|
-
Addressable::URI.encode_component \
|
20
|
-
component, Addressable::URI::CharacterClasses::UNRESERVED
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/lib/vacuum/response/base.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
module Vacuum
|
2
|
-
module Response
|
3
|
-
# An Amazon Web Services (AWS) API response.
|
4
|
-
class Base
|
5
|
-
# Gets/Sets the String response body.
|
6
|
-
attr_accessor :body
|
7
|
-
|
8
|
-
# Gets/Sets the Integer HTTP response code.
|
9
|
-
attr_accessor :code
|
10
|
-
|
11
|
-
# Initializes a new Response.
|
12
|
-
#
|
13
|
-
# body - The String response body.
|
14
|
-
# code - An HTTP response code that responds to to_i.
|
15
|
-
def initialize(body, code)
|
16
|
-
@body, @code = body, code.to_i
|
17
|
-
end
|
18
|
-
|
19
|
-
# Queries the response.
|
20
|
-
#
|
21
|
-
# query - String attribute to be queried.
|
22
|
-
#
|
23
|
-
# Yields matching nodes to a given block if one is given.
|
24
|
-
#
|
25
|
-
# Returns an Array of matching nodes or the return values of the yielded
|
26
|
-
# block if latter was given.
|
27
|
-
def find(query)
|
28
|
-
path = if xml.namespaces.empty?
|
29
|
-
"//#{query}"
|
30
|
-
else
|
31
|
-
"//xmlns:#{query}"
|
32
|
-
end
|
33
|
-
|
34
|
-
xml.xpath(path).map do |node|
|
35
|
-
hsh = Utils.xml_to_hash node
|
36
|
-
block_given? ? yield(hsh) : hsh
|
37
|
-
end
|
38
|
-
end
|
39
|
-
alias [] find
|
40
|
-
|
41
|
-
# Returns a Hash representation of the response.
|
42
|
-
def to_hash
|
43
|
-
Utils.xml_to_hash xml
|
44
|
-
end
|
45
|
-
|
46
|
-
# Returns whether the HTTP response is OK.
|
47
|
-
def valid?
|
48
|
-
code == 200
|
49
|
-
end
|
50
|
-
|
51
|
-
# Returns an XML document.
|
52
|
-
def xml
|
53
|
-
@xml ||= Nokogiri::XML.parse @body
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
data/lib/vacuum/response/mws.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Vacuum
|
2
|
-
module Response
|
3
|
-
# A Product Advertising API response.
|
4
|
-
class ProductAdvertising < Base
|
5
|
-
# Returns an Array of errors.
|
6
|
-
def errors
|
7
|
-
find 'Error'
|
8
|
-
end
|
9
|
-
|
10
|
-
# Returns whether the response has errors.
|
11
|
-
#
|
12
|
-
# Note that a response with errors is still technically valid, i.e. the
|
13
|
-
# response code is 200.
|
14
|
-
def has_errors?
|
15
|
-
errors.count > 0
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module Vacuum
|
2
|
-
module Response
|
3
|
-
module Utils
|
4
|
-
# Builds a Hash from an XML document.
|
5
|
-
#
|
6
|
-
# xml - a Nokogiri::XML::Document or Nokogiri::XML::Element.
|
7
|
-
#
|
8
|
-
# Returns a Hash representation of the XML document.
|
9
|
-
def self.xml_to_hash(xml)
|
10
|
-
case xml
|
11
|
-
when Nokogiri::XML::Document
|
12
|
-
xml_to_hash xml.root
|
13
|
-
when Nokogiri::XML::Element
|
14
|
-
hsh = {}
|
15
|
-
|
16
|
-
xml.attributes.each_pair do |key, attribute|
|
17
|
-
hsh[key] = attribute.value
|
18
|
-
end
|
19
|
-
|
20
|
-
xml.children.each do |child|
|
21
|
-
result = xml_to_hash child
|
22
|
-
|
23
|
-
if child.name == 'text'
|
24
|
-
if hsh.empty?
|
25
|
-
return result
|
26
|
-
else
|
27
|
-
hsh['__content__'] = result
|
28
|
-
end
|
29
|
-
elsif hsh[child.name]
|
30
|
-
case hsh[child.name]
|
31
|
-
when Array
|
32
|
-
hsh[child.name] << result
|
33
|
-
else
|
34
|
-
hsh[child.name] = [hsh[child.name]] << result
|
35
|
-
end
|
36
|
-
else
|
37
|
-
hsh[child.name] = result
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
hsh
|
42
|
-
else
|
43
|
-
xml.content.to_s
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<?xml version="1.0" ?><ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01"><OperationRequest><RequestId>86b89a15-b717-4d95-99aa-fe531b4ca762</RequestId><Arguments><Argument Name="Operation" Value="ItemLookup"></Argument><Argument Name="Service" Value="AWSECommerceService"></Argument><Argument Name="AssociateTag" Value="theorydot08-20"></Argument><Argument Name="Version" Value="2011-08-01"></Argument><Argument Name="Signature" Value="vOT9O1NW8PYLvrUX6KI3jrZ4Fg7LdtEYTrlsWzhbm1k="></Argument><Argument Name="ItemId" Value="0816614024,0143105825"></Argument><Argument Name="IdType" Value="ASIN"></Argument><Argument Name="AWSAccessKeyId" Value="0ZVSQ33MDFPQS8H2PM02"></Argument><Argument Name="Timestamp" Value="2011-07-29T17:52:34Z"></Argument></Arguments><RequestProcessingTime>0.0111990000000000</RequestProcessingTime></OperationRequest><Items><Request><IsValid>True</IsValid><ItemLookupRequest><IdType>ASIN</IdType><ItemId>0816614024</ItemId><ItemId>0143105825</ItemId><ResponseGroup>Small</ResponseGroup><VariationPage>All</VariationPage></ItemLookupRequest></Request><Item><ASIN>0816614024</ASIN><DetailPageURL>http://www.amazon.com/Thousand-Plateaus-Schizophrenia-Gilles-Deleuze/dp/0816614024%3FSubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0816614024</DetailPageURL><ItemLinks><ItemLink><Description>Technical Details</Description><URL>http://www.amazon.com/Thousand-Plateaus-Schizophrenia-Gilles-Deleuze/dp/tech-data/0816614024%3FSubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0816614024</URL></ItemLink><ItemLink><Description>Add To Baby Registry</Description><URL>http://www.amazon.com/gp/registry/baby/add-item.html%3Fasin.0%3D0816614024%26SubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0816614024</URL></ItemLink><ItemLink><Description>Add To Wedding Registry</Description><URL>http://www.amazon.com/gp/registry/wedding/add-item.html%3Fasin.0%3D0816614024%26SubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0816614024</URL></ItemLink><ItemLink><Description>Add To Wishlist</Description><URL>http://www.amazon.com/gp/registry/wishlist/add-item.html%3Fasin.0%3D0816614024%26SubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0816614024</URL></ItemLink><ItemLink><Description>Tell A Friend</Description><URL>http://www.amazon.com/gp/pdp/taf/0816614024%3FSubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0816614024</URL></ItemLink><ItemLink><Description>All Customer Reviews</Description><URL>http://www.amazon.com/review/product/0816614024%3FSubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0816614024</URL></ItemLink><ItemLink><Description>All Offers</Description><URL>http://www.amazon.com/gp/offer-listing/0816614024%3FSubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0816614024</URL></ItemLink></ItemLinks><ItemAttributes><Author>Gilles Deleuze</Author><Creator Role="Contributor">Felix Guattari</Creator><Manufacturer>Univ Of Minnesota Press</Manufacturer><ProductGroup>Book</ProductGroup><Title>Thousand Plateaus: Capitalism and Schizophrenia</Title></ItemAttributes></Item><Item><ASIN>0143105825</ASIN><DetailPageURL>http://www.amazon.com/Anti-Oedipus-Capitalism-Schizophrenia-Penguin-Classics/dp/0143105825%3FSubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0143105825</DetailPageURL><ItemLinks><ItemLink><Description>Technical Details</Description><URL>http://www.amazon.com/Anti-Oedipus-Capitalism-Schizophrenia-Penguin-Classics/dp/tech-data/0143105825%3FSubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0143105825</URL></ItemLink><ItemLink><Description>Add To Baby Registry</Description><URL>http://www.amazon.com/gp/registry/baby/add-item.html%3Fasin.0%3D0143105825%26SubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0143105825</URL></ItemLink><ItemLink><Description>Add To Wedding Registry</Description><URL>http://www.amazon.com/gp/registry/wedding/add-item.html%3Fasin.0%3D0143105825%26SubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0143105825</URL></ItemLink><ItemLink><Description>Add To Wishlist</Description><URL>http://www.amazon.com/gp/registry/wishlist/add-item.html%3Fasin.0%3D0143105825%26SubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0143105825</URL></ItemLink><ItemLink><Description>Tell A Friend</Description><URL>http://www.amazon.com/gp/pdp/taf/0143105825%3FSubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0143105825</URL></ItemLink><ItemLink><Description>All Customer Reviews</Description><URL>http://www.amazon.com/review/product/0143105825%3FSubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0143105825</URL></ItemLink><ItemLink><Description>All Offers</Description><URL>http://www.amazon.com/gp/offer-listing/0143105825%3FSubscriptionId%3D0ZVSQ33MDFPQS8H2PM02%26tag%3Dtheorydot08-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0143105825</URL></ItemLink></ItemLinks><ItemAttributes><Author>Gilles Deleuze</Author><Author>Felix Guattari</Author><Creator Role="Translator">Robert Hurley</Creator><Creator Role="Translator">Mark Seem</Creator><Creator Role="Introduction">Mark Seem</Creator><Creator Role="Translator">Helen Lane</Creator><Creator Role="Preface">Michel Foucault</Creator><Manufacturer>Penguin Classics</Manufacturer><ProductGroup>Book</ProductGroup><Title>Anti-Oedipus: Capitalism and Schizophrenia (Penguin Classics)</Title></ItemAttributes></Item></Items></ItemLookupResponse>
|
data/spec/spec_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
begin
|
3
|
-
require 'pry'
|
4
|
-
rescue LoadError
|
5
|
-
end
|
6
|
-
|
7
|
-
require 'vacuum'
|
8
|
-
require 'vacuum/mws'
|
9
|
-
require 'vacuum/product_advertising'
|
10
|
-
|
11
|
-
RSpec.configure do |c|
|
12
|
-
c.treat_symbols_as_metadata_keys_with_true_values = true
|
13
|
-
end
|
14
|
-
|
15
|
-
Dir['./spec/support/**/*.rb'].each { |f| require f }
|
@@ -1,43 +0,0 @@
|
|
1
|
-
shared_examples 'an endpoint' do
|
2
|
-
describe '#key' do
|
3
|
-
it 'requires key to have been set' do
|
4
|
-
expect { endpoint.key }.to raise_error Vacuum::MissingKey
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
describe '#locale' do
|
9
|
-
it 'defaults to the US' do
|
10
|
-
endpoint.locale.should eql 'US'
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'if not valid' do
|
14
|
-
before do
|
15
|
-
endpoint.locale = 'foo'
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'raises an error' do
|
19
|
-
expect { endpoint.locale }.to raise_error Vacuum::BadLocale
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#secret' do
|
25
|
-
it 'requires secret to have been set' do
|
26
|
-
expect { endpoint.secret }.to raise_error Vacuum::MissingSecret
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#user_agent' do
|
31
|
-
it 'includes the library version number' do
|
32
|
-
endpoint.user_agent.should match /Vacuum\/[\d\w.]+\s/
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'describes the Ruby interpreter' do
|
36
|
-
endpoint.user_agent.should match /Language=(?:j?ruby|rbx)/
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'describes the host' do
|
40
|
-
endpoint.user_agent.should match /Host=[\w\d]+/
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|