Skip to content

Commit

Permalink
adding since_date/until_date from advanced search form
Browse files Browse the repository at this point in the history
  • Loading branch information
jschairb authored and Wynn Netherland committed Nov 29, 2009
1 parent cdd9dba commit 9dcd340
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
16 changes: 15 additions & 1 deletion lib/twitter/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -103,4 +117,4 @@ def each
fetch()['results'].each { |r| yield r }
end
end
end
end
14 changes: 13 additions & 1 deletion test/twitter/search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'})
Expand Down Expand Up @@ -141,4 +153,4 @@ class SearchTest < Test::Unit::TestCase
end
end

end
end

0 comments on commit 9dcd340

Please sign in to comment.