handcrafted-ebay_products 0.1.1 → 0.1.2
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/Rakefile +2 -0
- data/VERSION +1 -1
- data/ebay_products.gemspec +9 -2
- data/lib/ebay_products.rb +9 -2
- data/spec/ebay_products_spec.rb +11 -0
- data/spec/samples/failure.xml +16 -0
- metadata +24 -4
data/Rakefile
CHANGED
|
@@ -10,6 +10,8 @@ begin
|
|
|
10
10
|
gem.homepage = "http://github.com/handcrafted/ebay_products"
|
|
11
11
|
gem.authors = ["Josh Owens"]
|
|
12
12
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
|
13
|
+
gem.add_dependency('httparty', '>= 0.4.3')
|
|
14
|
+
gem.add_dependency('activesupport', '>= 2.2.2')
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
rescue LoadError
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.2
|
data/ebay_products.gemspec
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = %q{ebay_products}
|
|
5
|
-
s.version = "0.1.
|
|
5
|
+
s.version = "0.1.2"
|
|
6
6
|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
8
|
s.authors = ["Josh Owens"]
|
|
9
|
-
s.date = %q{2009-
|
|
9
|
+
s.date = %q{2009-07-01}
|
|
10
10
|
s.email = %q{joshua.owens@gmail.com}
|
|
11
11
|
s.extra_rdoc_files = [
|
|
12
12
|
"LICENSE",
|
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
|
23
23
|
"lib/ebay_products.rb",
|
|
24
24
|
"lib/ebay_products/data.rb",
|
|
25
25
|
"spec/ebay_products_spec.rb",
|
|
26
|
+
"spec/samples/failure.xml",
|
|
26
27
|
"spec/samples/harry_potter.xml",
|
|
27
28
|
"spec/spec.opts",
|
|
28
29
|
"spec/spec_helper.rb"
|
|
@@ -42,8 +43,14 @@ Gem::Specification.new do |s|
|
|
|
42
43
|
s.specification_version = 3
|
|
43
44
|
|
|
44
45
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
46
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.4.3"])
|
|
47
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.2.2"])
|
|
45
48
|
else
|
|
49
|
+
s.add_dependency(%q<httparty>, [">= 0.4.3"])
|
|
50
|
+
s.add_dependency(%q<activesupport>, [">= 2.2.2"])
|
|
46
51
|
end
|
|
47
52
|
else
|
|
53
|
+
s.add_dependency(%q<httparty>, [">= 0.4.3"])
|
|
54
|
+
s.add_dependency(%q<activesupport>, [">= 2.2.2"])
|
|
48
55
|
end
|
|
49
56
|
end
|
data/lib/ebay_products.rb
CHANGED
|
@@ -20,7 +20,12 @@ class EbayProducts
|
|
|
20
20
|
|
|
21
21
|
def search
|
|
22
22
|
if @search.blank?
|
|
23
|
-
|
|
23
|
+
response = self.class.get("/shopping", :query => options, :format => :xml)["FindProductsResponse"]
|
|
24
|
+
errors = response['Errors']
|
|
25
|
+
if errors
|
|
26
|
+
raise SearchFailure, errors['LongMessage']
|
|
27
|
+
end
|
|
28
|
+
@search = response["Product"]
|
|
24
29
|
if @search.is_a? Hash
|
|
25
30
|
@search = [@search]
|
|
26
31
|
end
|
|
@@ -46,4 +51,6 @@ class EbayProducts
|
|
|
46
51
|
end
|
|
47
52
|
hash
|
|
48
53
|
end
|
|
49
|
-
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
class SearchFailure < RuntimeError; end
|
data/spec/ebay_products_spec.rb
CHANGED
|
@@ -37,6 +37,17 @@ describe "EbayProducts" do
|
|
|
37
37
|
@ebay.products.size.should == 2
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
context "Search failure" do
|
|
41
|
+
before(:each) do
|
|
42
|
+
FakeWeb.register_uri(:get, "http://open.api.ebay.com:80/shopping?QueryKeywords=xbox&callname=FindProducts&siteid=0&maxentries=18&appid=123abc&version=619&responseencoding=XML", :body => File.read("#{File.dirname(__FILE__)}/samples/failure.xml"))
|
|
43
|
+
@ebay = EbayProducts.new({:keywords => "xbox"}, "123abc")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should throw search failure" do
|
|
47
|
+
lambda { @ebay.search }.should raise_error(SearchFailure)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
40
51
|
end
|
|
41
52
|
|
|
42
53
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
|
|
3
|
+
<FindProductsResponse xmlns="urn:ebay:apis:eBLBaseComponents">
|
|
4
|
+
<Timestamp>2009-07-01T09:18:26.109Z</Timestamp>
|
|
5
|
+
<Ack>Failure</Ack>
|
|
6
|
+
<Errors>
|
|
7
|
+
<ShortMessage>Your query would return too many items.</ShortMessage>
|
|
8
|
+
<LongMessage>Your query would return too many items. Please define a more specific query.</LongMessage>
|
|
9
|
+
<ErrorCode>10.4</ErrorCode>
|
|
10
|
+
<SeverityCode>Error</SeverityCode>
|
|
11
|
+
<ErrorClassification>RequestError</ErrorClassification>
|
|
12
|
+
</Errors>
|
|
13
|
+
<Build>e623__Bundled_9520957_R1</Build>
|
|
14
|
+
<Version>623</Version>
|
|
15
|
+
</FindProductsResponse>
|
|
16
|
+
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: handcrafted-ebay_products
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Josh Owens
|
|
@@ -9,10 +9,29 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-07-01 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
|
-
dependencies:
|
|
15
|
-
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: httparty
|
|
17
|
+
type: :runtime
|
|
18
|
+
version_requirement:
|
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
20
|
+
requirements:
|
|
21
|
+
- - ">="
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: 0.4.3
|
|
24
|
+
version:
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: activesupport
|
|
27
|
+
type: :runtime
|
|
28
|
+
version_requirement:
|
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 2.2.2
|
|
34
|
+
version:
|
|
16
35
|
description:
|
|
17
36
|
email: joshua.owens@gmail.com
|
|
18
37
|
executables: []
|
|
@@ -33,6 +52,7 @@ files:
|
|
|
33
52
|
- lib/ebay_products.rb
|
|
34
53
|
- lib/ebay_products/data.rb
|
|
35
54
|
- spec/ebay_products_spec.rb
|
|
55
|
+
- spec/samples/failure.xml
|
|
36
56
|
- spec/samples/harry_potter.xml
|
|
37
57
|
- spec/spec.opts
|
|
38
58
|
- spec/spec_helper.rb
|