tcocca-etsy4r 0.1.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/LICENSE +20 -0
- data/README +51 -0
- data/Rakefile +60 -0
- data/VERSION.yml +4 -0
- data/examples/etsy.rb +192 -0
- data/lib/etsy4r/client.rb +17 -0
- data/lib/etsy4r/commands.rb +11 -0
- data/lib/etsy4r/favorite_commands.rb +21 -0
- data/lib/etsy4r/gift_guide_commands.rb +13 -0
- data/lib/etsy4r/image_parser.rb +39 -0
- data/lib/etsy4r/response.rb +37 -0
- data/lib/etsy4r/server_commands.rb +17 -0
- data/lib/etsy4r/tag_commands.rb +14 -0
- data/lib/etsy4r/user_commands.rb +14 -0
- data/lib/etsy4r.rb +14 -0
- data/spec/etsy4r/client_spec.rb +22 -0
- data/spec/etsy4r/commands_spec.rb +18 -0
- data/spec/etsy4r/favorite_commands_spec.rb +81 -0
- data/spec/etsy4r/gift_guide_commands_spec.rb +56 -0
- data/spec/etsy4r/image_parser_spec.rb +33 -0
- data/spec/etsy4r/server_commands_spec.rb +45 -0
- data/spec/etsy4r/tag_commands_spec.rb +49 -0
- data/spec/etsy4r/user_commands_spec.rb +72 -0
- data/spec/fixtures/images.html +0 -0
- data/spec/rcov.opts +1 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +60 -0
- data/tasks/rspec.rake +33 -0
- metadata +100 -0
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2008 Tom Cocca
|
|
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
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
etsy4r
|
|
2
|
+
======
|
|
3
|
+
|
|
4
|
+
etsy4r is a Ruby wrapper for the Etsy API. It utilizes the amazing HTTParty gem by John Nunemaker.
|
|
5
|
+
If you need to build an API wrapper that gem is an enourmous help, refer to the following:
|
|
6
|
+
|
|
7
|
+
http://railstips.org/2008/7/29/it-s-an-httparty-and-everyone-is-invited
|
|
8
|
+
|
|
9
|
+
etsy4r wraps all of the etsy api calls into 1 nice library. Etsy's API is currenly in beta so this library will probably
|
|
10
|
+
be changing frequently. Most likely their will only be additions.
|
|
11
|
+
|
|
12
|
+
One thing that does not exist in the Etsy API is the ability to grab all the images for a listing so I have written a parser based on
|
|
13
|
+
Hpricot. This may dissapear when etsy releases a call to get all images to their API.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
Etsy API
|
|
17
|
+
=========
|
|
18
|
+
|
|
19
|
+
The Etsy api is currently in beta. See this blog post for details:
|
|
20
|
+
http://www.etsy.com/storque/etsy-news/tech-updates-handmade-code-etsys-beta-api-3055/
|
|
21
|
+
|
|
22
|
+
You will need to email their development staff to get access to the API setion of the website before you can
|
|
23
|
+
register for an API key which you will need to do.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
USAGE
|
|
27
|
+
==========
|
|
28
|
+
|
|
29
|
+
See http://github.com/tcocca/etsy4r/tree/master/examples
|
|
30
|
+
|
|
31
|
+
I have added example calls to all of the methods and object.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
INSTALATION
|
|
35
|
+
==========
|
|
36
|
+
|
|
37
|
+
sudo gem install tcocca-etsy4r -s http://gems.github.com
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
QUESTION/CONCERNS/COMMENTS
|
|
41
|
+
==========
|
|
42
|
+
|
|
43
|
+
Send me an email through github or at tom dot cocca at gmail dot com
|
|
44
|
+
Feel free to fork and submit changes
|
|
45
|
+
There is a test suite built on rspec.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
COPYRIGHT
|
|
49
|
+
=========
|
|
50
|
+
|
|
51
|
+
Copyright (c) 2008 Tom Cocca. See LICENSE for details.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'rake/rdoctask'
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'jeweler'
|
|
6
|
+
Jeweler::Tasks.new do |s|
|
|
7
|
+
s.name = "etsy4r"
|
|
8
|
+
s.summary = %Q{Handcrafted API Wrapper}
|
|
9
|
+
s.email = "tom.cocca@gmail.com"
|
|
10
|
+
s.homepage = "http://github.com/tcocca/etsy4r"
|
|
11
|
+
s.description = "Handcrafted API Wrapper for Etsy utilizing httparty"
|
|
12
|
+
s.files = [
|
|
13
|
+
"README",
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"Rakefile",
|
|
16
|
+
"VERSION.yml",
|
|
17
|
+
"lib/etsy4r.rb",
|
|
18
|
+
"lib/etsy4r/client.rb",
|
|
19
|
+
"lib/etsy4r/commands.rb",
|
|
20
|
+
"lib/etsy4r/favorite_commands.rb",
|
|
21
|
+
"lib/etsy4r/gift_guide_commands.rb",
|
|
22
|
+
"lib/etsy4r/image_parser.rb",
|
|
23
|
+
"lib/etsy4r/response.rb",
|
|
24
|
+
"lib/etsy4r/server_commands.rb",
|
|
25
|
+
"lib/etsy4r/tag_commands.rb",
|
|
26
|
+
"lib/etsy4r/user_commands.rb",
|
|
27
|
+
"spec/rcov.opts",
|
|
28
|
+
"spec/spec.opts",
|
|
29
|
+
"spec/spec_helper.rb",
|
|
30
|
+
"spec/fixtures/images.html",
|
|
31
|
+
"spec/etsy4r/client_spec.rb",
|
|
32
|
+
"spec/etsy4r/commands_spec.rb",
|
|
33
|
+
"spec/etsy4r/favorite_commands_spec.rb",
|
|
34
|
+
"spec/etsy4r/gift_guide_commands_spec.rb",
|
|
35
|
+
"spec/etsy4r/image_parser_spec.rb",
|
|
36
|
+
"spec/etsy4r/server_commands_spec.rb",
|
|
37
|
+
"spec/etsy4r/tag_commands_spec.rb",
|
|
38
|
+
"spec/etsy4r/user_commands_spec.rb",
|
|
39
|
+
"tasks/rspec.rake",
|
|
40
|
+
"examples/etsy.rb"
|
|
41
|
+
]
|
|
42
|
+
s.authors = ["Tom Cocca"]
|
|
43
|
+
s.add_dependency 'httparty'
|
|
44
|
+
s.add_dependency 'hpricot'
|
|
45
|
+
end
|
|
46
|
+
rescue LoadError
|
|
47
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
Rake::RDocTask.new do |rdoc|
|
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
52
|
+
rdoc.title = 'etsy4r'
|
|
53
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
|
54
|
+
rdoc.rdoc_files.include('README*')
|
|
55
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
|
59
|
+
|
|
60
|
+
task :default => :spec
|
data/VERSION.yml
ADDED
data/examples/etsy.rb
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../lib/etsy4r'
|
|
2
|
+
require 'yaml'
|
|
3
|
+
|
|
4
|
+
# Read the Etsy API Documentation
|
|
5
|
+
# http://developer.etsy.com/docs
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Initialize a new Etsy API Client
|
|
9
|
+
client = Etsy4r::Client.new('your_api_key')
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# Initialize a ServerCommands object
|
|
13
|
+
server = Etsy4r::ServerCommands.new(client)
|
|
14
|
+
|
|
15
|
+
# Ping the server
|
|
16
|
+
res = server.ping
|
|
17
|
+
|
|
18
|
+
# Return a list of all available method calls
|
|
19
|
+
res = server.get_method_table
|
|
20
|
+
|
|
21
|
+
# Get the current time on the Etsy server in epoch
|
|
22
|
+
res = server.get_server_epoch
|
|
23
|
+
|
|
24
|
+
# Go from epoch time to ruby Time object
|
|
25
|
+
puts Time.at(res.results.first)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Every call return a response object
|
|
29
|
+
# Below are the following methods on that object
|
|
30
|
+
# These methods are available on every single call except on the image parser object
|
|
31
|
+
if res.success?
|
|
32
|
+
puts res.body .to_yaml # Return the full body response of the call
|
|
33
|
+
puts res.results.to_yaml # Return the results (the actual deta) in an array of hashes
|
|
34
|
+
puts res.count # Count of all pieces of data that the Query returned (note: this is a total count not the count returned)
|
|
35
|
+
puts res.limit # The max number of records returned in the API call
|
|
36
|
+
puts res.type # The type of result passed back
|
|
37
|
+
puts res.params # The params passed in to the query
|
|
38
|
+
else
|
|
39
|
+
puts res.error_message # If the call was not successful an error message is returned
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# Initialize a GiftGuideCommands object
|
|
44
|
+
gift_guide = Etsy4r::GiftGuideCommands.new(client)
|
|
45
|
+
|
|
46
|
+
# Get a list of available GiftGuides
|
|
47
|
+
res = gift_guide.get_gift_guides
|
|
48
|
+
|
|
49
|
+
# Get the listings for a gift guide
|
|
50
|
+
# The first params is the id of the gift guide
|
|
51
|
+
# This method takes the following optional params
|
|
52
|
+
# :offset default = 0 type = int
|
|
53
|
+
# :limit default = 10 type = int, max = 50
|
|
54
|
+
# :detail_level default = 'low' options = enum(low, medium, high)
|
|
55
|
+
res = gift_guide.get_gift_guide_listings(61, {:detail_level => "high"})
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# Initialize a UserCommands object
|
|
59
|
+
user = Etsy4r::UserCommands.new(client)
|
|
60
|
+
|
|
61
|
+
# Return the details for a user
|
|
62
|
+
# You can pass a user id:
|
|
63
|
+
res = user.get_user_details(5565464)
|
|
64
|
+
# Or a user_name
|
|
65
|
+
res = user.get_user_details('maymaydesigns')
|
|
66
|
+
# Also, this methods take the :detail_level optional param
|
|
67
|
+
res = user.get_user_details('maymaydesigns', {:detail_level => 'high'})
|
|
68
|
+
|
|
69
|
+
# Search for users by name
|
|
70
|
+
# The search name is required
|
|
71
|
+
# The method takes the :detail_level, :limit and :offset optional params
|
|
72
|
+
res = user.get_users_by_name('amanda', {:detail_level => 'medium', :limit => 50})
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# Initialize a ShopCommands object
|
|
76
|
+
shop = Etsy4r::ShopCommands.new(client)
|
|
77
|
+
|
|
78
|
+
# Get shop details, this method takes either a user_id or user_name
|
|
79
|
+
# Also takes the :detail_level optional params
|
|
80
|
+
res = shop.get_shop_details(5565464)
|
|
81
|
+
res = shop.get_shop_details('maymaydesigns')
|
|
82
|
+
|
|
83
|
+
# Returns a list of featured selers, not params
|
|
84
|
+
res = shop.get_featured_sellers
|
|
85
|
+
|
|
86
|
+
# Returns all listings for a "shop" (or user)
|
|
87
|
+
# Takes either a user_id or a user_name
|
|
88
|
+
# Also takes :detail_level, :limit and :offset optional params
|
|
89
|
+
res = shop.get_listings(5565464)
|
|
90
|
+
res = shop.get_listings('maymaydesigns')
|
|
91
|
+
|
|
92
|
+
# Search for shops be a name
|
|
93
|
+
# The name params is required
|
|
94
|
+
# Take the following optional params
|
|
95
|
+
# :detail_level, :limit, :offset
|
|
96
|
+
# :sort_order default => 'down' enum (down, up)
|
|
97
|
+
res = shop.get_shops_by_name('amanda')
|
|
98
|
+
|
|
99
|
+
# Get a shops feauted listings
|
|
100
|
+
# Takes either a user_id or user_name
|
|
101
|
+
# Also taks the :detail_level optional_param
|
|
102
|
+
res = shop.get_featured_details(5565464)
|
|
103
|
+
res = shop.get_featured_details('maymaydesigns', :detail_level => 'high')
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# Initialize a TagCommands object
|
|
107
|
+
tag = Etsy4r::TagCommands.new(client)
|
|
108
|
+
|
|
109
|
+
# Returns the top level tags, no params
|
|
110
|
+
res = tag.get_top_tags
|
|
111
|
+
|
|
112
|
+
# Returns the child tags of a tag
|
|
113
|
+
# Spaces and dashes get converted to underscores
|
|
114
|
+
res = tag.get_child_tags('bags-and-purses')
|
|
115
|
+
res = tag.get_child_tags('bags and purses')
|
|
116
|
+
res = tag.get_child_tags('bags_and_purses')
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
# Initialiaze a ListingCommands object
|
|
120
|
+
listing = Etsy4r::ListingCommands.new(client)
|
|
121
|
+
|
|
122
|
+
# Returns details for a specific listing
|
|
123
|
+
# Takes the listing_id as a params and the optional :detail_level param
|
|
124
|
+
res = listing.get_listing_details(19781773, :detail_level => 'high')
|
|
125
|
+
|
|
126
|
+
# Returns listings that match the tags
|
|
127
|
+
# Pass tags in as an array
|
|
128
|
+
# Takes the following optional params
|
|
129
|
+
# :sort_on default => 'created' enum(created, price)
|
|
130
|
+
# :sort_order detfault => 'down' enum(up, down)
|
|
131
|
+
# :detail_level, :limit, :offset
|
|
132
|
+
res = listing.get_listings_by_tags(['bags_and_purses', 'art', 'shoulder bag'])
|
|
133
|
+
res = listing.get_listings_by_tags(['bags_and_purses', 'art', 'shoulder bag'], :sort_on => 'price', :sort_order => 'down')
|
|
134
|
+
|
|
135
|
+
# Return listings that match keywords
|
|
136
|
+
# Takes an array of keywords
|
|
137
|
+
# Takes the following optional params
|
|
138
|
+
# :min_price default => NULL type = float
|
|
139
|
+
# :max_price default => NULL type = float
|
|
140
|
+
# :search_description default => false enum(true, false)
|
|
141
|
+
# :sort_order, :sort_on, :detail_level, :limit, :offset
|
|
142
|
+
res = listing.get_listings_by_keywords(['bags and purses', 'art', 'shoulder bag'])
|
|
143
|
+
res = listing.get_listings_by_keywords(['bags and purses', 'art', 'shoulder bag'], :min_price => 0, :max_price => 22.99)
|
|
144
|
+
|
|
145
|
+
# Returns the list of listings featured on the etsy homepage
|
|
146
|
+
# No required params
|
|
147
|
+
# Optional params
|
|
148
|
+
# :detail_level, :limit, :offset
|
|
149
|
+
res = listing.get_front_featured_listings
|
|
150
|
+
res = listing.get_front_featured_listings(:detail_level => 'medium', :limit => '45')
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
# Initialize a FavoriteCommands object
|
|
154
|
+
favorite = Etsy4r::FavoriteCommands.new(client)
|
|
155
|
+
|
|
156
|
+
# Returns the users who favorited the user passed in
|
|
157
|
+
# Takes either a user_id or user_name
|
|
158
|
+
# Optional params
|
|
159
|
+
# :detail_level, :limit, :offset
|
|
160
|
+
res = favorite.get_favorers_of_user(5565464)
|
|
161
|
+
res = favorite.get_favorers_of_user(5565464, :detail_level => 'high', :limit => 5, :offset => 5)
|
|
162
|
+
|
|
163
|
+
# Returns the users who favorited the listing passed in
|
|
164
|
+
# Takes a listing_id
|
|
165
|
+
# Optional params
|
|
166
|
+
# :detail_level, :limit, :offset
|
|
167
|
+
res = favorite.get_favorers_of_listing(19749826)
|
|
168
|
+
res = favorite.get_favorers_of_listing(19749826, :detail_level => 'high', :limit => 5, :offset => 5)
|
|
169
|
+
|
|
170
|
+
# Returns the users who the user passed in favorited
|
|
171
|
+
# Takes either a user_id or user_name
|
|
172
|
+
# Optional params
|
|
173
|
+
# :detail_level, :limit, :offset
|
|
174
|
+
res = favorite.get_favorite_shops_of_user(5565464)
|
|
175
|
+
res = favorite.get_favorite_shops_of_user(5565464, :detail_level => 'high', :limit => 5, :offset => 5)
|
|
176
|
+
|
|
177
|
+
# Returns the listings who the user passed in favorited
|
|
178
|
+
# Takes either a user_id or user_name
|
|
179
|
+
# Optional params
|
|
180
|
+
# :detail_level, :limit, :offset
|
|
181
|
+
res = favorite.get_favorite_listings_of_user(5565464)
|
|
182
|
+
res = favorite.get_favorite_listings_of_user(5565464, :detail_level => 'high', :limit => 5, :offset => 5)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
# Initialize an ImageParser object
|
|
186
|
+
# This takes a single parameter which is the id of an Etsy listing
|
|
187
|
+
image_parser = Etsy4r::ImageParser.new(19781773)
|
|
188
|
+
|
|
189
|
+
# Calling images on the object return a hash of the images
|
|
190
|
+
# The hash contains all the formatted URLs that Etsy returns
|
|
191
|
+
# (for the single image they give for a listing)
|
|
192
|
+
puts image_parser.images.to_yaml
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Etsy4r
|
|
2
|
+
class Client
|
|
3
|
+
|
|
4
|
+
include HTTParty
|
|
5
|
+
base_uri 'beta-api.etsy.com/v1'
|
|
6
|
+
format :json
|
|
7
|
+
|
|
8
|
+
def initialize(apikey)
|
|
9
|
+
self.class.default_params :api_key => apikey
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def process(uri, optional_params = {})
|
|
13
|
+
Response.new(self.class.get(uri, :query => optional_params))
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Etsy4r
|
|
2
|
+
class FavoriteCommands < Etsy4r::Commands
|
|
3
|
+
|
|
4
|
+
def get_favorers_of_user(user_id, optional_params = {})
|
|
5
|
+
@client.process("/users/#{user_id}/favorers", optional_params)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def get_favorers_of_listing(listing_id, optional_params = {})
|
|
9
|
+
@client.process("/listings/#{listing_id}/favorers", optional_params)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def get_favorite_shops_of_user(user_id, optional_params = {})
|
|
13
|
+
@client.process("/users/#{user_id}/favorites/shops", optional_params)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def get_favorite_listings_of_user(user_id, optional_params = {})
|
|
17
|
+
@client.process("/users/#{user_id}/favorites/listings", optional_params)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Etsy4r
|
|
2
|
+
class GiftGuideCommands < Etsy4r::Commands
|
|
3
|
+
|
|
4
|
+
def get_gift_guides
|
|
5
|
+
@client.process('/gift-guides')
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def get_gift_guide_listings(guide_id, optional_params = {})
|
|
9
|
+
@client.process("/gift-guides/#{guide_id}/listings", optional_params)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Etsy4r
|
|
2
|
+
class ImageParser
|
|
3
|
+
|
|
4
|
+
attr_accessor :listing_id, :parse_url, :images
|
|
5
|
+
|
|
6
|
+
def initialize(listing_id)
|
|
7
|
+
@listing_id = listing_id
|
|
8
|
+
@parse_url = "http://www.etsy.com/view_listing.php?listing_id=#{@listing_id}"
|
|
9
|
+
@images = {}
|
|
10
|
+
get_images
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def get_images
|
|
14
|
+
require 'hpricot'
|
|
15
|
+
require 'open-uri'
|
|
16
|
+
|
|
17
|
+
image_list = []
|
|
18
|
+
doc = open(parse_url) {|f| Hpricot(f)}
|
|
19
|
+
img_table = doc.search("/html/body/table/tr/td/table/tr[2]/td/table/tr[3]/td/table/tr[2]/td/table/tr/td[2]/table")
|
|
20
|
+
img_table.first.search('img').each do |img|
|
|
21
|
+
image_list << img.attributes['src']
|
|
22
|
+
end
|
|
23
|
+
image_list.each_with_index do |img_url, i|
|
|
24
|
+
img_dom = /\/\/(\S*)\//.match(img_url)[1]
|
|
25
|
+
img_id = /\.([\d]*)\./.match(img_url)[1]
|
|
26
|
+
@images["#{i}"] = {
|
|
27
|
+
"image_url_430xN" => "http://#{img_dom}/il_430xN.#{img_id}.jpg",
|
|
28
|
+
"image_url_200x200" => "http://#{img_dom}/il_200x200.#{img_id}.jpg",
|
|
29
|
+
"image_url_155x125" => "http://#{img_dom}/il_155x125.#{img_id}.jpg",
|
|
30
|
+
"image_url_75x75" => "http://#{img_dom}/il_75x75.#{img_id}.jpg",
|
|
31
|
+
"image_url_50x50" => "http://#{img_dom}/il_50x50.#{img_id}.jpg",
|
|
32
|
+
"image_url_25x25" => "http://#{img_dom}/il_25x25.#{img_id}.jpg"
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
return @images
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Etsy4r
|
|
2
|
+
class Response
|
|
3
|
+
|
|
4
|
+
attr_accessor :body
|
|
5
|
+
|
|
6
|
+
def initialize(body)
|
|
7
|
+
@body = body
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def results
|
|
11
|
+
@body['results']
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def count
|
|
15
|
+
@body['count']
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def type
|
|
19
|
+
@body['type']
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def params
|
|
23
|
+
@body['params']
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def success?
|
|
27
|
+
results
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def error_message
|
|
31
|
+
if !success?
|
|
32
|
+
@body
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Etsy4r
|
|
2
|
+
class ServerCommands < Etsy4r::Commands
|
|
3
|
+
|
|
4
|
+
def get_method_table
|
|
5
|
+
@client.process('/')
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def ping
|
|
9
|
+
@client.process('/server/ping')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def get_server_epoch
|
|
13
|
+
@client.process('/server/epoch')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Etsy4r
|
|
2
|
+
class UserCommands < Etsy4r::Commands
|
|
3
|
+
|
|
4
|
+
def get_user_details(user_id, optional_params = {})
|
|
5
|
+
@client.process("/users/#{user_id}", optional_params)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def get_users_by_name(search_name, optional_params = {})
|
|
9
|
+
search_name_param = search_name.gsub(" ", "_")
|
|
10
|
+
@client.process("/users/keywords/#{search_name_param}", optional_params)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
data/lib/etsy4r.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'httparty'
|
|
3
|
+
|
|
4
|
+
require File.dirname(__FILE__) + '/etsy4r/client'
|
|
5
|
+
require File.dirname(__FILE__) + '/etsy4r/commands'
|
|
6
|
+
require File.dirname(__FILE__) + '/etsy4r/response'
|
|
7
|
+
require File.dirname(__FILE__) + '/etsy4r/server_commands'
|
|
8
|
+
require File.dirname(__FILE__) + '/etsy4r/gift_guide_commands'
|
|
9
|
+
require File.dirname(__FILE__) + '/etsy4r/user_commands'
|
|
10
|
+
require File.dirname(__FILE__) + '/etsy4r/shop_commands'
|
|
11
|
+
require File.dirname(__FILE__) + '/etsy4r/listing_commands'
|
|
12
|
+
require File.dirname(__FILE__) + '/etsy4r/tag_commands'
|
|
13
|
+
require File.dirname(__FILE__) + '/etsy4r/favorite_commands'
|
|
14
|
+
require File.dirname(__FILE__) + '/etsy4r/image_parser'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/etsy4r'
|
|
3
|
+
require File.dirname(__FILE__) + '/../../lib/etsy4r/client'
|
|
4
|
+
|
|
5
|
+
describe Etsy4r::Client do
|
|
6
|
+
include Etsy4rSpecHelper
|
|
7
|
+
|
|
8
|
+
describe 'initialize' do
|
|
9
|
+
before do
|
|
10
|
+
@client = etsy4r_client
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'sets the base_uri' do
|
|
14
|
+
@client.class.base_uri.should == 'http://beta-api.etsy.com/v1'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'sets default params to include the api key' do
|
|
18
|
+
@client.class.default_params.should == {:api_key => 'dacmw5zgq4x82z95ben5em6v'}
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/etsy4r'
|
|
3
|
+
|
|
4
|
+
describe Etsy4r::Commands do
|
|
5
|
+
include Etsy4rSpecHelper
|
|
6
|
+
|
|
7
|
+
before do
|
|
8
|
+
@client = etsy4r_client
|
|
9
|
+
@commands = Etsy4r::Commands.new(@client)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe 'initialize' do
|
|
13
|
+
it 'set the client' do
|
|
14
|
+
@commands.client.class.should == Etsy4r::Client
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/etsy4r'
|
|
3
|
+
|
|
4
|
+
describe Etsy4r::FavoriteCommands do
|
|
5
|
+
include Etsy4rSpecHelper
|
|
6
|
+
|
|
7
|
+
before do
|
|
8
|
+
@client = etsy4r_client
|
|
9
|
+
@favorite_commands = Etsy4r::FavoriteCommands.new(@client)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe 'initialize' do
|
|
13
|
+
it 'set the client' do
|
|
14
|
+
@favorite_commands.client.class.should == Etsy4r::Client
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe 'get_favorers_of_user' do
|
|
19
|
+
it 'should return users who favor the user' do
|
|
20
|
+
@res = @favorite_commands.get_favorers_of_user(5565464)
|
|
21
|
+
@res.should be_success
|
|
22
|
+
@res.results.should_not be_nil
|
|
23
|
+
@res.error_message.should be_blank
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should accept the optional params' do
|
|
27
|
+
@res = @favorite_commands.get_favorers_of_user(5565464, :detail_level => 'high', :limit => 5, :offset => 5)
|
|
28
|
+
@res.should be_success
|
|
29
|
+
@res.results.should_not be_nil
|
|
30
|
+
@res.error_message.should be_blank
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe 'get_favorers_of_listing' do
|
|
35
|
+
it 'should return users who favor the user' do
|
|
36
|
+
@res = @favorite_commands.get_favorers_of_listing(19749826)
|
|
37
|
+
@res.should be_success
|
|
38
|
+
@res.results.should_not be_nil
|
|
39
|
+
@res.error_message.should be_blank
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'should accept the optional params' do
|
|
43
|
+
@res = @favorite_commands.get_favorers_of_listing(19749826, :detail_level => 'high', :limit => 5, :offset => 5)
|
|
44
|
+
@res.should be_success
|
|
45
|
+
@res.results.should_not be_nil
|
|
46
|
+
@res.error_message.should be_blank
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe 'get_favorite_shops_of_user' do
|
|
51
|
+
it 'should return users who favor the user' do
|
|
52
|
+
@res = @favorite_commands.get_favorite_shops_of_user(5565464)
|
|
53
|
+
@res.should be_success
|
|
54
|
+
@res.results.should_not be_nil
|
|
55
|
+
@res.error_message.should be_blank
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'should accept the optional params' do
|
|
59
|
+
@res = @favorite_commands.get_favorite_shops_of_user(5565464, :detail_level => 'high', :limit => 5, :offset => 5)
|
|
60
|
+
@res.should be_success
|
|
61
|
+
@res.results.should_not be_nil
|
|
62
|
+
@res.error_message.should be_blank
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe 'get_favorite_listings_of_user' do
|
|
67
|
+
it 'should return users who favor the user' do
|
|
68
|
+
@res = @favorite_commands.get_favorite_listings_of_user(5565464)
|
|
69
|
+
@res.should be_success
|
|
70
|
+
@res.results.should_not be_nil
|
|
71
|
+
@res.error_message.should be_blank
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'should accept the optional params' do
|
|
75
|
+
@res = @favorite_commands.get_favorite_listings_of_user(5565464, :detail_level => 'high', :limit => 5, :offset => 5)
|
|
76
|
+
@res.should be_success
|
|
77
|
+
@res.results.should_not be_nil
|
|
78
|
+
@res.error_message.should be_blank
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/etsy4r'
|
|
3
|
+
|
|
4
|
+
describe Etsy4r::GiftGuideCommands do
|
|
5
|
+
include Etsy4rSpecHelper
|
|
6
|
+
|
|
7
|
+
before do
|
|
8
|
+
@client = etsy4r_client
|
|
9
|
+
@gift_guide_commands = Etsy4r::GiftGuideCommands.new(@client)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe 'initialize' do
|
|
13
|
+
it 'set the client' do
|
|
14
|
+
@gift_guide_commands.client.class.should == Etsy4r::Client
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe 'get_gift_guides' do
|
|
19
|
+
it 'should return all gift guides' do
|
|
20
|
+
@res = @gift_guide_commands.get_gift_guides
|
|
21
|
+
@res.should be_success
|
|
22
|
+
@res.results.should_not be_nil
|
|
23
|
+
@res.error_message.should be_blank
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe 'get_gift_guide_listings' do
|
|
28
|
+
it 'should return the listing in a gift guide' do
|
|
29
|
+
@res = @gift_guide_commands.get_gift_guide_listings(100)
|
|
30
|
+
@res.should be_success
|
|
31
|
+
@res.results.should_not be_nil
|
|
32
|
+
@res.count.should_not == 0
|
|
33
|
+
@res.results.size.should == 10
|
|
34
|
+
@res.error_message.should be_blank
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'should not return listings when given a bad guide_id' do
|
|
38
|
+
@res = @gift_guide_commands.get_gift_guide_listings(1000)
|
|
39
|
+
@res.should be_success
|
|
40
|
+
@res.results.should_not be_nil
|
|
41
|
+
@res.results.should be_empty
|
|
42
|
+
@res.count.should == 0
|
|
43
|
+
@res.results.size.should == 0
|
|
44
|
+
@res.error_message.should be_blank
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'shoulde return the number of listings specified' do
|
|
48
|
+
@res = @gift_guide_commands.get_gift_guide_listings(100, {:limit => 40})
|
|
49
|
+
@res.should be_success
|
|
50
|
+
@res.results.should_not be_nil
|
|
51
|
+
@res.count.should_not == 0
|
|
52
|
+
@res.results.size.should <= 40
|
|
53
|
+
@res.error_message.should be_blank
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/etsy4r'
|
|
3
|
+
|
|
4
|
+
describe Etsy4r::ImageParser do
|
|
5
|
+
include Etsy4rSpecHelper
|
|
6
|
+
include Etsy4rImageParserSpecHelper
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
@image_parser = Etsy4r::ImageParser.new(19781773)
|
|
10
|
+
@image_parser.parse_url = File.dirname(__FILE__) + "/../fixtures/images.html"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe 'initialize' do
|
|
14
|
+
it 'should set the url for the page to parse' do
|
|
15
|
+
@image_parser.parse_url.should_not be_blank
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'should set the listing_id' do
|
|
19
|
+
@image_parser.listing_id.should == 19781773
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'should set the images hash' do
|
|
23
|
+
@image_parser.images.should_not be_nil
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe 'get_images' do
|
|
28
|
+
it 'should set images as a hash' do
|
|
29
|
+
@image_parser.images.should == test_image_hash
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/etsy4r'
|
|
3
|
+
|
|
4
|
+
describe Etsy4r::ServerCommands do
|
|
5
|
+
include Etsy4rSpecHelper
|
|
6
|
+
|
|
7
|
+
before do
|
|
8
|
+
@client = etsy4r_client
|
|
9
|
+
@server_commands = Etsy4r::ServerCommands.new(@client)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe 'initialize' do
|
|
13
|
+
it 'set the client' do
|
|
14
|
+
@server_commands.client.class.should == Etsy4r::Client
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe 'get_method_table' do
|
|
19
|
+
it 'should get all methods' do
|
|
20
|
+
@res = @server_commands.get_method_table
|
|
21
|
+
@res.should be_success
|
|
22
|
+
@res.results.should_not be_nil
|
|
23
|
+
@res.error_message.should be_blank
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe 'ping' do
|
|
28
|
+
it 'should ping the server' do
|
|
29
|
+
@res = @server_commands.ping
|
|
30
|
+
@res.should be_success
|
|
31
|
+
@res.results.should_not be_nil
|
|
32
|
+
@res.error_message.should be_blank
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe 'get_server_epoch' do
|
|
37
|
+
it 'should return the server time' do
|
|
38
|
+
@res = @server_commands.get_server_epoch
|
|
39
|
+
@res.should be_success
|
|
40
|
+
@res.results.should_not be_nil
|
|
41
|
+
@res.error_message.should be_blank
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/etsy4r'
|
|
3
|
+
|
|
4
|
+
describe Etsy4r::TagCommands do
|
|
5
|
+
include Etsy4rSpecHelper
|
|
6
|
+
|
|
7
|
+
before do
|
|
8
|
+
@client = etsy4r_client
|
|
9
|
+
@tag_commands = Etsy4r::TagCommands.new(@client)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe 'initialize' do
|
|
13
|
+
it 'set the client' do
|
|
14
|
+
@tag_commands.client.class.should == Etsy4r::Client
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe 'get_top_tags' do
|
|
19
|
+
it 'should return the top level tags' do
|
|
20
|
+
@res = @tag_commands.get_top_tags
|
|
21
|
+
@res.should be_success
|
|
22
|
+
@res.results.should_not be_nil
|
|
23
|
+
@res.error_message.should be_blank
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe 'get_child_tags' do
|
|
28
|
+
it 'should return child tags when given a formatted tag' do
|
|
29
|
+
@res = @tag_commands.get_child_tags('bags_and_purses')
|
|
30
|
+
@res.should be_success
|
|
31
|
+
@res.results.should_not be_nil
|
|
32
|
+
@res.error_message.should be_blank
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'should return child tags when given a tag with spaces' do
|
|
36
|
+
@res = @tag_commands.get_child_tags('bags and purses')
|
|
37
|
+
@res.should be_success
|
|
38
|
+
@res.results.should_not be_nil
|
|
39
|
+
@res.error_message.should be_blank
|
|
40
|
+
end
|
|
41
|
+
it 'should return child tags when given a tag with dashes' do
|
|
42
|
+
@res = @tag_commands.get_child_tags('bags-and-purses')
|
|
43
|
+
@res.should be_success
|
|
44
|
+
@res.results.should_not be_nil
|
|
45
|
+
@res.error_message.should be_blank
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/etsy4r'
|
|
3
|
+
|
|
4
|
+
describe Etsy4r::UserCommands do
|
|
5
|
+
include Etsy4rSpecHelper
|
|
6
|
+
|
|
7
|
+
before do
|
|
8
|
+
@client = etsy4r_client
|
|
9
|
+
@user_commands = Etsy4r::UserCommands.new(@client)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe 'initialize' do
|
|
13
|
+
it 'set the client' do
|
|
14
|
+
@user_commands.client.class.should == Etsy4r::Client
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe 'get_user_details' do
|
|
19
|
+
it 'should return details for a user when given a user_id' do
|
|
20
|
+
@res = @user_commands.get_user_details(5565464)
|
|
21
|
+
@res.should be_success
|
|
22
|
+
@res.results.should_not be_blank
|
|
23
|
+
@res.error_message.should be_blank
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should return details for a user when given a user_name' do
|
|
27
|
+
@res = @user_commands.get_user_details('maymaydesigns')
|
|
28
|
+
@res.should be_success
|
|
29
|
+
@res.results.should_not be_nil
|
|
30
|
+
@res.error_message.should be_blank
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'should accept detail_level as an optional param' do
|
|
34
|
+
@res = @user_commands.get_user_details('maymaydesigns', {:detail_level => 'high'})
|
|
35
|
+
@res.should be_success
|
|
36
|
+
@res.results.should_not be_nil
|
|
37
|
+
@res.error_message.should be_blank
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe 'get_users_by_name' do
|
|
42
|
+
it 'should find users by the search_name provided' do
|
|
43
|
+
@res = @user_commands.get_users_by_name('amanda')
|
|
44
|
+
@res.should be_success
|
|
45
|
+
@res.results.should_not be_nil
|
|
46
|
+
@res.error_message.should be_blank
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'should find users by the search_name provided with spaces' do
|
|
50
|
+
@res = @user_commands.get_users_by_name('amanda t')
|
|
51
|
+
@res.should be_success
|
|
52
|
+
@res.results.should_not be_nil
|
|
53
|
+
@res.error_message.should be_blank
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'should accept limit as an optional param' do
|
|
57
|
+
@res = @user_commands.get_users_by_name('amanda', {:limit => 15})
|
|
58
|
+
@res.should be_success
|
|
59
|
+
@res.results.should_not be_nil
|
|
60
|
+
@res.results.size.should <= 15
|
|
61
|
+
@res.error_message.should be_blank
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'should error on limit > 50' do
|
|
65
|
+
@res = @user_commands.get_users_by_name('amanda', {:limit => 150})
|
|
66
|
+
@res.should_not be_success
|
|
67
|
+
@res.results.should be_nil
|
|
68
|
+
@res.error_message.should_not be_blank
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
File without changes
|
data/spec/rcov.opts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--exclude "spec/*"
|
data/spec/spec.opts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'spec'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
require 'rubygems'
|
|
5
|
+
gem 'rspec'
|
|
6
|
+
require 'spec'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
|
10
|
+
require 'etsy4r'
|
|
11
|
+
|
|
12
|
+
module Etsy4rSpecHelper
|
|
13
|
+
|
|
14
|
+
def etsy4r_client
|
|
15
|
+
Etsy4r::Client.new('dacmw5zgq4x82z95ben5em6v')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
module Etsy4rImageParserSpecHelper
|
|
22
|
+
|
|
23
|
+
def test_image_hash
|
|
24
|
+
{
|
|
25
|
+
"0" => {
|
|
26
|
+
"image_url_430xN" => "http://ny-image2.etsy.com/il_430xN.53071410.jpg",
|
|
27
|
+
"image_url_200x200" => "http://ny-image2.etsy.com/il_200x200.53071410.jpg",
|
|
28
|
+
"image_url_155x125" => "http://ny-image2.etsy.com/il_155x125.53071410.jpg",
|
|
29
|
+
"image_url_75x75" => "http://ny-image2.etsy.com/il_75x75.53071410.jpg",
|
|
30
|
+
"image_url_25x25" => "http://ny-image2.etsy.com/il_25x25.53071410.jpg",
|
|
31
|
+
"image_url_50x50" => "http://ny-image2.etsy.com/il_50x50.53071410.jpg"
|
|
32
|
+
},
|
|
33
|
+
"1" => {
|
|
34
|
+
"image_url_430xN" => "http://ny-image2.etsy.com/il_430xN.53071678.jpg",
|
|
35
|
+
"image_url_200x200" => "http://ny-image2.etsy.com/il_200x200.53071678.jpg",
|
|
36
|
+
"image_url_155x125" => "http://ny-image2.etsy.com/il_155x125.53071678.jpg",
|
|
37
|
+
"image_url_75x75" => "http://ny-image2.etsy.com/il_75x75.53071678.jpg",
|
|
38
|
+
"image_url_25x25" => "http://ny-image2.etsy.com/il_25x25.53071678.jpg",
|
|
39
|
+
"image_url_50x50" => "http://ny-image2.etsy.com/il_50x50.53071678.jpg"
|
|
40
|
+
},
|
|
41
|
+
"2" => {
|
|
42
|
+
"image_url_430xN" => "http://ny-image0.etsy.com/il_430xN.53498548.jpg",
|
|
43
|
+
"image_url_200x200" => "http://ny-image0.etsy.com/il_200x200.53498548.jpg",
|
|
44
|
+
"image_url_155x125" => "http://ny-image0.etsy.com/il_155x125.53498548.jpg",
|
|
45
|
+
"image_url_75x75" => "http://ny-image0.etsy.com/il_75x75.53498548.jpg",
|
|
46
|
+
"image_url_25x25" => "http://ny-image0.etsy.com/il_25x25.53498548.jpg",
|
|
47
|
+
"image_url_50x50" => "http://ny-image0.etsy.com/il_50x50.53498548.jpg"
|
|
48
|
+
},
|
|
49
|
+
"3" => {
|
|
50
|
+
"image_url_430xN" => "http://ny-image1.etsy.com/il_430xN.53498749.jpg",
|
|
51
|
+
"image_url_200x200" => "http://ny-image1.etsy.com/il_200x200.53498749.jpg",
|
|
52
|
+
"image_url_155x125" => "http://ny-image1.etsy.com/il_155x125.53498749.jpg",
|
|
53
|
+
"image_url_75x75" => "http://ny-image1.etsy.com/il_75x75.53498749.jpg",
|
|
54
|
+
"image_url_25x25" => "http://ny-image1.etsy.com/il_25x25.53498749.jpg",
|
|
55
|
+
"image_url_50x50" => "http://ny-image1.etsy.com/il_50x50.53498749.jpg"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
data/tasks/rspec.rake
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'spec'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
require 'rubygems'
|
|
5
|
+
require 'spec'
|
|
6
|
+
end
|
|
7
|
+
begin
|
|
8
|
+
require 'spec/rake/spectask'
|
|
9
|
+
rescue LoadError
|
|
10
|
+
puts <<-EOS
|
|
11
|
+
To use rspec for testing you must install rspec gem:
|
|
12
|
+
gem install rspec
|
|
13
|
+
EOS
|
|
14
|
+
exit(0)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Run the specs under spec/models"
|
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
namespace :spec do
|
|
24
|
+
desc "Run all specs in spec directory with RCov (excluding plugin specs)"
|
|
25
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
|
26
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
|
27
|
+
t.spec_files = FileList['spec/**/*/*_spec.rb']
|
|
28
|
+
t.rcov = true
|
|
29
|
+
t.rcov_opts = lambda do
|
|
30
|
+
IO.readlines("spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: tcocca-etsy4r
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Tom Cocca
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-03-01 00:00:00 -08:00
|
|
13
|
+
default_executable:
|
|
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"
|
|
24
|
+
version:
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: hpricot
|
|
27
|
+
type: :runtime
|
|
28
|
+
version_requirement:
|
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: "0"
|
|
34
|
+
version:
|
|
35
|
+
description: Handcrafted API Wrapper for Etsy utilizing httparty
|
|
36
|
+
email: tom.cocca@gmail.com
|
|
37
|
+
executables: []
|
|
38
|
+
|
|
39
|
+
extensions: []
|
|
40
|
+
|
|
41
|
+
extra_rdoc_files: []
|
|
42
|
+
|
|
43
|
+
files:
|
|
44
|
+
- README
|
|
45
|
+
- LICENSE
|
|
46
|
+
- Rakefile
|
|
47
|
+
- VERSION.yml
|
|
48
|
+
- lib/etsy4r.rb
|
|
49
|
+
- lib/etsy4r/client.rb
|
|
50
|
+
- lib/etsy4r/commands.rb
|
|
51
|
+
- lib/etsy4r/favorite_commands.rb
|
|
52
|
+
- lib/etsy4r/gift_guide_commands.rb
|
|
53
|
+
- lib/etsy4r/image_parser.rb
|
|
54
|
+
- lib/etsy4r/response.rb
|
|
55
|
+
- lib/etsy4r/server_commands.rb
|
|
56
|
+
- lib/etsy4r/tag_commands.rb
|
|
57
|
+
- lib/etsy4r/user_commands.rb
|
|
58
|
+
- spec/rcov.opts
|
|
59
|
+
- spec/spec.opts
|
|
60
|
+
- spec/spec_helper.rb
|
|
61
|
+
- spec/fixtures/images.html
|
|
62
|
+
- spec/etsy4r/client_spec.rb
|
|
63
|
+
- spec/etsy4r/commands_spec.rb
|
|
64
|
+
- spec/etsy4r/favorite_commands_spec.rb
|
|
65
|
+
- spec/etsy4r/gift_guide_commands_spec.rb
|
|
66
|
+
- spec/etsy4r/image_parser_spec.rb
|
|
67
|
+
- spec/etsy4r/server_commands_spec.rb
|
|
68
|
+
- spec/etsy4r/tag_commands_spec.rb
|
|
69
|
+
- spec/etsy4r/user_commands_spec.rb
|
|
70
|
+
- tasks/rspec.rake
|
|
71
|
+
- examples/etsy.rb
|
|
72
|
+
has_rdoc: true
|
|
73
|
+
homepage: http://github.com/tcocca/etsy4r
|
|
74
|
+
post_install_message:
|
|
75
|
+
rdoc_options:
|
|
76
|
+
- --inline-source
|
|
77
|
+
- --charset=UTF-8
|
|
78
|
+
require_paths:
|
|
79
|
+
- lib
|
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
|
+
requirements:
|
|
82
|
+
- - ">="
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
version: "0"
|
|
85
|
+
version:
|
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
- - ">="
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: "0"
|
|
91
|
+
version:
|
|
92
|
+
requirements: []
|
|
93
|
+
|
|
94
|
+
rubyforge_project:
|
|
95
|
+
rubygems_version: 1.2.0
|
|
96
|
+
signing_key:
|
|
97
|
+
specification_version: 2
|
|
98
|
+
summary: Handcrafted API Wrapper
|
|
99
|
+
test_files: []
|
|
100
|
+
|