secobarbital-twitter 0.9.2.1 → 0.9.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
- data/lib/twitter/search.rb +2 -2
- data/test/twitter/search_test.rb +14 -14
- metadata +3 -3
data/VERSION.yml
CHANGED
data/lib/twitter/search.rb
CHANGED
@@ -2,7 +2,7 @@ module Twitter
|
|
2
2
|
class Search
|
3
3
|
include HTTParty
|
4
4
|
include Enumerable
|
5
|
-
base_uri "
|
5
|
+
base_uri "search.twitter.com/search"
|
6
6
|
format :json
|
7
7
|
|
8
8
|
attr_reader :result, :query
|
@@ -149,7 +149,7 @@ module Twitter
|
|
149
149
|
protected
|
150
150
|
|
151
151
|
def perform_get(query)
|
152
|
-
response = self.class.get("
|
152
|
+
response = self.class.get("#{self.class.base_uri}.json", :query => query, :format => :json, :headers => {"User-Agent" => user_agent})
|
153
153
|
@fetch = Twitter.mash(response)
|
154
154
|
end
|
155
155
|
|
data/test/twitter/search_test.rb
CHANGED
@@ -21,7 +21,7 @@ class SearchTest < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
should "pass user agent along with headers when making request" do
|
24
|
-
Twitter::Search.expects(:get).with('http://
|
24
|
+
Twitter::Search.expects(:get).with('http://search.twitter.com/search.json', {:format => :json, :query => {:q => 'foo'}, :headers => {'User-Agent' => 'Foobar'}})
|
25
25
|
Twitter::Search.new('foo', :user_agent => 'Foobar').fetch()
|
26
26
|
end
|
27
27
|
|
@@ -75,61 +75,61 @@ class SearchTest < Test::Unit::TestCase
|
|
75
75
|
|
76
76
|
should "should be able to specify the language" do
|
77
77
|
@search.lang('en')
|
78
|
-
@search.class.expects(:get).with('http://
|
78
|
+
@search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:lang => 'en', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
|
79
79
|
@search.fetch()
|
80
80
|
end
|
81
81
|
|
82
82
|
should "should be able to specify the number of results per page" do
|
83
83
|
@search.per_page(25)
|
84
|
-
@search.class.expects(:get).with('http://
|
84
|
+
@search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:rpp => 25, :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
|
85
85
|
@search.fetch()
|
86
86
|
end
|
87
87
|
|
88
88
|
should "should be able to specify the page number" do
|
89
89
|
@search.page(20)
|
90
|
-
@search.class.expects(:get).with('http://
|
90
|
+
@search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:page => 20, :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
|
91
91
|
@search.fetch()
|
92
92
|
end
|
93
93
|
|
94
94
|
should "should be able to specify only returning results greater than an id" do
|
95
95
|
@search.since(1234)
|
96
|
-
@search.class.expects(:get).with('http://
|
96
|
+
@search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:since_id => 1234, :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
|
97
97
|
@search.fetch()
|
98
98
|
end
|
99
99
|
|
100
100
|
should "should be able to specify since a date" do
|
101
101
|
@search.since_date('2009-04-14')
|
102
|
-
@search.class.expects(:get).with('http://
|
102
|
+
@search.class.expects(:get).with('http://search.twitter.com/search.json', :query => { :since => '2009-04-14', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({ 'foo' => 'bar'})
|
103
103
|
@search.fetch
|
104
104
|
end
|
105
105
|
|
106
106
|
should "should be able to specify until a date" do
|
107
107
|
@search.until_date('2009-04-14')
|
108
|
-
@search.class.expects(:get).with('http://
|
108
|
+
@search.class.expects(:get).with('http://search.twitter.com/search.json', :query => { :until => '2009-04-14', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({ 'foo' => 'bar'})
|
109
109
|
@search.fetch
|
110
110
|
end
|
111
111
|
|
112
112
|
should "should be able to specify geo coordinates" do
|
113
113
|
@search.geocode('40.757929', '-73.985506', '25mi')
|
114
|
-
@search.class.expects(:get).with('http://
|
114
|
+
@search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:geocode => '40.757929,-73.985506,25mi', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
|
115
115
|
@search.fetch()
|
116
116
|
end
|
117
117
|
|
118
118
|
should "should be able to specify max id" do
|
119
119
|
@search.max(1234)
|
120
|
-
@search.class.expects(:get).with('http://
|
120
|
+
@search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:max_id => 1234, :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
|
121
121
|
@search.fetch()
|
122
122
|
end
|
123
123
|
|
124
124
|
should "should be able to set the phrase" do
|
125
125
|
@search.phrase("Who Dat")
|
126
|
-
@search.class.expects(:get).with('http://
|
126
|
+
@search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:phrase => "Who Dat", :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
|
127
127
|
@search.fetch()
|
128
128
|
end
|
129
129
|
|
130
130
|
should "should be able to set the result type" do
|
131
131
|
@search.result_type("popular")
|
132
|
-
@search.class.expects(:get).with('http://
|
132
|
+
@search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:result_type => 'popular', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
|
133
133
|
@search.fetch()
|
134
134
|
end
|
135
135
|
|
@@ -149,7 +149,7 @@ class SearchTest < Test::Unit::TestCase
|
|
149
149
|
|
150
150
|
context "fetching" do
|
151
151
|
setup do
|
152
|
-
stub_get('http://
|
152
|
+
stub_get('http://search.twitter.com:80/search.json?q=%40jnunemaker', 'search.json')
|
153
153
|
@search = Twitter::Search.new('@jnunemaker')
|
154
154
|
@response = @search.fetch
|
155
155
|
end
|
@@ -179,14 +179,14 @@ class SearchTest < Test::Unit::TestCase
|
|
179
179
|
end
|
180
180
|
|
181
181
|
should "be able to fetch the next page" do
|
182
|
-
Twitter::Search.expects(:get).with('http://
|
182
|
+
Twitter::Search.expects(:get).with('http://search.twitter.com/search.json', :query => 'page=2&max_id=1446791544&q=%40jnunemaker', :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
|
183
183
|
@search.fetch_next_page
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
187
|
context "iterating over results" do
|
188
188
|
setup do
|
189
|
-
stub_get('http://
|
189
|
+
stub_get('http://search.twitter.com:80/search.json?q=from%3Ajnunemaker', 'search_from_jnunemaker.json')
|
190
190
|
@search.from('jnunemaker')
|
191
191
|
end
|
192
192
|
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 9
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.9.2.
|
9
|
+
- 2
|
10
|
+
version: 0.9.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Nunemaker
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-03-
|
20
|
+
date: 2010-03-29 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|