gilesbowkett-twitter 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/History +126 -0
  2. data/License +19 -0
  3. data/Manifest +69 -0
  4. data/README +84 -0
  5. data/Rakefile +42 -0
  6. data/bin/twitter +14 -0
  7. data/examples/blocks.rb +15 -0
  8. data/examples/direct_messages.rb +29 -0
  9. data/examples/favorites.rb +20 -0
  10. data/examples/friends_followers.rb +25 -0
  11. data/examples/friendships.rb +13 -0
  12. data/examples/identica_timeline.rb +7 -0
  13. data/examples/location.rb +8 -0
  14. data/examples/posting.rb +9 -0
  15. data/examples/replies.rb +27 -0
  16. data/examples/search.rb +18 -0
  17. data/examples/sent_messages.rb +27 -0
  18. data/examples/timeline.rb +34 -0
  19. data/examples/twitter.rb +27 -0
  20. data/examples/verify_credentials.rb +13 -0
  21. data/lib/twitter/base.rb +284 -0
  22. data/lib/twitter/cli/config.rb +9 -0
  23. data/lib/twitter/cli/helpers.rb +109 -0
  24. data/lib/twitter/cli/migrations/20080722194500_create_accounts.rb +13 -0
  25. data/lib/twitter/cli/migrations/20080722194508_create_tweets.rb +16 -0
  26. data/lib/twitter/cli/migrations/20080722214605_add_account_id_to_tweets.rb +9 -0
  27. data/lib/twitter/cli/migrations/20080722214606_create_configurations.rb +13 -0
  28. data/lib/twitter/cli/models/account.rb +33 -0
  29. data/lib/twitter/cli/models/configuration.rb +13 -0
  30. data/lib/twitter/cli/models/tweet.rb +20 -0
  31. data/lib/twitter/cli.rb +334 -0
  32. data/lib/twitter/direct_message.rb +30 -0
  33. data/lib/twitter/easy_class_maker.rb +43 -0
  34. data/lib/twitter/rate_limit_status.rb +19 -0
  35. data/lib/twitter/search.rb +101 -0
  36. data/lib/twitter/search_result.rb +83 -0
  37. data/lib/twitter/search_result_info.rb +82 -0
  38. data/lib/twitter/status.rb +22 -0
  39. data/lib/twitter/user.rb +37 -0
  40. data/lib/twitter/version.rb +3 -0
  41. data/lib/twitter.rb +32 -0
  42. data/spec/base_spec.rb +139 -0
  43. data/spec/cli/helper_spec.rb +49 -0
  44. data/spec/direct_message_spec.rb +40 -0
  45. data/spec/fixtures/follower_ids.xml +11 -0
  46. data/spec/fixtures/followers.xml +706 -0
  47. data/spec/fixtures/friend_ids.xml +12 -0
  48. data/spec/fixtures/friends.xml +609 -0
  49. data/spec/fixtures/friends_for.xml +584 -0
  50. data/spec/fixtures/friends_lite.xml +192 -0
  51. data/spec/fixtures/friends_timeline.xml +66 -0
  52. data/spec/fixtures/friendship_already_exists.xml +5 -0
  53. data/spec/fixtures/friendship_created.xml +12 -0
  54. data/spec/fixtures/public_timeline.xml +148 -0
  55. data/spec/fixtures/rate_limit_status.xml +7 -0
  56. data/spec/fixtures/search_result_info.yml +147 -0
  57. data/spec/fixtures/search_results.json +1 -0
  58. data/spec/fixtures/status.xml +25 -0
  59. data/spec/fixtures/user.xml +38 -0
  60. data/spec/fixtures/user_timeline.xml +465 -0
  61. data/spec/search_spec.rb +100 -0
  62. data/spec/spec.opts +1 -0
  63. data/spec/spec_helper.rb +23 -0
  64. data/spec/status_spec.rb +40 -0
  65. data/spec/user_spec.rb +42 -0
  66. data/twitter.gemspec +45 -0
  67. data/website/css/common.css +47 -0
  68. data/website/images/terminal_output.png +0 -0
  69. data/website/index.html +147 -0
  70. metadata +188 -0
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <user>
3
+ <id>4243</id>
4
+ <name>John Nunemaker</name>
5
+ <screen_name>jnunemaker</screen_name>
6
+ <location>Indiana</location>
7
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
8
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
9
+ <url>http://addictedtonew.com</url>
10
+ <protected>false</protected>
11
+ <followers_count>363</followers_count>
12
+ <profile_background_color>FFFFFF</profile_background_color>
13
+ <profile_text_color>000000</profile_text_color>
14
+
15
+ <profile_link_color>000000</profile_link_color>
16
+ <profile_sidebar_fill_color>FD8C19</profile_sidebar_fill_color>
17
+ <profile_sidebar_border_color>F82500</profile_sidebar_border_color>
18
+ <friends_count>109</friends_count>
19
+ <created_at>Sun Aug 13 22:56:06 +0000 2006</created_at>
20
+ <favourites_count>18</favourites_count>
21
+ <utc_offset>-18000</utc_offset>
22
+ <time_zone>Indiana (East)</time_zone>
23
+ <profile_background_image_url>http://s3.amazonaws.com/twitter_production/profile_background_images/2349547/logo.jpg</profile_background_image_url>
24
+ <profile_background_tile>false</profile_background_tile>
25
+ <following>false</following>
26
+ <notifications>false</notifications>
27
+ <statuses_count>1981</statuses_count>
28
+ <status>
29
+ <created_at>Sun May 04 21:59:52 +0000 2008</created_at>
30
+ <id>803435310</id>
31
+ <text>Writing tests (rspec) for the twitter gem that all can run. Wish I would have done this when I wrote it years back.</text>
32
+ <source>&lt;a href="http://iconfactory.com/software/twitterrific"&gt;twitterrific&lt;/a&gt;</source>
33
+ <truncated>false</truncated>
34
+ <in_reply_to_status_id></in_reply_to_status_id>
35
+ <in_reply_to_user_id></in_reply_to_user_id>
36
+ <favorited>false</favorited>
37
+ </status>
38
+ </user>
@@ -0,0 +1,465 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <statuses type="array">
3
+ <status>
4
+ <created_at>Sun May 04 21:59:52 +0000 2008</created_at>
5
+ <id>803435310</id>
6
+ <text>Writing tests (rspec) for the twitter gem that all can run. Wish I would have done this when I wrote it years back.</text>
7
+ <source>&lt;a href="http://iconfactory.com/software/twitterrific"&gt;twitterrific&lt;/a&gt;</source>
8
+
9
+ <truncated>false</truncated>
10
+ <in_reply_to_status_id></in_reply_to_status_id>
11
+ <in_reply_to_user_id></in_reply_to_user_id>
12
+ <favorited>false</favorited>
13
+ <user>
14
+ <id>4243</id>
15
+ <name>John Nunemaker</name>
16
+
17
+ <screen_name>jnunemaker</screen_name>
18
+ <location>Indiana</location>
19
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
20
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
21
+ <url>http://addictedtonew.com</url>
22
+ <protected>false</protected>
23
+
24
+ <followers_count>363</followers_count>
25
+ </user>
26
+ </status>
27
+ <status>
28
+ <created_at>Sun May 04 17:46:45 +0000 2008</created_at>
29
+ <id>803313859</id>
30
+ <text>recracking iphone cause i love me some mobilescrobbler, among other things.</text>
31
+
32
+ <source>&lt;a href="http://iconfactory.com/software/twitterrific"&gt;twitterrific&lt;/a&gt;</source>
33
+ <truncated>false</truncated>
34
+ <in_reply_to_status_id></in_reply_to_status_id>
35
+ <in_reply_to_user_id></in_reply_to_user_id>
36
+ <favorited>false</favorited>
37
+ <user>
38
+
39
+ <id>4243</id>
40
+ <name>John Nunemaker</name>
41
+ <screen_name>jnunemaker</screen_name>
42
+ <location>Indiana</location>
43
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
44
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
45
+
46
+ <url>http://addictedtonew.com</url>
47
+ <protected>false</protected>
48
+ <followers_count>363</followers_count>
49
+ </user>
50
+ </status>
51
+ <status>
52
+ <created_at>Sun May 04 17:16:47 +0000 2008</created_at>
53
+
54
+ <id>803298454</id>
55
+ <text>Nervously restoring my iphone. First time. Need to try out @jnewland's fireeagle auto updates.</text>
56
+ <source>&lt;a href="http://iconfactory.com/software/twitterrific"&gt;twitterrific&lt;/a&gt;</source>
57
+ <truncated>false</truncated>
58
+ <in_reply_to_status_id></in_reply_to_status_id>
59
+ <in_reply_to_user_id></in_reply_to_user_id>
60
+
61
+ <favorited>false</favorited>
62
+ <user>
63
+ <id>4243</id>
64
+ <name>John Nunemaker</name>
65
+ <screen_name>jnunemaker</screen_name>
66
+ <location>Indiana</location>
67
+
68
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
69
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
70
+ <url>http://addictedtonew.com</url>
71
+ <protected>false</protected>
72
+ <followers_count>363</followers_count>
73
+ </user>
74
+
75
+ </status>
76
+ <status>
77
+ <created_at>Sun May 04 04:48:47 +0000 2008</created_at>
78
+ <id>803010119</id>
79
+ <text>memcache is sweet. i'm amazed i haven't played with it for this long.</text>
80
+ <source>&lt;a href="http://iconfactory.com/software/twitterrific"&gt;twitterrific&lt;/a&gt;</source>
81
+
82
+ <truncated>false</truncated>
83
+ <in_reply_to_status_id></in_reply_to_status_id>
84
+ <in_reply_to_user_id></in_reply_to_user_id>
85
+ <favorited>false</favorited>
86
+ <user>
87
+ <id>4243</id>
88
+ <name>John Nunemaker</name>
89
+
90
+ <screen_name>jnunemaker</screen_name>
91
+ <location>Indiana</location>
92
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
93
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
94
+ <url>http://addictedtonew.com</url>
95
+ <protected>false</protected>
96
+
97
+ <followers_count>363</followers_count>
98
+ </user>
99
+ </status>
100
+ <status>
101
+ <created_at>Sat May 03 21:45:41 +0000 2008</created_at>
102
+ <id>802827613</id>
103
+ <text>Headed to steak and ale with steph to meet college roommate and his wife for dinner.</text>
104
+
105
+ <source>&lt;a href="http://iconfactory.com/software/twitterrific"&gt;twitterrific&lt;/a&gt;</source>
106
+ <truncated>false</truncated>
107
+ <in_reply_to_status_id></in_reply_to_status_id>
108
+ <in_reply_to_user_id></in_reply_to_user_id>
109
+ <favorited>false</favorited>
110
+ <user>
111
+
112
+ <id>4243</id>
113
+ <name>John Nunemaker</name>
114
+ <screen_name>jnunemaker</screen_name>
115
+ <location>Indiana</location>
116
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
117
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
118
+
119
+ <url>http://addictedtonew.com</url>
120
+ <protected>false</protected>
121
+ <followers_count>363</followers_count>
122
+ </user>
123
+ </status>
124
+ <status>
125
+ <created_at>Sat May 03 19:54:59 +0000 2008</created_at>
126
+
127
+ <id>802778602</id>
128
+ <text>Ruthlessly cleaning my desk. Zero clutter goal from here on out.</text>
129
+ <source>&lt;a href="http://help.twitter.com/index.php?pg=kb.page&amp;id=75"&gt;txt&lt;/a&gt;</source>
130
+ <truncated>false</truncated>
131
+ <in_reply_to_status_id></in_reply_to_status_id>
132
+
133
+ <in_reply_to_user_id></in_reply_to_user_id>
134
+ <favorited>false</favorited>
135
+ <user>
136
+ <id>4243</id>
137
+ <name>John Nunemaker</name>
138
+ <screen_name>jnunemaker</screen_name>
139
+ <location>Indiana</location>
140
+
141
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
142
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
143
+ <url>http://addictedtonew.com</url>
144
+ <protected>false</protected>
145
+ <followers_count>363</followers_count>
146
+ </user>
147
+
148
+ </status>
149
+ <status>
150
+ <created_at>Sat May 03 18:20:17 +0000 2008</created_at>
151
+ <id>802734033</id>
152
+ <text>@mattklawitter i'm jealous. hit a 3 for me.</text>
153
+ <source>&lt;a href="http://iconfactory.com/software/twitterrific"&gt;twitterrific&lt;/a&gt;</source>
154
+
155
+ <truncated>false</truncated>
156
+ <in_reply_to_status_id>802733703</in_reply_to_status_id>
157
+ <in_reply_to_user_id>13647</in_reply_to_user_id>
158
+ <favorited>false</favorited>
159
+ <user>
160
+ <id>4243</id>
161
+
162
+ <name>John Nunemaker</name>
163
+ <screen_name>jnunemaker</screen_name>
164
+ <location>Indiana</location>
165
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
166
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
167
+ <url>http://addictedtonew.com</url>
168
+
169
+ <protected>false</protected>
170
+ <followers_count>363</followers_count>
171
+ </user>
172
+ </status>
173
+ <status>
174
+ <created_at>Sat May 03 17:28:09 +0000 2008</created_at>
175
+ <id>802707224</id>
176
+
177
+ <text>Home. Doing a bit of freelance catch up.</text>
178
+ <source>&lt;a href="http://iconfactory.com/software/twitterrific"&gt;twitterrific&lt;/a&gt;</source>
179
+ <truncated>false</truncated>
180
+ <in_reply_to_status_id></in_reply_to_status_id>
181
+ <in_reply_to_user_id></in_reply_to_user_id>
182
+ <favorited>false</favorited>
183
+
184
+ <user>
185
+ <id>4243</id>
186
+ <name>John Nunemaker</name>
187
+ <screen_name>jnunemaker</screen_name>
188
+ <location>Indiana</location>
189
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
190
+
191
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
192
+ <url>http://addictedtonew.com</url>
193
+ <protected>false</protected>
194
+ <followers_count>363</followers_count>
195
+ </user>
196
+ </status>
197
+ <status>
198
+
199
+ <created_at>Sat May 03 17:08:24 +0000 2008</created_at>
200
+ <id>802696808</id>
201
+ <text>Target with steph. No luck.</text>
202
+ <source>&lt;a href="http://help.twitter.com/index.php?pg=kb.page&amp;id=75"&gt;txt&lt;/a&gt;</source>
203
+ <truncated>false</truncated>
204
+
205
+ <in_reply_to_status_id></in_reply_to_status_id>
206
+ <in_reply_to_user_id></in_reply_to_user_id>
207
+ <favorited>false</favorited>
208
+ <user>
209
+ <id>4243</id>
210
+ <name>John Nunemaker</name>
211
+ <screen_name>jnunemaker</screen_name>
212
+
213
+ <location>Indiana</location>
214
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
215
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
216
+ <url>http://addictedtonew.com</url>
217
+ <protected>false</protected>
218
+ <followers_count>363</followers_count>
219
+
220
+ </user>
221
+ </status>
222
+ <status>
223
+ <created_at>Sat May 03 01:26:00 +0000 2008</created_at>
224
+ <id>802316223</id>
225
+ <text>@lizsmc1 we have a tornado warning right now? where was sighting?</text>
226
+ <source>&lt;a href="http://iconfactory.com/software/twitterrific"&gt;twitterrific&lt;/a&gt;</source>
227
+
228
+ <truncated>false</truncated>
229
+ <in_reply_to_status_id>802314575</in_reply_to_status_id>
230
+ <in_reply_to_user_id>11485452</in_reply_to_user_id>
231
+ <favorited>false</favorited>
232
+ <user>
233
+ <id>4243</id>
234
+
235
+ <name>John Nunemaker</name>
236
+ <screen_name>jnunemaker</screen_name>
237
+ <location>Indiana</location>
238
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
239
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
240
+ <url>http://addictedtonew.com</url>
241
+
242
+ <protected>false</protected>
243
+ <followers_count>363</followers_count>
244
+ </user>
245
+ </status>
246
+ <status>
247
+ <created_at>Fri May 02 22:48:52 +0000 2008</created_at>
248
+ <id>802237608</id>
249
+
250
+ <text>Mishawaka brewing company.</text>
251
+ <source>&lt;a href="http://help.twitter.com/index.php?pg=kb.page&amp;id=75"&gt;txt&lt;/a&gt;</source>
252
+ <truncated>false</truncated>
253
+ <in_reply_to_status_id></in_reply_to_status_id>
254
+ <in_reply_to_user_id></in_reply_to_user_id>
255
+ <favorited>false</favorited>
256
+
257
+ <user>
258
+ <id>4243</id>
259
+ <name>John Nunemaker</name>
260
+ <screen_name>jnunemaker</screen_name>
261
+ <location>Indiana</location>
262
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
263
+
264
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
265
+ <url>http://addictedtonew.com</url>
266
+ <protected>false</protected>
267
+ <followers_count>363</followers_count>
268
+ </user>
269
+ </status>
270
+
271
+ <status>
272
+ <created_at>Fri May 02 18:06:57 +0000 2008</created_at>
273
+ <id>802062302</id>
274
+ <text>Trim time. It's like hammer time but with trim.</text>
275
+ <source>&lt;a href="http://help.twitter.com/index.php?pg=kb.page&amp;id=75"&gt;txt&lt;/a&gt;</source>
276
+
277
+ <truncated>false</truncated>
278
+ <in_reply_to_status_id></in_reply_to_status_id>
279
+ <in_reply_to_user_id></in_reply_to_user_id>
280
+ <favorited>false</favorited>
281
+ <user>
282
+ <id>4243</id>
283
+ <name>John Nunemaker</name>
284
+
285
+ <screen_name>jnunemaker</screen_name>
286
+ <location>Indiana</location>
287
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
288
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
289
+ <url>http://addictedtonew.com</url>
290
+ <protected>false</protected>
291
+
292
+ <followers_count>363</followers_count>
293
+ </user>
294
+ </status>
295
+ <status>
296
+ <created_at>Fri May 02 15:34:27 +0000 2008</created_at>
297
+ <id>801951791</id>
298
+ <text>Window shimming.</text>
299
+
300
+ <source>&lt;a href="http://help.twitter.com/index.php?pg=kb.page&amp;id=75"&gt;txt&lt;/a&gt;</source>
301
+ <truncated>false</truncated>
302
+ <in_reply_to_status_id></in_reply_to_status_id>
303
+ <in_reply_to_user_id></in_reply_to_user_id>
304
+ <favorited>false</favorited>
305
+ <user>
306
+
307
+ <id>4243</id>
308
+ <name>John Nunemaker</name>
309
+ <screen_name>jnunemaker</screen_name>
310
+ <location>Indiana</location>
311
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
312
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
313
+
314
+ <url>http://addictedtonew.com</url>
315
+ <protected>false</protected>
316
+ <followers_count>363</followers_count>
317
+ </user>
318
+ </status>
319
+ <status>
320
+ <created_at>Fri May 02 15:14:33 +0000 2008</created_at>
321
+
322
+ <id>801937014</id>
323
+ <text>Lowes for more supplies. Wish it wasn't raining.</text>
324
+ <source>&lt;a href="http://help.twitter.com/index.php?pg=kb.page&amp;id=75"&gt;txt&lt;/a&gt;</source>
325
+ <truncated>false</truncated>
326
+ <in_reply_to_status_id></in_reply_to_status_id>
327
+
328
+ <in_reply_to_user_id></in_reply_to_user_id>
329
+ <favorited>false</favorited>
330
+ <user>
331
+ <id>4243</id>
332
+ <name>John Nunemaker</name>
333
+ <screen_name>jnunemaker</screen_name>
334
+ <location>Indiana</location>
335
+
336
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
337
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
338
+ <url>http://addictedtonew.com</url>
339
+ <protected>false</protected>
340
+ <followers_count>363</followers_count>
341
+ </user>
342
+
343
+ </status>
344
+ <status>
345
+ <created_at>Fri May 02 14:22:52 +0000 2008</created_at>
346
+ <id>801898311</id>
347
+ <text>Holding a new window in place while Brady gets nails.</text>
348
+ <source>&lt;a href="http://help.twitter.com/index.php?pg=kb.page&amp;id=75"&gt;txt&lt;/a&gt;</source>
349
+
350
+ <truncated>false</truncated>
351
+ <in_reply_to_status_id></in_reply_to_status_id>
352
+ <in_reply_to_user_id></in_reply_to_user_id>
353
+ <favorited>false</favorited>
354
+ <user>
355
+ <id>4243</id>
356
+ <name>John Nunemaker</name>
357
+
358
+ <screen_name>jnunemaker</screen_name>
359
+ <location>Indiana</location>
360
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
361
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
362
+ <url>http://addictedtonew.com</url>
363
+ <protected>false</protected>
364
+
365
+ <followers_count>363</followers_count>
366
+ </user>
367
+ </status>
368
+ <status>
369
+ <created_at>Fri May 02 13:24:41 +0000 2008</created_at>
370
+ <id>801857351</id>
371
+ <text>@mwklawit yes. yes. yes.</text>
372
+
373
+ <source>&lt;a href="http://iconfactory.com/software/twitterrific"&gt;twitterrific&lt;/a&gt;</source>
374
+ <truncated>false</truncated>
375
+ <in_reply_to_status_id>801846483</in_reply_to_status_id>
376
+ <in_reply_to_user_id>3672651</in_reply_to_user_id>
377
+ <favorited>false</favorited>
378
+
379
+ <user>
380
+ <id>4243</id>
381
+ <name>John Nunemaker</name>
382
+ <screen_name>jnunemaker</screen_name>
383
+ <location>Indiana</location>
384
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
385
+
386
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
387
+ <url>http://addictedtonew.com</url>
388
+ <protected>false</protected>
389
+ <followers_count>363</followers_count>
390
+ </user>
391
+ </status>
392
+ <status>
393
+
394
+ <created_at>Fri May 02 09:11:58 +0000 2008</created_at>
395
+ <id>801737962</id>
396
+ <text>Ironman == AWESOME!!!</text>
397
+ <source>&lt;a href="http://help.twitter.com/index.php?pg=kb.page&amp;id=75"&gt;txt&lt;/a&gt;</source>
398
+ <truncated>false</truncated>
399
+
400
+ <in_reply_to_status_id></in_reply_to_status_id>
401
+ <in_reply_to_user_id></in_reply_to_user_id>
402
+ <favorited>false</favorited>
403
+ <user>
404
+ <id>4243</id>
405
+ <name>John Nunemaker</name>
406
+ <screen_name>jnunemaker</screen_name>
407
+
408
+ <location>Indiana</location>
409
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
410
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
411
+ <url>http://addictedtonew.com</url>
412
+ <protected>false</protected>
413
+ <followers_count>363</followers_count>
414
+
415
+ </user>
416
+ </status>
417
+ <status>
418
+ <created_at>Fri May 02 04:44:19 +0000 2008</created_at>
419
+ <id>801654740</id>
420
+ <text>Never been at a movie with more clapping by the audience.</text>
421
+ <source>&lt;a href="http://help.twitter.com/index.php?pg=kb.page&amp;id=75"&gt;txt&lt;/a&gt;</source>
422
+
423
+ <truncated>false</truncated>
424
+ <in_reply_to_status_id></in_reply_to_status_id>
425
+ <in_reply_to_user_id></in_reply_to_user_id>
426
+ <favorited>false</favorited>
427
+ <user>
428
+ <id>4243</id>
429
+ <name>John Nunemaker</name>
430
+
431
+ <screen_name>jnunemaker</screen_name>
432
+ <location>Indiana</location>
433
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
434
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
435
+ <url>http://addictedtonew.com</url>
436
+ <protected>false</protected>
437
+
438
+ <followers_count>363</followers_count>
439
+ </user>
440
+ </status>
441
+ <status>
442
+ <created_at>Fri May 02 04:25:55 +0000 2008</created_at>
443
+ <id>801648988</id>
444
+ <text>@hreview Iron Man; totally AWESOME, never seen/heard so much clapping in a movie. *****</text>
445
+
446
+ <source>web</source>
447
+ <truncated>false</truncated>
448
+ <in_reply_to_status_id>787398088</in_reply_to_status_id>
449
+ <in_reply_to_user_id>14073831</in_reply_to_user_id>
450
+ <favorited>false</favorited>
451
+ <user>
452
+
453
+ <id>4243</id>
454
+ <name>John Nunemaker</name>
455
+ <screen_name>jnunemaker</screen_name>
456
+ <location>Indiana</location>
457
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
458
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
459
+
460
+ <url>http://addictedtonew.com</url>
461
+ <protected>false</protected>
462
+ <followers_count>363</followers_count>
463
+ </user>
464
+ </status>
465
+ </statuses>
@@ -0,0 +1,100 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe Twitter::Search do
4
+ before do
5
+ @search = Twitter::Search.new
6
+ end
7
+
8
+ it "should be able to initialize with a search term" do
9
+ Twitter::Search.new('httparty').query[:q].should include('httparty')
10
+ end
11
+
12
+ it "should be able to specify from" do
13
+ @search.from('jnunemaker').query[:q].should include('from:jnunemaker')
14
+ end
15
+
16
+ it "should be able to specify to" do
17
+ @search.to('jnunemaker').query[:q].should include('to:jnunemaker')
18
+ end
19
+
20
+ it "should be able to specify referencing" do
21
+ @search.referencing('jnunemaker').query[:q].should include('@jnunemaker')
22
+ end
23
+
24
+ it "should alias references to referencing" do
25
+ @search.references('jnunemaker').query[:q].should include('@jnunemaker')
26
+ end
27
+
28
+ it "should alias ref to referencing" do
29
+ @search.ref('jnunemaker').query[:q].should include('@jnunemaker')
30
+ end
31
+
32
+ it "should be able to specify containing" do
33
+ @search.containing('milk').query[:q].should include('milk')
34
+ end
35
+
36
+ it "should alias contains to containing" do
37
+ @search.contains('milk').query[:q].should include('milk')
38
+ end
39
+
40
+ it "should be able to specify hashed" do
41
+ @search.hashed('twitter').query[:q].should include('#twitter')
42
+ end
43
+
44
+ it "should be able to specify the language" do
45
+ @search.lang('en').query[:lang].should == 'en'
46
+ end
47
+
48
+ it "should be able to specify the number of results per page" do
49
+ @search.per_page(25).query[:rpp].should == 25
50
+ end
51
+
52
+ it "should be able to specify the page number" do
53
+ @search.page(20).query[:page].should == 20
54
+ end
55
+
56
+ it "should be able to specify only returning results greater than an id" do
57
+ @search.since(1234).query[:since_id].should == 1234
58
+ end
59
+
60
+ it "should be able to specify geo coordinates" do
61
+ @search.geocode('40.757929', '-73.985506', '25mi').query[:geocode].should == '40.757929,-73.985506,25mi'
62
+ end
63
+
64
+ it "should be able to clear the filters set" do
65
+ @search.from('jnunemaker').to('oaknd1')
66
+ @search.clear.query.should == {:q => []}
67
+ end
68
+
69
+ it "should be able to chain methods together" do
70
+ @search.from('jnunemaker').to('oaknd1').referencing('orderedlist').containing('milk').hashed('twitter').lang('en').per_page(20).since(1234).geocode('40.757929', '-73.985506', '25mi')
71
+ @search.query[:q].should == ['from:jnunemaker', 'to:oaknd1', '@orderedlist', 'milk', '#twitter']
72
+ @search.query[:lang].should == 'en'
73
+ @search.query[:rpp].should == 20
74
+ @search.query[:since_id].should == 1234
75
+ @search.query[:geocode].should == '40.757929,-73.985506,25mi'
76
+ end
77
+
78
+ describe "fetching" do
79
+ before do
80
+ @response = YAML.load_file(File.dirname(__FILE__) + '/fixtures/search_result_info.yml')
81
+ @search.class.stub!(:get).and_return(@response)
82
+ end
83
+
84
+ it "should return results" do
85
+ @search.class.should_receive(:get).and_return(@response)
86
+ @search.from('jnunemaker').fetch().should == @response
87
+ end
88
+
89
+ it "should support dot notation" do
90
+ @search.class.should_receive(:get).and_return(@response)
91
+ info = @search.from('httparty').fetch()
92
+ info["max_id"].should == info.max_id
93
+ info["results"].first["text"].should == info.results.first.text
94
+ end
95
+ end
96
+
97
+ it "should be able to iterate over results" do
98
+ @search.respond_to?(:each).should == true
99
+ end
100
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,23 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ dir = File.dirname(__FILE__)
10
+
11
+ $:.unshift(File.join(dir, '/../lib/'))
12
+ require dir + '/../lib/twitter'
13
+
14
+
15
+ def stdout_for(&block)
16
+ # Inspired by http://www.ruby-forum.com/topic/58647
17
+ old_stdout = $stdout
18
+ $stdout = StringIO.new
19
+ yield
20
+ output = $stdout.string
21
+ $stdout = old_stdout
22
+ output
23
+ end
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe Twitter::Status do
4
+ it "should create new status from xml doc" do
5
+ xml = <<EOF
6
+ <status>
7
+ <created_at>Sun May 04 21:59:52 +0000 2008</created_at>
8
+ <id>803435310</id>
9
+ <text>Writing tests (rspec) for the twitter gem that all can run. Wish I would have done this when I wrote it years back.</text>
10
+ <source>&lt;a href="http://iconfactory.com/software/twitterrific"&gt;twitterrific&lt;/a&gt;</source>
11
+ <truncated>false</truncated>
12
+ <in_reply_to_status_id></in_reply_to_status_id>
13
+ <in_reply_to_user_id></in_reply_to_user_id>
14
+ <favorited>false</favorited>
15
+ <user>
16
+ <id>4243</id>
17
+ <name>John Nunemaker</name>
18
+ <screen_name>jnunemaker</screen_name>
19
+ <location>Indiana</location>
20
+ <description>Loves his wife, ruby, notre dame football and iu basketball</description>
21
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
22
+ <url>http://addictedtonew.com</url>
23
+ <protected>false</protected>
24
+ <followers_count>363</followers_count>
25
+ </user>
26
+ </status>
27
+ EOF
28
+ s = Twitter::Status.new_from_xml(Hpricot.XML(xml))
29
+ s.id.should == '803435310'
30
+ s.created_at.should == 'Sun May 04 21:59:52 +0000 2008'
31
+ s.text.should == 'Writing tests (rspec) for the twitter gem that all can run. Wish I would have done this when I wrote it years back.'
32
+ s.source.should == '&lt;a href="http://iconfactory.com/software/twitterrific"&gt;twitterrific&lt;/a&gt;'
33
+ s.truncated.should == false
34
+ s.in_reply_to_status_id.should == ''
35
+ s.in_reply_to_user_id.should == ''
36
+ s.favorited.should == false
37
+ s.user.id.should == '4243'
38
+ s.user.name.should == 'John Nunemaker'
39
+ end
40
+ end