yahoo-se 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -4,8 +4,6 @@ Yahoo Site Explorer API integration.
4
4
 
5
5
  == Installation
6
6
 
7
- gem sources -a http://gems.github.com
8
-
9
7
  gem install yahoo-se
10
8
 
11
9
  == Usage
@@ -14,10 +14,12 @@ module Yahoo
14
14
 
15
15
  # First page of results
16
16
  results = obj.results
17
-
18
- # The rest of the page results
19
- (obj.total_results_available/100).ceil.times do |i|
20
- results += obj.next
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
@@ -15,7 +15,7 @@ module Yahoo
15
15
  end
16
16
 
17
17
  def total_results_available
18
- @total_results_available = @total_results_available ||= response.total_results_available
18
+ @total_results_available ||= response.total_results_available
19
19
  end
20
20
 
21
21
  def last?
@@ -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 total_results
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
- self.to_json["ResultSet"]["Result"].map do |result_hash|
22
- Yahoo::SE::Result.new(result_hash)
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 = @json ||= JSON.parse(@body)
34
+ @json ||= JSON.parse(@body)
31
35
  end
32
36
  end
33
37
  end
@@ -1,5 +1,5 @@
1
1
  module Yahoo
2
2
  module SE
3
- VERSION = "1.0.5" unless defined?(Yahoo::SE::VERSION)
3
+ VERSION = "1.0.6" unless defined?(Yahoo::SE::VERSION)
4
4
  end
5
5
  end
@@ -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.5
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-20 00:00:00 -05:00
12
+ date: 2008-11-28 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency