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
data/History ADDED
@@ -0,0 +1,290 @@
1
+ 0.9.8 - June 22, 2010
2
+ * Patch from @spagalloco for Geo API
3
+ * Patch from @apigee to set api_endpoint for unauthenticated calls
4
+ 0.9.7 - May 25, 2010
5
+ * Added api_endpoint option for Search
6
+ 0.9.6 - May 25, 2010
7
+ * Deprecated Basic Auth
8
+ * Added api_endpoint option for OAuth
9
+ 0.9.5 - April 21, 2010
10
+ * Saved searches (@zmoazeni)
11
+ * Patch to handle nil in .each in Search.fetch (@sferik)
12
+ * Added report_spam - Christopher Bailey
13
+ * Tests for friendship_exists? (@sferik)
14
+ * YAJL for JSON (@sferik)
15
+ * Cursors for lists (@moazeni)
16
+ 0.9.4 - March 30, 2010
17
+ * Rolled back search api endpoint to get around rate limiting issues
18
+ 0.9.3 - March 23, 2010
19
+ * Applied patch from @raykrueger for Ruby 1.8.6 compatibility
20
+ 0.9.2 - March 24, 2010
21
+ * More patches from @sferik for better authentication error handling and tests
22
+ 0.9.1 - March 23, 2010
23
+ * More patches from @sferik for bug fixes, removed rubygems dependencies, and more
24
+ 0.9.0 - March 20, 2010
25
+ * Added support for new retweeted_by and retweeted_by ids methods
26
+ * Added support for popular/recent search
27
+ * Patch from @sferik for API versioning and bulk user import
28
+ * Patch from @abozanich for search exclusions
29
+ 0.8.6 - March 11, 2010
30
+ * Patch from @dewski for httparty version
31
+ 0.8.5 - February 21, 2010
32
+ * Patch from @cyu to add fetch_next_page to search
33
+ 0.8.4 - February 11, 2010
34
+ * Added membership query options // thanks ming yeow ng
35
+ * Added support for a phrase search (instead of a group of words) from @zagari
36
+ * Added support for trends/available and trends/location
37
+ 0.8.3 - January 29, 2010
38
+ * Added patch for unauthenticated list timelines from @spastorino
39
+ 0.8.2 - January 21, 2010
40
+ * Added patch for update_profile_image from @taazza
41
+ 0.8.1 - January 12, 2010
42
+ * Added unauthenticated timeline method just for @mtodd
43
+ 0.8.0 - December 18, 2009
44
+ * Made API endpoint configurable to use services like Tumblr
45
+ 0.7.11 - December 16, 2009
46
+ * Added support for list timeline paging (patch from Chen)
47
+ 0.7.10 - December 12, 2009
48
+ * Added support for blocks/blocking
49
+ 0.7.9 - December 1, 2009
50
+ * Applied patch from ivey for retweets support
51
+ 0.7.8 - November 30, 2009
52
+ * Applied patch from ivey to use cursor with list_members
53
+ 0.7.7 - November 29, 2009
54
+ * Fixed bug when removing list members using OAuth
55
+ * Merged patch from kevn for update_profile_background
56
+ * Bumped OAuth dependency to 0.3.6
57
+ * Merged patch from rizwanreza for blocked_ids
58
+ * Merged patch from Josh Schairbaum for since_date and until_date search methods
59
+ 0.7.6 - November 25, 2009
60
+ * Patch from coderifous for home_timeline support
61
+ 0.7.5 - November 17, 2009
62
+ * Patch from hassox to swap Mash for Hashie to avoid conflicts
63
+ 0.7.4 - November 16, 2009
64
+ * Support for user search
65
+ 0.7.3 - November 5, 2009
66
+ * Support for list_subscriptions from christospappas
67
+ 0.7.2 - November 5, 2009
68
+ * Support for friendship_show from dcrec1
69
+ 0.7.1 - November 4, 2009
70
+ * Dependency changes
71
+ 0.7.0 - October 31, 2009
72
+ * Twitter lists! - based on draft API
73
+ 0.6.14 - August 16, 2009
74
+ * Lowered the oauth requirement to 0.3.4 as people are complaining about 0.3.5
75
+
76
+ 0.6.13 - July 27, 2009
77
+ * 1 minor update
78
+ * Set oauth version to >= 0.3.5 so I don't have to release new gem for each oauth update, which seems to be frequent of late
79
+
80
+ 0.6.12 - June 26, 2009
81
+ * 2 minor additions
82
+ * fixed fakeweb test issue (obie fernandez)
83
+ * added user agent option to searches
84
+
85
+ 0.6.11 - May 18, 2009
86
+ * 1 minor addition
87
+ * Added the ability to sign in with twitter instead of authorizing
88
+
89
+ 0.6.10 - May 18, 2009
90
+ * 1 cool addition
91
+ * Added full support for trends - current, daily and weekly (even allowing excluding of hashtags and for specific dates)
92
+
93
+ 0.6.9 - May 17, 2009
94
+ * 1 minor tweak
95
+ * Bumped oauth dependency version to 0.3.4.
96
+
97
+ 0.6.8 - April 23, 2009
98
+ * 1 dependency fix
99
+ * forgot to update rakefile rendering previous 0.6.7 release useless. crap!
100
+
101
+ 0.6.7 - April 23, 2009
102
+ * 1 minor fix
103
+ * Bumped httparty version to 0.4.3 which allows response.message and fixes errors that the lack of response.message was causing to the twitter gem
104
+
105
+ 0.6.6 - April 16, 2009
106
+ * 1 minor enhancement
107
+ * added ability to pass query parameters to user method
108
+ * httpauth can now accept :ssl option to use https instead of http
109
+ * Added Twitter.status method for no auth calls to fetch status
110
+ * Added Twitter.friend_ids method for no auth calls to fetch status
111
+ * Added Twitter.follower_ids method for no auth calls to fetch status
112
+
113
+ 0.6.5 - April 15, 2009
114
+ * 1 bug fix
115
+ * fixed that friend_ids and follower_ids were bombing from trying to mash them. Added :mash option to Twitter::Request so I can specifically not mash certain responses from twitter
116
+
117
+ 0.6.4 - April 14, 2009
118
+ * 1 minor tweak
119
+ * More explicit about dependency versions in gemspec and when requiring.
120
+
121
+ 0.6.3 - April 14, 2009
122
+ * 1 minor addition
123
+ * Added Twitter.user method to get user's information without authenticating
124
+
125
+ 0.6.2 - April 14, 2009
126
+ * 1 minor addition
127
+ * added max to search so you can set the max id that should be used
128
+
129
+ 0.6.1 - April 12, 2009
130
+ * 1 minor fix
131
+ * Had two friend_ids functions. Renamed one of them to follower_ids.
132
+
133
+ 0.6.0 - April 11, 2009
134
+ * 1 feature addition
135
+ * Added http authentication back in. You can now use oauth or http auth as your client.
136
+
137
+ 0.5.3 - April 10, 2009
138
+ * 1 minor fix
139
+ * Twitter API assumed follow true whether true or false. Now only sending follow along to request if follow is true for calls to friendship_create.
140
+
141
+ 0.5.2 - April 8, 2009
142
+ * 4 minor fixes
143
+ * added mash as an install dependency, forgot it initially
144
+ * fixed that search wasn't taking into account a bunch of options duh!
145
+ * fixed some missing vars and stuff in exception raising
146
+ * added development dependencies to rake file to make that more explicit (technomancy)
147
+ * lame workaround for Mash#hash that allows using return objects in sets and such (technomancy)
148
+
149
+ 0.5.1 - April 5, 2009
150
+ * 1 minor change
151
+ * Added data error hash returned from twitter to a few of the exceptions to help with debugging
152
+ * Fixed friendship_exists?. Was throwing mash stringify keys error because it was returning true or false instead of hash or array.
153
+
154
+ 0.5.0 - April 3, 2009
155
+ * 1 major rewrite for OAuth
156
+ * Backwards compatibility thrown to the wind
157
+ * Proxy no longer supported (someone please add it back in, I never use proxies)
158
+ * Identica support killed with an axe (nothing against them but I don't use it)
159
+ * CLI shot to death (will be reborn at a later date using oauth and its own gem)
160
+
161
+ 0.4.3 - February 21, 2009
162
+ * 1 minor enhancement
163
+ * verify_credentials now returns a Twitter::User rather than an hpricot doc
164
+
165
+ 0.4.2 - February 10, 2009
166
+ * 1 minor enhancement
167
+ * Adding the Social Graph API methods (Josh Owens)
168
+
169
+ 0.4.1 - January 1, 2009
170
+ * 4 minor enhancements and 2 bug fixes:
171
+ * Added better exception handling (Billy Gray)
172
+ * Added page to search (Michael Ivey)
173
+ * Adding an option to display tweets on CLI in reverse order (oldest first). (Cameron Booth)
174
+ * Added in_reply_to_status_id option for replying to statuses (anthonycrumley)
175
+ * Fixed a bug where the @config was improperly set (K. Adam Christensen)
176
+ * Fix verify_credentials to include a format (breaks in laconica). (dustin)
177
+
178
+ 0.4.0 - December 23, 2008
179
+ * 3 major changes
180
+ * Removed active support as dependency
181
+ * Removed CLI dependencies from install dependency list
182
+ (they are now only installed by you manually)
183
+ * Switched to echoe for gem managment
184
+
185
+ 0.3.7 - August 26, 2008
186
+ * Fixed source param not getting through
187
+
188
+ 0.3.6 - August 11, 2008
189
+ * Fixed a few more methods that required post.
190
+ * Refactored the remaining methods that were not using #request to use it.
191
+
192
+ 0.3.5 - August 4, 2008
193
+ * Removed sqlite-ruby 1.2.2 as a dependency due to install issues on linux
194
+
195
+ 0.3.4 - August 3, 2008
196
+ * Added search support
197
+
198
+ 0.3.3 - August 3, 2008
199
+ * Now has option for host when initializing to support identi.ca (Dustin Sallings)
200
+ * Twitter changed a bunch of methods to POST only so I updated those to now work
201
+
202
+ 0.3.2 - July 26, 2008
203
+ * added the CLI gems as dependencies for now until I separate out the CLI from the API wrapper
204
+ * cleaner CLI errors for no active account or no accounts at all
205
+ * remove sets a new active account if there are none
206
+ * added username and password optional arguments to add
207
+ * added import attempt on install and on anything that uses #current_account helper
208
+
209
+ 0.3.1 - July 23, 2008
210
+ * added open to CLI twitter open jnunemaker would open default browser to http://twitter.com/jnunemaker
211
+ * added -f to timeline and replies which ignores the since_id and shows all results
212
+ * added clear_config to remove all cached since id's and such
213
+ * Majorly pimped the output of timelines and replies.
214
+
215
+ 0.3.0 - July 22, 2008
216
+ * complete rewrite of CLI. Now supports multiple accounts and changing between them.
217
+ * added source, truncated, in_reply_to_status_id, in_reply_to_user_id, and favorited to Twitter::Status
218
+ * added protected to Twitter::User
219
+ * d CLI method now takes standard input like post
220
+ * Rewrote several methods that had since parameter to now use a hash instead. This makes it more flexible as API updates.
221
+ * Rewrote the methods that took lite or since as an argument to instead take a hash.
222
+ * added Twitter::Base#friendship_exists?
223
+ * added Twitter::Base#update_location
224
+ * added Twitter::Base#update_delivery_device
225
+ * added Twitter::Base#favorites
226
+ * added Twitter::Base#create_favorite
227
+ * added Twitter::Base#destroy_favorite
228
+ * added Twitter::Base#block
229
+ * added Twitter::Base#unblock
230
+
231
+ BACKWORDS COMPATIBILITY BREAK:
232
+ Any method that you have using lite or since as an argument
233
+ will no longer work with this version. Simply change to a
234
+ hash and you'll be fine. For example:
235
+
236
+ friends(true) would now be friends(:lite => true)
237
+
238
+ 0.2.7 - June 29, 2008
239
+ * added #rate_limit_status (Daniel Morrison)
240
+ * added source parameter option to Base#post
241
+ * added twittergem as source when posting from command line
242
+ * Twitter::RateExceeded raised when you hit your limit (Jim O'Leary)
243
+ * Twitter::Unavailable raised when twitter returns 503
244
+ * Twitter::CantConnect is now more descriptive as to what is the problem when it is raised during a request
245
+ * quoting your message when using twitter post on the command line is now optional (Benoit Caccinolo)
246
+ * aliased post to p on command line so it's shorter (Benoit Caccinolo)
247
+ * unescaped html and added some color in command line view (Miles Z. Sterrett)
248
+ * added gemspec (technoweenie, Miles Z. Sterrett)
249
+ * Fixed stack trace error on first command line operation (Matt Rose)
250
+ 0.2.6 - April 2, 2008
251
+ * found a more simple way of doing stdin without any extra gem dependencies
252
+ 0.2.5 - April 2, 2008
253
+ * Command line interface can now use stdin for posting (ideas and example code from Jeremy Friesen)
254
+ $ twitter post 'test without stdin' # => twitters: test without stdin
255
+ $ echo 'test with stdin' | twitter post 'and an argv[1]' # => twitters: test with stdin and an argv[1]
256
+ $ echo 'test with stdin without any argv[1]' | twitter post # => twitters: test with stdin without any argv[1]
257
+ 0.2.4 - Mar 31, 2008
258
+ * Added lite option to friends and followers, which doesn't include the user's current status (Daniel Morrison)
259
+ * Updated since option to use HTTP header, and added the option on timeline() and replies(). (Daniel Morrison)
260
+ 0.2.3 - Jan 16, 2008
261
+ * added d to command line interface twitter d jnunemaker 'hola' (Humbucker)
262
+ * added progress dots when posting for confirmation when twitter is running slow (Hendy Irawan)
263
+ 0.2.2 - added leave and follow which are new twitter api methods for turning notifications on and off
264
+ 0.2.0 - Aug 4, 2007
265
+ * added sent_messages
266
+ * alias direct_messages to received_messages
267
+ * added create_friendship
268
+ * added destroy_friendship
269
+ * added featured to retrieve the featured twitter users
270
+ * added replies
271
+ * added destroy to destroy a status by id
272
+ * added status to find a status by id
273
+ * added active support as an extra dependency
274
+ * implemented d method to send direct messages (jnewland)
275
+ * fixed since argument in direct_messages method (jnewland)
276
+ 0.1.1 - May 20, 2007
277
+ * hpricot 0.5+ now supported; just a bug fix (Ryan Waldron is the man!)
278
+ 0.1.0 - March 31, 2007
279
+ * added d method for creating direct messages (waiting for it to work as documented)
280
+ * added featured method for getting featured users statuses (waiting for it to work as documented)
281
+ * added direct_messages method
282
+ * added friends_for method
283
+ * added a few tests
284
+ * removed relative_created_at as it is deprecated
285
+ * separated out the call method into call, request and parse methods
286
+ 0.0.5 - just a bit of code cleanup
287
+ 0.0.4 - added :location, :description, :url, :profile_image_url to user class (Alex Payne)
288
+ 0.0.3 - added a bit more informative message when things go wrong
289
+ 0.0.2 - added the command line options i forgot to add (friend and follower); improved some docs
290
+ 0.0.1 - initial release
data/License ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 John Nunemaker
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Notes ADDED
@@ -0,0 +1,33 @@
1
+ *****************************************************************
2
+ * From Twitter API Docs, so I don't have to keep going to them. *
3
+ *****************************************************************
4
+
5
+ http://apiwiki.twitter.com/REST+API+Documentation
6
+
7
+ 200 OK: everything went awesome.
8
+ 304 Not Modified: there was no new data to return.
9
+ 400 Bad Request: your request is invalid, and we'll return an error message that tells you why. This is the status code returned if you've exceeded the rate limit (see below).
10
+ 401 Not Authorized: either you need to provide authentication credentials, or the credentials provided aren't valid.
11
+ 403 Forbidden: we understand your request, but are refusing to fulfill it. An accompanying error message should explain why.
12
+ 404 Not Found: either you're requesting an invalid URI or the resource in question doesn't exist (ex: no such user).
13
+ 500 Internal Server Error: we did something wrong. Please post to the group about it and the Twitter team will investigate.
14
+ 502 Bad Gateway: returned if Twitter is down or being upgraded.
15
+ 503 Service Unavailable: the Twitter servers are up, but are overloaded with requests. Try again later.
16
+
17
+ **********
18
+ * Errors *
19
+ **********
20
+
21
+ <?xml version="1.0" encoding="UTF-8"?>
22
+ <hash>
23
+ <request>/direct_messages/destroy/456.xml</request>
24
+ <error>No direct message with that ID found.</error>
25
+ </hash>
26
+
27
+ **********************
28
+ * Rate Limit Headers *
29
+ **********************
30
+
31
+ X-RateLimit-Limit the current limit in effect
32
+ X-RateLimit-Remaining the number of hits remaining before you are rate limited
33
+ X-RateLimit-Reset the time the current rate limiting period ends (in epoch time, number of seconds since 1970-01-01 00:00:00)
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = twitter
2
+
3
+ The ruby twitter gem. The gem heard round the world and famous on the streets. Haha. This gem *works with both oauth and http auth*, if you care.
4
+
5
+ For now this is just an API wrapper. The command line interface is temporarily dead until I have time to make it work with oauth. At that point, I'll make it a new gem twitter-cli or something and it will depend on this gem to work. That will keep the separation of the api wrapper and cli and fix a lot of dependency issues.
6
+
7
+ == examples
8
+
9
+ See the examples directory.
10
+
11
+ http://github.com/jnunemaker/twitter/tree/master/examples
12
+
13
+ == docs
14
+
15
+ http://rdoc.info/projects/jnunemaker/twitter
16
+
17
+ == Copyright
18
+
19
+ Copyright (c) 2009 John Nunemaker. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ require "rake"
2
+ require "jeweler"
3
+
4
+ Jeweler::Tasks.new do |gem|
5
+ gem.name = "twitter"
6
+ gem.summary = %Q{wrapper for the twitter api}
7
+ gem.email = "nunemaker@gmail.com"
8
+ gem.homepage = "http://github.com/jnunemaker/twitter"
9
+ gem.authors = ["John Nunemaker", "Wynn Netherland"]
10
+ gem.files = FileList["[A-Z]*", "{examples,lib,test}/**/*"]
11
+
12
+ gem.add_dependency("oauth", "~> 0.4.1")
13
+ gem.add_dependency("hashie", "~> 0.2.0")
14
+ gem.add_dependency("httparty", "~> 0.5.0")
15
+ gem.add_dependency("yajl-ruby", "~> 0.7.0")
16
+
17
+ gem.add_development_dependency("shoulda", "~> 2.10.0")
18
+ gem.add_development_dependency("jnunemaker-matchy", "~> 0.4.0")
19
+ gem.add_development_dependency("mocha", "~> 0.9.0")
20
+ gem.add_development_dependency("fakeweb", "~> 1.2.0")
21
+ gem.add_development_dependency("redgreen", "~> 1.2.2")
22
+ end
23
+
24
+ Jeweler::GemcutterTasks.new
25
+
26
+ require "rake/testtask"
27
+ Rake::TestTask.new(:test) do |test|
28
+ test.libs << "test"
29
+ test.ruby_opts << "-rubygems"
30
+ test.pattern = "test/**/*_test.rb"
31
+ test.verbose = true
32
+ end
33
+
34
+ task :default => :test
35
+ task :test => :check_dependencies
36
+
37
+ desc "Upload website files to rubyforge"
38
+ task :website do
39
+ sh %{rsync -av website/ jnunemaker@rubyforge.org:/var/www/gforge-projects/twitter}
40
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 9
4
+ :build:
5
+ :patch: 8
@@ -0,0 +1,30 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.twitter")
6
+ oauth = Twitter::OAuth.new(config['token'], config['secret'])
7
+
8
+ if config['atoken'] && config['asecret']
9
+ oauth.authorize_from_access(config['atoken'], config['asecret'])
10
+ twitter = Twitter::Base.new(oauth)
11
+ pp twitter.friends_timeline
12
+
13
+ elsif config['rtoken'] && config['rsecret']
14
+ oauth.authorize_from_request(config['rtoken'], config['rsecret'], 'PIN')
15
+ twitter = Twitter::Base.new(oauth)
16
+ pp twitter.friends_timeline
17
+
18
+ config.update({
19
+ 'atoken' => oauth.access_token.token,
20
+ 'asecret' => oauth.access_token.secret,
21
+ }).delete('rtoken', 'rsecret')
22
+ else
23
+ config.update({
24
+ 'rtoken' => oauth.request_token.token,
25
+ 'rsecret' => oauth.request_token.secret,
26
+ })
27
+
28
+ # authorize in browser
29
+ %x(open #{oauth.request_token.authorize_url})
30
+ end
@@ -0,0 +1,13 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.twitter")
6
+
7
+ oauth = Twitter::OAuth.new(config['token'], config['secret'])
8
+ oauth.authorize_from_access(config['atoken'], config['asecret'])
9
+
10
+ client = Twitter::Base.new(oauth)
11
+
12
+ puts client.friendship_exists?('jnunemaker', 'orderedlist')
13
+ puts client.friendship_exists?('jnunemaker', 'biz')
@@ -0,0 +1,38 @@
1
+ class ConfigStore
2
+ attr_reader :file
3
+
4
+ def initialize(file)
5
+ @file = file
6
+ end
7
+
8
+ def load
9
+ @config ||= YAML::load(open(file))
10
+ self
11
+ end
12
+
13
+ def [](key)
14
+ load
15
+ @config[key]
16
+ end
17
+
18
+ def []=(key, value)
19
+ @config[key] = value
20
+ end
21
+
22
+ def delete(*keys)
23
+ keys.each { |key| @config.delete(key) }
24
+ save
25
+ self
26
+ end
27
+
28
+ def update(c={})
29
+ @config.merge!(c)
30
+ save
31
+ self
32
+ end
33
+
34
+ def save
35
+ File.open(file, 'w') { |f| f.write(YAML.dump(@config)) }
36
+ self
37
+ end
38
+ end
@@ -0,0 +1,11 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.twitter")
6
+
7
+ httpauth = Twitter::HTTPAuth.new(config['email'], config['password'])
8
+ base = Twitter::Base.new(httpauth)
9
+
10
+ pp base.user_timeline
11
+ pp base.verify_credentials
data/examples/ids.rb ADDED
@@ -0,0 +1,13 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.twitter")
6
+
7
+ oauth = Twitter::OAuth.new(config['token'], config['secret'])
8
+ oauth.authorize_from_access(config['atoken'], config['asecret'])
9
+
10
+ client = Twitter::Base.new(oauth)
11
+
12
+ puts client.friend_ids
13
+ puts client.follower_ids
data/examples/lists.rb ADDED
@@ -0,0 +1,11 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.twitter")
6
+
7
+ httpauth = Twitter::HTTPAuth.new(config['email'], config['password'])
8
+ base = Twitter::Base.new(httpauth)
9
+
10
+ pp base.lists('pengwynn')
11
+ pp base.list_members('pengwynn', 'rubyists')
data/examples/oauth.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'pp'
2
+ require 'pathname'
3
+ dir = Pathname(__FILE__).dirname.expand_path
4
+ require (dir + '..' + 'lib' + 'twitter').expand_path
5
+ require dir + 'helpers' + 'config_store'
6
+
7
+ config = ConfigStore.new("#{ENV['HOME']}/.twitter")
8
+ oauth = Twitter::OAuth.new(config['token'], config['secret'])
9
+ rtoken = oauth.request_token.token
10
+ rsecret = oauth.request_token.secret
11
+
12
+ puts "> redirecting you to twitter to authorize..."
13
+ %x(open #{oauth.request_token.authorize_url})
14
+
15
+ print "> what was the PIN twitter provided you with? "
16
+ pin = gets.chomp
17
+
18
+ begin
19
+ oauth.authorize_from_request(rtoken, rsecret, pin)
20
+
21
+ twitter = Twitter::Base.new(oauth)
22
+ twitter.user_timeline.each do |tweet|
23
+ puts "#{tweet.user.screen_name}: #{tweet.text}"
24
+ end
25
+ rescue OAuth::Unauthorized
26
+ puts "> FAIL!"
27
+ end
@@ -0,0 +1,15 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require 'pp'
3
+
4
+ search = Twitter::Search.new.from('jnunemaker')
5
+
6
+ puts '*'*50, 'First Run', '*'*50
7
+ search.each { |result| pp result }
8
+
9
+ puts '*'*50, 'Second Run', '*'*50
10
+ search.each { |result| pp result }
11
+
12
+ puts '*'*50, 'Parameter Check', '*'*50
13
+ pp Twitter::Search.new('#austineats').fetch().results.first
14
+ pp Twitter::Search.new('#austineats').page(2).fetch().results.first
15
+ pp Twitter::Search.new('#austineats').since(1412737343).fetch().results.first
@@ -0,0 +1,19 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.twitter")
6
+
7
+ oauth = Twitter::OAuth.new(config['token'], config['secret'])
8
+ oauth.authorize_from_access(config['atoken'], config['asecret'])
9
+
10
+ client = Twitter::Base.new(oauth)
11
+
12
+ pp client.friends_timeline
13
+ puts '*'*50
14
+
15
+ pp client.user_timeline
16
+ puts '*'*50
17
+
18
+ pp client.replies
19
+ puts '*'*50
@@ -0,0 +1,9 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require 'pp'
3
+
4
+
5
+ httpauth = Twitter::HTTPAuth.new('email', 'password', :api_endpoint => 'tumblr.com')
6
+ base = Twitter::Base.new(httpauth)
7
+
8
+ pp base.user_timeline
9
+ pp base.verify_credentials
@@ -0,0 +1,16 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require 'pp'
3
+
4
+ puts 'User', '*'*50
5
+ pp Twitter.user('jnunemaker')
6
+ pp Twitter.user('snitch_test')
7
+
8
+ puts 'Status', '*'*50
9
+ pp Twitter.status(1533815199)
10
+
11
+ puts 'Friend Ids', '*'*50
12
+ pp Twitter.friend_ids('jnunemaker')
13
+
14
+ puts 'Follower Ids', '*'*50
15
+ pp Twitter.follower_ids('jnunemaker')
16
+
@@ -0,0 +1,11 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.twitter")
6
+
7
+ oauth = Twitter::OAuth.new(config['token'], config['secret'])
8
+ oauth.authorize_from_access(config['atoken'], config['asecret'])
9
+
10
+ client = Twitter::Base.new(oauth)
11
+ pp client.update('This is an update from the twitter gem')
data/examples/user.rb ADDED
@@ -0,0 +1,5 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require 'pp'
3
+
4
+ pp Twitter.user('jnunemaker')
5
+ pp Twitter.user('snitch_test')