twitter 5.0.0 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +4 -0
- data/CHANGELOG.md +47 -0
- data/CONTRIBUTING.md +5 -5
- data/README.md +57 -56
- data/Rakefile +26 -5
- data/lib/twitter/arguments.rb +1 -2
- data/lib/twitter/base.rb +15 -18
- data/lib/twitter/basic_user.rb +3 -3
- data/lib/twitter/client.rb +9 -10
- data/lib/twitter/configuration.rb +5 -5
- data/lib/twitter/creatable.rb +0 -1
- data/lib/twitter/cursor.rb +9 -36
- data/lib/twitter/direct_message.rb +1 -1
- data/lib/twitter/entity/uri.rb +2 -2
- data/lib/twitter/enumerable.rb +10 -1
- data/lib/twitter/error/already_favorited.rb +1 -1
- data/lib/twitter/error/already_posted.rb +1 -1
- data/lib/twitter/error/already_retweeted.rb +1 -1
- data/lib/twitter/error/too_many_requests.rb +2 -2
- data/lib/twitter/error.rb +6 -6
- data/lib/twitter/factory.rb +2 -6
- data/lib/twitter/geo/point.rb +3 -5
- data/lib/twitter/geo.rb +1 -1
- data/lib/twitter/geo_factory.rb +1 -5
- data/lib/twitter/geo_results.rb +5 -8
- data/lib/twitter/identity.rb +1 -2
- data/lib/twitter/list.rb +10 -11
- data/lib/twitter/media/photo.rb +1 -2
- data/lib/twitter/media_factory.rb +1 -5
- data/lib/twitter/null_object.rb +4 -6
- data/lib/twitter/oembed.rb +1 -1
- data/lib/twitter/place.rb +17 -6
- data/lib/twitter/profile_banner.rb +1 -3
- data/lib/twitter/rate_limit.rb +1 -3
- data/lib/twitter/relationship.rb +1 -2
- data/lib/twitter/rest/api/direct_messages.rb +15 -15
- data/lib/twitter/rest/api/favorites.rb +15 -15
- data/lib/twitter/rest/api/friends_and_followers.rb +37 -42
- data/lib/twitter/rest/api/help.rb +8 -9
- data/lib/twitter/rest/api/lists.rb +69 -69
- data/lib/twitter/rest/api/oauth.rb +3 -4
- data/lib/twitter/rest/api/places_and_geo.rb +9 -10
- data/lib/twitter/rest/api/saved_searches.rb +8 -8
- data/lib/twitter/rest/api/search.rb +10 -2
- data/lib/twitter/rest/api/spam_reporting.rb +1 -2
- data/lib/twitter/rest/api/suggested_users.rb +4 -5
- data/lib/twitter/rest/api/timelines.rb +17 -18
- data/lib/twitter/rest/api/trends.rb +10 -11
- data/lib/twitter/rest/api/tweets.rb +31 -20
- data/lib/twitter/rest/api/undocumented.rb +6 -7
- data/lib/twitter/rest/api/users.rb +53 -54
- data/lib/twitter/rest/api/utils.rb +28 -34
- data/lib/twitter/rest/client.rb +8 -9
- data/lib/twitter/rest/request/multipart_with_file.rb +7 -5
- data/lib/twitter/rest/response/parse_error_json.rb +0 -2
- data/lib/twitter/rest/response/parse_json.rb +2 -2
- data/lib/twitter/rest/response/raise_error.rb +1 -3
- data/lib/twitter/search_results.rb +38 -56
- data/lib/twitter/settings.rb +2 -2
- data/lib/twitter/size.rb +2 -2
- data/lib/twitter/source_user.rb +1 -1
- data/lib/twitter/streaming/client.rb +69 -18
- data/lib/twitter/streaming/connection.rb +1 -3
- data/lib/twitter/streaming/deleted_tweet.rb +8 -0
- data/lib/twitter/streaming/event.rb +8 -8
- data/lib/twitter/streaming/friend_list.rb +2 -9
- data/lib/twitter/streaming/message_parser.rb +13 -3
- data/lib/twitter/streaming/response.rb +0 -2
- data/lib/twitter/streaming/stall_warning.rb +7 -0
- data/lib/twitter/suggestion.rb +0 -1
- data/lib/twitter/token.rb +2 -3
- data/lib/twitter/trend_results.rb +5 -8
- data/lib/twitter/tweet.rb +17 -18
- data/lib/twitter/user.rb +33 -35
- data/lib/twitter/utils.rb +14 -0
- data/lib/twitter/version.rb +2 -5
- data/lib/twitter.rb +1 -1
- data/spec/fixtures/forbidden.json +1 -0
- data/spec/fixtures/search.json +1 -1
- data/spec/fixtures/search2.json +1 -0
- data/spec/fixtures/track_streaming_user.json +2 -1
- data/spec/helper.rb +6 -2
- data/spec/twitter/base_spec.rb +9 -9
- data/spec/twitter/basic_user_spec.rb +6 -6
- data/spec/twitter/configuration_spec.rb +4 -4
- data/spec/twitter/cursor_spec.rb +13 -51
- data/spec/twitter/direct_message_spec.rb +36 -36
- data/spec/twitter/entity/uri_spec.rb +29 -29
- data/spec/twitter/error_spec.rb +21 -21
- data/spec/twitter/geo/point_spec.rb +9 -9
- data/spec/twitter/geo/polygon_spec.rb +5 -5
- data/spec/twitter/geo_factory_spec.rb +7 -7
- data/spec/twitter/geo_results_spec.rb +11 -11
- data/spec/twitter/geo_spec.rb +5 -5
- data/spec/twitter/identifiable_spec.rb +9 -9
- data/spec/twitter/list_spec.rb +38 -38
- data/spec/twitter/media/photo_spec.rb +58 -58
- data/spec/twitter/media_factory_spec.rb +5 -5
- data/spec/twitter/null_object_spec.rb +6 -6
- data/spec/twitter/oembed_spec.rb +68 -68
- data/spec/twitter/place_spec.rb +91 -62
- data/spec/twitter/profile_banner_spec.rb +3 -3
- data/spec/twitter/rate_limit_spec.rb +18 -18
- data/spec/twitter/relationship_spec.rb +16 -16
- data/spec/twitter/rest/api/direct_messages_spec.rb +61 -61
- data/spec/twitter/rest/api/favorites_spec.rb +93 -93
- data/spec/twitter/rest/api/friends_and_followers_spec.rb +357 -349
- data/spec/twitter/rest/api/geo_spec.rb +33 -33
- data/spec/twitter/rest/api/help_spec.rb +24 -24
- data/spec/twitter/rest/api/lists_spec.rb +487 -487
- data/spec/twitter/rest/api/oauth_spec.rb +30 -30
- data/spec/twitter/rest/api/saved_searches_spec.rb +50 -40
- data/spec/twitter/rest/api/search_spec.rb +27 -26
- data/spec/twitter/rest/api/spam_reporting_spec.rb +9 -9
- data/spec/twitter/rest/api/suggested_users_spec.rb +23 -23
- data/spec/twitter/rest/api/timelines_spec.rb +58 -58
- data/spec/twitter/rest/api/trends_spec.rb +26 -26
- data/spec/twitter/rest/api/tweets_spec.rb +304 -266
- data/spec/twitter/rest/api/undocumented_spec.rb +51 -51
- data/spec/twitter/rest/api/users_spec.rb +360 -360
- data/spec/twitter/rest/client_spec.rb +99 -103
- data/spec/twitter/saved_search_spec.rb +16 -16
- data/spec/twitter/search_results_spec.rb +14 -110
- data/spec/twitter/settings_spec.rb +8 -8
- data/spec/twitter/size_spec.rb +5 -5
- data/spec/twitter/source_user_spec.rb +6 -6
- data/spec/twitter/streaming/client_spec.rb +85 -54
- data/spec/twitter/streaming/deleted_tweet_spec.rb +23 -0
- data/spec/twitter/streaming/event_spec.rb +20 -22
- data/spec/twitter/streaming/friend_list_spec.rb +11 -0
- data/spec/twitter/streaming/message_parser_spec.rb +54 -0
- data/spec/twitter/suggestion_spec.rb +11 -11
- data/spec/twitter/target_user_spec.rb +6 -6
- data/spec/twitter/token_spec.rb +4 -4
- data/spec/twitter/trend_results_spec.rb +30 -30
- data/spec/twitter/trend_spec.rb +21 -21
- data/spec/twitter/tweet_spec.rb +178 -164
- data/spec/twitter/user_spec.rb +190 -190
- data/twitter.gemspec +6 -6
- data.tar.gz.sig +0 -0
- metadata +44 -16
- metadata.gz.sig +0 -0
- data/lib/twitter/core_ext/enumerable.rb +0 -10
- data/lib/twitter/core_ext/kernel.rb +0 -10
- data/spec/twitter_spec.rb +0 -0
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
+
5.4.1
|
|
2
|
+
-----
|
|
3
|
+
* [Default to maximum number of tweets per request](https://github.com/sferik/twitter/commit/1e41b5d4dde8678f5968b57dafe9da63b092646c)
|
|
4
|
+
|
|
5
|
+
5.4.0
|
|
6
|
+
-----
|
|
7
|
+
* [Fix enumerable search interface](https://github.com/sferik/twitter/commit/e14cc3391ebe8229184e9e83806c870df3baa24c)
|
|
8
|
+
|
|
9
|
+
5.3.1
|
|
10
|
+
-----
|
|
11
|
+
* [Add `Twitter::Utils` module](https://github.com/sferik/twitter/commit/a1f47fbf19b859c8e680a0a92eff5e225a015090) ([@charliesome](https://twitter.com/charliesome))
|
|
12
|
+
* [Remove `Enumerable` monkey patch](https://github.com/sferik/twitter/commit/818b28d1621e843c0c6f9ef471076f4125623e52) ([@charliesome](https://twitter.com/charliesome))
|
|
13
|
+
* [Don't spawning a new thread if there's only one element](https://github.com/sferik/twitter/commit/c01ea8309c16eb77eeb368452df1dadd1e405532)
|
|
14
|
+
* [Introduce meaningful constant names](https://github.com/sferik/twitter/commit/215c80890d702535de83d8f849885a95ec153920) ([@futuresanta](https://twitter.com/futuresanta))
|
|
15
|
+
* [Automatically flatten `Twitter::Arguments`](https://github.com/sferik/twitter/commit/a556028ace04cb00c3c2b9cb8f72f792a86f04d6)
|
|
16
|
+
|
|
17
|
+
5.3.0
|
|
18
|
+
-----
|
|
19
|
+
* [Add `UNABLE_TO_VERIFY_CREDENTIALS` error code](https://github.com/sferik/twitter/commit/6a47e715ef7935cd36a2f78ed877deb3c09af162)
|
|
20
|
+
* [Don't suppress `Twitter::Error::Forbidden` in #follow and #follow!](https://github.com/sferik/twitter/commit/b949c0400dabc6774419025e7b131d0a18447c3a)
|
|
21
|
+
* [Update memoizable dependency to ~> 0.3.1](https://github.com/sferik/twitter/pull/501)
|
|
22
|
+
|
|
23
|
+
5.2.0
|
|
24
|
+
-----
|
|
25
|
+
* [Replace `URI` with `adressable`](https://github.com/sferik/twitter/commit/7ea2f5390dc7456950f55c90aa4e48f29dcd4604)
|
|
26
|
+
* [Make `Twitter::Streaming::FriendList` an array](https://github.com/sferik/twitter/commit/1a38e5e8182823c3060fc59c270ef754bd49a179)
|
|
27
|
+
* [Add `Twitter::Streaming::DeletedTweet`](https://github.com/sferik/twitter/commit/084025b5e348bd33b4c29c6b9e40565c0e77319c)
|
|
28
|
+
* [Add `Twitter::Streaming::StallWarning`](https://github.com/sferik/twitter/commit/b07ac50552f5063ee43a490fa40da8b6889df772)
|
|
29
|
+
* [Add error code for "User is over daily status update limit"](https://github.com/sferik/twitter/commit/76c088d38e594703ee391f2a524142aa357b0972)
|
|
30
|
+
* [`Twitter::Streaming::Client#site` can take a `String` or `Twitter::User`](https://github.com/sferik/twitter/commit/e3ad4f2da1f8fc82e1d3febbc2602f626bced8a8)
|
|
31
|
+
* [Update `http_parser.rb` dependency to `~> 0.6.0`](https://github.com/sferik/twitter/commit/6d2f81bfc5bd469d558868a0f65356f30ca9f5e7)
|
|
32
|
+
|
|
33
|
+
5.1.1
|
|
34
|
+
-----
|
|
35
|
+
* [Custom equalizer for `Twitter::Place`](https://github.com/sferik/twitter/commit/79c76a9bed4f0170c8c09fe38ad4f0ee6aa4505e)
|
|
36
|
+
|
|
37
|
+
5.1.0
|
|
38
|
+
-----
|
|
39
|
+
* [Use `Addressable::URI` everywhere](https://github.com/sferik/twitter/commit/97d7c68900c9974a1f6841f6eed2706df9030d64) ([@matthewrudy](https://twitter.com/matthewrudy))
|
|
40
|
+
* [Allow use of `Twitter::Place` instead of `place_id`](https://github.com/sferik/twitter/commit/c2b31dd2385fefa30a9ddccf15415a713cf5953a)
|
|
41
|
+
* [Allow use of `Twitter::Tweet` instead of `in_reply_to_status_id`](https://github.com/sferik/twitter/commit/6b7d6c2b637a074c348a56a51fb1e02252482fb2)
|
|
42
|
+
|
|
43
|
+
5.0.1
|
|
44
|
+
-----
|
|
45
|
+
* [Fix `buftok` delimiter handling](https://github.com/sferik/twitter/pull/484)
|
|
46
|
+
* [Started handling streaming deletes](https://github.com/sferik/twitter/commit/8860b97bce4bc36086116f380a2771af3c199ea2)
|
|
47
|
+
|
|
1
48
|
5.0.0
|
|
2
49
|
-----
|
|
3
50
|
* [Remove `Twitter::API::Undocumented#status_activity` and `#statuses_activity`](https://github.com/sferik/twitter/commit/7f970810af251b2fe80c38b30c54485c55bd2034)
|
data/CONTRIBUTING.md
CHANGED
|
@@ -14,10 +14,10 @@ improve this project. Here are some ways *you* can contribute:
|
|
|
14
14
|
* Refactor code.
|
|
15
15
|
* Fix [issues][].
|
|
16
16
|
* Review patches.
|
|
17
|
-
* Financially pledge using [
|
|
17
|
+
* Financially pledge using [gittip][].
|
|
18
18
|
|
|
19
19
|
[issues]: https://github.com/sferik/twitter/issues
|
|
20
|
-
[
|
|
20
|
+
[gittip]: https://www.gittip.com/sferik/
|
|
21
21
|
|
|
22
22
|
## Submitting an Issue
|
|
23
23
|
We use the [GitHub issue tracker][issues] to track bugs and features. Before
|
|
@@ -35,13 +35,13 @@ Ideally, a bug report should include a pull request with failing specs.
|
|
|
35
35
|
3. Add specs for your unimplemented feature or bug fix.
|
|
36
36
|
4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
|
|
37
37
|
5. Implement your feature or bug fix.
|
|
38
|
-
6. Run `bundle exec rake
|
|
38
|
+
6. Run `bundle exec rake default`. If your specs fail, return to step 5.
|
|
39
39
|
7. Run `open coverage/index.html`. If your changes are not completely covered
|
|
40
40
|
by your tests, return to step 3.
|
|
41
|
-
8.
|
|
41
|
+
8. Run `RUBYOPT=W2 bundle exec rake spec 2>&1 | grep twitter`. If your changes
|
|
42
42
|
produce any warnings, return to step 5.
|
|
43
43
|
9. Add documentation for your feature or bug fix.
|
|
44
|
-
10. Run `bundle exec rake
|
|
44
|
+
10. Run `bundle exec rake verify_measurements`. If your changes are not 100% documented, go
|
|
45
45
|
back to step 9.
|
|
46
46
|
11. Commit and push your changes.
|
|
47
47
|
12. [Submit a pull request.][pr]
|
data/README.md
CHANGED
|
@@ -5,30 +5,20 @@
|
|
|
5
5
|
[][gemnasium]
|
|
6
6
|
[][codeclimate]
|
|
7
7
|
[][coveralls]
|
|
8
|
-
[][gittip]
|
|
9
9
|
|
|
10
10
|
[gem]: https://rubygems.org/gems/twitter
|
|
11
11
|
[travis]: http://travis-ci.org/sferik/twitter
|
|
12
12
|
[gemnasium]: https://gemnasium.com/sferik/twitter
|
|
13
13
|
[codeclimate]: https://codeclimate.com/github/sferik/twitter
|
|
14
14
|
[coveralls]: https://coveralls.io/r/sferik/twitter
|
|
15
|
-
[
|
|
15
|
+
[gittip]: https://www.gittip.com/sferik/
|
|
16
16
|
|
|
17
17
|
A Ruby interface to the Twitter API.
|
|
18
18
|
|
|
19
19
|
## Installation
|
|
20
20
|
gem install twitter
|
|
21
21
|
|
|
22
|
-
To ensure the code you're installing hasn't been tampered with, it's
|
|
23
|
-
recommended that you verify the signature. To do this, you need to add my
|
|
24
|
-
public key as a trusted certificate (you only need to do this once):
|
|
25
|
-
|
|
26
|
-
gem cert --add <(curl -Ls https://raw.github.com/sferik/twitter/master/certs/sferik.pem)
|
|
27
|
-
|
|
28
|
-
Then, install the gem with the high security trust policy:
|
|
29
|
-
|
|
30
|
-
gem install twitter -P HighSecurity
|
|
31
|
-
|
|
32
22
|
## CLI
|
|
33
23
|
|
|
34
24
|
Looking for the Twitter command-line interface? It was [removed][] from this
|
|
@@ -42,6 +32,11 @@ gem in version 0.5.0 and now exists as a [separate project][t].
|
|
|
42
32
|
|
|
43
33
|
[documentation]: http://rdoc.info/gems/twitter
|
|
44
34
|
|
|
35
|
+
## Examples
|
|
36
|
+
[https://github.com/sferik/twitter/tree/master/examples][examples]
|
|
37
|
+
|
|
38
|
+
[examples]: https://github.com/sferik/twitter/tree/master/examples
|
|
39
|
+
|
|
45
40
|
## Announcements
|
|
46
41
|
You should [follow @gem][follow] on Twitter for announcements and updates about
|
|
47
42
|
this library.
|
|
@@ -120,55 +115,60 @@ end
|
|
|
120
115
|
|
|
121
116
|
```ruby
|
|
122
117
|
topics = ["coffee", "tea"]
|
|
123
|
-
client.filter(:track => topics.join(",")) do |
|
|
124
|
-
puts
|
|
118
|
+
client.filter(:track => topics.join(",")) do |object|
|
|
119
|
+
puts object.text if object.is_a?(Twitter::Tweet)
|
|
125
120
|
end
|
|
126
121
|
```
|
|
127
122
|
|
|
128
123
|
**Stream a random sample of all tweets**
|
|
129
124
|
|
|
130
125
|
```ruby
|
|
131
|
-
client.sample do |
|
|
132
|
-
puts
|
|
126
|
+
client.sample do |object|
|
|
127
|
+
puts object.text if object.is_a?(Twitter::Tweet)
|
|
133
128
|
end
|
|
134
129
|
```
|
|
135
130
|
|
|
136
|
-
**Stream tweets, events and direct messages for the authenticated user**
|
|
131
|
+
**Stream tweets, events, and direct messages for the authenticated user**
|
|
137
132
|
|
|
138
133
|
```ruby
|
|
139
|
-
client.user do |
|
|
140
|
-
|
|
134
|
+
client.user do |object|
|
|
135
|
+
case object
|
|
136
|
+
when Twitter::Tweet
|
|
137
|
+
puts "It's a tweet!"
|
|
138
|
+
when Twitter::DirectMessage
|
|
139
|
+
puts "It's a direct message!"
|
|
140
|
+
when Twitter::Streaming::StallWarning
|
|
141
|
+
warn "Falling behind!"
|
|
142
|
+
end
|
|
141
143
|
end
|
|
142
144
|
```
|
|
143
145
|
|
|
144
|
-
`
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
146
|
+
An `object` may be one of the following:
|
|
147
|
+
* Twitter::DirectMessage
|
|
148
|
+
* Twitter::Streaming::DeletedTweet
|
|
149
|
+
* Twitter::Streaming::Event
|
|
150
|
+
* Twitter::Streaming::FriendList
|
|
151
|
+
* Twitter::Streaming::StallWarning
|
|
152
|
+
* Twitter::Tweet
|
|
151
153
|
|
|
152
154
|
### Cursors
|
|
153
155
|
The `Twitter::Cursor` class has been completely redesigned with a focus on
|
|
154
156
|
simplicity and performance.
|
|
155
157
|
|
|
156
|
-
[cursors]: https://dev.twitter.com/docs/misc/cursoring
|
|
157
|
-
|
|
158
158
|
<table>
|
|
159
159
|
<thead>
|
|
160
160
|
<tr>
|
|
161
161
|
<th>Notes</th>
|
|
162
162
|
<th colspan="2">Version 4</th>
|
|
163
163
|
<th colspan="2">Version 5</th>
|
|
164
|
-
</
|
|
164
|
+
</tr>
|
|
165
165
|
<tr>
|
|
166
166
|
<th></th>
|
|
167
167
|
<th>Code</th>
|
|
168
168
|
<th>HTTP GETs</th>
|
|
169
169
|
<th>Code</th>
|
|
170
170
|
<th>HTTP GETs</th>
|
|
171
|
-
</
|
|
171
|
+
</tr>
|
|
172
172
|
</thead>
|
|
173
173
|
<tbody>
|
|
174
174
|
<tr>
|
|
@@ -176,13 +176,13 @@ simplicity and performance.
|
|
|
176
176
|
Are you at the start of the cursor?
|
|
177
177
|
</td>
|
|
178
178
|
<td>
|
|
179
|
-
<pre><code
|
|
179
|
+
<pre><code>client.friends.first</code></pre>
|
|
180
180
|
</td>
|
|
181
181
|
<td>
|
|
182
182
|
<em>Θ(1)</em>
|
|
183
183
|
</td>
|
|
184
184
|
<td>
|
|
185
|
-
<pre><code
|
|
185
|
+
<pre><code>client.friends.first?</code></pre>
|
|
186
186
|
</td>
|
|
187
187
|
<td>
|
|
188
188
|
<em>Θ(1)</em>
|
|
@@ -193,13 +193,13 @@ simplicity and performance.
|
|
|
193
193
|
Return your most recent follower.
|
|
194
194
|
</td>
|
|
195
195
|
<td>
|
|
196
|
-
<pre><code
|
|
196
|
+
<pre><code>client.friends.users.first</code></pre>
|
|
197
197
|
</td>
|
|
198
198
|
<td>
|
|
199
199
|
<em>Θ(1)</em>
|
|
200
200
|
</td>
|
|
201
201
|
<td>
|
|
202
|
-
<pre><code
|
|
202
|
+
<pre><code>client.friends.first</code></pre>
|
|
203
203
|
</td>
|
|
204
204
|
<td>
|
|
205
205
|
<em>Θ(1)</em>
|
|
@@ -210,13 +210,13 @@ simplicity and performance.
|
|
|
210
210
|
Return an array of all your friends.
|
|
211
211
|
</td>
|
|
212
212
|
<td>
|
|
213
|
-
<pre><code
|
|
213
|
+
<pre><code>client.friends.all</code></pre>
|
|
214
214
|
</td>
|
|
215
215
|
<td>
|
|
216
216
|
<em>Θ(n+1)</em>
|
|
217
217
|
</td>
|
|
218
218
|
<td>
|
|
219
|
-
<pre><code
|
|
219
|
+
<pre><code>client.friends.to_a</code></pre>
|
|
220
220
|
</td>
|
|
221
221
|
<td>
|
|
222
222
|
<em>Θ(n)</em>
|
|
@@ -227,13 +227,13 @@ simplicity and performance.
|
|
|
227
227
|
Collect your 20 most recent friends.
|
|
228
228
|
</td>
|
|
229
229
|
<td>
|
|
230
|
-
<pre><code
|
|
230
|
+
<pre><code>client.friends.take(20)</code></pre>
|
|
231
231
|
</td>
|
|
232
232
|
<td>
|
|
233
233
|
<em>Θ(n+1)</em>
|
|
234
234
|
</td>
|
|
235
235
|
<td>
|
|
236
|
-
<pre><code
|
|
236
|
+
<pre><code>client.friends.take(20)</code></pre>
|
|
237
237
|
</td>
|
|
238
238
|
<td>
|
|
239
239
|
<em>Θ(1)</em>
|
|
@@ -244,7 +244,7 @@ simplicity and performance.
|
|
|
244
244
|
Collect your 20 most recent friends twice.
|
|
245
245
|
</td>
|
|
246
246
|
<td>
|
|
247
|
-
<pre><code
|
|
247
|
+
<pre><code>friends = client.friends
|
|
248
248
|
2.times.collect do
|
|
249
249
|
friends.take(20)
|
|
250
250
|
end</code></pre>
|
|
@@ -253,7 +253,7 @@ end</code></pre>
|
|
|
253
253
|
<em>Θ(2n+2)</em>
|
|
254
254
|
</td>
|
|
255
255
|
<td>
|
|
256
|
-
<pre><code
|
|
256
|
+
<pre><code>friends = client.friends
|
|
257
257
|
2.times.collect do
|
|
258
258
|
friends.take(20)
|
|
259
259
|
end</code></pre>
|
|
@@ -423,8 +423,8 @@ These methods are aliased to `#url` for users who prefer that nomenclature.
|
|
|
423
423
|
`Twitter::User` previously had a `#url` method, which returned the user's
|
|
424
424
|
website. This URI is now available via the `#website` method.
|
|
425
425
|
|
|
426
|
-
All `#uri` methods now return `URI` objects instead of strings. To convert
|
|
427
|
-
`URI` object to a string, call `#to_s` on it.
|
|
426
|
+
All `#uri` methods now return `Addressable::URI` objects instead of strings. To convert an
|
|
427
|
+
`Addressable::URI` object to a string, call `#to_s` on it.
|
|
428
428
|
|
|
429
429
|
## Configuration
|
|
430
430
|
Twitter API v1.1 requires you to authenticate via OAuth, so you'll need to
|
|
@@ -500,14 +500,14 @@ client.follow(213747670)
|
|
|
500
500
|
client.user("gem")
|
|
501
501
|
client.user(213747670)
|
|
502
502
|
```
|
|
503
|
-
**Fetch a cursored list of followers with profile details (by screen name or user ID, or by
|
|
503
|
+
**Fetch a cursored list of followers with profile details (by screen name or user ID, or by implicit authenticated user)**
|
|
504
504
|
|
|
505
505
|
```ruby
|
|
506
506
|
client.followers("gem")
|
|
507
507
|
client.followers(213747670)
|
|
508
508
|
client.followers
|
|
509
509
|
```
|
|
510
|
-
**Fetch a cursored list of friends with profile details (by screen name or user ID, or by
|
|
510
|
+
**Fetch a cursored list of friends with profile details (by screen name or user ID, or by implicit authenticated user)**
|
|
511
511
|
|
|
512
512
|
```ruby
|
|
513
513
|
client.friends("gem")
|
|
@@ -569,26 +569,27 @@ command:
|
|
|
569
569
|
bundle exec rake erd
|
|
570
570
|
|
|
571
571
|
## Supported Ruby Versions
|
|
572
|
+
|
|
572
573
|
This library aims to support and is [tested against][travis] the following Ruby
|
|
573
|
-
|
|
574
|
+
versions:
|
|
574
575
|
|
|
575
576
|
* Ruby 1.8.7
|
|
576
577
|
* Ruby 1.9.2
|
|
577
578
|
* Ruby 1.9.3
|
|
578
579
|
* Ruby 2.0.0
|
|
579
580
|
|
|
580
|
-
If something doesn't work on one of these
|
|
581
|
+
If something doesn't work on one of these versions, it's a bug.
|
|
581
582
|
|
|
582
|
-
This library may inadvertently work (or seem to work) on other Ruby
|
|
583
|
-
|
|
584
|
-
above.
|
|
583
|
+
This library may inadvertently work (or seem to work) on other Ruby versions,
|
|
584
|
+
however support will only be provided for the versions listed above.
|
|
585
585
|
|
|
586
|
-
If you would like this library to support another Ruby version
|
|
587
|
-
volunteer to be a maintainer. Being a maintainer
|
|
588
|
-
run and pass on that implementation. When
|
|
589
|
-
implementation, you will be responsible for providing
|
|
590
|
-
fashion. If critical issues for a particular implementation
|
|
591
|
-
of a major release, support for that Ruby version may be
|
|
586
|
+
If you would like this library to support another Ruby version or
|
|
587
|
+
implementation, you may volunteer to be a maintainer. Being a maintainer
|
|
588
|
+
entails making sure all tests run and pass on that implementation. When
|
|
589
|
+
something breaks on your implementation, you will be responsible for providing
|
|
590
|
+
patches in a timely fashion. If critical issues for a particular implementation
|
|
591
|
+
exist at the time of a major release, support for that Ruby version may be
|
|
592
|
+
dropped.
|
|
592
593
|
|
|
593
594
|
## Versioning
|
|
594
595
|
This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
|
|
@@ -600,7 +601,7 @@ introduced with new major versions. As a result of this policy, you can (and
|
|
|
600
601
|
should) specify a dependency on this gem using the [Pessimistic Version
|
|
601
602
|
Constraint][pvc] with two digits of precision. For example:
|
|
602
603
|
|
|
603
|
-
spec.add_dependency 'twitter', '~>
|
|
604
|
+
spec.add_dependency 'twitter', '~> 5.0'
|
|
604
605
|
|
|
605
606
|
[semver]: http://semver.org/
|
|
606
607
|
[pvc]: http://docs.rubygems.org/read/chapter/16#page74
|
data/Rakefile
CHANGED
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
require 'bundler'
|
|
2
2
|
Bundler::GemHelper.install_tasks
|
|
3
3
|
|
|
4
|
+
task :erd do
|
|
5
|
+
`bundle exec ruby ./etc/erd.rb > ./etc/erd.dot`
|
|
6
|
+
`dot -Tpng ./etc/erd.dot -o ./etc/erd.png`
|
|
7
|
+
`open ./etc/erd.png`
|
|
8
|
+
end
|
|
9
|
+
|
|
4
10
|
require 'rspec/core/rake_task'
|
|
5
11
|
RSpec::Core::RakeTask.new(:spec)
|
|
6
12
|
|
|
7
13
|
task :test => :spec
|
|
8
|
-
task :default => :spec
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
begin
|
|
16
|
+
require 'rubocop/rake_task'
|
|
17
|
+
Rubocop::RakeTask.new
|
|
18
|
+
rescue LoadError
|
|
19
|
+
desc 'Run RuboCop'
|
|
20
|
+
task :rubocop do
|
|
21
|
+
$stderr.puts 'Rubocop is disabled'
|
|
22
|
+
end
|
|
14
23
|
end
|
|
15
24
|
|
|
16
25
|
require 'yard'
|
|
17
26
|
YARD::Rake::YardocTask.new
|
|
27
|
+
|
|
28
|
+
require 'yardstick/rake/measurement'
|
|
29
|
+
Yardstick::Rake::Measurement.new do |measurement|
|
|
30
|
+
measurement.output = 'measurement/report.txt'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
require 'yardstick/rake/verify'
|
|
34
|
+
Yardstick::Rake::Verify.new do |verify|
|
|
35
|
+
verify.threshold = 59.9
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
task :default => [:spec, :rubocop, :verify_measurements]
|
data/lib/twitter/arguments.rb
CHANGED
data/lib/twitter/base.rb
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
+
require 'addressable/uri'
|
|
1
2
|
require 'forwardable'
|
|
2
3
|
require 'memoizable'
|
|
3
4
|
require 'twitter/null_object'
|
|
4
|
-
require 'uri'
|
|
5
5
|
|
|
6
6
|
module Twitter
|
|
7
7
|
class Base
|
|
8
8
|
extend Forwardable
|
|
9
9
|
include Memoizable
|
|
10
10
|
attr_reader :attrs
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
alias_method :to_h, :attrs
|
|
12
|
+
alias_method :to_hash, :attrs
|
|
13
|
+
alias_method :to_hsh, :attrs
|
|
14
14
|
|
|
15
15
|
class << self
|
|
16
|
-
|
|
17
16
|
# Construct an object from a response hash
|
|
18
17
|
#
|
|
19
18
|
# @param response [Hash]
|
|
20
19
|
# @return [Twitter::Base]
|
|
21
|
-
def from_response(response={})
|
|
20
|
+
def from_response(response = {})
|
|
22
21
|
new(response[:body])
|
|
23
22
|
end
|
|
24
23
|
|
|
@@ -37,7 +36,7 @@ module Twitter
|
|
|
37
36
|
# @param klass [Symbol]
|
|
38
37
|
# @param key1 [Symbol]
|
|
39
38
|
# @param key2 [Symbol]
|
|
40
|
-
def object_attr_reader(klass, key1, key2=nil)
|
|
39
|
+
def object_attr_reader(klass, key1, key2 = nil)
|
|
41
40
|
define_attribute_method(key1, klass, key2)
|
|
42
41
|
define_predicate_method(key1)
|
|
43
42
|
end
|
|
@@ -47,10 +46,10 @@ module Twitter
|
|
|
47
46
|
# @param attrs [Array, Symbol]
|
|
48
47
|
def uri_attr_reader(*attrs)
|
|
49
48
|
attrs.each do |uri_key|
|
|
50
|
-
array = uri_key.to_s.split(
|
|
51
|
-
index = array.index(
|
|
52
|
-
array[index] =
|
|
53
|
-
url_key = array.join(
|
|
49
|
+
array = uri_key.to_s.split('_')
|
|
50
|
+
index = array.index('uri')
|
|
51
|
+
array[index] = 'url'
|
|
52
|
+
url_key = array.join('_').to_sym
|
|
54
53
|
define_uri_method(uri_key, url_key)
|
|
55
54
|
alias_method(url_key, uri_key)
|
|
56
55
|
define_predicate_method(uri_key, url_key)
|
|
@@ -74,7 +73,7 @@ module Twitter
|
|
|
74
73
|
# @param key2 [Symbol]
|
|
75
74
|
def define_uri_method(key1, key2)
|
|
76
75
|
define_method(key1) do ||
|
|
77
|
-
URI.parse(@attrs[key2]) if @attrs[key2]
|
|
76
|
+
Addressable::URI.parse(@attrs[key2]) if @attrs[key2]
|
|
78
77
|
end
|
|
79
78
|
memoize(key1)
|
|
80
79
|
end
|
|
@@ -84,7 +83,7 @@ module Twitter
|
|
|
84
83
|
# @param key1 [Symbol]
|
|
85
84
|
# @param klass [Symbol]
|
|
86
85
|
# @param key2 [Symbol]
|
|
87
|
-
def define_attribute_method(key1, klass=nil, key2=nil)
|
|
86
|
+
def define_attribute_method(key1, klass = nil, key2 = nil)
|
|
88
87
|
define_method(key1) do ||
|
|
89
88
|
if klass.nil?
|
|
90
89
|
@attrs[key1]
|
|
@@ -104,20 +103,19 @@ module Twitter
|
|
|
104
103
|
#
|
|
105
104
|
# @param key1 [Symbol]
|
|
106
105
|
# @param key2 [Symbol]
|
|
107
|
-
def define_predicate_method(key1, key2=key1)
|
|
106
|
+
def define_predicate_method(key1, key2 = key1)
|
|
108
107
|
define_method(:"#{key1}?") do ||
|
|
109
108
|
!!@attrs[key2]
|
|
110
109
|
end
|
|
111
110
|
memoize(:"#{key1}?")
|
|
112
111
|
end
|
|
113
|
-
|
|
114
112
|
end
|
|
115
113
|
|
|
116
114
|
# Initializes a new object
|
|
117
115
|
#
|
|
118
116
|
# @param attrs [Hash]
|
|
119
117
|
# @return [Twitter::Base]
|
|
120
|
-
def initialize(attrs={})
|
|
118
|
+
def initialize(attrs = {})
|
|
121
119
|
@attrs = attrs || {}
|
|
122
120
|
end
|
|
123
121
|
|
|
@@ -132,7 +130,7 @@ module Twitter
|
|
|
132
130
|
|
|
133
131
|
private
|
|
134
132
|
|
|
135
|
-
def attrs_for_object(key1, key2=nil)
|
|
133
|
+
def attrs_for_object(key1, key2 = nil)
|
|
136
134
|
if key2.nil?
|
|
137
135
|
@attrs[key1]
|
|
138
136
|
else
|
|
@@ -140,6 +138,5 @@ module Twitter
|
|
|
140
138
|
attrs.delete(key1).merge(key2 => attrs)
|
|
141
139
|
end
|
|
142
140
|
end
|
|
143
|
-
|
|
144
141
|
end
|
|
145
142
|
end
|
data/lib/twitter/basic_user.rb
CHANGED
|
@@ -3,8 +3,8 @@ require 'twitter/identity'
|
|
|
3
3
|
module Twitter
|
|
4
4
|
class BasicUser < Twitter::Identity
|
|
5
5
|
attr_reader :following, :screen_name
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
alias_method :handle, :screen_name
|
|
7
|
+
alias_method :username, :screen_name
|
|
8
|
+
alias_method :user_name, :screen_name
|
|
9
9
|
end
|
|
10
10
|
end
|
data/lib/twitter/client.rb
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
require 'addressable/uri'
|
|
1
2
|
require 'simple_oauth'
|
|
2
3
|
require 'twitter/version'
|
|
3
|
-
require 'uri'
|
|
4
4
|
|
|
5
5
|
module Twitter
|
|
6
6
|
class Client
|
|
7
7
|
attr_accessor :access_token, :access_token_secret, :consumer_key, :consumer_secret
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
alias_method :oauth_token, :access_token
|
|
9
|
+
alias_method :oauth_token=, :access_token=
|
|
10
|
+
alias_method :oauth_token_secret, :access_token_secret
|
|
11
|
+
alias_method :oauth_token_secret=, :access_token_secret=
|
|
12
12
|
|
|
13
13
|
# Initializes a new Client object
|
|
14
14
|
#
|
|
15
15
|
# @param options [Hash]
|
|
16
16
|
# @return [Twitter::Client]
|
|
17
|
-
def initialize(options={})
|
|
17
|
+
def initialize(options = {})
|
|
18
18
|
options.each do |key, value|
|
|
19
19
|
send(:"#{key}=", value)
|
|
20
20
|
end
|
|
@@ -57,14 +57,13 @@ module Twitter
|
|
|
57
57
|
def validate_credential_type!
|
|
58
58
|
credentials.each do |credential, value|
|
|
59
59
|
next if value.nil?
|
|
60
|
-
|
|
60
|
+
fail(Error::ConfigurationError, "Invalid #{credential} specified: #{value.inspect} must be a string or symbol.") unless value.is_a?(String) || value.is_a?(Symbol)
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
def oauth_auth_header(method, uri, params={})
|
|
65
|
-
uri = URI.parse(uri)
|
|
64
|
+
def oauth_auth_header(method, uri, params = {})
|
|
65
|
+
uri = Addressable::URI.parse(uri)
|
|
66
66
|
SimpleOAuth::Header.new(method, uri, params, credentials)
|
|
67
67
|
end
|
|
68
|
-
|
|
69
68
|
end
|
|
70
69
|
end
|
|
@@ -3,20 +3,20 @@ require 'twitter/base'
|
|
|
3
3
|
module Twitter
|
|
4
4
|
class Configuration < Twitter::Base
|
|
5
5
|
attr_reader :characters_reserved_per_media, :max_media_per_upload,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
:non_username_paths, :photo_size_limit, :short_url_length,
|
|
7
|
+
:short_url_length_https
|
|
8
|
+
alias_method :short_uri_length, :short_url_length
|
|
9
|
+
alias_method :short_uri_length_https, :short_url_length_https
|
|
9
10
|
|
|
10
11
|
# Returns an array of photo sizes
|
|
11
12
|
#
|
|
12
13
|
# @return [Array<Twitter::Size>]
|
|
13
14
|
def photo_sizes
|
|
14
|
-
Array(@attrs[:photo_sizes]).
|
|
15
|
+
Array(@attrs[:photo_sizes]).reduce({}) do |object, (key, value)|
|
|
15
16
|
object[key] = Size.new(value)
|
|
16
17
|
object
|
|
17
18
|
end
|
|
18
19
|
end
|
|
19
20
|
memoize :photo_sizes
|
|
20
|
-
|
|
21
21
|
end
|
|
22
22
|
end
|