rorra-twitter 0.9.9

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.
Files changed (97) hide show
  1. data/History +290 -0
  2. data/License +20 -0
  3. data/Notes +33 -0
  4. data/README.rdoc +19 -0
  5. data/Rakefile +36 -0
  6. data/VERSION.yml +5 -0
  7. data/examples/connect.rb +30 -0
  8. data/examples/friendship_existence.rb +13 -0
  9. data/examples/helpers/config_store.rb +38 -0
  10. data/examples/httpauth.rb +11 -0
  11. data/examples/ids.rb +13 -0
  12. data/examples/lists.rb +11 -0
  13. data/examples/oauth.rb +27 -0
  14. data/examples/search.rb +15 -0
  15. data/examples/timeline.rb +19 -0
  16. data/examples/tumblr.rb +9 -0
  17. data/examples/unauthorized.rb +16 -0
  18. data/examples/update.rb +11 -0
  19. data/examples/user.rb +5 -0
  20. data/lib/twitter.rb +156 -0
  21. data/lib/twitter/base.rb +393 -0
  22. data/lib/twitter/geo.rb +25 -0
  23. data/lib/twitter/httpauth.rb +53 -0
  24. data/lib/twitter/local_trends.rb +30 -0
  25. data/lib/twitter/oauth.rb +64 -0
  26. data/lib/twitter/request.rb +71 -0
  27. data/lib/twitter/search.rb +163 -0
  28. data/lib/twitter/trends.rb +55 -0
  29. data/test/fixtures/blocking.json +1632 -0
  30. data/test/fixtures/firehose.json +1 -0
  31. data/test/fixtures/follower_ids.json +1 -0
  32. data/test/fixtures/followers.json +1 -0
  33. data/test/fixtures/friend_ids.json +1 -0
  34. data/test/fixtures/friends_timeline.json +1 -0
  35. data/test/fixtures/friendship.json +1 -0
  36. data/test/fixtures/friendship_exists.json +1 -0
  37. data/test/fixtures/geo_place.json +1 -0
  38. data/test/fixtures/geo_reverse_geocode.json +1 -0
  39. data/test/fixtures/geo_reverse_geocode_granularity.json +1 -0
  40. data/test/fixtures/geo_reverse_geocode_limit.json +1 -0
  41. data/test/fixtures/geo_search.json +1 -0
  42. data/test/fixtures/geo_search_ip_address.json +1 -0
  43. data/test/fixtures/geo_search_query.json +1 -0
  44. data/test/fixtures/home_timeline.json +1 -0
  45. data/test/fixtures/ids.json +1 -0
  46. data/test/fixtures/list.json +1 -0
  47. data/test/fixtures/list_statuses.json +1 -0
  48. data/test/fixtures/list_statuses_1_1.json +1 -0
  49. data/test/fixtures/list_statuses_2_1.json +1 -0
  50. data/test/fixtures/list_subscriptions.json +1 -0
  51. data/test/fixtures/list_users.json +1 -0
  52. data/test/fixtures/lists.json +1 -0
  53. data/test/fixtures/memberships.json +1 -0
  54. data/test/fixtures/mentions.json +1 -0
  55. data/test/fixtures/not_found.json +1 -0
  56. data/test/fixtures/people_search.json +39 -0
  57. data/test/fixtures/rate_limit_exceeded.json +1 -0
  58. data/test/fixtures/report_spam.json +41 -0
  59. data/test/fixtures/retweet.json +1 -0
  60. data/test/fixtures/retweeted_by_me.json +1 -0
  61. data/test/fixtures/retweeted_to_me.json +1 -0
  62. data/test/fixtures/retweeters_of_tweet.json +166 -0
  63. data/test/fixtures/retweets.json +1 -0
  64. data/test/fixtures/retweets_of_me.json +1 -0
  65. data/test/fixtures/sample-image.png +0 -0
  66. data/test/fixtures/saved_search.json +7 -0
  67. data/test/fixtures/saved_searches.json +16 -0
  68. data/test/fixtures/search.json +1 -0
  69. data/test/fixtures/search_from_jnunemaker.json +1 -0
  70. data/test/fixtures/status.json +1 -0
  71. data/test/fixtures/status_show.json +1 -0
  72. data/test/fixtures/trends_available.json +253 -0
  73. data/test/fixtures/trends_current.json +1 -0
  74. data/test/fixtures/trends_current_exclude.json +1 -0
  75. data/test/fixtures/trends_daily.json +1925 -0
  76. data/test/fixtures/trends_daily_date.json +1 -0
  77. data/test/fixtures/trends_daily_exclude.json +1 -0
  78. data/test/fixtures/trends_location.json +57 -0
  79. data/test/fixtures/trends_weekly.json +1 -0
  80. data/test/fixtures/trends_weekly_date.json +1 -0
  81. data/test/fixtures/trends_weekly_exclude.json +1 -0
  82. data/test/fixtures/unauthorized.json +1 -0
  83. data/test/fixtures/update_profile_background_image.json +1 -0
  84. data/test/fixtures/update_profile_image.json +1 -0
  85. data/test/fixtures/user.json +1 -0
  86. data/test/fixtures/user_timeline.json +710 -0
  87. data/test/fixtures/users.json +1 -0
  88. data/test/test_helper.rb +47 -0
  89. data/test/twitter/base_test.rb +426 -0
  90. data/test/twitter/geo_test.rb +79 -0
  91. data/test/twitter/httpauth_test.rb +86 -0
  92. data/test/twitter/oauth_test.rb +108 -0
  93. data/test/twitter/request_test.rb +217 -0
  94. data/test/twitter/search_test.rb +208 -0
  95. data/test/twitter/trends_test.rb +112 -0
  96. data/test/twitter_test.rb +106 -0
  97. metadata +328 -0
