shoppr 0.1.1 → 0.2.3
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/README.markdown +40 -0
- data/Rakefile +9 -4
- data/VERSION.yml +3 -3
- data/lib/shoppr.rb +13 -40
- data/lib/shoppr/api_exception.rb +6 -5
- data/lib/shoppr/attribute.rb +13 -7
- data/lib/shoppr/attribute_selection.rb +0 -6
- data/lib/shoppr/attribute_value.rb +5 -6
- data/lib/shoppr/category.rb +28 -10
- data/lib/shoppr/category_selection.rb +5 -7
- data/lib/shoppr/client.rb +11 -5
- data/lib/shoppr/client_tracking.rb +4 -9
- data/lib/shoppr/consumer_review.rb +9 -12
- data/lib/shoppr/dynamic_navigation_history.rb +0 -4
- data/lib/shoppr/feature.rb +13 -5
- data/lib/shoppr/feature_group.rb +11 -5
- data/lib/shoppr/feature_rating.rb +6 -5
- data/lib/shoppr/general_search_response.rb +25 -8
- data/lib/shoppr/generic_response.rb +9 -4
- data/lib/shoppr/image.rb +5 -7
- data/lib/shoppr/keyword_search.rb +0 -6
- data/lib/shoppr/offer.rb +12 -22
- data/lib/shoppr/offer_selection.rb +0 -6
- data/lib/shoppr/product.rb +22 -23
- data/lib/shoppr/product_selection.rb +0 -6
- data/lib/shoppr/search_history.rb +13 -6
- data/lib/shoppr/server_detail.rb +5 -9
- data/lib/shoppr/store.rb +10 -14
- data/test/fixtures/general_search_specs_offers_reviews.xml +1311 -1
- data/test/shoppr/general_search_response_test.rb +40 -71
- data/test/shoppr/generic_response_test.rb +1 -1
- metadata +85 -41
- data/README.rdoc +0 -17
@@ -4,28 +4,33 @@ class GeneralSearchResponseTest < Test::Unit::TestCase
|
|
4
4
|
include Shoppr
|
5
5
|
|
6
6
|
context "When mapping general search response XML to ruby objects" do
|
7
|
-
setup
|
7
|
+
setup do
|
8
|
+
@client = Shoppr::Client.new(true)
|
9
|
+
stub_get 'http://sandbox.api.shopping.com/publisher/3.0/rest/GeneralSearch?apiKey=authorized-key&showProductReviews=true&trackingId=7000610&groupItemsByCategory=true&showProductSpecs=true&showProductOffers=true&keyword=nikon', 'general_search_specs_offers_reviews.xml'
|
10
|
+
# @general_response = GeneralSearchResponse.from_xml(fixture_file('general_search_specs_offers_reviews.xml'))
|
11
|
+
@general_response = @client.search({:keyword => "nikon", :show_product_specs => true, :show_product_reviews => true, :show_product_offers => true})
|
12
|
+
end
|
8
13
|
|
9
14
|
should "include server detail information" do
|
10
|
-
@general_response.server_detail.api_version.should == '3.1
|
15
|
+
@general_response.server_detail.api_version.should == '3.1 R25.4.1'
|
11
16
|
@general_response.server_detail.api_env.should == 'sandbox'
|
12
17
|
end
|
13
18
|
|
14
19
|
should "include exceptions" do
|
15
20
|
@general_response.exceptions.size.should == 1
|
16
|
-
@general_response.exceptions.first.code.should == 1112
|
21
|
+
@general_response.exceptions.first.code.should == '1112'
|
17
22
|
end
|
18
23
|
|
19
24
|
should "include client tracking info" do
|
20
|
-
@general_response.client_tracking.height.should == 19
|
21
|
-
@general_response.client_tracking.width.should == 106
|
25
|
+
@general_response.client_tracking.height.should == '19'
|
26
|
+
@general_response.client_tracking.width.should == '106'
|
22
27
|
@general_response.client_tracking.type.should == 'logo'
|
23
28
|
@general_response.client_tracking.alt_text.should == 'Digital Cameras'
|
24
29
|
end
|
25
30
|
|
26
31
|
should "include search history info" do
|
27
32
|
@general_response.search_history.category_selections.size.should == 3
|
28
|
-
@general_response.search_history.category_selections.last.id.should == 7185
|
33
|
+
@general_response.search_history.category_selections.last.id.should == '7185'
|
29
34
|
@general_response.search_history.category_selections.last.category_url.should == 'http://www.shopping.com/xPP-digital_cameras-nikon~linkin_id-7000610?oq=nikon'
|
30
35
|
end
|
31
36
|
|
@@ -44,13 +49,13 @@ class GeneralSearchResponseTest < Test::Unit::TestCase
|
|
44
49
|
end
|
45
50
|
|
46
51
|
should "include category properties" do
|
47
|
-
@categories.first.id.should == 7185
|
52
|
+
@categories.first.id.should == '7185'
|
48
53
|
@categories.first.name.should == 'Digital Cameras'
|
49
54
|
@categories.first.category_url.should == 'http://www.shopping.com/xPP-digital_cameras-nikon~linkin_id-7000610?oq=nikon'
|
50
55
|
end
|
51
56
|
|
52
57
|
should "include products" do
|
53
|
-
@categories.first.products.size.should ==
|
58
|
+
@categories.first.products.size.should == 2
|
54
59
|
end
|
55
60
|
|
56
61
|
context "when mapping products" do
|
@@ -59,13 +64,11 @@ class GeneralSearchResponseTest < Test::Unit::TestCase
|
|
59
64
|
end
|
60
65
|
|
61
66
|
should "should map product attributes" do
|
62
|
-
@product.id.should ==
|
63
|
-
@product.name.should ==
|
64
|
-
@product.short_description.should == '
|
65
|
-
@product.min_price.should ==
|
66
|
-
@product.max_price.should ==
|
67
|
-
@product.product_offers_url.should == 'http://www.shopping.com/xPO-Nikon-D40-with-G-II-18-55mm-Lens~linkin_id-7000610'
|
68
|
-
@product.product_specs_url.should == 'http://www.shopping.com/xPF-Nikon-D40-with-G-II-18-55mm-Lens~linkin_id-7000610'
|
67
|
+
@product.id.should == '95738382'
|
68
|
+
@product.name.should == "Nikon COOLPIX S4000 Digital Camera"
|
69
|
+
@product.short_description.should == '12 Megapixel, Compact Camera, 3 in. LCD Screen, 4x Optical Zoom, With High Definition Video, Weight: 0.29 lb.'
|
70
|
+
@product.min_price.should == '167.00'
|
71
|
+
@product.max_price.should == '301.00'
|
69
72
|
end
|
70
73
|
|
71
74
|
context "when mapping offers" do
|
@@ -75,23 +78,10 @@ class GeneralSearchResponseTest < Test::Unit::TestCase
|
|
75
78
|
|
76
79
|
should "should include offer info" do
|
77
80
|
@product.offers.size.should == 5
|
78
|
-
@offer.featured
|
79
|
-
@offer.smart_buy
|
80
|
-
@offer.used
|
81
|
-
@offer.name.should == '
|
82
|
-
@offer.description.length.should_not == 0
|
83
|
-
@offer.category_id.should == 7185
|
84
|
-
@offer.manufacturer.should == 'Nikon'
|
85
|
-
@offer.images.size.should == 4
|
86
|
-
@offer.images.last.width.should == 400
|
87
|
-
@offer.stock_status.should == 'in-stock'
|
88
|
-
@offer.store_notes.should == 'Refurbished Model'
|
89
|
-
#@offer.currency.should == 'USD'
|
90
|
-
@offer.base_price.should == 374.95
|
91
|
-
@offer.tax.should == nil
|
92
|
-
@offer.shipping_cost.should == 0.00
|
93
|
-
@offer.total_price.should == nil
|
94
|
-
@offer.offer_url.include?('http://').should == true
|
81
|
+
@offer.featured.should == false
|
82
|
+
@offer.smart_buy.should == false
|
83
|
+
@offer.used.should == false
|
84
|
+
@offer.name.should == 'Coolpix S4000 Digital Camera, 12MP, 4x Zoom, Black'
|
95
85
|
end
|
96
86
|
|
97
87
|
context "when mapping store info" do
|
@@ -100,20 +90,17 @@ class GeneralSearchResponseTest < Test::Unit::TestCase
|
|
100
90
|
end
|
101
91
|
|
102
92
|
should "should include store info" do
|
103
|
-
@store.name.should == '
|
104
|
-
@store.logo.height.should == 31
|
105
|
-
@store.rating.should == 4.50
|
106
|
-
@store.review_count.should ==
|
107
|
-
@store.review_url.should == 'http://www.shopping.com/xMR-null~MRD-9391~S-1~linkin_id-7000610'
|
108
|
-
@store.rating_image.source_url.should == 'http://img.shopping.com/sc/mr/sdc_checks_45.gif'
|
109
|
-
@store.country_code.should == 'US'
|
93
|
+
@store.name.should == 'PC Connection Express'
|
94
|
+
@store.logo.height.should == '31'
|
95
|
+
@store.rating.should == '4.50'
|
96
|
+
@store.review_count.should == '5686'
|
110
97
|
end
|
111
98
|
end
|
112
99
|
|
113
100
|
end
|
114
101
|
|
115
102
|
should "include specifications" do
|
116
|
-
@product.specifications.size.should ==
|
103
|
+
@product.specifications.size.should == 14
|
117
104
|
end
|
118
105
|
|
119
106
|
context "when mapping feature groups" do
|
@@ -122,24 +109,19 @@ class GeneralSearchResponseTest < Test::Unit::TestCase
|
|
122
109
|
end
|
123
110
|
|
124
111
|
should "should include feature info" do
|
125
|
-
@feature_group.features.size.should ==
|
112
|
+
@feature_group.features.size.should == 6
|
126
113
|
@feature = @feature_group.features[3]
|
127
|
-
@feature.name.should == '
|
128
|
-
@feature.description.nil?.should == false
|
129
|
-
@feature.values.first.should == 'CCD'
|
114
|
+
@feature.name.should == 'Optical Zoom'
|
130
115
|
end
|
131
116
|
end
|
132
117
|
|
133
118
|
|
134
119
|
should "include review info" do
|
135
|
-
@product.review_count.should ==
|
136
|
-
@product.rating.should == 4.00
|
120
|
+
@product.review_count.should == '4'
|
121
|
+
@product.rating.should == '4.00'
|
137
122
|
@product.rating_image.source_url.should == 'http://img.shopping.com/sc/pr/sdc_stars_sm_4.gif'
|
138
|
-
@product.reviews.size.should ==
|
139
|
-
@product.overall_rating.should == 4.00
|
140
|
-
@product.feature_ratings.size.should == 5
|
141
|
-
@product.feature_ratings.last.name.should == 'Shutter Lag'
|
142
|
-
@product.feature_ratings.last.value.should == 4.64
|
123
|
+
@product.reviews.size.should == 1
|
124
|
+
@product.overall_rating.should == '4.00'
|
143
125
|
end
|
144
126
|
|
145
127
|
context "when mapping consumer reviews" do
|
@@ -148,17 +130,9 @@ class GeneralSearchResponseTest < Test::Unit::TestCase
|
|
148
130
|
end
|
149
131
|
|
150
132
|
should "include review info" do
|
151
|
-
@review.author_id.should == '
|
152
|
-
@review.post_date.yday.should ==
|
153
|
-
@review.rating.should ==
|
154
|
-
@review.feature_ratings.size.should == 5
|
155
|
-
@review.feature_ratings.first.name.should == 'Ease of Use:'
|
156
|
-
@review.feature_ratings.first.value.should == 4
|
157
|
-
@review.summary.should == 'Nikon D40'
|
158
|
-
@review.pros.should == 'Lots of features.<br>Easy to use.<br>Intuitive menu.'
|
159
|
-
@review.cons.should == 'No video capture like most recent SLR\'s, but not really a "con".'
|
160
|
-
@review.content.should == 'This is an EXCELLENT camera for the money. Don\'t be drawn to more expensive cameras just becau'
|
161
|
-
@review.url.should == 'http://www.epinions.com/content_469199523460?linkin_id=7000610'
|
133
|
+
@review.author_id.should == 'hdsquared'
|
134
|
+
@review.post_date.to_datetime.yday.should == 146
|
135
|
+
@review.rating.should == '1.00'
|
162
136
|
end
|
163
137
|
end
|
164
138
|
|
@@ -166,19 +140,14 @@ class GeneralSearchResponseTest < Test::Unit::TestCase
|
|
166
140
|
|
167
141
|
should "should include images" do
|
168
142
|
#@product.images.size.should == 4
|
169
|
-
@product.images.first.height.should == 100
|
170
|
-
@product.images.last.width.should ==
|
171
|
-
@product.images.last.source_url.should ==
|
143
|
+
@product.images.first.height.should == '100'
|
144
|
+
@product.images.last.width.should == '350'
|
145
|
+
@product.images.last.source_url.should == "http://di1.shopping.com/images/pi/36/ff/8e/95738382-350x349-0-0.jpg?p=p2.90ca531eeb3e309b5933&a=2&c=1&l=7000610&t=100610122258&r=2"
|
172
146
|
end
|
173
147
|
end
|
174
148
|
|
175
149
|
end
|
176
|
-
|
177
|
-
|
178
|
-
should "include offers" do
|
179
|
-
@categories.first.offers.size.should == 0
|
180
|
-
end
|
181
|
-
|
150
|
+
|
182
151
|
should "include attributes" do
|
183
152
|
@categories.first.attributes.size.should == 5
|
184
153
|
end
|
@@ -4,7 +4,7 @@ class GenericResponseTest < Test::Unit::TestCase
|
|
4
4
|
include Shoppr
|
5
5
|
|
6
6
|
context "When mapping generic response XML to ruby objects" do
|
7
|
-
setup { @response =
|
7
|
+
setup { @response = Shoppr::Client.new(true).generic_response }
|
8
8
|
|
9
9
|
should "include server detail information" do
|
10
10
|
@response.server_detail.api_version.should == '3.1 R21.4'
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoppr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 17
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Wynn Netherland
|
@@ -10,91 +16,123 @@ autorequire:
|
|
10
16
|
bindir: bin
|
11
17
|
cert_chain: []
|
12
18
|
|
13
|
-
date:
|
19
|
+
date: 2010-06-16 00:00:00 -05:00
|
14
20
|
default_executable:
|
15
21
|
dependencies:
|
16
22
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
18
|
-
|
19
|
-
|
20
|
-
|
23
|
+
name: hashie
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
21
27
|
requirements:
|
22
28
|
- - "="
|
23
29
|
- !ruby/object:Gem::Version
|
24
|
-
|
25
|
-
|
30
|
+
hash: 23
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
- 2
|
34
|
+
- 0
|
35
|
+
version: 0.2.0
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
26
38
|
- !ruby/object:Gem::Dependency
|
27
39
|
name: httparty
|
28
|
-
|
29
|
-
|
30
|
-
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
31
43
|
requirements:
|
32
|
-
- -
|
44
|
+
- - ">="
|
33
45
|
- !ruby/object:Gem::Version
|
34
|
-
|
35
|
-
|
46
|
+
hash: 11
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
- 5
|
50
|
+
- 0
|
51
|
+
version: 0.5.0
|
52
|
+
type: :runtime
|
53
|
+
version_requirements: *id002
|
36
54
|
- !ruby/object:Gem::Dependency
|
37
55
|
name: thoughtbot-shoulda
|
38
|
-
|
39
|
-
|
40
|
-
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
41
59
|
requirements:
|
42
60
|
- - ">="
|
43
61
|
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 0
|
44
65
|
version: "0"
|
45
|
-
|
66
|
+
type: :development
|
67
|
+
version_requirements: *id003
|
46
68
|
- !ruby/object:Gem::Dependency
|
47
69
|
name: jeremymcanally-matchy
|
48
|
-
|
49
|
-
|
50
|
-
|
70
|
+
prerelease: false
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
51
73
|
requirements:
|
52
74
|
- - ">="
|
53
75
|
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
54
79
|
version: "0"
|
55
|
-
|
80
|
+
type: :development
|
81
|
+
version_requirements: *id004
|
56
82
|
- !ruby/object:Gem::Dependency
|
57
83
|
name: mocha
|
58
|
-
|
59
|
-
|
60
|
-
|
84
|
+
prerelease: false
|
85
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
61
87
|
requirements:
|
62
88
|
- - ">="
|
63
89
|
- !ruby/object:Gem::Version
|
90
|
+
hash: 3
|
91
|
+
segments:
|
92
|
+
- 0
|
64
93
|
version: "0"
|
65
|
-
|
94
|
+
type: :development
|
95
|
+
version_requirements: *id005
|
66
96
|
- !ruby/object:Gem::Dependency
|
67
97
|
name: fakeweb
|
68
|
-
|
69
|
-
|
70
|
-
|
98
|
+
prerelease: false
|
99
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
71
101
|
requirements:
|
72
102
|
- - ">="
|
73
103
|
- !ruby/object:Gem::Version
|
104
|
+
hash: 3
|
105
|
+
segments:
|
106
|
+
- 0
|
74
107
|
version: "0"
|
75
|
-
version:
|
76
|
-
- !ruby/object:Gem::Dependency
|
77
|
-
name: mash
|
78
108
|
type: :development
|
79
|
-
|
80
|
-
|
109
|
+
version_requirements: *id006
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: hashie
|
112
|
+
prerelease: false
|
113
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
81
115
|
requirements:
|
82
116
|
- - ">="
|
83
117
|
- !ruby/object:Gem::Version
|
118
|
+
hash: 3
|
119
|
+
segments:
|
120
|
+
- 0
|
84
121
|
version: "0"
|
85
|
-
|
122
|
+
type: :development
|
123
|
+
version_requirements: *id007
|
86
124
|
description:
|
87
|
-
email:
|
125
|
+
email: jim@squeejee.com
|
88
126
|
executables: []
|
89
127
|
|
90
128
|
extensions: []
|
91
129
|
|
92
130
|
extra_rdoc_files:
|
93
|
-
- README.
|
131
|
+
- README.markdown
|
94
132
|
files:
|
95
133
|
- History
|
96
134
|
- License
|
97
|
-
- README.
|
135
|
+
- README.markdown
|
98
136
|
- Rakefile
|
99
137
|
- VERSION.yml
|
100
138
|
- lib/shoppr.rb
|
@@ -140,21 +178,27 @@ rdoc_options:
|
|
140
178
|
require_paths:
|
141
179
|
- lib
|
142
180
|
required_ruby_version: !ruby/object:Gem::Requirement
|
181
|
+
none: false
|
143
182
|
requirements:
|
144
183
|
- - ">="
|
145
184
|
- !ruby/object:Gem::Version
|
185
|
+
hash: 3
|
186
|
+
segments:
|
187
|
+
- 0
|
146
188
|
version: "0"
|
147
|
-
version:
|
148
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
|
+
none: false
|
149
191
|
requirements:
|
150
192
|
- - ">="
|
151
193
|
- !ruby/object:Gem::Version
|
194
|
+
hash: 3
|
195
|
+
segments:
|
196
|
+
- 0
|
152
197
|
version: "0"
|
153
|
-
version:
|
154
198
|
requirements: []
|
155
199
|
|
156
200
|
rubyforge_project: shoppr
|
157
|
-
rubygems_version: 1.3.
|
201
|
+
rubygems_version: 1.3.7
|
158
202
|
signing_key:
|
159
203
|
specification_version: 3
|
160
204
|
summary: Ruby wrapper for the Shopping.com API
|
data/README.rdoc
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
= shoppr
|
2
|
-
|
3
|
-
The Ruby Shopping.com API gem.
|
4
|
-
|
5
|
-
== examples
|
6
|
-
|
7
|
-
See the examples directory.
|
8
|
-
|
9
|
-
http://github.com/squeejee/shoppr/tree/master/examples
|
10
|
-
|
11
|
-
== docs
|
12
|
-
|
13
|
-
http://rdoc.info/projects/squeejee/shoppr
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2009 Squeejee. See LICENSE for details.
|