joelind-twitter 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
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 +40 -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/base.rb +390 -0
  21. data/lib/twitter/geo.rb +25 -0
  22. data/lib/twitter/httpauth.rb +53 -0
  23. data/lib/twitter/local_trends.rb +30 -0
  24. data/lib/twitter/oauth.rb +85 -0
  25. data/lib/twitter/request.rb +71 -0
  26. data/lib/twitter/search.rb +163 -0
  27. data/lib/twitter/trends.rb +55 -0
  28. data/lib/twitter.rb +156 -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 +127 -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 +305 -0
@@ -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,305 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: joelind-twitter
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 9
8
+ - 9
9
+ version: 0.9.9
10
+ platform: ruby
11
+ authors:
12
+ - John Nunemaker
13
+ - Wynn Netherland
14
+ - Joe Lind
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-07-15 00:00:00 -04:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: oauth
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 0
31
+ - 4
32
+ - 1
33
+ version: 0.4.1
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: hashie
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 0
45
+ - 2
46
+ - 0
47
+ version: 0.2.0
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: httparty
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ - 6
60
+ - 1
61
+ version: 0.6.1
62
+ type: :runtime
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: yajl-ruby
66
+ prerelease: false
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ segments:
72
+ - 0
73
+ - 7
74
+ - 0
75
+ version: 0.7.0
76
+ type: :runtime
77
+ version_requirements: *id004
78
+ - !ruby/object:Gem::Dependency
79
+ name: shoulda
80
+ prerelease: false
81
+ requirement: &id005 !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ segments:
86
+ - 2
87
+ - 10
88
+ - 0
89
+ version: 2.10.0
90
+ type: :development
91
+ version_requirements: *id005
92
+ - !ruby/object:Gem::Dependency
93
+ name: jnunemaker-matchy
94
+ prerelease: false
95
+ requirement: &id006 !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ~>
98
+ - !ruby/object:Gem::Version
99
+ segments:
100
+ - 0
101
+ - 4
102
+ - 0
103
+ version: 0.4.0
104
+ type: :development
105
+ version_requirements: *id006
106
+ - !ruby/object:Gem::Dependency
107
+ name: mocha
108
+ prerelease: false
109
+ requirement: &id007 !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ~>
112
+ - !ruby/object:Gem::Version
113
+ segments:
114
+ - 0
115
+ - 9
116
+ - 0
117
+ version: 0.9.0
118
+ type: :development
119
+ version_requirements: *id007
120
+ - !ruby/object:Gem::Dependency
121
+ name: fakeweb
122
+ prerelease: false
123
+ requirement: &id008 !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ~>
126
+ - !ruby/object:Gem::Version
127
+ segments:
128
+ - 1
129
+ - 2
130
+ - 0
131
+ version: 1.2.0
132
+ type: :development
133
+ version_requirements: *id008
134
+ - !ruby/object:Gem::Dependency
135
+ name: redgreen
136
+ prerelease: false
137
+ requirement: &id009 !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ segments:
142
+ - 1
143
+ - 2
144
+ - 2
145
+ version: 1.2.2
146
+ type: :development
147
+ version_requirements: *id009
148
+ description:
149
+ email: joelind@gmail.com
150
+ executables: []
151
+
152
+ extensions: []
153
+
154
+ extra_rdoc_files:
155
+ - README.rdoc
156
+ files:
157
+ - History
158
+ - License
159
+ - Notes
160
+ - README.rdoc
161
+ - Rakefile
162
+ - VERSION.yml
163
+ - examples/connect.rb
164
+ - examples/friendship_existence.rb
165
+ - examples/helpers/config_store.rb
166
+ - examples/httpauth.rb
167
+ - examples/ids.rb
168
+ - examples/lists.rb
169
+ - examples/oauth.rb
170
+ - examples/search.rb
171
+ - examples/timeline.rb
172
+ - examples/tumblr.rb
173
+ - examples/unauthorized.rb
174
+ - examples/update.rb
175
+ - examples/user.rb
176
+ - lib/twitter.rb
177
+ - lib/twitter/base.rb
178
+ - lib/twitter/geo.rb
179
+ - lib/twitter/httpauth.rb
180
+ - lib/twitter/local_trends.rb
181
+ - lib/twitter/oauth.rb
182
+ - lib/twitter/request.rb
183
+ - lib/twitter/search.rb
184
+ - lib/twitter/trends.rb
185
+ - test/fixtures/blocking.json
186
+ - test/fixtures/firehose.json
187
+ - test/fixtures/follower_ids.json
188
+ - test/fixtures/followers.json
189
+ - test/fixtures/friend_ids.json
190
+ - test/fixtures/friends_timeline.json
191
+ - test/fixtures/friendship.json
192
+ - test/fixtures/friendship_exists.json
193
+ - test/fixtures/geo_place.json
194
+ - test/fixtures/geo_reverse_geocode.json
195
+ - test/fixtures/geo_reverse_geocode_granularity.json
196
+ - test/fixtures/geo_reverse_geocode_limit.json
197
+ - test/fixtures/geo_search.json
198
+ - test/fixtures/geo_search_ip_address.json
199
+ - test/fixtures/geo_search_query.json
200
+ - test/fixtures/home_timeline.json
201
+ - test/fixtures/ids.json
202
+ - test/fixtures/list.json
203
+ - test/fixtures/list_statuses.json
204
+ - test/fixtures/list_statuses_1_1.json
205
+ - test/fixtures/list_statuses_2_1.json
206
+ - test/fixtures/list_subscriptions.json
207
+ - test/fixtures/list_users.json
208
+ - test/fixtures/lists.json
209
+ - test/fixtures/memberships.json
210
+ - test/fixtures/mentions.json
211
+ - test/fixtures/not_found.json
212
+ - test/fixtures/people_search.json
213
+ - test/fixtures/rate_limit_exceeded.json
214
+ - test/fixtures/report_spam.json
215
+ - test/fixtures/retweet.json
216
+ - test/fixtures/retweeted_by_me.json
217
+ - test/fixtures/retweeted_to_me.json
218
+ - test/fixtures/retweeters_of_tweet.json
219
+ - test/fixtures/retweets.json
220
+ - test/fixtures/retweets_of_me.json
221
+ - test/fixtures/sample-image.png
222
+ - test/fixtures/saved_search.json
223
+ - test/fixtures/saved_searches.json
224
+ - test/fixtures/search.json
225
+ - test/fixtures/search_from_jnunemaker.json
226
+ - test/fixtures/status.json
227
+ - test/fixtures/status_show.json
228
+ - test/fixtures/trends_available.json
229
+ - test/fixtures/trends_current.json
230
+ - test/fixtures/trends_current_exclude.json
231
+ - test/fixtures/trends_daily.json
232
+ - test/fixtures/trends_daily_date.json
233
+ - test/fixtures/trends_daily_exclude.json
234
+ - test/fixtures/trends_location.json
235
+ - test/fixtures/trends_weekly.json
236
+ - test/fixtures/trends_weekly_date.json
237
+ - test/fixtures/trends_weekly_exclude.json
238
+ - test/fixtures/unauthorized.json
239
+ - test/fixtures/update_profile_background_image.json
240
+ - test/fixtures/update_profile_image.json
241
+ - test/fixtures/user.json
242
+ - test/fixtures/user_timeline.json
243
+ - test/fixtures/users.json
244
+ - test/test_helper.rb
245
+ - test/twitter/base_test.rb
246
+ - test/twitter/geo_test.rb
247
+ - test/twitter/httpauth_test.rb
248
+ - test/twitter/oauth_test.rb
249
+ - test/twitter/request_test.rb
250
+ - test/twitter/search_test.rb
251
+ - test/twitter/trends_test.rb
252
+ - test/twitter_test.rb
253
+ has_rdoc: true
254
+ homepage: http://github.com/joelind/twitter
255
+ licenses: []
256
+
257
+ post_install_message:
258
+ rdoc_options:
259
+ - --charset=UTF-8
260
+ require_paths:
261
+ - lib
262
+ required_ruby_version: !ruby/object:Gem::Requirement
263
+ requirements:
264
+ - - ">="
265
+ - !ruby/object:Gem::Version
266
+ segments:
267
+ - 0
268
+ version: "0"
269
+ required_rubygems_version: !ruby/object:Gem::Requirement
270
+ requirements:
271
+ - - ">="
272
+ - !ruby/object:Gem::Version
273
+ segments:
274
+ - 0
275
+ version: "0"
276
+ requirements: []
277
+
278
+ rubyforge_project:
279
+ rubygems_version: 1.3.6
280
+ signing_key:
281
+ specification_version: 3
282
+ summary: wrapper for the twitter api
283
+ test_files:
284
+ - test/test_helper.rb
285
+ - test/twitter/base_test.rb
286
+ - test/twitter/geo_test.rb
287
+ - test/twitter/httpauth_test.rb
288
+ - test/twitter/oauth_test.rb
289
+ - test/twitter/request_test.rb
290
+ - test/twitter/search_test.rb
291
+ - test/twitter/trends_test.rb
292
+ - test/twitter_test.rb
293
+ - examples/connect.rb
294
+ - examples/friendship_existence.rb
295
+ - examples/helpers/config_store.rb
296
+ - examples/httpauth.rb
297
+ - examples/ids.rb
298
+ - examples/lists.rb
299
+ - examples/oauth.rb
300
+ - examples/search.rb
301
+ - examples/timeline.rb
302
+ - examples/tumblr.rb
303
+ - examples/unauthorized.rb
304
+ - examples/update.rb
305
+ - examples/user.rb