@@ -0,0 +1,208 @@
1
+ require 'test_helper'
2
+
3
+ class SearchTest < Test::Unit::TestCase
4
+ context "searching" do
5
+ setup do
6
+ @search = Twitter::Search.new
7
+ end
8
+
9
+ should "should be able to initialize with a search term" do
10
+ Twitter::Search.new('httparty').query[:q].should include('httparty')
11
+ end
12
+
13
+ should "default user agent to Ruby Twitter Gem" do
14
+ search = Twitter::Search.new('foo')
15
+ search.user_agent.should == 'Ruby Twitter Gem'
16
+ end
17
+
18
+ should "allow overriding default user agent" do
19
+ search = Twitter::Search.new('foo', :user_agent => 'Foobar')
20
+ search.user_agent.should == 'Foobar'
21
+ end
22
+
23
+ should "pass user agent along with headers when making request" do
24
+ Twitter::Search.expects(:get).with('http://search.twitter.com/search.json', {:format => :json, :query => {:q => 'foo'}, :headers => {'User-Agent' => 'Foobar'}})
25
+ Twitter::Search.new('foo', :user_agent => 'Foobar').fetch()
26
+ end
27
+
28
+ should "should be able to specify from" do
29
+ @search.from('jnunemaker').query[:q].should include('from:jnunemaker')
30
+ end
31
+
32
+ should "should be able to specify not from" do
33
+ @search.from('jnunemaker',true).query[:q].should include('-from:jnunemaker')
34
+ end
35
+
36
+ should "should be able to specify to" do
37
+ @search.to('jnunemaker').query[:q].should include('to:jnunemaker')
38
+ end
39
+
40
+ should "should be able to specify not to" do
41
+ @search.to('jnunemaker',true).query[:q].should include('-to:jnunemaker')
42
+ end
43
+
44
+ should "should be able to specify not referencing" do
45
+ @search.referencing('jnunemaker',true).query[:q].should include('-@jnunemaker')
46
+ end
47
+
48
+ should "should alias references to referencing" do
49
+ @search.references('jnunemaker').query[:q].should include('@jnunemaker')
50
+ end
51
+
52
+ should "should alias ref to referencing" do
53
+ @search.ref('jnunemaker').query[:q].should include('@jnunemaker')
54
+ end
55
+
56
+ should "should be able to specify containing" do
57
+ @search.containing('milk').query[:q].should include('milk')
58
+ end
59
+
60
+ should "should be able to specify not containing" do
61
+ @search.containing('milk',true).query[:q].should include('-milk')
62
+ end
63
+
64
+ should "should alias contains to containing" do
65
+ @search.contains('milk').query[:q].should include('milk')
66
+ end
67
+
68
+ should "should be able to specify hashed" do
69
+ @search.hashed('twitter').query[:q].should include('#twitter')
70
+ end
71
+
72
+ should "should be able to specify not hashed" do
73
+ @search.hashed('twitter',true).query[:q].should include('-#twitter')
74
+ end
75
+
76
+ should "should be able to specify the language" do
77
+ @search.lang('en')
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
+ @search.fetch()
80
+ end
81
+
82
+ should "should be able to specify the number of results per page" do
83
+ @search.per_page(25)
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
+ @search.fetch()
86
+ end
87
+
88
+ should "should be able to specify the page number" do
89
+ @search.page(20)
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
+ @search.fetch()
92
+ end
93
+
94
+ should "should be able to specify only returning results greater than an id" do
95
+ @search.since(1234)
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
+ @search.fetch()
98
+ end
99
+
100
+ should "should be able to specify since a date" do
101
+ @search.since_date('2009-04-14')
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
+ @search.fetch
104
+ end
105
+
106
+ should "should be able to specify until a date" do
107
+ @search.until_date('2009-04-14')
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
+ @search.fetch
110
+ end
111
+
112
+ should "should be able to specify geo coordinates" do
113
+ @search.geocode('40.757929', '-73.985506', '25mi')
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
+ @search.fetch()
116
+ end
117
+
118
+ should "should be able to specify max id" do
119
+ @search.max(1234)
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
+ @search.fetch()
122
+ end
123
+
124
+ should "should be able to set the phrase" do
125
+ @search.phrase("Who Dat")
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
+ @search.fetch()
128
+ end
129
+
130
+ should "should be able to set the result type" do
131
+ @search.result_type("popular")
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
+ @search.fetch()
134
+ end
135
+
136
+ should "should be able to clear the filters set" do
137
+ @search.from('jnunemaker').to('oaknd1')
138
+ @search.clear.query.should == {:q => []}
139
+ end
140
+
141
+ should "should be able to chain methods together" do
142
+ @search.from('jnunemaker').to('oaknd1').referencing('orderedlist').containing('milk').hashed('twitter').lang('en').per_page(20).since(1234).geocode('40.757929', '-73.985506', '25mi')
143
+ @search.query[:q].should == ['from:jnunemaker', 'to:oaknd1', '@orderedlist', 'milk', '#twitter']
144
+ @search.query[:lang].should == 'en'
145
+ @search.query[:rpp].should == 20
146
+ @search.query[:since_id].should == 1234
147
+ @search.query[:geocode].should == '40.757929,-73.985506,25mi'
148
+ end
149
+
150
+ context "fetching" do
151
+ setup do
152
+ stub_get('http://search.twitter.com:80/search.json?q=%40jnunemaker', 'search.json')
153
+ @search = Twitter::Search.new('@jnunemaker')
154
+ @response = @search.fetch
155
+ end
156
+
157
+ should "should return results" do
158
+ @response.results.size.should == 15
159
+ end
160
+
161
+ should "should support dot notation" do
162
+ first = @response.results.first
163
+ first.text.should == %q(Someone asked about a tweet reader. Easy to do in ruby with @jnunemaker's twitter gem and the win32-sapi gem, if you are on windows.)
164
+ first.from_user.should == 'PatParslow'
165
+ end
166
+
167
+ should "cache fetched results so multiple fetches don't keep hitting api" do
168
+ Twitter::Search.expects(:get).never
169
+ @search.fetch
170
+ end
171
+
172
+ should "rehit api if fetch is called with true" do
173
+ Twitter::Search.expects(:get).once
174
+ @search.fetch(true)
175
+ end
176
+
177
+ should "tell if another page is available" do
178
+ @search.next_page?.should == true
179
+ end
180
+
181
+ should "be able to fetch the next page" do
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
+ @search.fetch_next_page
184
+ end
185
+ end
186
+
187
+ context "iterating over results" do
188
+ setup do
189
+ stub_get('http://search.twitter.com:80/search.json?q=from%3Ajnunemaker', 'search_from_jnunemaker.json')
190
+ @search.from('jnunemaker')
191
+ end
192
+
193
+ should "work" do
194
+ @search.each { |result| result.should_not be(nil) }
195
+ end
196
+
197
+ should "work multiple times in a row" do
198
+ @search.each { |result| result.should_not be(nil) }
199
+ @search.each { |result| result.should_not be(nil) }
200
+ end
201
+ end
202
+
203
+ should "should be able to iterate over results" do
204
+ @search.respond_to?(:each).should be(true)
205
+ end
206
+ end
207
+
208
+ end
@@ -0,0 +1,112 @@
1
+ require 'test_helper'
2
+
3
+ class TrendsTest < Test::Unit::TestCase
4
+ include Twitter
5
+
6
+ context "Getting current trends" do
7
+ should "work" do
8
+ stub_get 'http://search.twitter.com:80/trends/current.json', 'trends_current.json'
9
+ trends = Trends.current
10
+ trends.size.should == 10
11
+ trends[0].name.should == '#musicmonday'
12
+ trends[0].query.should == '#musicmonday'
13
+ trends[1].name.should == '#newdivide'
14
+ trends[1].query.should == '#newdivide'
15
+ end
16
+
17
+ should "be able to exclude hashtags" do
18
+ stub_get 'http://search.twitter.com:80/trends/current.json?exclude=hashtags', 'trends_current_exclude.json'
19
+ trends = Trends.current(:exclude => 'hashtags')
20
+ trends.size.should == 10
21
+ trends[0].name.should == 'New Divide'
22
+ trends[0].query.should == %Q(\"New Divide\")
23
+ trends[1].name.should == 'Star Trek'
24
+ trends[1].query.should == %Q(\"Star Trek\")
25
+ end
26
+ end
27
+
28
+ context "Getting daily trends" do
29
+ should "work" do
30
+ stub_get 'http://search.twitter.com:80/trends/daily.json?', 'trends_daily.json'
31
+ trends = Trends.daily
32
+ trends.size.should == 480
33
+ trends[0].name.should == '#3turnoffwords'
34
+ trends[0].query.should == '#3turnoffwords'
35
+ end
36
+
37
+ should "be able to exclude hastags" do
38
+ stub_get 'http://search.twitter.com:80/trends/daily.json?exclude=hashtags', 'trends_daily_exclude.json'
39
+ trends = Trends.daily(:exclude => 'hashtags')
40
+ trends.size.should == 480
41
+ trends[0].name.should == 'Kobe'
42
+ trends[0].query.should == %Q(Kobe)
43
+ end
44
+
45
+ should "be able to get for specific date (with date string)" do
46
+ stub_get 'http://search.twitter.com:80/trends/daily.json?date=2009-05-01', 'trends_daily_date.json'
47
+ trends = Trends.daily(:date => '2009-05-01')
48
+ trends.size.should == 440
49
+ trends[0].name.should == 'Swine Flu'
50
+ trends[0].query.should == %Q(\"Swine Flu\" OR Flu)
51
+ end
52
+
53
+ should "be able to get for specific date (with date object)" do
54
+ stub_get 'http://search.twitter.com:80/trends/daily.json?date=2009-05-01', 'trends_daily_date.json'
55
+ trends = Trends.daily(:date => Date.new(2009, 5, 1))
56
+ trends.size.should == 440
57
+ trends[0].name.should == 'Swine Flu'
58
+ trends[0].query.should == %Q(\"Swine Flu\" OR Flu)
59
+ end
60
+ end
61
+
62
+ context "Getting weekly trends" do
63
+ should "work" do
64
+ stub_get 'http://search.twitter.com:80/trends/weekly.json?', 'trends_weekly.json'
65
+ trends = Trends.weekly
66
+ trends.size.should == 210
67
+ trends[0].name.should == 'Happy Mothers Day'
68
+ trends[0].query.should == %Q(\"Happy Mothers Day\" OR \"Mothers Day\")
69
+ end
70
+
71
+ should "be able to exclude hastags" do
72
+ stub_get 'http://search.twitter.com:80/trends/weekly.json?exclude=hashtags', 'trends_weekly_exclude.json'
73
+ trends = Trends.weekly(:exclude => 'hashtags')
74
+ trends.size.should == 210
75
+ trends[0].name.should == 'Happy Mothers Day'
76
+ trends[0].query.should == %Q(\"Happy Mothers Day\" OR \"Mothers Day\")
77
+ end
78
+
79
+ should "be able to get for specific date (with date string)" do
80
+ stub_get 'http://search.twitter.com:80/trends/weekly.json?date=2009-05-01', 'trends_weekly_date.json'
81
+ trends = Trends.weekly(:date => '2009-05-01')
82
+ trends.size.should == 210
83
+ trends[0].name.should == 'TGIF'
84
+ trends[0].query.should == 'TGIF'
85
+ end
86
+
87
+ should "be able to get for specific date (with date object)" do
88
+ stub_get 'http://search.twitter.com:80/trends/weekly.json?date=2009-05-01', 'trends_weekly_date.json'
89
+ trends = Trends.weekly(:date => Date.new(2009, 5, 1))
90
+ trends.size.should == 210
91
+ trends[0].name.should == 'TGIF'
92
+ trends[0].query.should == 'TGIF'
93
+ end
94
+ end
95
+
96
+ context "Getting local trends" do
97
+
98
+ should "return a list of available locations" do
99
+ stub_get 'http://api.twitter.com/1/trends/available.json?lat=33.237593417&lng=-96.960559033', 'trends_available.json'
100
+ locations = Trends.available(:lat => 33.237593417, :lng => -96.960559033)
101
+ locations.first.country.should == 'Ireland'
102
+ locations.first.placeType.code.should == 12
103
+ end
104
+
105
+ should "return a list of trends for a given location" do
106
+ stub_get 'http://api.twitter.com/1/trends/2487956.json', 'trends_location.json'
107
+ trends = Trends.for_location(2487956).first.trends
108
+ trends.last.name.should == 'Gmail'
109
+ end
110
+ end
111
+
112
+ end
@@ -0,0 +1,106 @@
1
+ require 'test_helper'
2
+
3
+ class TwitterTest < Test::Unit::TestCase
4
+ should "have firehose method for public timeline" do
5
+ stub_get('http://api.twitter.com:80/1/statuses/public_timeline.json', 'firehose.json')
6
+ hose = Twitter.firehose
7
+ hose.size.should == 20
8
+ first = hose.first
9
+ first.text.should == '#torrents Ultimativer Flirt Guide - In 10 Minuten jede Frau erobern: Ultimativer Flirt Guide - In 10 Mi.. http://tinyurl.com/d3okh4'
10
+ first.user.name.should == 'P2P Torrents'
11
+ end
12
+
13
+ should "have user method for unauthenticated calls to get a user's information" do
14
+ stub_get('http://api.twitter.com:80/1/users/show/jnunemaker.json', 'user.json')
15
+ user = Twitter.user('jnunemaker')
16
+ user.name.should == 'John Nunemaker'
17
+ user.description.should == 'Loves his wife, ruby, notre dame football and iu basketball'
18
+ end
19
+
20
+ should "have status method for unauthenticated calls to get a status" do
21
+ stub_get('http://api.twitter.com:80/1/statuses/show/1533815199.json', 'status_show.json')
22
+ status = Twitter.status(1533815199)
23
+ status.id.should == 1533815199
24
+ status.text.should == 'Eating some oatmeal and butterscotch cookies with a cold glass of milk for breakfast. Tasty!'
25
+ end
26
+
27
+ should "raise NotFound for unauthenticated calls to get a deleted or nonexistent status" do
28
+ stub_get('http://api.twitter.com:80/1/statuses/show/1.json', 'not_found.json', 404)
29
+ lambda {
30
+ Twitter.status(1)
31
+ }.should raise_error(Twitter::NotFound)
32
+ end
33
+
34
+ should "have a timeline method for unauthenticated calls to get a user's timeline" do
35
+ stub_get('http://api.twitter.com:80/1/statuses/user_timeline/jnunemaker.json', 'user_timeline.json')
36
+ statuses = Twitter.timeline('jnunemaker')
37
+ statuses.first.id.should == 1445986256
38
+ statuses.first.user.screen_name.should == 'jnunemaker'
39
+ end
40
+
41
+ should "raise Unauthorized for unauthenticated calls to get a protected user's timeline" do
42
+ stub_get('http://api.twitter.com:80/1/statuses/user_timeline/protected.json', 'unauthorized.json', 401)
43
+ lambda {
44
+ Twitter.timeline('protected')
45
+ }.should raise_error(Twitter::Unauthorized)
46
+ end
47
+
48
+ should "have friend_ids method" do
49
+ stub_get('http://api.twitter.com:80/1/friends/ids/jnunemaker.json', 'friend_ids.json')
50
+ ids = Twitter.friend_ids('jnunemaker')
51
+ ids.size.should == 161
52
+ end
53
+
54
+ should "raise Unauthorized for unauthenticated calls to get a protected user's friend_ids" do
55
+ stub_get('http://api.twitter.com:80/1/friends/ids/protected.json', 'unauthorized.json', 401)
56
+ lambda {
57
+ Twitter.friend_ids('protected')
58
+ }.should raise_error(Twitter::Unauthorized)
59
+ end
60
+
61
+ should "have follower_ids method" do
62
+ stub_get('http://api.twitter.com:80/1/followers/ids/jnunemaker.json', 'follower_ids.json')
63
+ ids = Twitter.follower_ids('jnunemaker')
64
+ ids.size.should == 1252
65
+ end
66
+
67
+ should "raise Unauthorized for unauthenticated calls to get a protected user's follower_ids" do
68
+ stub_get('http://api.twitter.com:80/1/followers/ids/protected.json', 'unauthorized.json', 401)
69
+ lambda {
70
+ Twitter.follower_ids('protected')
71
+ }.should raise_error(Twitter::Unauthorized)
72
+ end
73
+
74
+ context "when using lists" do
75
+
76
+ should "be able to view list timeline" do
77
+ stub_get('http://api.twitter.com:80/1/pengwynn/lists/rubyists/statuses.json', 'list_statuses.json')
78
+ tweets = Twitter.list_timeline('pengwynn', 'rubyists')
79
+ tweets.size.should == 20
80
+ tweets.first.id.should == 5272535583
81
+ tweets.first.user.name.should == 'John Nunemaker'
82
+ end
83
+
84
+ should "be able to limit number of tweets in list timeline" do
85
+ stub_get('http://api.twitter.com:80/1/pengwynn/lists/rubyists/statuses.json?per_page=1', 'list_statuses_1_1.json')
86
+ tweets = Twitter.list_timeline('pengwynn', 'rubyists', :per_page => 1)
87
+ tweets.size.should == 1
88
+ tweets.first.id.should == 5272535583
89
+ tweets.first.user.name.should == 'John Nunemaker'
90
+ end
91
+
92
+ should "be able to paginate through the timeline" do
93
+ stub_get('http://api.twitter.com:80/1/pengwynn/lists/rubyists/statuses.json?page=1&per_page=1', 'list_statuses_1_1.json')
94
+ stub_get('http://api.twitter.com:80/1/pengwynn/lists/rubyists/statuses.json?page=2&per_page=1', 'list_statuses_2_1.json')
95
+ tweets = Twitter.list_timeline('pengwynn', 'rubyists', { :page => 1, :per_page => 1 })
96
+ tweets.size.should == 1
97
+ tweets.first.id.should == 5272535583
98
+ tweets.first.user.name.should == 'John Nunemaker'
99
+ tweets = Twitter.list_timeline('pengwynn', 'rubyists', { :page => 2, :per_page => 1 })
100
+ tweets.size.should == 1
101
+ tweets.first.id.should == 5264324712
102
+ tweets.first.user.name.should == 'John Nunemaker'
103
+ end
104
+
105
+ end
106
+ end
metadata ADDED
@@ -0,0 +1,328 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rorra-twitter
3
+ version: !ruby/object:Gem::Version
4
+ hash: 41
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 9
9
+ - 9
10
+ version: 0.9.9
11
+ platform: ruby
12
+ authors:
13
+ - John Nunemaker
14
+ - Wynn Netherland
15
+ - Rodrigo Dominguez
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2010-09-14 00:00:00 -03:00
21
+ default_executable:
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
24
+ name: oauth
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ hash: 13
32
+ segments:
33
+ - 0
34
+ - 4
35
+ - 1
36
+ version: 0.4.1
37
+ type: :runtime
38
+ version_requirements: *id001
39
+ - !ruby/object:Gem::Dependency
40
+ name: hashie
41
+ prerelease: false
42
+ requirement: &id002 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ hash: 23
48
+ segments:
49
+ - 0
50
+ - 2
51
+ - 0
52
+ version: 0.2.0
53
+ type: :runtime
54
+ version_requirements: *id002
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ prerelease: false
58
+ requirement: &id003 !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ hash: 11
64
+ segments:
65
+ - 0
66
+ - 5
67
+ - 0
68
+ version: 0.5.0
69
+ type: :runtime
70
+ version_requirements: *id003
71
+ - !ruby/object:Gem::Dependency
72
+ name: yajl-ruby
73
+ prerelease: false
74
+ requirement: &id004 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ hash: 3
80
+ segments:
81
+ - 0
82
+ - 7
83
+ - 0
84
+ version: 0.7.0
85
+ type: :runtime
86
+ version_requirements: *id004
87
+ - !ruby/object:Gem::Dependency
88
+ name: shoulda
89
+ prerelease: false
90
+ requirement: &id005 !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ hash: 39
96
+ segments:
97
+ - 2
98
+ - 10
99
+ - 0
100
+ version: 2.10.0
101
+ type: :development
102
+ version_requirements: *id005
103
+ - !ruby/object:Gem::Dependency
104
+ name: jnunemaker-matchy
105
+ prerelease: false
106
+ requirement: &id006 !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ~>
110
+ - !ruby/object:Gem::Version
111
+ hash: 15
112
+ segments:
113
+ - 0
114
+ - 4
115
+ - 0
116
+ version: 0.4.0
117
+ type: :development
118
+ version_requirements: *id006
119
+ - !ruby/object:Gem::Dependency
120
+ name: mocha
121
+ prerelease: false
122
+ requirement: &id007 !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ~>
126
+ - !ruby/object:Gem::Version
127
+ hash: 59
128
+ segments:
129
+ - 0
130
+ - 9
131
+ - 0
132
+ version: 0.9.0
133
+ type: :development
134
+ version_requirements: *id007
135
+ - !ruby/object:Gem::Dependency
136
+ name: fakeweb
137
+ prerelease: false
138
+ requirement: &id008 !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ~>
142
+ - !ruby/object:Gem::Version
143
+ hash: 31
144
+ segments:
145
+ - 1
146
+ - 2
147
+ - 0
148
+ version: 1.2.0
149
+ type: :development
150
+ version_requirements: *id008
151
+ - !ruby/object:Gem::Dependency
152
+ name: redgreen
153
+ prerelease: false
154
+ requirement: &id009 !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ~>
158
+ - !ruby/object:Gem::Version
159
+ hash: 27
160
+ segments:
161
+ - 1
162
+ - 2
163
+ - 2
164
+ version: 1.2.2
165
+ type: :development
166
+ version_requirements: *id009
167
+ description:
168
+ email: rorra@rorra.com.ar
169
+ executables: []
170
+
171
+ extensions: []
172
+
173
+ extra_rdoc_files:
174
+ - README.rdoc
175
+ files:
176
+ - History
177
+ - License
178
+ - Notes
179
+ - README.rdoc
180
+ - Rakefile
181
+ - VERSION.yml
182
+ - examples/connect.rb
183
+ - examples/friendship_existence.rb
184
+ - examples/helpers/config_store.rb
185
+ - examples/httpauth.rb
186
+ - examples/ids.rb
187
+ - examples/lists.rb
188
+ - examples/oauth.rb
189
+ - examples/search.rb
190
+ - examples/timeline.rb
191
+ - examples/tumblr.rb
192
+ - examples/unauthorized.rb
193
+ - examples/update.rb
194
+ - examples/user.rb
195
+ - lib/twitter.rb
196
+ - lib/twitter/base.rb
197
+ - lib/twitter/geo.rb
198
+ - lib/twitter/httpauth.rb
199
+ - lib/twitter/local_trends.rb
200
+ - lib/twitter/oauth.rb
201
+ - lib/twitter/request.rb
202
+ - lib/twitter/search.rb
203
+ - lib/twitter/trends.rb
204
+ - test/fixtures/blocking.json
205
+ - test/fixtures/firehose.json
206
+ - test/fixtures/follower_ids.json
207
+ - test/fixtures/followers.json
208
+ - test/fixtures/friend_ids.json
209
+ - test/fixtures/friends_timeline.json
210
+ - test/fixtures/friendship.json
211
+ - test/fixtures/friendship_exists.json
212
+ - test/fixtures/geo_place.json
213
+ - test/fixtures/geo_reverse_geocode.json
214
+ - test/fixtures/geo_reverse_geocode_granularity.json
215
+ - test/fixtures/geo_reverse_geocode_limit.json
216
+ - test/fixtures/geo_search.json
217
+ - test/fixtures/geo_search_ip_address.json
218
+ - test/fixtures/geo_search_query.json
219
+ - test/fixtures/home_timeline.json
220
+ - test/fixtures/ids.json
221
+ - test/fixtures/list.json
222
+ - test/fixtures/list_statuses.json
223
+ - test/fixtures/list_statuses_1_1.json
224
+ - test/fixtures/list_statuses_2_1.json
225
+ - test/fixtures/list_subscriptions.json
226
+ - test/fixtures/list_users.json
227
+ - test/fixtures/lists.json
228
+ - test/fixtures/memberships.json
229
+ - test/fixtures/mentions.json
230
+ - test/fixtures/not_found.json
231
+ - test/fixtures/people_search.json
232
+ - test/fixtures/rate_limit_exceeded.json
233
+ - test/fixtures/report_spam.json
234
+ - test/fixtures/retweet.json
235
+ - test/fixtures/retweeted_by_me.json
236
+ - test/fixtures/retweeted_to_me.json
237
+ - test/fixtures/retweeters_of_tweet.json
238
+ - test/fixtures/retweets.json
239
+ - test/fixtures/retweets_of_me.json
240
+ - test/fixtures/sample-image.png
241
+ - test/fixtures/saved_search.json
242
+ - test/fixtures/saved_searches.json
243
+ - test/fixtures/search.json
244
+ - test/fixtures/search_from_jnunemaker.json
245
+ - test/fixtures/status.json
246
+ - test/fixtures/status_show.json
247
+ - test/fixtures/trends_available.json
248
+ - test/fixtures/trends_current.json
249
+ - test/fixtures/trends_current_exclude.json
250
+ - test/fixtures/trends_daily.json
251
+ - test/fixtures/trends_daily_date.json
252
+ - test/fixtures/trends_daily_exclude.json
253
+ - test/fixtures/trends_location.json
254
+ - test/fixtures/trends_weekly.json
255
+ - test/fixtures/trends_weekly_date.json
256
+ - test/fixtures/trends_weekly_exclude.json
257
+ - test/fixtures/unauthorized.json
258
+ - test/fixtures/update_profile_background_image.json
259
+ - test/fixtures/update_profile_image.json
260
+ - test/fixtures/user.json
261
+ - test/fixtures/user_timeline.json
262
+ - test/fixtures/users.json
263
+ - test/test_helper.rb
264
+ - test/twitter/base_test.rb
265
+ - test/twitter/geo_test.rb
266
+ - test/twitter/httpauth_test.rb
267
+ - test/twitter/oauth_test.rb
268
+ - test/twitter/request_test.rb
269
+ - test/twitter/search_test.rb
270
+ - test/twitter/trends_test.rb
271
+ - test/twitter_test.rb
272
+ has_rdoc: true
273
+ homepage: http://github.com/rorra/twitter
274
+ licenses: []
275
+
276
+ post_install_message:
277
+ rdoc_options:
278
+ - --charset=UTF-8
279
+ require_paths:
280
+ - lib
281
+ required_ruby_version: !ruby/object:Gem::Requirement
282
+ none: false
283
+ requirements:
284
+ - - ">="
285
+ - !ruby/object:Gem::Version
286
+ hash: 3
287
+ segments:
288
+ - 0
289
+ version: "0"
290
+ required_rubygems_version: !ruby/object:Gem::Requirement
291
+ none: false
292
+ requirements:
293
+ - - ">="
294
+ - !ruby/object:Gem::Version
295
+ hash: 3
296
+ segments:
297
+ - 0
298
+ version: "0"
299
+ requirements: []
300
+
301
+ rubyforge_project:
302
+ rubygems_version: 1.3.7
303
+ signing_key:
304
+ specification_version: 3
305
+ summary: wrapper for the twitter api
306
+ test_files:
307
+ - test/test_helper.rb
308
+ - test/twitter/base_test.rb
309
+ - test/twitter/geo_test.rb
310
+ - test/twitter/httpauth_test.rb
311
+ - test/twitter/oauth_test.rb
312
+ - test/twitter/request_test.rb
313
+ - test/twitter/search_test.rb
314
+ - test/twitter/trends_test.rb
315
+ - test/twitter_test.rb
316
+ - examples/connect.rb
317
+ - examples/friendship_existence.rb
318
+ - examples/helpers/config_store.rb
319
+ - examples/httpauth.rb
320
+ - examples/ids.rb
321
+ - examples/lists.rb
322
+ - examples/oauth.rb
323
+ - examples/search.rb
324
+ - examples/timeline.rb
325
+ - examples/tumblr.rb
326
+ - examples/unauthorized.rb
327
+ - examples/update.rb
328
+ - examples/user.rb