sucker 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -63,3 +63,5 @@ Notes
63
63
  * 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`.
64
64
 
65
65
  * Version 0.6.0 now has Active Support's Nokogiri-based `to_hash` under the hood. After some meddling, it does what it's supposed to do and is blazing fast. Fix up your code accordingly.
66
+
67
+ * To test specs against all rubies on your system , run `./rake_rubies.sh spec:progress`.
data/lib/sucker.rb CHANGED
@@ -8,6 +8,8 @@ require "sucker/response"
8
8
  # = Sucker
9
9
  # Sucker is a paper-thin Ruby wrapper to the Amazon Product Advertising API.
10
10
  module Sucker
11
+ $KCODE = "u" if RUBY_VERSION.include?("1.8")
12
+
11
13
  AMAZON_API_VERSION = "2009-11-01"
12
14
 
13
15
  def self.new(args={})
@@ -15,7 +15,7 @@ module Sucker
15
15
  content_to_string(doc.to_hash)
16
16
  end
17
17
 
18
- alias_method :to_hash, :to_h
18
+ alias :to_hash :to_h
19
19
 
20
20
  private
21
21
 
@@ -1,5 +1,4 @@
1
1
  # encoding: utf-8
2
-
3
2
  require "spec_helper"
4
3
 
5
4
  module Sucker
@@ -24,7 +23,7 @@ module Sucker
24
23
 
25
24
  context "single item" do
26
25
  before do
27
- @worker << { "ItemId" => "0816614024" }
26
+ @worker << { "ItemId" => "2070119874" }
28
27
  @item = @worker.get.to_h["ItemLookupResponse"]["Items"]["Item"]
29
28
  end
30
29
 
@@ -32,10 +31,6 @@ module Sucker
32
31
  @item.should be_an_instance_of Hash
33
32
  end
34
33
 
35
- it "includes an ASIN string" do
36
- @item["ASIN"].should eql "0816614024"
37
- end
38
-
39
34
  it "includes requested response groups" do
40
35
  @item["ItemAttributes"].should be_an_instance_of Hash
41
36
  @item["Offers"].should be_an_instance_of Hash
@@ -18,7 +18,7 @@ module Sucker
18
18
 
19
19
  context "single item" do
20
20
  before do
21
- @worker << { "ItemId" => "0816614024" }
21
+ @worker << { "ItemId" => "482224816X" }
22
22
  @item = @worker.get.to_h["ItemLookupResponse"]["Items"]["Item"]
23
23
  end
24
24
 
@@ -47,7 +47,7 @@ module Sucker
47
47
  end
48
48
 
49
49
  it "returns a Response object" do
50
- @worker.get.class.ancestors.should include Response
50
+ @worker.get.class.ancestors.should include Sucker::Response
51
51
  end
52
52
  end
53
53
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require "spec_helper"
2
3
 
3
4
  module Sucker
@@ -8,7 +9,7 @@ module Sucker
8
9
  curl.stub!(:body_str).and_return('<?xml version="1.0" ?><books><book><creator role="author">Gilles Deleuze</author><title>A Thousand Plateaus</title></book><book><creator role="author">Gilles Deleuze</author><title>Anti-Oedipus</title></book></books>')
9
10
  curl.stub!(:response_code).and_return(200)
10
11
  curl.stub!(:total_time).and_return(1.0)
11
- @response = Response.new(curl)
12
+ @response = Sucker::Response.new(curl)
12
13
  end
13
14
 
14
15
  context ".new" do
@@ -33,6 +34,25 @@ module Sucker
33
34
  it "converts a content hash to string" do
34
35
  @response.to_h["books"]["book"].first["title"].should be_an_instance_of String
35
36
  end
37
+
38
+ it "is aliased as to_hash" do
39
+ @response.to_hash.should eql @response.to_h
40
+ end
41
+
42
+ it "renders French" do
43
+ @response.body = "<Title>L'archéologie du savoir</Title>"
44
+ @response.to_h["Title"].should eql "L'archéologie du savoir"
45
+ end
46
+
47
+ it "renders German" do
48
+ @response.body = "<Title>Kafka: Für eine kleine Literatur</Title>"
49
+ @response.to_h["Title"].should eql "Kafka: Für eine kleine Literatur"
50
+ end
51
+
52
+ it "renders Japanese" do
53
+ @response.body = "<Title>スティーブ・ジョブズ 驚異のプレゼン―人々を惹きつける18の法則</Title>"
54
+ @response.to_h["Title"].should eql "スティーブ・ジョブズ 驚異のプレゼン―人々を惹きつける18の法則"
55
+ end
36
56
  end
37
57
  end
38
58
  end
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: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 4
10
- version: 0.6.4
9
+ - 5
10
+ version: 0.6.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Hakan Ensari
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-08-03 00:00:00 +01:00
19
+ date: 2010-08-04 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency