handcrafted-ebay_products 0.0.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.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/lib/ebay_products.rb +26 -0
- data/lib/ebay_products/data.rb +24 -0
- data/spec/ebay_products_spec.rb +33 -0
- data/spec/samples/harry_potter.xml +1 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +11 -0
- metadata +66 -0
data/.document
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2009 Josh Owens
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'rake'
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'jeweler'
|
|
6
|
+
Jeweler::Tasks.new do |gem|
|
|
7
|
+
gem.name = "ebay_products"
|
|
8
|
+
gem.summary = %Q{TODO}
|
|
9
|
+
gem.email = "joshua.owens@gmail.com"
|
|
10
|
+
gem.homepage = "http://github.com/handcrafted/ebay_products"
|
|
11
|
+
gem.authors = ["Josh Owens"]
|
|
12
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
rescue LoadError
|
|
16
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
require 'spec/rake/spectask'
|
|
20
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
|
21
|
+
spec.libs << 'lib' << 'spec'
|
|
22
|
+
spec.spec_opts = ['--options', "spec/spec.opts"]
|
|
23
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
|
28
|
+
spec.spec_opts = ['--options', "spec/spec.opts"]
|
|
29
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
|
30
|
+
spec.rcov = true
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
task :default => :spec
|
|
35
|
+
|
|
36
|
+
require 'rake/rdoctask'
|
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
|
38
|
+
if File.exist?('VERSION.yml')
|
|
39
|
+
config = YAML.load(File.read('VERSION.yml'))
|
|
40
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
|
41
|
+
else
|
|
42
|
+
version = ""
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
46
|
+
rdoc.title = "ebay_products #{version}"
|
|
47
|
+
rdoc.rdoc_files.include('README*')
|
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
49
|
+
end
|
|
50
|
+
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.0.1
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
gem 'httparty'
|
|
3
|
+
require 'httparty'
|
|
4
|
+
require File.dirname(__FILE__) + '/ebay_products/data'
|
|
5
|
+
|
|
6
|
+
class EbayProducts
|
|
7
|
+
|
|
8
|
+
include HTTParty
|
|
9
|
+
base_uri "open.api.ebay.com"
|
|
10
|
+
default_params :responseencoding => 'XML', :callname => "FindProducts", :version => "619", :siteid => 0, :maxentries => 18
|
|
11
|
+
|
|
12
|
+
attr_reader :query, :appid
|
|
13
|
+
|
|
14
|
+
def initialize(query, appid)
|
|
15
|
+
@query, @appid = query, appid
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def search
|
|
19
|
+
@search ||= self.class.get("/shopping", :query => {:QueryKeywords => @query, :appid => @appid})["FindProductsResponse"]["Product"]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def products
|
|
23
|
+
@products ||= search.collect {|product| ProductInformation.new(product) }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class EbayProducts
|
|
2
|
+
class Data
|
|
3
|
+
attr_reader :data
|
|
4
|
+
|
|
5
|
+
def initialize(data)
|
|
6
|
+
@data = data
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def method_missing(method, *args)
|
|
10
|
+
if @data.keys.include?(method.to_s)
|
|
11
|
+
@data[method.to_s]
|
|
12
|
+
else
|
|
13
|
+
super(*args)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# def inspect
|
|
18
|
+
# data = @data.inject([]) { |collection, key| collection << "#{key[0]}: #{key[1]['data']}"; collection }.join("\n ")
|
|
19
|
+
# "#<#{self.class}:0x#{object_id}\n #{data}>"
|
|
20
|
+
# end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class ProductInformation < Data; end
|
|
24
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "EbayProducts" do
|
|
4
|
+
|
|
5
|
+
context "Initializing" do
|
|
6
|
+
|
|
7
|
+
it "should raise an error without a query and appid" do
|
|
8
|
+
lambda {EbayProducts.new}.should raise_error
|
|
9
|
+
lambda {EbayProducts.new("query")}.should raise_error
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "save the query and appid" do
|
|
13
|
+
ebay = EbayProducts.new("query", "1234")
|
|
14
|
+
ebay.query.should == "query"
|
|
15
|
+
ebay.appid.should == "1234"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context "Finding" do
|
|
21
|
+
|
|
22
|
+
before(:each) do
|
|
23
|
+
FakeWeb.register_uri(:get, "http://open.api.ebay.com:80/shopping?QueryKeywords=harry%20potter&callname=FindProducts&siteid=0&maxentries=18&appid=123abc&version=619&responseencoding=XML", :string => File.read("#{File.dirname(__FILE__)}/samples/harry_potter.xml"))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should find the products" do
|
|
27
|
+
e = EbayProducts.new("harry potter", "123abc")
|
|
28
|
+
puts e.products
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?> <FindProductsResponse xmlns="urn:ebay:apis:eBLBaseComponents"> <Timestamp>2008-03-07T23:09:03.495Z</Timestamp> <Ack>Success</Ack> <Build>e555_core_Bundled_6206837_R1</Build> <Version>555</Version> <ApproximatePages>207</ApproximatePages> <MoreResults>true</MoreResults> <PageNumber>1</PageNumber> <Product> <DomainName>DVDs</DomainName> <DetailsURL>http://syicatalogs.ebay.com/ws/eBayISAPI.dll?PageSyiProductDetails&IncludeAttributes=1&ShowAttributesTable=1&ProductMementoString=92460:2:1049:1489297318:138039228:f19efe1397d028d65cd2b81e1112fcfa:1:1:1:1382045716</DetailsURL> <DisplayStockPhotos>true</DisplayStockPhotos> <ProductID type="Reference">62923188</ProductID> <ProductID type="UPC">012569593268</ProductID> <ItemSpecifics> <NameValueList> <Name>Rating</Name> <Value>PG-13</Value> </NameValueList> <NameValueList> <Name>Leading Role</Name> <Value>Daniel Radcliffe</Value> <Value>Emma Watson</Value> <Value>Rupert Grint</Value> </NameValueList> <NameValueList> <Name>Format</Name> <Value>DVD</Value> </NameValueList> </ItemSpecifics> <ReviewCount>56</ReviewCount> <StockPhotoURL>http://i11.ebayimg.com/08/c/000/77/43/ade9_6.JPG</StockPhotoURL> <Title>Harry Potter and the Order of the Phoenix (2007, DVD)</Title> </Product> <Product> <DomainName>Children's Books</DomainName> <DetailsURL>http://syicatalogs.ebay.com/ws/eBayISAPI.dll?PageSyiProductDetails&IncludeAttributes=1&ShowAttributesTable=1&ProductMementoString=88519:2:1055:1565202560:138165260:59e578afaa39f41a8361fe9b641f3352:1:1:1:1378670148</DetailsURL> <DisplayStockPhotos>true</DisplayStockPhotos> <ProductID type="Reference">59049480</ProductID> <ProductID type="ISBN">0545010225</ProductID> <ProductID type="ISBN">9780545010221</ProductID> <ItemSpecifics> <NameValueList> <Name>Binding</Name> <Value>Hardcover</Value> </NameValueList> <NameValueList> <Name>Author</Name> <Value>J. K. Rowling</Value> </NameValueList> </ItemSpecifics> <ReviewCount>181</ReviewCount> <StockPhotoURL>http://i20.ebayimg.com/05/c/000/77/3c/71fc_6.JPG</StockPhotoURL> <Title>Harry Potter and the Deathly Hallows by J. K. Rowling (2007)</Title> </Product> <TotalProducts>414</TotalProducts> </FindProductsResponse>
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'spec'
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
5
|
+
require 'ebay_products'
|
|
6
|
+
require 'fakeweb'
|
|
7
|
+
FakeWeb.allow_net_connect = false
|
|
8
|
+
|
|
9
|
+
Spec::Runner.configure do |config|
|
|
10
|
+
|
|
11
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: handcrafted-ebay_products
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Josh Owens
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-06-20 00:00:00 -07:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description:
|
|
17
|
+
email: joshua.owens@gmail.com
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files:
|
|
23
|
+
- LICENSE
|
|
24
|
+
- README.rdoc
|
|
25
|
+
files:
|
|
26
|
+
- .document
|
|
27
|
+
- .gitignore
|
|
28
|
+
- LICENSE
|
|
29
|
+
- README.rdoc
|
|
30
|
+
- Rakefile
|
|
31
|
+
- VERSION
|
|
32
|
+
- lib/ebay_products.rb
|
|
33
|
+
- lib/ebay_products/data.rb
|
|
34
|
+
- spec/ebay_products_spec.rb
|
|
35
|
+
- spec/samples/harry_potter.xml
|
|
36
|
+
- spec/spec.opts
|
|
37
|
+
- spec/spec_helper.rb
|
|
38
|
+
has_rdoc: true
|
|
39
|
+
homepage: http://github.com/handcrafted/ebay_products
|
|
40
|
+
post_install_message:
|
|
41
|
+
rdoc_options:
|
|
42
|
+
- --charset=UTF-8
|
|
43
|
+
require_paths:
|
|
44
|
+
- lib
|
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: "0"
|
|
50
|
+
version:
|
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: "0"
|
|
56
|
+
version:
|
|
57
|
+
requirements: []
|
|
58
|
+
|
|
59
|
+
rubyforge_project:
|
|
60
|
+
rubygems_version: 1.2.0
|
|
61
|
+
signing_key:
|
|
62
|
+
specification_version: 3
|
|
63
|
+
summary: TODO
|
|
64
|
+
test_files:
|
|
65
|
+
- spec/ebay_products_spec.rb
|
|
66
|
+
- spec/spec_helper.rb
|