yahoo-se 1.0.5 → 1.0.6
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 +0 -2
- data/lib/yahoo-se.rb +6 -4
- data/lib/yahoo-se/paginator.rb +1 -1
- data/lib/yahoo-se/response.rb +8 -4
- data/lib/yahoo-se/version.rb +1 -1
- data/spec/yahoo-se/pages_spec.rb +6 -0
- data/spec/yahoo-se/response_spec.rb +8 -0
- metadata +2 -2
data/README
CHANGED
data/lib/yahoo-se.rb
CHANGED
@@ -14,10 +14,12 @@ module Yahoo
|
|
14
14
|
|
15
15
|
# First page of results
|
16
16
|
results = obj.results
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
|
18
|
+
if obj.total_results_available > 100
|
19
|
+
# The rest of the page results
|
20
|
+
(obj.total_results_available/100).ceil.times do |i|
|
21
|
+
results += obj.next
|
22
|
+
end
|
21
23
|
end
|
22
24
|
results
|
23
25
|
end
|
data/lib/yahoo-se/paginator.rb
CHANGED
data/lib/yahoo-se/response.rb
CHANGED
@@ -6,7 +6,7 @@ module Yahoo
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# The number of URLs returned. This may be lower than the number of results requested if there were fewer total results available.
|
9
|
-
def
|
9
|
+
def total_results_available
|
10
10
|
self.to_json["ResultSet"]["totalResultsReturned"].to_i
|
11
11
|
end
|
12
12
|
|
@@ -18,8 +18,12 @@ module Yahoo
|
|
18
18
|
# The result objects returned from the request
|
19
19
|
def results
|
20
20
|
begin
|
21
|
-
|
22
|
-
Yahoo::SE::Result.new(
|
21
|
+
if total_results_available == 1
|
22
|
+
[Yahoo::SE::Result.new(self.to_json["ResultSet"]["Result"])]
|
23
|
+
else
|
24
|
+
self.to_json["ResultSet"]["Result"].map do |result_hash|
|
25
|
+
Yahoo::SE::Result.new(result_hash)
|
26
|
+
end
|
23
27
|
end
|
24
28
|
rescue
|
25
29
|
[]
|
@@ -27,7 +31,7 @@ module Yahoo
|
|
27
31
|
end
|
28
32
|
|
29
33
|
def to_json
|
30
|
-
@json
|
34
|
+
@json ||= JSON.parse(@body)
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
data/lib/yahoo-se/version.rb
CHANGED
data/spec/yahoo-se/pages_spec.rb
CHANGED
@@ -13,6 +13,12 @@ describe Yahoo::SE::Pages do
|
|
13
13
|
results = Yahoo::SE.all(pages)
|
14
14
|
results.length.should == 303
|
15
15
|
end
|
16
|
+
|
17
|
+
it "should list all of the results for a given page request" do
|
18
|
+
pages = Yahoo::SE.pages("http://rubyskills.com/contact")
|
19
|
+
results = Yahoo::SE.all(pages)
|
20
|
+
results.length.should == 1
|
21
|
+
end
|
16
22
|
end
|
17
23
|
|
18
24
|
it "should have the service path for the pages service" do
|
@@ -8,4 +8,12 @@ describe Yahoo::SE::Response do
|
|
8
8
|
it "should list 100 result objects" do
|
9
9
|
@response.results.size.should equal(100)
|
10
10
|
end
|
11
|
+
|
12
|
+
it "should show the total results return from the request" do
|
13
|
+
@response.total_results.should == 100
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should show the total results found from Yahoo!" do
|
17
|
+
@response.total_results_available.should == 328
|
18
|
+
end
|
11
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yahoo-se
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lance Carlson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-11-
|
12
|
+
date: 2008-11-28 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|