dancroak-twitter-search 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.textile CHANGED
@@ -1,3 +1,8 @@
1
+ h2. 0.5.6 (June 6, 2009)
2
+
3
+ * When Twitter returns a 404, raise a TwitterSearch::SearchServerError instead
4
+ of a JSON parse error. (Luke Francl)
5
+
1
6
  h2. 0.5.5 (May 18, 2009)
2
7
 
3
8
  * raise error when query contains :near or :within:. (Dan Croak)
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ task :default => :test
13
13
 
14
14
  gem_spec = Gem::Specification.new do |gem_spec|
15
15
  gem_spec.name = "twitter-search"
16
- gem_spec.version = "0.5.5"
16
+ gem_spec.version = "0.5.6"
17
17
  gem_spec.summary = "Ruby client for Twitter Search. Includes trends."
18
18
  gem_spec.email = "dcroak@thoughtbot.com"
19
19
  gem_spec.homepage = "http://github.com/dancroak/twitter-search"
@@ -9,6 +9,8 @@ require File.join(File.dirname(__FILE__), 'trends')
9
9
  module TwitterSearch
10
10
  class SearchOperatorError < ArgumentError
11
11
  end
12
+ class SearchServerError < RuntimeError
13
+ end
12
14
 
13
15
  class Client
14
16
  TWITTER_SEARCH_API_URL = 'http://search.twitter.com/search.json'
@@ -38,9 +40,16 @@ module TwitterSearch
38
40
  http = Net::HTTP.new(url.host, url.port)
39
41
  http.read_timeout = timeout
40
42
 
41
- json = http.start { |http|
43
+ res = http.start { |http|
42
44
  http.get("#{url.path}?#{url.query}", headers)
43
- }.body
45
+ }
46
+
47
+ if res.code == '404'
48
+ raise TwitterSearch::SearchServerError, "Twitter responded with a 404 for your query. It is likely too complicated to process."
49
+ end
50
+
51
+ json = res.body
52
+
44
53
  Tweets.new JSON.parse(json)
45
54
  end
46
55
 
@@ -57,6 +66,7 @@ module TwitterSearch
57
66
  json = http.start { |http|
58
67
  http.get("#{url.path}?#{url.query}", headers)
59
68
  }.body
69
+
60
70
  Trends.new JSON.parse(json)
61
71
  end
62
72
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dancroak-twitter-search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Sallings
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2009-05-17 21:00:00 -07:00
19
+ date: 2009-06-05 21:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency