twitter 6.1.0 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +22 -15
  3. data/README.md +69 -394
  4. data/lib/twitter/base.rb +2 -16
  5. data/lib/twitter/basic_user.rb +0 -3
  6. data/lib/twitter/client.rb +5 -19
  7. data/lib/twitter/configuration.rb +3 -2
  8. data/lib/twitter/creatable.rb +1 -1
  9. data/lib/twitter/cursor.rb +0 -1
  10. data/lib/twitter/entity/uri.rb +0 -4
  11. data/lib/twitter/error.rb +81 -96
  12. data/lib/twitter/geo_results.rb +0 -1
  13. data/lib/twitter/headers.rb +11 -10
  14. data/lib/twitter/media/photo.rb +4 -0
  15. data/lib/twitter/media/video.rb +4 -1
  16. data/lib/twitter/media/video_info.rb +1 -1
  17. data/lib/twitter/null_object.rb +2 -2
  18. data/lib/twitter/profile.rb +3 -2
  19. data/lib/twitter/rate_limit.rb +1 -1
  20. data/lib/twitter/rest/api.rb +0 -2
  21. data/lib/twitter/rest/client.rb +0 -78
  22. data/lib/twitter/rest/direct_messages.rb +3 -3
  23. data/lib/twitter/rest/favorites.rb +25 -4
  24. data/lib/twitter/rest/friends_and_followers.rb +1 -3
  25. data/lib/twitter/rest/lists.rb +18 -29
  26. data/lib/twitter/rest/oauth.rb +15 -15
  27. data/lib/twitter/rest/request.rb +105 -16
  28. data/lib/twitter/rest/saved_searches.rb +0 -2
  29. data/lib/twitter/rest/search.rb +2 -0
  30. data/lib/twitter/rest/trends.rb +1 -0
  31. data/lib/twitter/rest/tweets.rb +80 -15
  32. data/lib/twitter/rest/undocumented.rb +3 -4
  33. data/lib/twitter/rest/users.rb +20 -34
  34. data/lib/twitter/rest/utils.rb +13 -20
  35. data/lib/twitter/search_results.rb +1 -2
  36. data/lib/twitter/streaming/client.rb +17 -23
  37. data/lib/twitter/streaming/connection.rb +23 -10
  38. data/lib/twitter/streaming/deleted_tweet.rb +0 -1
  39. data/lib/twitter/streaming/event.rb +6 -6
  40. data/lib/twitter/streaming/message_parser.rb +1 -1
  41. data/lib/twitter/streaming/response.rb +2 -2
  42. data/lib/twitter/trend_results.rb +1 -2
  43. data/lib/twitter/tweet.rb +1 -5
  44. data/lib/twitter/user.rb +0 -2
  45. data/lib/twitter/utils.rb +1 -16
  46. data/lib/twitter/version.rb +1 -1
  47. data/twitter.gemspec +13 -13
  48. metadata +35 -27
  49. data/lib/twitter/rest/media.rb +0 -30
  50. data/lib/twitter/rest/request/multipart_with_file.rb +0 -47
  51. data/lib/twitter/rest/response/parse_error_json.rb +0 -13
  52. data/lib/twitter/rest/response/parse_json.rb +0 -31
  53. data/lib/twitter/rest/response/raise_error.rb +0 -32
  54. data/lib/twitter/token.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2e958fdeea560a9ce78c044d026a4a9aaf9c5fab
4
- data.tar.gz: 42e63cf78c08bbba893c962839e716b68c9131eb
2
+ SHA256:
3
+ metadata.gz: 6c1797367fcb91dca015c7a77acd6273beb4c49e929c98d2d3a913ea37009496
4
+ data.tar.gz: 3c4a9f1fca5d3e99b9be0cb8993c4f274cb309b8fc19b2f3cf45838622484bce
5
5
  SHA512:
6
- metadata.gz: ea08743dba187f71a9a19b1ab2ef8718b86ee94ed39d4c9b1367fd304d46012c640350185b87d45ec13b544594698f21a56d22d2e45d644ceea92949922af586
7
- data.tar.gz: a9b84b50a9b18a25503799a71c2aa85b7b16bff5a243576eea2372251fc71afe6c69261d4f7d17547da1dffe178a6b84798cb1127f4244a58a3fad61e298bec7
6
+ metadata.gz: 887f6a6acfb58cd602fe1507c66e12fcb53c5b7479054a91e0ca68ee0c2a227c620b8bab614d256e4dfb31015cdc5c85fe8bdf9f05e9f48b8c38c8d945fbbf1e
7
+ data.tar.gz: 631417a20ae3bca7970e05f6a63c6049af3c613b0f078a6d178d81f13750ff4a885514aa882be050a94f3909dc24df8df084fbc816bec280a9e7963fb7ab3750
@@ -1,24 +1,31 @@
1
+ 6.2.0
2
+ ------
3
+
4
+ Not yet documented, sorry. For now, please use git to compare tags:
5
+ https://github.com/sferik/twitter/compare/v6.1.0...v6.2.0
6
+
1
7
  6.1.0
2
- -----
3
- * [Update faraday dependency to ~> 0.11.0](https://github.com/sferik/twitter/commit/6eb494d7c4ac1b06730d22bc9183e6a9035e3643)
8
+ ------
9
+
10
+ Not yet documented, sorry. For now, please use git to compare tags:
11
+ https://github.com/sferik/twitter/compare/v6.0.0...v6.1.0
4
12
 
5
- 6.0.0
6
- -----
7
- * [Drop support for Ruby 1.8.7 and Ruby 1.9.3](https://github.com/sferik/twitter/commit/27980f45fb357e34b86e46cb9134d86ed29b3ce3)
8
13
 
9
- 5.17.0
14
+ 6.0.0
10
15
  ------
11
- * [Add `email` to `Twitter::User`](https://github.com/sferik/twitter/commit/1d3aebcd0186d36c7c657ec913ac73bfa802d6ff)
12
- * [Add `current_user_retweet` attribute to `Twitter::Tweet`](https://github.com/sferik/twitter/pull/819) ([@ysr227](https://twitter.com/ysr227))
13
- * [Add `quoted_tweet` Twitter::Streaming::Event](https://github.com/sferik/twitter/pull/800)
14
- * [Dump `Twitter::NullObject` as JSON properly](https://github.com/sferik/twitter/pull/815) ([@okkez](https://twitter.com/okkez))
16
+
17
+ Not yet documented, sorry. For now, please use git to compare tags:
18
+ https://github.com/sferik/twitter/compare/v5.16.0...v6.0.0
15
19
 
16
20
  5.16.0
17
21
  ------
18
- * [Add new settings to `Twitter::Settings`](https://github.com/sferik/twitter/commit/d047ce00034d26a99927076c28679ce08fd69308)
19
- * [Add `Twitter::Trend#tweet_volume`](https://github.com/sferik/twitter/commit/e797b62e5e6a768e8aeafde6186e1f5310e6bfc6)
20
- * [Remove the encoding of profile urls](https://github.com/sferik/twitter/commit/6d46bd689ab4a4f119d1d692488aab37e4e99893) ([@TimHaines](https://twitter.com/TimHaines))
21
- * [Fix issue with port number in streaming connection](https://github.com/sferik/twitter/issues/709)
22
+
23
+ * [Add Twitter::Trend#tweet_volume](https://github.com/sferik/twitter/commit/e797b62e5e6a768e8aeafde6186e1f5310e6bfc6)
24
+ * [Add new settings to Twitter::Settings](https://github.com/sferik/twitter/commit/d047ce00034d26a99927076c28679ce08fd69308)
25
+ * [Fix `Version.to_a`](https://github.com/sferik/twitter/commit/0cd119abf64e6c2b7fd861b0df65b7cb41d892b4)
26
+ * [Remove the encoding of profile urls](https://github.com/sferik/twitter/commit/6d46bd689ab4a4f119d1d692488aab37e4e99893)
27
+ * [Update http dependency to ~> 1.0](https://github.com/sferik/twitter/commit/8d379a45be6948a9d9264aa2e91ef5f7bdbe1db8)
28
+ * [Fetch host and port directly from the request object](https://github.com/sferik/twitter/commit/f9f1bbdabde2ec96dcdd8900fe7bca072f9bea6b)
22
29
 
23
30
  5.15.0
24
31
  ------
@@ -67,7 +74,7 @@
67
74
  5.9.0
68
75
  -----
69
76
  * [Use expanded URIs when available](https://github.com/sferik/twitter/commit/f1d5d1f4c0ea75ebeaf9e7eb760b9efd245a5df2)
70
- * [Deprecate `Twitter::REST::Client#middleware=` and `#connection_options`](https://github.com/sferik/twitter/commit/71b0a38670102841fda9642de586e6cb67d33083)
77
+ * [Deprecate `Twitter::REST::Client#middleware=` and `#connection_options`](https://github.com/sferik/twitter/commit/2ec17d8d43a87766dd4b89fcc6d5a2433530bf7c)
71
78
  * [Ensure predicate methods return `false` for `Twitter::NullObject`](https://github.com/sferik/twitter/commit/f1b42bf82440f2dc0ba61761fc8f12460e20aadf)
72
79
  * [Make `Twitter::Place#id` attribute accessible](https://github.com/sferik/twitter/commit/a4fa4739283a325886d44f97b2648e3b00f933b1)
73
80
  * [Enable injection of custom TCP/SSL socket classes](https://github.com/sferik/twitter/commit/3629a1edfbc6b35099d4b0fc165b938a67c02d86) ([@neektza](https://twitter.com/neektza))
data/README.md CHANGED
@@ -20,7 +20,6 @@ A Ruby interface to the Twitter API.
20
20
  gem install twitter
21
21
 
22
22
  ## CLI
23
-
24
23
  Looking for the Twitter command-line interface? It was [removed][] from this
25
24
  gem in version 0.5.0 and now exists as a [separate project][t].
26
25
 
@@ -54,376 +53,6 @@ wiki][apps]!
54
53
 
55
54
  [apps]: https://github.com/sferik/twitter/wiki/apps
56
55
 
57
- ## What's New in Version 5?
58
- ### Configuration
59
- Global configuration has been removed, as it was not threadsafe. Instead, you
60
- can configure a `Twitter::REST::Client` by passing it a block when it's
61
- initialized.
62
-
63
- ```ruby
64
- client = Twitter::REST::Client.new do |config|
65
- config.consumer_key = "YOUR_CONSUMER_KEY"
66
- config.consumer_secret = "YOUR_CONSUMER_SECRET"
67
- config.access_token = "YOUR_ACCESS_TOKEN"
68
- config.access_token_secret = "YOUR_ACCESS_SECRET"
69
- end
70
- ```
71
-
72
- Note: `oauth_token` has been renamed to `access_token` and `oauth_token_secret`
73
- is now `access_token_secret` to conform to the terminology used in Twitter's
74
- developer documentation.
75
-
76
- ### Streaming (Experimental)
77
- This library now offers support for the [Twitter Streaming API][streaming].
78
-
79
- [streaming]: https://dev.twitter.com/streaming/overview
80
- [tweetstream]: http://rubygems.org/gems/tweetstream
81
-
82
- Site Streams are restricted to whitelisted accounts. To apply for access,
83
- [follow the steps in the Site Streams documentation][site-streams]. [User
84
- Streams][user-streams] do not require prior approval.
85
-
86
- [site-streams]: https://dev.twitter.com/streaming/sitestreams#applyingforaccess
87
- [user-streams]: https://dev.twitter.com/streaming/userstreams
88
-
89
- Unlike the rest of this library, this feature is not well tested and not
90
- recommended for production applications. I've decided to ship it as an
91
- experimental feature and make it more robust over time. Patches in this area are
92
- particularly welcome.
93
-
94
- Hopefully, by the time version 6 is released, this gem can fully replace
95
- [TweetStream][], [em-twitter][], [twitterstream][], and [twitter-stream].
96
- Special thanks to [Steve Agalloco][spagalloco], [Tim Carey-Smith][halorgium],
97
- and [Tony Arcieri][tarcieri] for helping to develop this feature.
98
-
99
- [em-twitter]: http://rubygems.org/gems/em-twitter
100
- [twitterstream]: http://rubygems.org/gems/twitterstream
101
- [twitter-stream]: http://rubygems.org/gems/twitter-stream
102
- [spagalloco]: https://github.com/spagalloco
103
- [halorgium]: https://github.com/halorgium
104
- [tarcieri]: https://github.com/tarcieri
105
-
106
- **Configuration works just like `Twitter::REST::Client`**
107
-
108
- ```ruby
109
- client = Twitter::Streaming::Client.new do |config|
110
- config.consumer_key = "YOUR_CONSUMER_KEY"
111
- config.consumer_secret = "YOUR_CONSUMER_SECRET"
112
- config.access_token = "YOUR_ACCESS_TOKEN"
113
- config.access_token_secret = "YOUR_ACCESS_SECRET"
114
- end
115
- ```
116
-
117
- **Stream mentions of coffee or tea**
118
-
119
- ```ruby
120
- topics = ["coffee", "tea"]
121
- client.filter(:track => topics.join(",")) do |object|
122
- puts object.text if object.is_a?(Twitter::Tweet)
123
- end
124
- ```
125
-
126
- **Stream a random sample of all tweets**
127
-
128
- ```ruby
129
- client.sample do |object|
130
- puts object.text if object.is_a?(Twitter::Tweet)
131
- end
132
- ```
133
-
134
- **Stream tweets, events, and direct messages for the authenticated user**
135
-
136
- ```ruby
137
- client.user do |object|
138
- case object
139
- when Twitter::Tweet
140
- puts "It's a tweet!"
141
- when Twitter::DirectMessage
142
- puts "It's a direct message!"
143
- when Twitter::Streaming::StallWarning
144
- warn "Falling behind!"
145
- end
146
- end
147
- ```
148
-
149
- An `object` may be one of the following:
150
- * `Twitter::DirectMessage`
151
- * `Twitter::Streaming::DeletedTweet`
152
- * `Twitter::Streaming::Event`
153
- * `Twitter::Streaming::FriendList`
154
- * `Twitter::Streaming::StallWarning`
155
- * `Twitter::Tweet`
156
-
157
- ### Cursors
158
- The `Twitter::Cursor` class has been completely redesigned with a focus on
159
- simplicity and performance.
160
-
161
- <table>
162
- <thead>
163
- <tr>
164
- <th>Notes</th>
165
- <th colspan="2">Version 4</th>
166
- <th colspan="2">Version 5</th>
167
- </tr>
168
- <tr>
169
- <th></th>
170
- <th>Code</th>
171
- <th>HTTP GETs</th>
172
- <th>Code</th>
173
- <th>HTTP GETs</th>
174
- </tr>
175
- </thead>
176
- <tbody>
177
- <tr>
178
- <td>
179
- Are you at the start of the cursor?
180
- </td>
181
- <td>
182
- <pre><code>client.friends.first</code></pre>
183
- </td>
184
- <td>
185
- <em>Θ(1)</em>
186
- </td>
187
- <td>
188
- <pre><code>client.friends.first?</code></pre>
189
- </td>
190
- <td>
191
- <em>Θ(1)</em>
192
- </td>
193
- </tr>
194
- <tr>
195
- <td>
196
- Return your most recent friend.
197
- </td>
198
- <td>
199
- <pre><code>client.friends.users.first</code></pre>
200
- </td>
201
- <td>
202
- <em>Θ(1)</em>
203
- </td>
204
- <td>
205
- <pre><code>client.friends.first</code></pre>
206
- </td>
207
- <td>
208
- <em>Θ(1)</em>
209
- </td>
210
- </tr>
211
- <tr>
212
- <td>
213
- Return an array of all your friends.
214
- </td>
215
- <td>
216
- <pre><code>client.friends.all</code></pre>
217
- </td>
218
- <td>
219
- <em>Θ(n+1)</em>
220
- </td>
221
- <td>
222
- <pre><code>client.friends.to_a</code></pre>
223
- </td>
224
- <td>
225
- <em>Θ(n)</em>
226
- </td>
227
- </tr>
228
- <tr>
229
- <td>
230
- Collect your 20 most recent friends.
231
- </td>
232
- <td>
233
- <pre><code>client.friends.take(20)</code></pre>
234
- </td>
235
- <td>
236
- <em>Θ(n+1)</em>
237
- </td>
238
- <td>
239
- <pre><code>client.friends.take(20)</code></pre>
240
- </td>
241
- <td>
242
- <em>Θ(1)</em>
243
- </td>
244
- </tr>
245
- <tr>
246
- <td>
247
- Collect your 20 most recent friends twice.
248
- </td>
249
- <td>
250
- <pre><code>friends = client.friends
251
- 2.times.collect do
252
- friends.take(20)
253
- end</code></pre>
254
- </td>
255
- <td>
256
- <em>Θ(2n+2)</em>
257
- </td>
258
- <td>
259
- <pre><code>friends = client.friends
260
- 2.times.collect do
261
- friends.take(20)
262
- end</code></pre>
263
- </td>
264
- <td>
265
- <em>Θ(1)</em>
266
- </td>
267
- </tr>
268
- </tbody>
269
- </table>
270
-
271
- In the examples above, *n* varies with the number of people the authenticated
272
- user follows on Twitter. This resource returns up to 20 friends per HTTP GET,
273
- so if the authenticated user follows 200 people, calling
274
- `client.friends.take(20)` would make 11 HTTP requests in version 4. In version
275
- 5, it makes just 1 HTTP request. Keep in mind, eliminating a single HTTP
276
- request to the Twitter API will reduce the latency of your application by
277
- [about 500 ms][status].
278
-
279
- [status]: https://dev.twitter.com/overview/status
280
-
281
- The last example might seem contrived ("Why would I call
282
- `client.friends.take(20)` twice?") but it applies to any
283
- [`Enumerable`][enumerable] method you might call on a cursor, including:
284
- `#all?`, `#collect`, `#count`, `#each`, `#inject`, `#max`, `#min`, `#reject`,
285
- `#reverse_each`, `#select`, `#sort`, `#sort_by`, and `#to_a`. In version 4,
286
- each time you called one of those methods, it would perform *n+1* HTTP
287
- requests. In version 5, it only performs those HTTP requests the first time any
288
- one of those methods is called. Each subsequent call fetches data from a
289
- [cache][].
290
-
291
- [enumerable]: http://ruby-doc.org/core-2.0/Enumerable.html
292
- [cache]: https://github.com/sferik/twitter/commit/7d8b2727af9400643ac397207185fd54e3f6387b
293
-
294
- The performance improvements are actually even **better** than the table above
295
- indicates. In version 5, calling `Twitter::Cursor#each` (or any
296
- [`Enumerable`][enumerable] method) starts yielding results immediately and
297
- continues yielding as each response comes back from the server. In version 4,
298
- `#each` made a series of requests and waited for the last one to complete
299
- before yielding any data.
300
-
301
- Here is a list of the interface changes to `Twitter::Cursor`:
302
-
303
- * `#all` has been replaced by `#to_a`.
304
- * `#last` has been replaced by `#last?`.
305
- * `#first` has been replaced by `#first?`.
306
- * `#first` now returns the first element in the collection, as prescribed by `Enumerable`.
307
- * `#collection` and its aliases have been removed.
308
-
309
- ### Search Results
310
- The `Twitter::SearchResults` class has also been redesigned to have an
311
- [`Enumerable`][enumerable] interface. The `#statuses` method and its aliases
312
- (`#collection` and `#results`) have been replaced by `#to_a`. Additionally,
313
- this class no longer inherits from `Twitter::Base`. As a result, the `#[]`
314
- method has been removed.
315
-
316
- ### Trend Results
317
- The `#trends` method now returns an [`Enumerable`][enumerable]
318
- `Twitter::TrendResults` object instead of an array. This object provides
319
- methods to determine the recency of the trend (`#as_of`), when the trend
320
- started (`#created_at`), and the location of the trend (`#location`). This data
321
- was previously unavailable.
322
-
323
- ### Geo Results
324
- Similarly, the `#reverse_geocode`, `#geo_search`, and `#similar_places` methods
325
- now return an [`Enumerable`][enumerable] `Twitter::GeoResults` object instead
326
- of an array. This object provides access to the token to create a new place
327
- (`#token`), which was previously unavailable.
328
-
329
- ### Tweets
330
- The `Twitter::Tweet` object has been cleaned up. The following methods have been
331
- removed:
332
-
333
- * `#from_user`
334
- * `#from_user_id`
335
- * `#from_user_name`
336
- * `#to_user`
337
- * `#to_user_id`
338
- * `#to_user_name`
339
- * `#profile_image_url`
340
- * `#profile_image_url_https`
341
-
342
- These attributes can be accessed via the `Twitter::User` object, returned
343
- through the `#user` method.
344
-
345
- ### Users
346
- The `Twitter::User` object has also been cleaned up. The following aliases have
347
- been removed:
348
-
349
- * `#favorite_count` (use `#favorites_count`)
350
- * `#favoriters_count` (use `#favorites_count`)
351
- * `#favourite_count` (use `#favorites_count`)
352
- * `#favouriters_count` (use `#favorites_count`)
353
- * `#follower_count` (use `#followers_count`)
354
- * `#friend_count` (use `#friends_count`)
355
- * `#status_count` (use `#statuses_count`)
356
- * `#tweet_count` (use `#tweets_count`)
357
- * `#update_count` (use `#tweets_count`)
358
- * `#updates_count` (use `#tweets_count`)
359
- * `#translator` (use `#translator?`)
360
-
361
- ### Remove British English aliases
362
- Earlier versions of this library aliased `favourites` to `favorites`. These
363
- aliases have been removed. Ruby is implemented in American English. The
364
- `initialize` method is spelled with a "z", not an "s", and Ruby provides no
365
- alias. Likewise, this library does not provide aliases for Commonwealthers.
366
- Merica. :us:
367
-
368
- ### More natural method names
369
- All create, destroy, add, and remove methods have been renamed to put the verb
370
- at the beginning:
371
-
372
- * `#direct_message_create` is now `#create_direct_message`
373
- * `#direct_message_destroy` is now `#destroy_direct_message`
374
- * `#list_create` is now `#create_list`
375
- * `#list_destroy` is now `#destroy_list`
376
- * `#list_remove_member` is now `#remove_list_member`
377
- * `#list_remove_members` is now `#remove_list_members`
378
- * `#list_add_member` is now `#add_list_member`
379
- * `#list_add_members` is now `#add_list_members`
380
- * `#lists_owned` is now `#owned_lists`
381
- * `#saved_search_create` is now `#create_saved_search`
382
- * `#saved_search_destroy` is now `#destroy_saved_search`
383
- * `#status_destroy` is now `#destroy_status`
384
-
385
- ### Null Objects
386
- In version 4, methods you would expect to return a `Twitter` object would
387
- return `nil` if that object was missing. This may have resulted in a
388
- `NoMethodError`. To prevent such errors, you may have introduced checks for the
389
- truthiness of the response, for example:
390
-
391
- ```ruby
392
- status = client.status(55709764298092545)
393
- if status.place
394
- # Do something with the Twitter::Place object
395
- elsif status.geo
396
- # Do something with the Twitter::Geo object
397
- end
398
- ```
399
- In version 5, all such methods will return a `Twitter::NullObject` instead of
400
- `nil`. This should prevent `NoMethodError` but may result in unexpected
401
- behavior if you have truthiness checks in place, since everything is truthy in
402
- Ruby except `false` and `nil`. For these cases, there are now predicate
403
- methods:
404
-
405
- ```ruby
406
- status = client.status(55709764298092545)
407
- if status.place?
408
- # Do something with the Twitter::Place object
409
- elsif status.geo?
410
- # Do something with the Twitter::Geo object
411
- end
412
- ```
413
-
414
- ### URI Methods
415
- The `Twitter::List`, `Twitter::Tweet`, and `Twitter::User` objects all have a
416
- `#uri` method, which returns an HTTPS URI to twitter.com. This clobbers the
417
- `Twitter::List#uri` method, which previously returned the list URI's path (not
418
- a URI).
419
-
420
- These methods are aliased to `#url` for users who prefer that nomenclature.
421
- `Twitter::User` previously had a `#url` method, which returned the user's
422
- website. This URI is now available via the `#website` method.
423
-
424
- All `#uri` methods now return `Addressable::URI` objects instead of strings. To convert an
425
- `Addressable::URI` object to a string, call `#to_s` on it.
426
-
427
56
  ## Configuration
428
57
  Twitter API v1.1 requires you to authenticate via OAuth, so you'll need to
429
58
  [register your application with Twitter][register]. Once you've registered an
@@ -452,19 +81,8 @@ client = Twitter::REST::Client.new do |config|
452
81
  end
453
82
  ```
454
83
 
455
- After configuration, requests can be made like so:
456
-
457
- ```ruby
458
- client.update("I'm tweeting with @gem!")
459
- ```
460
-
461
- **Performance/DNS settings issue**
462
-
463
- When you are using the gem in production (running for example in a DigitalOcean VPS) be aware that DNS settings on the server can affect outbound traffic performance with `Twitter::Error::RequestTimeout` as a result. Don't use the public Google DNS services (4.4.4.4 / 8.8.8.8) they are rate-limited and have very bad response times. Use a DNS service close to your data-center.
464
-
465
84
  ## Usage Examples
466
- All examples require an authenticated Twitter client. See the section on <a
467
- href="#configuration">configuration</a>.
85
+ After configuring a `client`, you can do the following things.
468
86
 
469
87
  **Tweet (as the authenticated user)**
470
88
 
@@ -498,12 +116,6 @@ client.friends(213747670)
498
116
  client.friends
499
117
  ```
500
118
 
501
- **Fetch a collection of user_ids that the currently authenticated user does not want to receive retweets from**
502
-
503
- ```ruby
504
- client.no_retweet_ids
505
- ````
506
-
507
119
  **Fetch the timeline of Tweets by a user**
508
120
 
509
121
  ```ruby
@@ -528,19 +140,83 @@ client.status(27558893223)
528
140
  **Collect the three most recent marriage proposals to @justinbieber**
529
141
 
530
142
  ```ruby
531
- client.search("to:justinbieber marry me", :result_type => "recent").take(3).collect do |tweet|
143
+ client.search("to:justinbieber marry me", result_type: "recent").take(3).collect do |tweet|
532
144
  "#{tweet.user.screen_name}: #{tweet.text}"
533
145
  end
534
146
  ```
535
147
  **Find a Japanese-language Tweet tagged #ruby (excluding retweets)**
536
148
 
537
149
  ```ruby
538
- client.search("#ruby -rt", :lang => "ja").first.text
150
+ client.search("#ruby -rt", lang: "ja").first.text
539
151
  ```
540
152
  For more usage examples, please see the full [documentation][].
541
153
 
542
- ## Object Graph
154
+ ## Streaming
155
+ Site Streams are restricted to whitelisted accounts. To apply for access,
156
+ [follow the steps in the Site Streams documentation][site-streams]. [User
157
+ Streams][user-streams] do not require prior approval.
158
+
159
+ [site-streams]: https://dev.twitter.com/streaming/sitestreams#applyingforaccess
160
+ [user-streams]: https://dev.twitter.com/streaming/userstreams
161
+
162
+ **Configuration works just like `Twitter::REST::Client`**
163
+
164
+ ```ruby
165
+ client = Twitter::Streaming::Client.new do |config|
166
+ config.consumer_key = "YOUR_CONSUMER_KEY"
167
+ config.consumer_secret = "YOUR_CONSUMER_SECRET"
168
+ config.access_token = "YOUR_ACCESS_TOKEN"
169
+ config.access_token_secret = "YOUR_ACCESS_SECRET"
170
+ end
171
+ ```
543
172
 
173
+ **Stream a random sample of all tweets**
174
+
175
+ ```ruby
176
+ client.sample do |object|
177
+ puts object.text if object.is_a?(Twitter::Tweet)
178
+ end
179
+ ```
180
+
181
+ **Stream mentions of coffee or tea**
182
+
183
+ ```ruby
184
+ topics = ["coffee", "tea"]
185
+ client.filter(track: topics.join(",")) do |object|
186
+ puts object.text if object.is_a?(Twitter::Tweet)
187
+ end
188
+ ```
189
+
190
+ **Stream tweets, events, and direct messages for the authenticated user**
191
+
192
+ ```ruby
193
+ client.user do |object|
194
+ case object
195
+ when Twitter::Tweet
196
+ puts "It's a tweet!"
197
+ when Twitter::DirectMessage
198
+ puts "It's a direct message!"
199
+ when Twitter::Streaming::StallWarning
200
+ warn "Falling behind!"
201
+ end
202
+ end
203
+ ```
204
+
205
+ An `object` may be one of the following:
206
+ * `Twitter::Tweet`
207
+ * `Twitter::DirectMessage`
208
+ * `Twitter::Streaming::DeletedTweet`
209
+ * `Twitter::Streaming::Event`
210
+ * `Twitter::Streaming::FriendList`
211
+ * `Twitter::Streaming::StallWarning`
212
+
213
+ ## Ads
214
+
215
+ We recommend using the [Twitter Ads SDK for Ruby][ads] to interact with the Twitter Ads API.
216
+
217
+ [ads]: http://twitterdev.github.io/twitter-ruby-ads-sdk/
218
+
219
+ ## Object Graph
544
220
  ![Entity-relationship diagram][erd]
545
221
 
546
222
  [erd]: https://cdn.rawgit.com/sferik/twitter/master/etc/erd.svg "Entity-relationship diagram"
@@ -552,7 +228,6 @@ command:
552
228
  bundle exec rake erd
553
229
 
554
230
  ## Supported Ruby Versions
555
-
556
231
  This library aims to support and is [tested against][travis] the following Ruby
557
232
  versions:
558
233
 
@@ -585,7 +260,7 @@ introduced with new major versions. As a result of this policy, you can (and
585
260
  should) specify a dependency on this gem using the [Pessimistic Version
586
261
  Constraint][pvc] with two digits of precision. For example:
587
262
 
588
- spec.add_dependency 'twitter', '~> 5.0'
263
+ spec.add_dependency 'twitter', '~> 6.0'
589
264
 
590
265
  [semver]: http://semver.org/
591
266
  [pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint