vacuum 0.0.1 → 0.1.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.
- data/README.md +31 -49
- data/lib/vacuum/em.rb +23 -0
- data/lib/vacuum/{builder.rb → hash_builder.rb} +6 -12
- data/lib/vacuum/request.rb +79 -91
- data/lib/vacuum/response.rb +24 -46
- data/lib/vacuum/version.rb +1 -1
- data/lib/vacuum.rb +13 -12
- data/spec/vacuum/{builder_spec.rb → hash_builder_spec.rb} +5 -5
- data/spec/vacuum/request_spec.rb +54 -107
- data/spec/vacuum/response_spec.rb +30 -46
- metadata +11 -24
- data/lib/vacuum/cart.rb +0 -90
- data/lib/vacuum/cart_operations.rb +0 -12
- data/lib/vacuum/error.rb +0 -13
- data/lib/vacuum/locale.rb +0 -39
- data/lib/vacuum/lookup_operations.rb +0 -62
- data/lib/vacuum/search_operations.rb +0 -43
- data/spec/vacuum/cart_operations_spec.rb +0 -0
- data/spec/vacuum/cart_spec.rb +0 -0
- data/spec/vacuum/lookup_operations_spec.rb +0 -53
- data/spec/vacuum/search_operations_spec.rb +0 -59
@@ -1,43 +0,0 @@
|
|
1
|
-
module Vacuum
|
2
|
-
# Search operations
|
3
|
-
module SearchOperations
|
4
|
-
# Returns up to ten items that satisfy the search criteria,
|
5
|
-
# including one or more search indices.
|
6
|
-
#
|
7
|
-
# @param [String, nil] search_index search index or keyword query
|
8
|
-
# @param [String, Hash] params keyword query or hash of parameters
|
9
|
-
# @return [Vacuum::Response] a reponse
|
10
|
-
#
|
11
|
-
# @example The following searches the entire Amazon catalog for the
|
12
|
-
# keyword 'book'.
|
13
|
-
#
|
14
|
-
# req.search('book')
|
15
|
-
#
|
16
|
-
# @example The following searches the books search index for the
|
17
|
-
# keyword 'lacan'.
|
18
|
-
#
|
19
|
-
# req.search('Books', 'lacan')
|
20
|
-
#
|
21
|
-
# @example The following runs a power search on the books search
|
22
|
-
# index for non-fiction titles authored by Lacan and sorts results
|
23
|
-
# by Amazon's relevance ranking.
|
24
|
-
#
|
25
|
-
# req.search('Books', :power => 'author:lacan and not fiction',
|
26
|
-
# :sort => 'relevancerank')
|
27
|
-
#
|
28
|
-
def search(search_index, params = nil)
|
29
|
-
reset!
|
30
|
-
if params.nil?
|
31
|
-
params = { 'Keywords' => search_index }
|
32
|
-
search_index = 'All'
|
33
|
-
end
|
34
|
-
if params.is_a? String
|
35
|
-
params = { 'Keywords' => params }
|
36
|
-
end
|
37
|
-
self.<<({ 'Operation' => 'ItemSearch',
|
38
|
-
'SearchIndex' => search_index }.merge(params))
|
39
|
-
|
40
|
-
get
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
File without changes
|
data/spec/vacuum/cart_spec.rb
DELETED
File without changes
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Vacuum
|
4
|
-
describe LookupOperations do
|
5
|
-
let(:req) { Request.new('us') }
|
6
|
-
|
7
|
-
before do
|
8
|
-
req.configure do |c|
|
9
|
-
c.key = 'foo'
|
10
|
-
c.tag = 'bar'
|
11
|
-
end
|
12
|
-
req.stub!(:get)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#find" do
|
16
|
-
before do
|
17
|
-
req.find('1', '2', :foo => 'bar')
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'merges item ids' do
|
21
|
-
req.params['ItemId'].should eql '1,2'
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'merges additional parameters' do
|
25
|
-
req.params['Foo'].should eql 'bar'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "#find_browse_node" do
|
30
|
-
before do
|
31
|
-
req.find_browse_node('123', :foo => 'bar')
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'merges item ids' do
|
35
|
-
req.params['BrowseNodeId'].should eql '123'
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'merges additional parameters' do
|
39
|
-
req.params['Foo'].should eql 'bar'
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "#find_similar" do
|
44
|
-
before do
|
45
|
-
req.find_similar('1', '2')
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'merges item ids' do
|
49
|
-
req.params['ItemId'].should eql '1,2'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Vacuum
|
4
|
-
describe SearchOperations do
|
5
|
-
let(:req) { Request.new('us') }
|
6
|
-
|
7
|
-
before do
|
8
|
-
req.configure do |c|
|
9
|
-
c.key = 'foo'
|
10
|
-
c.tag = 'bar'
|
11
|
-
end
|
12
|
-
req.stub!(:get)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#search" do
|
16
|
-
context "when given a keyword" do
|
17
|
-
before do
|
18
|
-
req.search('foo')
|
19
|
-
end
|
20
|
-
|
21
|
-
it "does a keyword search" do
|
22
|
-
req.params['Keywords'].should eql 'foo'
|
23
|
-
end
|
24
|
-
|
25
|
-
it "searches all products" do
|
26
|
-
req.params["SearchIndex"].should eql 'All'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context "when given a search index and a keyword" do
|
31
|
-
before do
|
32
|
-
req.search('foo', 'bar')
|
33
|
-
end
|
34
|
-
|
35
|
-
it "does a keyword search" do
|
36
|
-
req.params['Keywords'].should eql 'bar'
|
37
|
-
end
|
38
|
-
|
39
|
-
it "sets the search index" do
|
40
|
-
req.params["SearchIndex"].should eql 'foo'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "when given a search index and parameters" do
|
45
|
-
before do
|
46
|
-
req.search('foo', :bar => 'baz')
|
47
|
-
end
|
48
|
-
|
49
|
-
it "sets the parameters" do
|
50
|
-
req.params['Bar'].should eql 'baz'
|
51
|
-
end
|
52
|
-
|
53
|
-
it "sets the search index" do
|
54
|
-
req.params["SearchIndex"].should eql 'foo'
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|