twitter 5.0.0 → 5.1.0

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 CHANGED
@@ -8,3 +8,5 @@ CHANGELOG.md
8
8
  CONTRIBUTING.md
9
9
  LICENSE.md
10
10
  README.md
11
+ examples/Configuration.md
12
+ examples/Update.md
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ 5.1.0
2
+ -----
3
+ * [Use `Addressable::URI` everywhere](https://github.com/sferik/twitter/commit/97d7c68900c9974a1f6841f6eed2706df9030d64) ([@matthewrudy](https://twitter.com/matthewrudy))
4
+ * [Allow use of `Twitter::Place` instead of `place_id`](https://github.com/sferik/twitter/commit/c2b31dd2385fefa30a9ddccf15415a713cf5953a)
5
+ * [Allow use of `Twitter::Tweet` instead of `in_reply_to_status_id`](https://github.com/sferik/twitter/commit/6b7d6c2b637a074c348a56a51fb1e02252482fb2)
6
+
7
+ 5.0.1
8
+ -----
9
+ * [Fix `buftok` delimiter handling](https://github.com/sferik/twitter/pull/484)
10
+ * [Started handling streaming deletes](https://github.com/sferik/twitter/commit/8860b97bce4bc36086116f380a2771af3c199ea2)
11
+ * [Replace `URI` with `adressable`](https://github.com/sferik/twitter/commit/7ea2f5390dc7456950f55c90aa4e48f29dcd4604)
12
+
1
13
  5.0.0
2
14
  -----
3
15
  * [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 [Pledgie][].
17
+ * Financially pledge using [gittip][].
18
18
 
19
19
  [issues]: https://github.com/sferik/twitter/issues
20
- [Pledgie]: http://pledgie.com/campaigns/18388
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
@@ -38,7 +38,7 @@ Ideally, a bug report should include a pull request with failing specs.
38
38
  6. Run `bundle exec rake spec`. 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. Run `RUBYOPT=W2 bundle exec rake spec 2>&1 | grep twitter`. If your changes
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
44
  10. Run `bundle exec rake yard`. If your changes are not 100% documented, go
data/README.md CHANGED
@@ -5,14 +5,14 @@
5
5
  [![Dependency Status](https://gemnasium.com/sferik/twitter.png?travis)][gemnasium]
6
6
  [![Code Climate](https://codeclimate.com/github/sferik/twitter.png)][codeclimate]
7
7
  [![Coverage Status](https://coveralls.io/repos/sferik/twitter/badge.png?branch=master)][coveralls]
8
- [![Click here to make a donation](http://www.pledgie.com/campaigns/18388.png)][pledgie]
8
+ [![Gittip](http://img.shields.io/gittip/sferik.png)][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
- [pledgie]: http://pledgie.com/campaigns/18388
15
+ [gittip]: https://www.gittip.com/sferik/
16
16
 
17
17
  A Ruby interface to the Twitter API.
18
18
 
@@ -137,7 +137,7 @@ end
137
137
 
138
138
  ```ruby
139
139
  client.user do |message|
140
- puts message
140
+ puts message
141
141
  end
142
142
  ```
143
143
 
@@ -161,14 +161,14 @@ simplicity and performance.
161
161
  <th>Notes</th>
162
162
  <th colspan="2">Version 4</th>
163
163
  <th colspan="2">Version 5</th>
164
- </th>
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
- </th>
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 lang="ruby">client.friends.first</code></pre>
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 lang="ruby">client.friends.first?</code></pre>
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 lang="ruby">client.friends.users.first</code></pre>
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 lang="ruby">client.friends.first</code></pre>
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 lang="ruby">client.friends.all</code></pre>
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 lang="ruby">client.friends.to_a</code></pre>
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 lang="ruby">client.friends.take(20)</code></pre>
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 lang="ruby">client.friends.take(20)</code></pre>
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 lang="ruby">friends = client.friends
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 lang="ruby">friends = client.friends
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 a
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
@@ -600,7 +600,7 @@ introduced with new major versions. As a result of this policy, you can (and
600
600
  should) specify a dependency on this gem using the [Pessimistic Version
601
601
  Constraint][pvc] with two digits of precision. For example:
602
602
 
603
- spec.add_dependency 'twitter', '~> 4.0'
603
+ spec.add_dependency 'twitter', '~> 5.0'
604
604
 
605
605
  [semver]: http://semver.org/
606
606
  [pvc]: http://docs.rubygems.org/read/chapter/16#page74
data/lib/twitter/base.rb CHANGED
@@ -1,7 +1,7 @@
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
@@ -74,7 +74,7 @@ module Twitter
74
74
  # @param key2 [Symbol]
75
75
  def define_uri_method(key1, key2)
76
76
  define_method(key1) do ||
77
- URI.parse(@attrs[key2]) if @attrs[key2]
77
+ Addressable::URI.parse(@attrs[key2]) if @attrs[key2]
78
78
  end
79
79
  memoize(key1)
80
80
  end
@@ -1,6 +1,6 @@
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
@@ -62,7 +62,7 @@ module Twitter
62
62
  end
63
63
 
64
64
  def oauth_auth_header(method, uri, params={})
65
- uri = URI.parse(uri)
65
+ uri = Addressable::URI.parse(uri)
66
66
  SimpleOAuth::Header.new(method, uri, params, credentials)
67
67
  end
68
68
 
data/lib/twitter/list.rb CHANGED
@@ -8,23 +8,23 @@ module Twitter
8
8
  :mode, :name, :slug, :subscriber_count
9
9
  object_attr_reader :User, :user
10
10
 
11
- # @return [URI] The URI to the list members.
11
+ # @return [Addressable::URI] The URI to the list members.
12
12
  def members_uri
13
- URI.parse("https://twitter.com/#{user.screen_name}/#{slug}/members")
13
+ Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}/members")
14
14
  end
15
15
  memoize :members_uri
16
16
  alias members_url members_uri
17
17
 
18
- # @return [URI] The URI to the list subscribers.
18
+ # @return [Addressable::URI] The URI to the list subscribers.
19
19
  def subscribers_uri
20
- URI.parse("https://twitter.com/#{user.screen_name}/#{slug}/subscribers")
20
+ Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}/subscribers")
21
21
  end
22
22
  memoize :subscribers_uri
23
23
  alias subscribers_url subscribers_uri
24
24
 
25
- # @return [URI] The URI to the list.
25
+ # @return [Addressable::URI] The URI to the list.
26
26
  def uri
27
- URI.parse("https://twitter.com/#{user.screen_name}/#{slug}")
27
+ Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}")
28
28
  end
29
29
  memoize :uri
30
30
  alias url uri
@@ -110,14 +110,19 @@ module Twitter
110
110
  # @return [Twitter::Tweet] The created Tweet.
111
111
  # @param status [String] The text of your status update, up to 140 characters.
112
112
  # @param options [Hash] A customizable set of options.
113
+ # @option options [Twitter::Tweet] :in_reply_to_status An existing status that the update is in reply to.
113
114
  # @option options [Integer] :in_reply_to_status_id The ID of an existing status that the update is in reply to.
114
115
  # @option options [Float] :lat The latitude of the location this tweet refers to. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option.
115
116
  # @option options [Float] :long The longitude of the location this tweet refers to. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option.
117
+ # @option options [Twitter::Place] :place A place in the world. These can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
116
118
  # @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
117
119
  # @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
118
120
  # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
119
121
  def update(status, options={})
120
- object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update.json", options.merge(:status => status))
122
+ hash = options.dup
123
+ hash[:in_reply_to_status_id] = hash.delete(:in_reply_to_status).id unless hash[:in_reply_to_status].nil?
124
+ hash[:place_id] = hash.delete(:place).woeid unless hash[:place].nil?
125
+ object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update.json", hash.merge(:status => status))
121
126
  rescue Twitter::Error::Forbidden => error
122
127
  handle_forbidden_error(Twitter::Error::AlreadyPosted, error)
123
128
  end
@@ -184,14 +189,20 @@ module Twitter
184
189
  # @param status [String] The text of your status update, up to 140 characters.
185
190
  # @param media [File, Hash] A File object with your picture (PNG, JPEG or GIF)
186
191
  # @param options [Hash] A customizable set of options.
192
+ # @option options [Boolean, String, Integer] :possibly_sensitive Set to true for content which may not be suitable for every audience.
193
+ # @option options [Twitter::Tweet] :in_reply_to_status An existing status that the update is in reply to.
187
194
  # @option options [Integer] :in_reply_to_status_id The ID of an existing Tweet that the update is in reply to.
188
195
  # @option options [Float] :lat The latitude of the location this tweet refers to. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option.
189
196
  # @option options [Float] :long The longitude of the location this tweet refers to. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option.
197
+ # @option options [Twitter::Place] :place A place in the world. These can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
190
198
  # @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
191
199
  # @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
192
200
  # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
193
201
  def update_with_media(status, media, options={})
194
- object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update_with_media.json", options.merge('media[]' => media, 'status' => status))
202
+ hash = options.dup
203
+ hash[:in_reply_to_status_id] = hash.delete(:in_reply_to_status).id unless hash[:in_reply_to_status].nil?
204
+ hash[:place_id] = hash.delete(:place).woeid unless hash[:place].nil?
205
+ object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update_with_media.json", hash.merge('media[]' => media, 'status' => status))
195
206
  rescue Twitter::Error::Forbidden => error
196
207
  handle_forbidden_error(Twitter::Error::AlreadyPosted, error)
197
208
  end
@@ -169,7 +169,7 @@ module Twitter
169
169
  user_id = case user
170
170
  when Integer
171
171
  user
172
- when String, URI
172
+ when String, URI, Addressable::URI
173
173
  user(user).id
174
174
  when Twitter::User
175
175
  user.id
@@ -1,7 +1,7 @@
1
+ require 'addressable/uri'
1
2
  require 'twitter/arguments'
2
3
  require 'twitter/cursor'
3
4
  require 'twitter/user'
4
- require 'uri'
5
5
 
6
6
  module Twitter
7
7
  module REST
@@ -185,7 +185,7 @@ module Twitter
185
185
  else
186
186
  set_compound_key("screen_name", user, hash, prefix)
187
187
  end
188
- when URI
188
+ when URI, Addressable::URI
189
189
  set_compound_key("screen_name", user.path.split("/").last, hash, prefix)
190
190
  when Twitter::User
191
191
  set_compound_key("user_id", user.id, hash, prefix)
@@ -11,6 +11,10 @@ module Twitter
11
11
  DirectMessage.new(data[:direct_message])
12
12
  elsif data[:friends]
13
13
  FriendList.new(data[:friends])
14
+ elsif data[:delete]
15
+ if data[:delete][:status]
16
+ Tweet.new(data[:delete][:status].merge(:deleted => true))
17
+ end
14
18
  end
15
19
  end
16
20
  end
data/lib/twitter/tweet.rb CHANGED
@@ -10,6 +10,7 @@ module Twitter
10
10
  alias favoriters_count favorite_count
11
11
  alias in_reply_to_tweet_id in_reply_to_status_id
12
12
  alias retweeters_count retweet_count
13
+ attr_reader :deleted
13
14
  object_attr_reader :GeoFactory, :geo
14
15
  object_attr_reader :Metadata, :metadata
15
16
  object_attr_reader :Place, :place
@@ -30,6 +31,12 @@ module Twitter
30
31
  @attrs[:filter_level] || "none"
31
32
  end
32
33
  memoize :filter_level
34
+
35
+ # @note Not a real entity
36
+ # @return [Boolean]
37
+ def deleted?
38
+ deleted == true
39
+ end
33
40
 
34
41
  # @return [String]
35
42
  # @note May be > 140 characters.
@@ -72,7 +79,7 @@ module Twitter
72
79
 
73
80
  # @return [String] The URL to the tweet.
74
81
  def uri
75
- URI.parse("https://twitter.com/#{user.screen_name}/status/#{id}")
82
+ Addressable::URI.parse("https://twitter.com/#{user.screen_name}/status/#{id}")
76
83
  end
77
84
  memoize :uri
78
85
  alias url uri
data/lib/twitter/user.rb CHANGED
@@ -109,14 +109,14 @@ module Twitter
109
109
 
110
110
  # @return [String] The URL to the user.
111
111
  def uri
112
- URI.parse("https://twitter.com/#{screen_name}")
112
+ Addressable::URI.parse("https://twitter.com/#{screen_name}")
113
113
  end
114
114
  memoize :uri
115
115
  alias url uri
116
116
 
117
117
  # @return [String] The URL to the user's website.
118
118
  def website
119
- URI.parse(@attrs[:url]) if @attrs[:url]
119
+ Addressable::URI.parse(@attrs[:url]) if @attrs[:url]
120
120
  end
121
121
  memoize :website
122
122
 
@@ -128,7 +128,7 @@ module Twitter
128
128
  private
129
129
 
130
130
  def parse_encoded_uri(uri)
131
- URI.parse(URI.encode(uri))
131
+ Addressable::URI.parse(URI.encode(uri))
132
132
  end
133
133
 
134
134
  def insecure_uri(uri)
@@ -1,7 +1,7 @@
1
1
  module Twitter
2
2
  class Version
3
3
  MAJOR = 5
4
- MINOR = 0
4
+ MINOR = 1
5
5
  PATCH = 0
6
6
  PRE = nil
7
7
 
data/lib/twitter.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'addressable/uri'
1
2
  require 'twitter/configuration'
2
3
  require 'twitter/cursor'
3
4
  require 'twitter/direct_message'
@@ -28,4 +29,3 @@ require 'twitter/target_user'
28
29
  require 'twitter/trend'
29
30
  require 'twitter/tweet'
30
31
  require 'twitter/user'
31
- require 'uri'
@@ -29,7 +29,7 @@ describe Twitter::Entity::URI do
29
29
  describe "#expanded_uri" do
30
30
  it "returns a URI when the expanded_url is set" do
31
31
  uri = Twitter::Entity::URI.new(:expanded_url => "https://github.com/sferik")
32
- expect(uri.expanded_uri).to be_a URI
32
+ expect(uri.expanded_uri).to be_a Addressable::URI
33
33
  expect(uri.expanded_uri.to_s).to eq("https://github.com/sferik")
34
34
  end
35
35
  it "returns nil when the expanded_url is not set" do
@@ -52,7 +52,7 @@ describe Twitter::Entity::URI do
52
52
  describe "#uri" do
53
53
  it "returns a URI when the url is set" do
54
54
  uri = Twitter::Entity::URI.new(:url => "https://github.com/sferik")
55
- expect(uri.uri).to be_a URI
55
+ expect(uri.uri).to be_a Addressable::URI
56
56
  expect(uri.uri.to_s).to eq("https://github.com/sferik")
57
57
  end
58
58
  it "returns nil when the url is not set" do
@@ -59,7 +59,7 @@ describe Twitter::Media::Photo do
59
59
  describe "#expanded_uri" do
60
60
  it "returns a URI when the expanded_url is set" do
61
61
  photo = Twitter::Media::Photo.new(:id => 1, :expanded_url => "http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png")
62
- expect(photo.expanded_uri).to be_a URI
62
+ expect(photo.expanded_uri).to be_a Addressable::URI
63
63
  expect(photo.expanded_uri.to_s).to eq("http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png")
64
64
  end
65
65
  it "returns nil when the expanded_url is not set" do
@@ -82,7 +82,7 @@ describe Twitter::Media::Photo do
82
82
  describe "#media_uri" do
83
83
  it "returns a URI when the media_url is set" do
84
84
  photo = Twitter::Media::Photo.new(:id => 1, :media_url => "http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png")
85
- expect(photo.media_uri).to be_a URI
85
+ expect(photo.media_uri).to be_a Addressable::URI
86
86
  expect(photo.media_uri.to_s).to eq("http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png")
87
87
  end
88
88
  it "returns nil when the media_url is not set" do
@@ -105,7 +105,7 @@ describe Twitter::Media::Photo do
105
105
  describe "#media_uri_https" do
106
106
  it "returns a URI when the media_url_https is set" do
107
107
  photo = Twitter::Media::Photo.new(:id => 1, :media_url_https => "http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png")
108
- expect(photo.media_uri_https).to be_a URI
108
+ expect(photo.media_uri_https).to be_a Addressable::URI
109
109
  expect(photo.media_uri_https.to_s).to eq("http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png")
110
110
  end
111
111
  it "returns nil when the media_url_https is not set" do
@@ -128,7 +128,7 @@ describe Twitter::Media::Photo do
128
128
  describe "#uri" do
129
129
  it "returns a URI when the url is set" do
130
130
  photo = Twitter::Media::Photo.new(:id => 1, :url => "http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png")
131
- expect(photo.uri).to be_a URI
131
+ expect(photo.uri).to be_a Addressable::URI
132
132
  expect(photo.uri.to_s).to eq("http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png")
133
133
  end
134
134
  it "returns nil when the url is not set" do
@@ -5,7 +5,7 @@ describe Twitter::OEmbed do
5
5
  describe "#author_uri" do
6
6
  it "returns a URI when the author_url is set" do
7
7
  oembed = Twitter::OEmbed.new(:author_url => "https://twitter.com/sferik")
8
- expect(oembed.author_uri).to be_a URI
8
+ expect(oembed.author_uri).to be_a Addressable::URI
9
9
  expect(oembed.author_uri.to_s).to eq("https://twitter.com/sferik")
10
10
  end
11
11
  it "returns nil when the author_uri is not set" do
@@ -87,7 +87,7 @@ describe Twitter::OEmbed do
87
87
  describe "#provider_uri" do
88
88
  it "returns a URI when the provider_url is set" do
89
89
  oembed = Twitter::OEmbed.new(:provider_url => "http://twitter.com")
90
- expect(oembed.provider_uri).to be_a URI
90
+ expect(oembed.provider_uri).to be_a Addressable::URI
91
91
  expect(oembed.provider_uri.to_s).to eq("http://twitter.com")
92
92
  end
93
93
  it "returns nil when the provider_uri is not set" do
@@ -136,7 +136,7 @@ describe Twitter::OEmbed do
136
136
  describe "#uri" do
137
137
  it "returns a URI when the url is set" do
138
138
  oembed = Twitter::OEmbed.new(:url => "https://twitter.com/twitterapi/status/133640144317198338")
139
- expect(oembed.uri).to be_a URI
139
+ expect(oembed.uri).to be_a Addressable::URI
140
140
  expect(oembed.uri.to_s).to eq("https://twitter.com/twitterapi/status/133640144317198338")
141
141
  end
142
142
  it "returns nil when the url is not set" do
@@ -108,7 +108,7 @@ describe Twitter::Place do
108
108
  describe "#uri" do
109
109
  it "returns a URI when the url is set" do
110
110
  place = Twitter::Place.new(:woeid => "247f43d441defc03", :url => "https://api.twitter.com/1.1/geo/id/247f43d441defc03.json")
111
- expect(place.uri).to be_a URI
111
+ expect(place.uri).to be_a Addressable::URI
112
112
  expect(place.uri.to_s).to eq("https://api.twitter.com/1.1/geo/id/247f43d441defc03.json")
113
113
  end
114
114
  it "returns nil when the url is not set" do
@@ -226,6 +226,44 @@ describe Twitter::REST::API::Tweets do
226
226
  expect{@client.update("The problem with your code is that it's doing exactly what you told it to do.")}.to raise_error Twitter::Error::AlreadyPosted
227
227
  end
228
228
  end
229
+ context "with an in-reply-to status" do
230
+ before do
231
+ @tweet = Twitter::Tweet.new(:id => 1)
232
+ stub_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do.", :in_reply_to_status_id => "1"}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
233
+ end
234
+ it "requests the correct resource" do
235
+ @client.update("The problem with your code is that it's doing exactly what you told it to do.", :in_reply_to_status => @tweet)
236
+ expect(a_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do.", :in_reply_to_status_id => "1"})).to have_been_made
237
+ end
238
+ end
239
+ context "with an in-reply-to status ID" do
240
+ before do
241
+ stub_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do.", :in_reply_to_status_id => "1"}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
242
+ end
243
+ it "requests the correct resource" do
244
+ @client.update("The problem with your code is that it's doing exactly what you told it to do.", :in_reply_to_status_id => 1)
245
+ expect(a_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do.", :in_reply_to_status_id => "1"})).to have_been_made
246
+ end
247
+ end
248
+ context "with a place" do
249
+ before do
250
+ @place = Twitter::Place.new(:woeid => "df51dec6f4ee2b2c")
251
+ stub_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do.", :place_id => "df51dec6f4ee2b2c"}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
252
+ end
253
+ it "requests the correct resource" do
254
+ @client.update("The problem with your code is that it's doing exactly what you told it to do.", :place => @place)
255
+ expect(a_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do.", :place_id => "df51dec6f4ee2b2c"})).to have_been_made
256
+ end
257
+ end
258
+ context "with a place ID" do
259
+ before do
260
+ stub_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do.", :place_id => "df51dec6f4ee2b2c"}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
261
+ end
262
+ it "requests the correct resource" do
263
+ @client.update("The problem with your code is that it's doing exactly what you told it to do.", :place_id => "df51dec6f4ee2b2c")
264
+ expect(a_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do.", :place_id => "df51dec6f4ee2b2c"})).to have_been_made
265
+ end
266
+ end
229
267
  end
230
268
 
231
269
  describe "#retweet" do
@@ -28,7 +28,7 @@ describe Twitter::Trend do
28
28
  describe "#uri" do
29
29
  it "returns a URI when the url is set" do
30
30
  trend = Twitter::Trend.new(:url => "http://twitter.com/search/?q=%23sevenwordsaftersex")
31
- expect(trend.uri).to be_a URI
31
+ expect(trend.uri).to be_a Addressable::URI
32
32
  expect(trend.uri.to_s).to eq("http://twitter.com/search/?q=%23sevenwordsaftersex")
33
33
  end
34
34
  it "returns nil when the url is not set" do
@@ -310,12 +310,29 @@ describe Twitter::Tweet do
310
310
  Twitter::Tweet.new(:id => 28669546014).urls
311
311
  expect($stderr.string).to match(/To get urls, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./)
312
312
  end
313
+
314
+ it "can handle strange urls" do
315
+ urls_array = [
316
+ {
317
+ :url => "http://with_underscore.example.com/t.co",
318
+ :expanded_url => "http://with_underscore.example.com/expanded",
319
+ :display_url => "with_underscore.example.com/expanded…",
320
+ :indices => [10, 33],
321
+ }
322
+ ]
323
+ tweet = Twitter::Tweet.new(:id => 28669546014, :entities => {:urls => urls_array})
324
+ uri = tweet.uris.first
325
+ expect{ uri.url }.to_not raise_error
326
+ expect{ uri.expanded_url }.to_not raise_error
327
+ expect{ uri.display_url }.to_not raise_error
328
+ end
329
+
313
330
  end
314
331
 
315
332
  describe "#uri" do
316
333
  it "returns the URI to the tweet" do
317
334
  tweet = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382, :screen_name => "sferik"})
318
- expect(tweet.uri).to be_a URI
335
+ expect(tweet.uri).to be_a Addressable::URI
319
336
  expect(tweet.uri.to_s).to eq("https://twitter.com/sferik/status/28669546014")
320
337
  end
321
338
  end
@@ -68,11 +68,11 @@ describe Twitter::User do
68
68
  describe "#profile_banner_uri" do
69
69
  it "accepts utf8 urls" do
70
70
  user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581©_normal.png")
71
- expect(user.profile_banner_uri).to be_a URI
71
+ expect(user.profile_banner_uri).to be_a Addressable::URI
72
72
  end
73
73
  it "returns a URI when profile_banner_url is set" do
74
74
  user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581")
75
- expect(user.profile_banner_uri).to be_a URI
75
+ expect(user.profile_banner_uri).to be_a Addressable::URI
76
76
  end
77
77
  it "returns nil when profile_banner_uri is not set" do
78
78
  user = Twitter::User.new(:id => 7505382)
@@ -117,11 +117,11 @@ describe Twitter::User do
117
117
  describe "#profile_banner_uri_https" do
118
118
  it "accepts utf8 urls" do
119
119
  user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581©_normal.png")
120
- expect(user.profile_banner_uri_https).to be_a URI
120
+ expect(user.profile_banner_uri_https).to be_a Addressable::URI
121
121
  end
122
122
  it "returns a URI when profile_banner_url is set" do
123
123
  user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581")
124
- expect(user.profile_banner_uri_https).to be_a URI
124
+ expect(user.profile_banner_uri_https).to be_a Addressable::URI
125
125
  end
126
126
  it "returns nil when created_at is not set" do
127
127
  user = Twitter::User.new(:id => 7505382)
@@ -168,7 +168,7 @@ describe Twitter::User do
168
168
  user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581")
169
169
  expect(user.profile_banner_uri?).to be true
170
170
  end
171
- it "returns false when status is not set" do
171
+ it "returns false when profile_banner_url is not set" do
172
172
  user = Twitter::User.new(:id => 7505382)
173
173
  expect(user.profile_banner_uri?).to be false
174
174
  end
@@ -177,11 +177,11 @@ describe Twitter::User do
177
177
  describe "#profile_image_uri" do
178
178
  it "accepts utf8 urls" do
179
179
  user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://si0.twimg.com/profile_images/7505382/1348266581©_normal.png")
180
- expect(user.profile_image_uri).to be_a URI
180
+ expect(user.profile_image_uri).to be_a Addressable::URI
181
181
  end
182
182
  it "returns a URI when profile_image_url_https is set" do
183
183
  user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png")
184
- expect(user.profile_image_uri).to be_a URI
184
+ expect(user.profile_image_uri).to be_a Addressable::URI
185
185
  end
186
186
  it "returns nil when created_at is not set" do
187
187
  user = Twitter::User.new(:id => 7505382)
@@ -222,11 +222,11 @@ describe Twitter::User do
222
222
  describe "#profile_image_uri_https" do
223
223
  it "accepts utf8 urls" do
224
224
  user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://si0.twimg.com/profile_images/7505382/1348266581©_normal.png")
225
- expect(user.profile_image_uri_https).to be_a URI
225
+ expect(user.profile_image_uri_https).to be_a Addressable::URI
226
226
  end
227
227
  it "returns a URI when profile_image_url_https is set" do
228
228
  user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png")
229
- expect(user.profile_image_uri_https).to be_a URI
229
+ expect(user.profile_image_uri_https).to be_a Addressable::URI
230
230
  end
231
231
  it "returns nil when created_at is not set" do
232
232
  user = Twitter::User.new(:id => 7505382)
@@ -265,11 +265,11 @@ describe Twitter::User do
265
265
  end
266
266
 
267
267
  describe "#profile_image_uri?" do
268
- it "returns true when profile_banner_url is set" do
268
+ it "returns true when profile_image_url_https is set" do
269
269
  user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://si0.twimg.com/profile_banners/7505382/1348266581")
270
270
  expect(user.profile_image_uri?).to be true
271
271
  end
272
- it "returns false when status is not set" do
272
+ it "returns false when profile_image_url_https is not set" do
273
273
  user = Twitter::User.new(:id => 7505382)
274
274
  expect(user.profile_image_uri?).to be false
275
275
  end
@@ -305,7 +305,7 @@ describe Twitter::User do
305
305
  describe "#uri" do
306
306
  it "returns the URI to the user" do
307
307
  user = Twitter::User.new(:id => 7505382, :screen_name => "sferik")
308
- expect(user.uri).to be_a URI
308
+ expect(user.uri).to be_a Addressable::URI
309
309
  expect(user.uri.to_s).to eq("https://twitter.com/sferik")
310
310
  end
311
311
  end
@@ -313,7 +313,7 @@ describe Twitter::User do
313
313
  describe "#website" do
314
314
  it "returns a URI when the url is set" do
315
315
  user = Twitter::User.new(:id => 7505382, :url => "https://github.com/sferik")
316
- expect(user.website).to be_a URI
316
+ expect(user.website).to be_a Addressable::URI
317
317
  expect(user.website.to_s).to eq("https://github.com/sferik")
318
318
  end
319
319
  it "returns nil when the url is not set" do
data/twitter.gemspec CHANGED
@@ -3,7 +3,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'twitter/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.add_dependency 'buftok', '~> 0.1.0'
6
+ spec.add_dependency 'addressable', '~> 2.3'
7
+ spec.add_dependency 'buftok', '~> 0.2.0'
7
8
  spec.add_dependency 'descendants_tracker', '~> 0.0.1'
8
9
  spec.add_dependency 'equalizer', '~> 0.0.7'
9
10
  spec.add_dependency 'faraday', ['>= 0.8', '< 0.10']
@@ -13,7 +14,6 @@ Gem::Specification.new do |spec|
13
14
  spec.add_dependency 'memoizable', '~> 0.2.0'
14
15
  spec.add_dependency 'simple_oauth', '~> 0.2.0'
15
16
  spec.add_development_dependency 'bundler', '~> 1.0'
16
- spec.date = "2013-11-18"
17
17
  spec.authors = ["Erik Michaels-Ober", "John Nunemaker", "Wynn Netherland", "Steve Richert", "Steve Agalloco"]
18
18
  spec.cert_chain = ['certs/sferik.pem']
19
19
  spec.description = %q{A Ruby interface to the Twitter API.}
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -40,8 +40,24 @@ cert_chain:
40
40
  U0xxV3ZRUnNCbHlwSGZoczZKSnVMbHlaUEdoVTNSL3YKU2YzbFZLcEJDV2dS
41
41
  cEdUdnk0NVhWcEIrNTl5MzNQSm1FdVExUFRFT1l2UXlhbzlVS01BQWFBTi83
42
42
  cVdRdGpsMApobHc9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
43
- date: 2013-11-18 00:00:00.000000000 Z
43
+ date: 2013-11-28 00:00:00.000000000 Z
44
44
  dependencies:
45
+ - !ruby/object:Gem::Dependency
46
+ name: addressable
47
+ requirement: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ~>
51
+ - !ruby/object:Gem::Version
52
+ version: '2.3'
53
+ type: :runtime
54
+ prerelease: false
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ version: '2.3'
45
61
  - !ruby/object:Gem::Dependency
46
62
  name: buftok
47
63
  requirement: !ruby/object:Gem::Requirement
@@ -49,7 +65,7 @@ dependencies:
49
65
  requirements:
50
66
  - - ~>
51
67
  - !ruby/object:Gem::Version
52
- version: 0.1.0
68
+ version: 0.2.0
53
69
  type: :runtime
54
70
  prerelease: false
55
71
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,7 +73,7 @@ dependencies:
57
73
  requirements:
58
74
  - - ~>
59
75
  - !ruby/object:Gem::Version
60
- version: 0.1.0
76
+ version: 0.2.0
61
77
  - !ruby/object:Gem::Dependency
62
78
  name: descendants_tracker
63
79
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file