sucker 0.9.0 → 0.9.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.
@@ -15,9 +15,9 @@ Set up a worker.
15
15
  :key => "API KEY",
16
16
  :secret => "API SECRET")
17
17
 
18
- Optionally, fiddle with curl. Say you want to query Amazon through a different network interface:
18
+ Optionally, fiddle with cURL. Say you want to query Amazon through a different network interface:
19
19
 
20
- worker.curl { |c| c.interface = "eth1" }
20
+ worker.curl { |c| c.interface = "eth0:0" }
21
21
 
22
22
  Set up a request.
23
23
 
@@ -41,11 +41,11 @@ View the internals of the response object.
41
41
  response.body,
42
42
  response.xml
43
43
 
44
- Here is the response parsed into a simple hash:
44
+ The response parsed into a simple hash:
45
45
 
46
46
  pp response.to_hash
47
47
 
48
- But you will probably be more interested particular nodes:
48
+ You will probably be more interested in particular nodes:
49
49
 
50
50
  response.node("Item"),
51
51
  response.node("Error")
@@ -55,9 +55,9 @@ Fetch another ASIN in a more DSL-y way.
55
55
  worker << { "ItemId" => "0486454398" }
56
56
  pp worker.get.node("Item")
57
57
 
58
- Check the integration specs for more examples.
58
+ Repeat ad infinitum.
59
59
 
60
- Ultimately, you should rely on the API documentation to build your queries.
60
+ Check the integration specs for more examples and then dive into API documentation.
61
61
 
62
62
  Stubbing
63
63
  --------
@@ -83,4 +83,4 @@ Specs pass against Ruby 1.8.7 and 1.9.2.
83
83
  Todo
84
84
  ----
85
85
 
86
- * Rip out the Stub class and use VCR instead once Webmock gets a cURL adapter.
86
+ * Rip out the Stub class and use VCR instead once someone writes up a Curb adaptor for Webmock.
@@ -41,11 +41,8 @@ module Sucker
41
41
 
42
42
  # A reusable, configurable cURL object
43
43
  def curl
44
- @curl ||= Curl::Easy.new
45
-
46
- yield @curl if block_given?
47
-
48
- @curl
44
+ yield curl_object if block_given?
45
+ curl_object
49
46
  end
50
47
 
51
48
  # Performs the request and returns a response object
@@ -74,6 +71,10 @@ module Sucker
74
71
  join("&")
75
72
  end
76
73
 
74
+ def curl_object
75
+ @curl ||= Curl::Easy.new
76
+ end
77
+
77
78
  def host
78
79
  HOSTS[locale.to_sym]
79
80
  end
@@ -0,0 +1,37 @@
1
+ require "spec_helper"
2
+
3
+ module Sucker
4
+ describe "Related items" do
5
+ before do
6
+ @worker = Sucker.new(
7
+ :locale => "us",
8
+ :key => amazon["key"],
9
+ :secret => amazon["secret"])
10
+
11
+ @worker << {
12
+ "Operation" => "ItemLookup",
13
+ "IdType" => "ASIN",
14
+ "ResponseGroup" => ["RelatedItems"],
15
+ "RelationshipType" => "AuthorityTitle" }
16
+
17
+ Sucker.stub(@worker)
18
+ end
19
+
20
+ it "finds authority title and related items" do
21
+ @worker << { "ItemId" => "0415246334" }
22
+ response = @worker.get
23
+ response.node("RelatedItem").size.should eql 1
24
+ parent_asin = response.node("RelatedItem").first["Item"]["ASIN"]
25
+
26
+ @worker << { "ItemId" => parent_asin }
27
+ response = @worker.get
28
+ response.node("RelatedItem").size.should > 1
29
+ end
30
+
31
+ it "foos items with no related items" do
32
+ @worker << { "ItemId" => "0804819491" }
33
+ response = @worker.get
34
+ response.node("RelatedItem").size.should eql 0
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 0
9
- version: 0.9.0
8
+ - 1
9
+ version: 0.9.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Hakan Ensari
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-19 00:00:00 +01:00
18
+ date: 2010-09-23 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -56,21 +56,22 @@ extensions: []
56
56
 
57
57
  extra_rdoc_files:
58
58
  - LICENSE
59
- - README.md
59
+ - README.markdown
60
60
  files:
61
61
  - LICENSE
62
+ - README.markdown
62
63
  - lib/sucker.rb
63
64
  - lib/sucker/active_support/core_ext/object/blank.rb
64
65
  - lib/sucker/active_support/xml_mini/nokogiri.rb
65
66
  - lib/sucker/request.rb
66
67
  - lib/sucker/response.rb
67
68
  - lib/sucker/stub.rb
68
- - README.md
69
69
  - spec/integration/errors_spec.rb
70
70
  - spec/integration/france_spec.rb
71
71
  - spec/integration/images_spec.rb
72
72
  - spec/integration/item_lookup_spec.rb
73
73
  - spec/integration/japan_spec.rb
74
+ - spec/integration/related_items_spec.rb
74
75
  - spec/integration/seller_listing_search_spec.rb
75
76
  - spec/integration/twenty_items_in_one_request_spec.rb
76
77
  - spec/spec_helper.rb
@@ -81,7 +82,7 @@ files:
81
82
  - spec/unit/sucker/stub_spec.rb
82
83
  - spec/unit/sucker_spec.rb
83
84
  has_rdoc: true
84
- homepage: http://github.com/papercavalier/sucker
85
+ homepage: http://gloss.papercavalier.com/sucker
85
86
  licenses: []
86
87
 
87
88
  post_install_message:
@@ -94,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
95
  requirements:
95
96
  - - ">="
96
97
  - !ruby/object:Gem::Version
97
- hash: -4366708092572469247
98
+ hash: 994351938248353578
98
99
  segments:
99
100
  - 0
100
101
  version: "0"
@@ -119,6 +120,7 @@ test_files:
119
120
  - spec/integration/images_spec.rb
120
121
  - spec/integration/item_lookup_spec.rb
121
122
  - spec/integration/japan_spec.rb
123
+ - spec/integration/related_items_spec.rb
122
124
  - spec/integration/seller_listing_search_spec.rb
123
125
  - spec/integration/twenty_items_in_one_request_spec.rb
124
126
  - spec/spec_helper.rb