razsell 0.0.7 → 0.0.8
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/VERSION +1 -1
- data/features/razsell.feature +9 -0
- data/features/step_definitions/razsell_steps.rb +18 -0
- data/lib/razsell/query.rb +11 -2
- data/razsell.gemspec +3 -2
- data/test/fixtures/rockstar_mug.rss +23 -0
- data/test/query_test.rb +7 -0
- data/test/results_test.rb +1 -1
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/features/razsell.feature
CHANGED
@@ -16,3 +16,12 @@ Feature: Query Image Link
|
|
16
16
|
Then there should be "3" items
|
17
17
|
And the items should have the keyword "Rockstar"
|
18
18
|
And the items should have a link to a thumbnail
|
19
|
+
|
20
|
+
Scenario: Querying item information from an item url
|
21
|
+
Given a desire to query a "rockstar_mug" item on Zazzle
|
22
|
+
When I query the link "http://www.zazzle.com/rockstar_coder_mug-168427986526885635"
|
23
|
+
Then there should be "1" items
|
24
|
+
And the items should have the keyword "Rockstar"
|
25
|
+
And the items should have the keyword "Coder"
|
26
|
+
And the items should have the keyword "Mug"
|
27
|
+
And the items should have a link to a thumbnail
|
@@ -5,6 +5,12 @@ Given /^a desire to query the artist "([^\"]*)" on Zazzle$/ do |artist|
|
|
5
5
|
@query = Razsell::Query.new.for_artist(artist)
|
6
6
|
end
|
7
7
|
|
8
|
+
Given /^a desire to query a "([^\"]*)" item on Zazzle$/ do |fixture|
|
9
|
+
@fixture = fixture
|
10
|
+
@sut = RazsellMixedIn.new
|
11
|
+
@query = Razsell::Query.new
|
12
|
+
end
|
13
|
+
|
8
14
|
When /^the "([^\"]*)" is "([^\"]*)"$/ do |name, value|
|
9
15
|
@query.add_criteria(name, value)
|
10
16
|
end
|
@@ -16,6 +22,18 @@ When /^I query "([^\"]*)"$/ do |fixture|
|
|
16
22
|
@result = @sut.request(@query, :http_service => http_service)
|
17
23
|
end
|
18
24
|
|
25
|
+
When /^I query the link "([^\"]*)"$/ do |link|
|
26
|
+
@query.for_item_url(link)
|
27
|
+
http_service = Razsell::HttpService.new
|
28
|
+
http_service.expects(:get).once.returns(feed(@fixture))
|
29
|
+
|
30
|
+
@result = @sut.request(@query, :http_service => http_service)
|
31
|
+
end
|
32
|
+
|
33
|
+
Then /^there should be "([^\"]*)" item$/ do |arg1|
|
34
|
+
pending # express the regexp above with the code you wish you had
|
35
|
+
end
|
36
|
+
|
19
37
|
Then /^there should be "([^\"]*)" items/ do |item_count|
|
20
38
|
assert_equal item_count.to_i, @result.item_count
|
21
39
|
end
|
data/lib/razsell/query.rb
CHANGED
@@ -11,7 +11,7 @@ module Razsell
|
|
11
11
|
|
12
12
|
def initialize *args
|
13
13
|
set_default_page_limit
|
14
|
-
|
14
|
+
|
15
15
|
default_criteria
|
16
16
|
|
17
17
|
@keys = { :keywords => 'qs', :product_line => 'cg', :product_type => 'pt',
|
@@ -24,7 +24,16 @@ module Razsell
|
|
24
24
|
@artist = artist
|
25
25
|
self
|
26
26
|
end
|
27
|
+
|
28
|
+
def for_item_url url
|
29
|
+
@item_url = url
|
30
|
+
self.keywords = strip_item_number_from url
|
31
|
+
self
|
32
|
+
end
|
27
33
|
|
34
|
+
def strip_item_number_from url
|
35
|
+
url.scan(/\d*$/)[0]
|
36
|
+
end
|
28
37
|
#def add_criteria name, value
|
29
38
|
# this.send name, value
|
30
39
|
#end
|
@@ -90,7 +99,7 @@ module Razsell
|
|
90
99
|
args.each do |attribute|
|
91
100
|
define_method "#{attribute}=" do |value|
|
92
101
|
@querystring[attribute] = value
|
93
|
-
end
|
102
|
+
end
|
94
103
|
end
|
95
104
|
end
|
96
105
|
|
data/razsell.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{razsell}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jamal Hansen"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-16}
|
13
13
|
s.description = %q{Queries Zazzle RSS feed for data.}
|
14
14
|
s.email = %q{jamal.hansen@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -47,6 +47,7 @@ Gem::Specification.new do |s|
|
|
47
47
|
"test/fixtures/page_1.rss",
|
48
48
|
"test/fixtures/page_2.rss",
|
49
49
|
"test/fixtures/rockstar.rss",
|
50
|
+
"test/fixtures/rockstar_mug.rss",
|
50
51
|
"test/product_types_test.rb",
|
51
52
|
"test/query_test.rb",
|
52
53
|
"test/razsell_test.rb",
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<rss version="2.0" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>168427986526885635: Zazzle.com Gallery: Products Matching "168427986526885635"</title><link>http://feed.zazzle.com/z.2/api/find.aspx?qs=168427986526885635&ft=rss&ou=/rss?qs=168427986526885635</link><description></description><language>en-us</language><pubDate>Tue, 16 Feb 2010 19:29:47 GMT</pubDate><ttl>60</ttl><opensearch:totalResults>1</opensearch:totalResults><opensearch:startIndex>1</opensearch:startIndex><opensearch:itemsPerPage>15</opensearch:itemsPerPage><opensearch:Query role="request" searchTerms="168427986526885635" />
|
2
|
+
<item><guid isPermaLink="false">http://www.zazzle.com/rockstar_coder_mug-168427986526885635</guid><pubDate>Sat, 02 May 2009 13:09:16 GMT</pubDate><title><![CDATA[Rockstar Coder Mug]]></title><link>http://www.zazzle.com/rockstar_coder_mug-168427986526885635</link><author>kungfutees</author><description><![CDATA[
|
3
|
+
><div class="gridCell " id="_assetCell1">
|
4
|
+
<div style="position:relative" class="clearfix">
|
5
|
+
<a href="http://www.zazzle.com/rockstar_coder_mug-168427986526885635" id="_assetCell1-imageLink" class="realviewLink"
|
6
|
+
><img id="_assetCell1-preview" src="http://rlv.zcache.com/rockstar_coder_mug-p1684279865268856352obaq_152.jpg" alt="Rockstar Coder Mug" title="Rockstar Coder Mug by kungfutees" class="realviewImage"
|
7
|
+
/></a>
|
8
|
+
<div id="_assetCell1-productTypeIcon" class="mugIcon"></div>
|
9
|
+
<a href="javascript://" id="_assetCell1-nextviewLink" class="nextviewLink"></a>
|
10
|
+
</div>
|
11
|
+
<div class="gridCellInfo" id="_assetCell1-info">
|
12
|
+
<a
|
13
|
+
href="http://www.zazzle.com/rockstar_coder_mug-168427986526885635"
|
14
|
+
id="_assetCell1-title"
|
15
|
+
class="productTitle" title="Rockstar Coder Mug"
|
16
|
+
>Rockstar Coder Mug</a><br />
|
17
|
+
<span class="byLine">by <a href="javascript://" id="_assetCell1-contributorLink">kungfutees</a><br /></span>
|
18
|
+
<span class="extraInfo">
|
19
|
+
<br />
|
20
|
+
|
21
|
+
</span>
|
22
|
+
</div>
|
23
|
+
</div>]]></description><media:title><![CDATA[Rockstar Coder Mug]]></media:title><media:description><![CDATA[Want to show your inner rockstar in the break room? Here is the perfect way.]]></media:description><media:thumbnail url="http://rlv.zcache.com/rockstar_coder_mug-p1684279865268856352obaq_125.jpg" /><media:content url="http://rlv.zcache.com/rockstar_coder_mug-p1684279865268856352obaq_500.jpg" /><media:keywords>rockstar, coder, ror, ruby, on, rails</media:keywords><media:rating scheme="urn:mpaa">g</media:rating></item></channel></rss>
|
data/test/query_test.rb
CHANGED
@@ -142,6 +142,13 @@ class QueryTest < Test::Unit::TestCase
|
|
142
142
|
expected = "http://feed.zazzle.com/kungfutees/rss?bg=FFFFFF&ft=rss&isz=large&opensearch=1&pg=1&ps=50&src=razsell&st=popularity"
|
143
143
|
assert_equal expected, qs
|
144
144
|
end
|
145
|
+
|
146
|
+
should "build url for a specific item url" do
|
147
|
+
query = Razsell::Query.new.for_item_url("http://www.zazzle.com/rockstar_coder_mug-168427986526885635")
|
148
|
+
qs = query.to_url
|
149
|
+
expected = "http://feed.zazzle.com/rss?bg=FFFFFF&ft=rss&isz=large&opensearch=1&pg=1&ps=50&qs=168427986526885635&src=razsell&st=popularity"
|
150
|
+
assert_equal expected, qs
|
151
|
+
end
|
145
152
|
end
|
146
153
|
|
147
154
|
context "advancing the page" do
|
data/test/results_test.rb
CHANGED
@@ -28,7 +28,7 @@ class ResultsTest < Test::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
should "have the correct pubDate" do
|
31
|
-
assert_equal
|
31
|
+
assert_equal Time.parse("Sat, 02 May 2009 13:06:08 GMT").to_s, @item.pub_date.to_s
|
32
32
|
end
|
33
33
|
|
34
34
|
should "have the correct link" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: razsell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamal Hansen
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-16 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- test/fixtures/page_1.rss
|
93
93
|
- test/fixtures/page_2.rss
|
94
94
|
- test/fixtures/rockstar.rss
|
95
|
+
- test/fixtures/rockstar_mug.rss
|
95
96
|
- test/product_types_test.rb
|
96
97
|
- test/query_test.rb
|
97
98
|
- test/razsell_test.rb
|