sucker 0.4.0 → 0.5.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 +9 -7
- data/lib/sucker.rb +1 -1
- data/lib/sucker/request.rb +1 -1
- data/lib/sucker/response.rb +1 -1
- data/spec/integration/item_lookup_spec.rb +2 -2
- data/spec/integration/japan_spec.rb +2 -2
- data/spec/integration/seller_listing_search_spec.rb +1 -1
- data/spec/integration/twenty_items_in_one_request_spec.rb +1 -1
- data/spec/unit/sucker/response_spec.rb +1 -1
- metadata +11 -11
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Sucker
|
2
2
|
======
|
3
3
|
|
4
|
-
Sucker is a thin Ruby wrapper to the [Amazon Product Advertising API](https://affiliate-program.amazon.co.uk/gp/advertising/api/detail/main.html). It runs on Curb and
|
4
|
+
Sucker is a thin Ruby wrapper to the [Amazon Product Advertising API](https://affiliate-program.amazon.co.uk/gp/advertising/api/detail/main.html). It runs on Curb and XmlSimple and supports __everything__ in the API.
|
5
5
|
|
6
6
|

|
7
7
|
|
@@ -33,7 +33,7 @@ Hit Amazon and do something with the response.
|
|
33
33
|
p response.time
|
34
34
|
p response.body
|
35
35
|
|
36
|
-
response.to_h["
|
36
|
+
response.to_h["Items"]["Item"].each { ... }
|
37
37
|
|
38
38
|
Hit Amazon again.
|
39
39
|
|
@@ -41,25 +41,27 @@ Hit Amazon again.
|
|
41
41
|
"ItemId" => 10.more.asins }
|
42
42
|
response = worker.get
|
43
43
|
|
44
|
-
|
44
|
+
Check the integration specs for more examples.
|
45
45
|
|
46
46
|
Testing
|
47
47
|
-------
|
48
48
|
|
49
49
|
To fake web requests, I do the following:
|
50
50
|
|
51
|
-
In a file such as `spec/support/sucker.rb`, I prep
|
51
|
+
In a file such as `spec/support/sucker.rb`, I prep:
|
52
52
|
|
53
53
|
require "sucker/stub"
|
54
54
|
Sucker.fixtures_path = File.dirname(__FILE__) + "/../fixtures"
|
55
55
|
|
56
|
-
|
56
|
+
In the spec, I set up a worker and then stub it:
|
57
57
|
|
58
58
|
Sucker.stub(@worker)
|
59
59
|
|
60
60
|
The first time you run the spec, the worker will perform the actual web request and cache the response. Subsequent requests are then mocked with the cached response.
|
61
61
|
|
62
|
-
|
62
|
+
Notes
|
63
63
|
-----
|
64
64
|
|
65
|
-
The unit specs should run out of the box after you `bundle install`, but the integration specs require you to create [an amazon.yml file with valid credentials](http://github.com/papercavalier/sucker/blob/master/spec/support/amazon.yml.example) in
|
65
|
+
* The unit specs should run out of the box after you `bundle install`, but the integration specs require you to create [an amazon.yml file with valid credentials](http://github.com/papercavalier/sucker/blob/master/spec/support/amazon.yml.example) in `spec/support`.
|
66
|
+
|
67
|
+
* Version 0.5.0 replaces Crack with XmlSimple, which results in a slightly different hash output. Fix up your code accordingly.
|
data/lib/sucker.rb
CHANGED
data/lib/sucker/request.rb
CHANGED
data/lib/sucker/response.rb
CHANGED
@@ -23,7 +23,7 @@ module Sucker
|
|
23
23
|
context "single item" do
|
24
24
|
before do
|
25
25
|
@worker << { "ItemId" => "0816614024" }
|
26
|
-
@item = @worker.get.to_h["
|
26
|
+
@item = @worker.get.to_h["Items"]["Item"]
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns an item" do
|
@@ -43,7 +43,7 @@ module Sucker
|
|
43
43
|
context "multiple items" do
|
44
44
|
before do
|
45
45
|
@worker << { "ItemId" => ["0816614024", "0143105825"] }
|
46
|
-
@items = @worker.get.to_h["
|
46
|
+
@items = @worker.get.to_h["Items"]["Item"]
|
47
47
|
end
|
48
48
|
|
49
49
|
it "returns two items" do
|
@@ -18,10 +18,10 @@ module Sucker
|
|
18
18
|
context "single item" do
|
19
19
|
before do
|
20
20
|
@worker << { "ItemId" => "0816614024" }
|
21
|
-
@item = @worker.get.to_h["
|
21
|
+
@item = @worker.get.to_h["Items"]["Item"]
|
22
22
|
end
|
23
23
|
|
24
|
-
it "returns an
|
24
|
+
it "returns an array of items" do
|
25
25
|
@item.should be_an_instance_of Hash
|
26
26
|
end
|
27
27
|
end
|
@@ -5,7 +5,7 @@ module Sucker
|
|
5
5
|
before do
|
6
6
|
curl = Sucker.new.curl
|
7
7
|
curl.stub(:get).and_return(nil)
|
8
|
-
curl.stub!(:body_str).and_return("foo")
|
8
|
+
curl.stub!(:body_str).and_return("<foo bar='baz' />")
|
9
9
|
curl.stub!(:response_code).and_return(200)
|
10
10
|
curl.stub!(:total_time).and_return(1.0)
|
11
11
|
@response = Response.new(curl)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sucker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Hakan Ensari
|
@@ -16,24 +16,24 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-07-
|
19
|
+
date: 2010-07-31 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
prerelease: false
|
24
24
|
type: :runtime
|
25
|
-
name:
|
25
|
+
name: xml-simple
|
26
26
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
27
27
|
none: false
|
28
28
|
requirements:
|
29
|
-
- - "
|
29
|
+
- - ">="
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
hash:
|
31
|
+
hash: 15
|
32
32
|
segments:
|
33
|
-
- 0
|
34
33
|
- 1
|
35
|
-
-
|
36
|
-
|
34
|
+
- 0
|
35
|
+
- 12
|
36
|
+
version: 1.0.12
|
37
37
|
requirement: *id001
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
prerelease: false
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
43
43
|
none: false
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
hash: 105
|
48
48
|
segments:
|