Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding since_date/until_date from advanced search form

  • Loading branch information...
commit 9dcd340817224fa34fcb515f79a846886ffa1427 1 parent cdd9dba
@jschairb jschairb authored Wynn Netherland committed
Showing with 28 additions and 2 deletions.
  1. +15 −1 lib/twitter/search.rb
  2. +13 −1 test/twitter/search_test.rb
View
16 lib/twitter/search.rb
@@ -68,6 +68,20 @@ def since(since_id)
self
end
+ # From the advanced search form, not documented in the API
+ # Format YYYY-MM-DD
+ def since_date(since_date)
+ @query[:since] = since_date
+ self
+ end
+
+ # From the advanced search form, not documented in the API
+ # Format YYYY-MM-DD
+ def until_date(until_date)
+ @query[:until] = until_date
+ self
+ end
+
# Search tweets by longitude, latitude and a given range.
# Ranges like 25km and 50mi work.
def geocode(long, lat, range)
@@ -103,4 +117,4 @@ def each
fetch()['results'].each { |r| yield r }
end
end
-end
+end
View
14 test/twitter/search_test.rb
@@ -66,6 +66,18 @@ class SearchTest < Test::Unit::TestCase
@search.fetch()
end
+ should "should be able to specify since a date" do
+ @search.since_date('2009-04-14')
+ @search.class.expects(:get).with('http://search.twitter.com/search.json', :query => { :since => '2009-04-14', :q => ''}, :format => :json).returns({ 'foo' => 'bar'})
+ @search.fetch
+ end
+
+ should "should be able to specify until a date" do
+ @search.until_date('2009-04-14')
+ @search.class.expects(:get).with('http://search.twitter.com/search.json', :query => { :until => '2009-04-14', :q => ''}, :format => :json).returns({ 'foo' => 'bar'})
+ @search.fetch
+ end
+
should "should be able to specify geo coordinates" do
@search.geocode('40.757929', '-73.985506', '25mi')
@search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:geocode => '40.757929,-73.985506,25mi', :q => ''}, :format => :json).returns({'foo' => 'bar'})
@@ -141,4 +153,4 @@ class SearchTest < Test::Unit::TestCase
end
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.