yahoo-se 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  module Yahoo
2
2
  module SE
3
3
  class ApplicationIDNotSet < RuntimeError; end
4
+ class RateLimitExceeded < RuntimeError; end
4
5
  end
5
6
  end
@@ -3,10 +3,11 @@ module Yahoo
3
3
  class Response
4
4
  def initialize(response_body)
5
5
  @body = response_body
6
+ raise RateLimitExceeded unless @body.to_json["Error"].nil?
6
7
  end
7
8
 
8
9
  # 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_available
10
+ def total_results_returned
10
11
  self.to_json["ResultSet"]["totalResultsReturned"].to_i
11
12
  end
12
13
 
@@ -1,5 +1,5 @@
1
1
  module Yahoo
2
2
  module SE
3
- VERSION = "1.0.6" unless defined?(Yahoo::SE::VERSION)
3
+ VERSION = "1.0.7" unless defined?(Yahoo::SE::VERSION)
4
4
  end
5
5
  end
@@ -0,0 +1 @@
1
+ {"Error":{"Message":"limit exceeded"}}
@@ -10,10 +10,14 @@ describe Yahoo::SE::Response do
10
10
  end
11
11
 
12
12
  it "should show the total results return from the request" do
13
- @response.total_results.should == 100
13
+ @response.total_results_returned.should == 100
14
14
  end
15
15
 
16
16
  it "should show the total results found from Yahoo!" do
17
17
  @response.total_results_available.should == 328
18
18
  end
19
+
20
+ it "should raise RateLimitExceeded when there are too many requests" do
21
+ lambda {Yahoo::SE::Response.new(fixture("rate_limit_exceeded.json"))}.should raise_error(Yahoo::SE::RateLimitExceeded)
22
+ end
19
23
  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.6
4
+ version: 1.0.7
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-28 00:00:00 -05:00
12
+ date: 2008-12-04 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -59,6 +59,7 @@ files:
59
59
  - spec/fixtures/erbmicha.com_backlinks.json
60
60
  - spec/fixtures/erbmicha.com_pages.json
61
61
  - spec/fixtures/erbmicha.com_ping.json
62
+ - spec/fixtures/rate_limit_exceeded.json
62
63
  - spec/spec.opts
63
64
  - spec/spec_helper.rb
64
65
  - spec/yahoo-se