twitter 4.4.0 → 4.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ 4.4.1
2
+ -----
3
+ * [Do not modify `Thread.abort_on_exception`](https://github.com/sferik/twitter/commit/6de998ced1f3dce97a24e500ecf2348192ae9316)
4
+
1
5
  4.4.0
2
6
  -----
3
7
  * [Add `Twitter::API::FriendsAndFollowers#friends` and `Twitter::API::FriendsAndFollowers#followers`](https://github.com/sferik/twitter/commit/03e1512a8e5e589771414aaf46db34718f1469ce) ([@tibbon](https://twitter.com/tibbon))
data/CONTRIBUTING.md CHANGED
@@ -12,7 +12,7 @@ Here are some ways *you* can contribute:
12
12
  * by writing or editing documentation
13
13
  * by writing specifications
14
14
  * by writing code (**no patch is too small**: fix typos, add comments, clean up
15
- inconsistent whitespace)
15
+ inconsistent whitespace)
16
16
  * by refactoring code
17
17
  * by fixing [issues][]
18
18
  * by reviewing patches
@@ -40,11 +40,13 @@ Ideally, a bug report should include a pull request with failing specs.
40
40
  6. Run `bundle exec rake spec`. If your specs fail, return to step 5.
41
41
  7. Run `open coverage/index.html`. If your changes are not completely covered
42
42
  by your tests, return to step 3.
43
- 8. Add documentation for your feature or bug fix.
44
- 9. Run `bundle exec rake yard`. If your changes are not 100% documented, go
45
- back to step 8.
46
- 10. Add, commit, and push your changes.
47
- 11. [Submit a pull request.][pr]
43
+ 8 Run `RUBYOPT=W2 bundle exec rake spec 2>&1 | grep twitter`. If your changes
44
+ produce any warnings, return to step 5.
45
+ 9. Add documentation for your feature or bug fix.
46
+ 10. Run `bundle exec rake yard`. If your changes are not 100% documented, go
47
+ back to step 9.
48
+ 11. Commit and push your changes.
49
+ 12. [Submit a pull request.][pr]
48
50
 
49
51
  [fork]: http://help.github.com/fork-a-repo/
50
52
  [branch]: http://learn.github.com/p/branching.html
data/README.md CHANGED
@@ -371,7 +371,7 @@ Here are some fun facts about this library:
371
371
 
372
372
  * It is implemented in just 2,000 lines of Ruby code
373
373
  * With over 4,000 lines of specs, the spec-to-code ratio is over 2:1
374
- * The spec suite contains 700 examples and runs in about 2 seconds
374
+ * The spec suite contains over 700 examples and runs in about 5 seconds
375
375
  * It has 100% C0 code coverage (the tests execute every line of
376
376
  source code at least once)
377
377
  * It is comprehensive: you can request all documented Twitter REST API
@@ -405,6 +405,22 @@ implementation, you will be personally responsible for providing patches in a
405
405
  timely fashion. If critical issues for a particular implementation exist at the
406
406
  time of a major release, support for that Ruby version may be dropped.
407
407
 
408
+ ## Versioning
409
+
410
+ This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
411
+ of this scheme should be reported as bugs. Specifically, if a minor or patch
412
+ version is released that breaks backward compatibility, that version should be
413
+ immediately yanked and/or a new version should be immediately released that
414
+ restores compatibility. Breaking changes to the public API will only be
415
+ introduced with new major versions. As a result of this policy, you can (and
416
+ should) specify a dependency on this gem using the [Pessimistic Version
417
+ Constraint][pvc] with two digits of precision. For example:
418
+
419
+ spec.add_dependency 'twitter', '~> 4.0'
420
+
421
+ [semver]: http://semver.org/
422
+ [pvc]: http://docs.rubygems.org/read/chapter/16#page74
423
+
408
424
  ## Additional Notes
409
425
  This will be the last major version of this library to support Ruby 1.8.
410
426
  Requiring Ruby 1.9 will allow us to [remove][class_variable_get]
data/lib/twitter.rb CHANGED
@@ -1,5 +1,34 @@
1
+ require 'twitter/action_factory'
1
2
  require 'twitter/client'
2
3
  require 'twitter/configurable'
4
+ require 'twitter/configuration'
5
+ require 'twitter/cursor'
6
+ require 'twitter/default'
7
+ require 'twitter/direct_message'
8
+ require 'twitter/entity'
9
+ require 'twitter/entity/hashtag'
10
+ require 'twitter/entity/url'
11
+ require 'twitter/entity/user_mention'
12
+ require 'twitter/geo_factory'
13
+ require 'twitter/language'
14
+ require 'twitter/list'
15
+ require 'twitter/media_factory'
16
+ require 'twitter/metadata'
17
+ require 'twitter/oembed'
18
+ require 'twitter/place'
19
+ require 'twitter/profile_banner'
20
+ require 'twitter/rate_limit'
21
+ require 'twitter/relationship'
22
+ require 'twitter/saved_search'
23
+ require 'twitter/search_results'
24
+ require 'twitter/settings'
25
+ require 'twitter/size'
26
+ require 'twitter/source_user'
27
+ require 'twitter/suggestion'
28
+ require 'twitter/target_user'
29
+ require 'twitter/trend'
30
+ require 'twitter/tweet'
31
+ require 'twitter/user'
3
32
 
4
33
  module Twitter
5
34
  class << self
@@ -1,6 +1,5 @@
1
1
  require 'twitter/base'
2
2
  require 'twitter/creatable'
3
- require 'twitter/user'
4
3
 
5
4
  module Twitter
6
5
  module Action
@@ -1,7 +1,5 @@
1
1
  require 'twitter/base'
2
2
  require 'twitter/creatable'
3
- require 'twitter/list'
4
- require 'twitter/user'
5
3
 
6
4
  module Twitter
7
5
  module Action
@@ -1,7 +1,5 @@
1
1
  require 'twitter/base'
2
2
  require 'twitter/creatable'
3
- require 'twitter/tweet'
4
- require 'twitter/user'
5
3
 
6
4
  module Twitter
7
5
  module Action
@@ -1,7 +1,5 @@
1
1
  require 'twitter/base'
2
2
  require 'twitter/creatable'
3
- require 'twitter/tweet'
4
- require 'twitter/user'
5
3
 
6
4
  module Twitter
7
5
  module Action
@@ -282,10 +282,7 @@ module Twitter
282
282
  # Twitter.followers('sferik')
283
283
  # Twitter.followers(7505382) # Same as above
284
284
  def followers(*args)
285
- options = extract_options!(args)
286
- merge_user!(options, args.pop || screen_name)
287
- merge_default_cursor!(options)
288
- cursor_from_response(:users, Twitter::User, :get, "/1.1/followers/list.json", options)
285
+ friends_or_followers_from_response(:get, "/1.1/followers/list.json", args)
289
286
  end
290
287
 
291
288
  # Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
@@ -316,12 +313,23 @@ module Twitter
316
313
  # Twitter.friends('sferik')
317
314
  # Twitter.friends(7505382) # Same as above
318
315
  def friends(*args)
316
+ friends_or_followers_from_response(:get, "/1.1/friends/list.json", args)
317
+ end
318
+ alias following friends
319
+
320
+ private
321
+
322
+ # @param request_method [Symbol]
323
+ # @param path [String]
324
+ # @param args [Array]
325
+ # @return [Array<Integer>]
326
+ def friends_or_followers_from_response(request_method, path, args)
319
327
  options = extract_options!(args)
320
- merge_user!(options, args.pop || screen_name)
321
328
  merge_default_cursor!(options)
322
- cursor_from_response(:users, Twitter::User, :get, "/1.1/friends/list.json", options)
329
+ merge_user!(options, args.pop || screen_name)
330
+ cursor_from_response(:users, Twitter::User, request_method, path, options, calling_method)
323
331
  end
324
- alias following friends
332
+
325
333
  end
326
334
  end
327
335
  end
@@ -12,7 +12,7 @@ module Twitter
12
12
  # @rate_limited Yes
13
13
  # @authentication_required Requires user context
14
14
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
15
- # @param place_id [String] A place in the world. These IDs can be retrieved from {Twitter::API::Geo#reverse_geocode}.
15
+ # @param place_id [String] A place in the world. These IDs can be retrieved from {Twitter::API::PlacesAndGeo#reverse_geocode}.
16
16
  # @param options [Hash] A customizable set of options.
17
17
  # @return [Twitter::Place] The requested place.
18
18
  # @example Return all the information about Twitter HQ
@@ -41,7 +41,7 @@ module Twitter
41
41
  geo_collection_from_response(:get, "/1.1/geo/reverse_geocode.json", options)
42
42
  end
43
43
 
44
- # Search for places that can be attached to a {Twitter::API::Statuses#update}
44
+ # Search for places that can be attached to a {Twitter::API::Tweets#update}
45
45
  #
46
46
  # @see https://dev.twitter.com/docs/api/1.1/get/geo/search
47
47
  # @rate_limited Yes
@@ -68,7 +68,7 @@ module Twitter
68
68
  # Locates places near the given coordinates which are similar in name
69
69
  #
70
70
  # @see https://dev.twitter.com/docs/api/1.1/get/geo/similar_places
71
- # @note Conceptually, you would use this method to get a list of known places to choose from first. Then, if the desired place doesn't exist, make a request to {Twitter::API::Geo#place} to create a new one. The token contained in the response is the token necessary to create a new place.
71
+ # @note Conceptually, you would use this method to get a list of known places to choose from first. Then, if the desired place doesn't exist, make a request to {Twitter::API::PlacesAndGeo#place} to create a new one. The token contained in the response is the token necessary to create a new place.
72
72
  # @rate_limited Yes
73
73
  # @authentication_required Requires user context
74
74
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
@@ -95,7 +95,7 @@ module Twitter
95
95
  # @param options [Hash] A customizable set of options.
96
96
  # @option options [String] :name The name a place is known as.
97
97
  # @option options [String] :contained_within This is the place_id which you would like to restrict the search results to. Setting this value means only places within the given place_id will be found.
98
- # @option options [String] :token The token found in the response from {Twitter::API::Geo#places_similar}.
98
+ # @option options [String] :token The token found in the response from {Twitter::API::PlacesAndGeo#places_similar}.
99
99
  # @option options [Float] :lat The latitude to search around. 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.
100
100
  # @option options [Float] :long The longitude to search around. The valid range 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.
101
101
  # @option options [String] :"attribute:street_address" This option searches for places which have this given street address. There are other well-known and application-specific attributes available. Custom attributes are also permitted.
@@ -110,7 +110,7 @@ module Twitter
110
110
 
111
111
  # @param request_method [Symbol]
112
112
  # @param path [String]
113
- # @param options [Hash]
113
+ # @param params [Hash]
114
114
  # @return [Array]
115
115
  def geo_collection_from_response(request_method, path, params={})
116
116
  collection_from_array(Twitter::Place, send(request_method.to_sym, path, params)[:body][:result][:places])
@@ -88,7 +88,6 @@ module Twitter
88
88
  # @authentication_required Requires user context
89
89
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
90
90
  # @return [Array<Twitter::Tweet>]
91
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
92
91
  # @param options [Hash] A customizable set of options.
93
92
  # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
94
93
  # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
@@ -99,8 +98,8 @@ module Twitter
99
98
  # @example Return the 20 most recent retweets posted by the authenticating user
100
99
  # Twitter.retweeted_by_me
101
100
  def retweeted_by_me(options={})
102
- retweets_from_timeline(options) do |options|
103
- user_timeline(options)
101
+ retweets_from_timeline(options) do |opts|
102
+ user_timeline(opts)
104
103
  end
105
104
  end
106
105
 
@@ -146,8 +145,8 @@ module Twitter
146
145
  # @example Return the 20 most recent retweets posted by users followed by the authenticating user
147
146
  # Twitter.retweeted_to_me
148
147
  def retweeted_to_me(options={})
149
- retweets_from_timeline(options) do |options|
150
- home_timeline(options)
148
+ retweets_from_timeline(options) do |opts|
149
+ home_timeline(opts)
151
150
  end
152
151
  end
153
152
 
@@ -119,7 +119,7 @@ module Twitter
119
119
  # @option options [Integer] :in_reply_to_status_id The ID of an existing status that the update is in reply to.
120
120
  # @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.
121
121
  # @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.
122
- # @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::API::Geo#reverse_geocode}.
122
+ # @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::API::PlacesAndGeo#reverse_geocode}.
123
123
  # @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
124
124
  # @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.
125
125
  # @example Update the authenticating user's status
@@ -195,7 +195,7 @@ module Twitter
195
195
  # @option options [Integer] :in_reply_to_status_id The ID of an existing Tweet that the update is in reply to.
196
196
  # @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.
197
197
  # @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.
198
- # @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::API::Geo#reverse_geocode}.
198
+ # @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::API::PlacesAndGeo#reverse_geocode}.
199
199
  # @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
200
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.
201
201
  # @example Update the authenticating user's status
@@ -158,9 +158,10 @@ module Twitter
158
158
  # @authentication_required Requires user context
159
159
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
160
160
  # @return [Array] Numeric user ids the authenticating user is blocking.
161
- # @param options [Hash] A customizable set of options.
162
161
  # @example Return an array of numeric user ids the authenticating user is blocking
163
162
  # Twitter.blocking_ids
163
+ # @overload block(options={})
164
+ # @param options [Hash] A customizable set of options.
164
165
  def blocked_ids(*args)
165
166
  ids_from_response(:get, "/1.1/blocks/ids.json", args)
166
167
  end
@@ -247,9 +248,8 @@ module Twitter
247
248
  # @option options [Symbol, String] :method Requests users via a GET request instead of the standard POST request if set to ':get'.
248
249
  # @option options [Boolean] :include_entities The tweet entities node will be disincluded when set to false.
249
250
  # @example Return extended information for @sferik and @pengwynn
250
- # Twitter.users('sferik', 'pengwynn', :method => :get) # Retrieve users with a GET request
251
- # Twitter.users(7505382, 14100886, {:method => :get}) # Same as above
252
- # Twitter.users(7505382, 14100886, {:method => :get, :include_entities => false}) # See Twitter API documentation
251
+ # Twitter.users('sferik', 'pengwynn', :method => :get) # Retrieve users with a GET request
252
+ # Twitter.users(7505382, 14100886, :method => :get) # Same as above
253
253
  def users(*args)
254
254
  options = extract_options!(args)
255
255
  method = options.delete(:method) || :post
@@ -394,7 +394,7 @@ module Twitter
394
394
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
395
395
  # @raise [Twitter::Error::UnprocessableEntity] Error raised when the image could not be resized or is too large.
396
396
  # @return [nil]
397
- # @param image [File] The Base64-encoded or raw image data being uploaded as the user's new profile banner.
397
+ # @param banner [File] The Base64-encoded or raw image data being uploaded as the user's new profile banner.
398
398
  # @param options [Hash] A customizable set of options.
399
399
  # @option options [Integer] :width The width of the preferred section of the image being uploaded in pixels. Use with height, offset_left, and offset_top to select the desired region of the image to use.
400
400
  # @option options [Integer] :height The height of the preferred section of the image being uploaded in pixels. Use with width, offset_left, and offset_top to select the desired region of the image to use.
@@ -24,7 +24,6 @@ module Twitter
24
24
  # @param request_method [Symbol]
25
25
  # @param path [String]
26
26
  # @param params [Hash]
27
- # @param options [Hash]
28
27
  # @return [Array]
29
28
  def collection_from_response(klass, request_method, path, params={})
30
29
  collection_from_array(klass, send(request_method.to_sym, path, params)[:body])
@@ -34,7 +33,6 @@ module Twitter
34
33
  # @param request_method [Symbol]
35
34
  # @param path [String]
36
35
  # @param params [Hash]
37
- # @param options [Hash]
38
36
  # @return [Object]
39
37
  def object_from_response(klass, request_method, path, params={})
40
38
  response = send(request_method.to_sym, path, params)
@@ -68,7 +66,7 @@ module Twitter
68
66
  # @param request_method [Symbol]
69
67
  # @param path [String]
70
68
  # @param params [Hash]
71
- # @param options [Hash]
69
+ # @param method_name [Symbol]
72
70
  # @return [Twitter::Cursor]
73
71
  def cursor_from_response(collection_name, klass, request_method, path, params={}, method_name=calling_method)
74
72
  response = send(request_method.to_sym, path, params)
@@ -1,5 +1,3 @@
1
- require 'twitter/default'
2
-
3
1
  module Twitter
4
2
  module Configurable
5
3
  attr_writer :consumer_key, :consumer_secret, :oauth_token, :oauth_token_secret
@@ -1,5 +1,4 @@
1
1
  require 'twitter/base'
2
- require 'twitter/size'
3
2
 
4
3
  module Twitter
5
4
  class Configuration < Twitter::Base
@@ -1,23 +1,10 @@
1
1
  module Enumerable
2
2
 
3
3
  def threaded_map
4
- abort_on_exception do
5
- threads = []
6
- each do |object|
7
- threads << Thread.new { yield object }
8
- end
9
- threads.map(&:value)
4
+ threads = map do |object|
5
+ Thread.new { yield object }
10
6
  end
11
- end
12
-
13
- private
14
-
15
- def abort_on_exception
16
- initial_abort_on_exception = Thread.abort_on_exception
17
- Thread.abort_on_exception ||= true
18
- yield
19
- ensure
20
- Thread.abort_on_exception = initial_abort_on_exception
7
+ threads.map(&:value)
21
8
  end
22
9
 
23
10
  end
@@ -1,6 +1,5 @@
1
1
  require 'twitter/creatable'
2
2
  require 'twitter/identity'
3
- require 'twitter/user'
4
3
 
5
4
  module Twitter
6
5
  class DirectMessage < Twitter::Identity
data/lib/twitter/error.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'twitter/rate_limit'
2
-
3
1
  module Twitter
4
2
  # Custom error class for rescuing from all Twitter errors
5
3
  class Error < StandardError
data/lib/twitter/list.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'twitter/creatable'
2
2
  require 'twitter/identity'
3
- require 'twitter/user'
4
3
 
5
4
  module Twitter
6
5
  class List < Twitter::Identity
@@ -1,5 +1,4 @@
1
1
  require 'twitter/identity'
2
- require 'twitter/size'
3
2
 
4
3
  module Twitter
5
4
  module Media
data/lib/twitter/place.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'twitter/geo_factory'
2
1
  require 'twitter/identity'
3
2
 
4
3
  module Twitter
@@ -1,5 +1,4 @@
1
1
  require 'twitter/base'
2
- require 'twitter/size'
3
2
 
4
3
  module Twitter
5
4
  class ProfileBanner < Twitter::Base
@@ -1,6 +1,4 @@
1
1
  require 'twitter/base'
2
- require 'twitter/source_user'
3
- require 'twitter/target_user'
4
2
 
5
3
  module Twitter
6
4
  class Relationship < Twitter::Base
@@ -3,17 +3,12 @@ require 'faraday'
3
3
  module Twitter
4
4
  module Request
5
5
  class MultipartWithFile < Faraday::Middleware
6
- CONTENT_TYPE = 'Content-Type'.freeze
7
- class << self
8
- attr_accessor :mime_type
9
- mime_type = 'multipart/form-data'.freeze
10
- end
6
+ CONTENT_TYPE = 'Content-Type'
11
7
 
12
8
  def call(env)
13
9
  env[:body].each do |key, value|
14
10
  if value.respond_to?(:to_io)
15
11
  env[:body][key] = Faraday::UploadIO.new(value, mime_type(value.path), value.path)
16
- env[:request_headers][CONTENT_TYPE] = self.class.mime_type
17
12
  end
18
13
  end if env[:body].is_a?(::Hash)
19
14
  @app.call(env)
@@ -1,5 +1,4 @@
1
1
  require 'twitter/base'
2
- require 'twitter/tweet'
3
2
 
4
3
  module Twitter
5
4
  class SearchResults < Twitter::Base
@@ -1,5 +1,4 @@
1
1
  require 'twitter/base'
2
- require 'twitter/place'
3
2
 
4
3
  module Twitter
5
4
  class Settings < Twitter::Base
@@ -1,5 +1,4 @@
1
1
  require 'twitter/base'
2
- require 'twitter/user'
3
2
 
4
3
  module Twitter
5
4
  class Suggestion < Twitter::Base
data/lib/twitter/tweet.rb CHANGED
@@ -1,14 +1,6 @@
1
1
  require 'twitter/creatable'
2
- require 'twitter/entity/hashtag'
3
- require 'twitter/entity/url'
4
- require 'twitter/entity/user_mention'
5
2
  require 'twitter/exceptable'
6
- require 'twitter/geo_factory'
7
3
  require 'twitter/identity'
8
- require 'twitter/media_factory'
9
- require 'twitter/metadata'
10
- require 'twitter/place'
11
- require 'twitter/user'
12
4
 
13
5
  module Twitter
14
6
  class Tweet < Twitter::Identity
data/lib/twitter/user.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'twitter/basic_user'
2
2
  require 'twitter/creatable'
3
3
  require 'twitter/exceptable'
4
- require 'twitter/tweet'
5
4
 
6
5
  module Twitter
7
6
  class User < Twitter::BasicUser
@@ -2,7 +2,7 @@ module Twitter
2
2
  class Version
3
3
  MAJOR = 4 unless defined? Twitter::Version::MAJOR
4
4
  MINOR = 4 unless defined? Twitter::Version::MINOR
5
- PATCH = 0 unless defined? Twitter::Version::PATCH
5
+ PATCH = 1 unless defined? Twitter::Version::PATCH
6
6
  PRE = nil unless defined? Twitter::Version::PRE
7
7
 
8
8
  class << self
@@ -3,9 +3,7 @@ require 'helper'
3
3
  describe Twitter::Client do
4
4
 
5
5
  subject do
6
- client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
7
- client.class_eval{public *Twitter::Client.private_instance_methods}
8
- client
6
+ Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
9
7
  end
10
8
 
11
9
  context "with module configuration" do
@@ -112,10 +110,10 @@ describe Twitter::Client do
112
110
 
113
111
  describe "#connection" do
114
112
  it "looks like Faraday connection" do
115
- expect(subject.connection).to respond_to(:run_request)
113
+ expect(subject.send(:connection)).to respond_to(:run_request)
116
114
  end
117
115
  it "memoizes the connection" do
118
- c1, c2 = subject.connection, subject.connection
116
+ c1, c2 = subject.send(:connection), subject.send(:connection)
119
117
  expect(c1.object_id).to eq c2.object_id
120
118
  end
121
119
  end
@@ -133,18 +131,18 @@ describe Twitter::Client do
133
131
  end
134
132
  it "catches Faraday errors" do
135
133
  subject.stub!(:connection).and_raise(Faraday::Error::ClientError.new("Oops"))
136
- expect{subject.request(:get, "/path")}.to raise_error Twitter::Error::ClientError
134
+ expect{subject.send(:request, :get, "/path")}.to raise_error Twitter::Error::ClientError
137
135
  end
138
136
  it "catches MultiJson::DecodeError errors" do
139
137
  subject.stub!(:connection).and_raise(MultiJson::DecodeError.new("unexpected token", [], "<!DOCTYPE html>"))
140
- expect{subject.request(:get, "/path")}.to raise_error Twitter::Error::DecodeError
138
+ expect{subject.send(:request, :get, "/path")}.to raise_error Twitter::Error::DecodeError
141
139
  end
142
140
  end
143
141
 
144
142
  describe "#auth_header" do
145
143
  it "creates the correct auth headers" do
146
144
  uri = "/1.1/direct_messages.json"
147
- authorization = subject.auth_header(:get, uri)
145
+ authorization = subject.send(:auth_header, :get, uri)
148
146
  expect(authorization.options[:signature_method]).to eq "HMAC-SHA1"
149
147
  expect(authorization.options[:version]).to eq "1.0"
150
148
  expect(authorization.options[:consumer_key]).to eq "CK"
@@ -20,24 +20,4 @@ describe Twitter::Error::ClientError do
20
20
  end
21
21
  end
22
22
 
23
- context "when response status is 404 from lookup" do
24
- context "using a post request" do
25
- before do
26
- stub_post("/1.1/users/lookup.json").with(:body => {:screen_name => "not_on_twitter"}).to_return(:status => 404, :body => fixture('no_user_matches.json'))
27
- end
28
- it "raises Twitter::Error::NotFound" do
29
- expect{@client.users('not_on_twitter')}.to raise_error Twitter::Error::NotFound
30
- end
31
- end
32
-
33
- context "using a get request" do
34
- before do
35
- stub_get("/1.1/users/lookup.json").with(:query => {:screen_name => "not_on_twitter"}).to_return(:status => 404, :body => fixture('no_user_matches.json'))
36
- end
37
- it "raises Twitter::Error::NotFound" do
38
- expect{@client.users('not_on_twitter', :method => :get)}.to raise_error Twitter::Error::NotFound
39
- end
40
- end
41
- end
42
-
43
23
  end
@@ -28,7 +28,7 @@ describe Twitter::Geo::Point do
28
28
 
29
29
  describe "#latitude" do
30
30
  it "returns the latitude" do
31
- expect(@point.latitude).to eq -122.399983
31
+ expect(@point.latitude).to eq(-122.399983)
32
32
  end
33
33
  end
34
34
 
@@ -122,7 +122,7 @@ describe Twitter::Tweet do
122
122
  end
123
123
  it "warns when not set" do
124
124
  Twitter::Tweet.new(:id => 28669546014).hashtags
125
- expect($stderr.string).to match /To get hashtags, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./
125
+ expect($stderr.string).to match(/To get hashtags, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./)
126
126
  end
127
127
  end
128
128
 
@@ -138,7 +138,7 @@ describe Twitter::Tweet do
138
138
  end
139
139
  it "warns when not set" do
140
140
  Twitter::Tweet.new(:id => 28669546014).media
141
- expect($stderr.string).to match /To get media, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./
141
+ expect($stderr.string).to match(/To get media, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./)
142
142
  end
143
143
  end
144
144
 
@@ -269,7 +269,7 @@ describe Twitter::Tweet do
269
269
  end
270
270
  it "warns when not set" do
271
271
  Twitter::Tweet.new(:id => 28669546014).urls
272
- expect($stderr.string).to match /To get urls, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./
272
+ expect($stderr.string).to match(/To get urls, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./)
273
273
  end
274
274
  end
275
275
 
@@ -322,7 +322,7 @@ describe Twitter::Tweet do
322
322
  end
323
323
  it "warns when not set" do
324
324
  Twitter::Tweet.new(:id => 28669546014).user_mentions
325
- expect($stderr.string).to match /To get user mentions, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./
325
+ expect($stderr.string).to match(/To get user mentions, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./)
326
326
  end
327
327
  end
328
328
 
data/twitter.gemspec CHANGED
@@ -4,12 +4,12 @@ require File.expand_path('../lib/twitter/version', __FILE__)
4
4
  Gem::Specification.new do |spec|
5
5
  spec.add_dependency 'faraday', '~> 0.8'
6
6
  spec.add_dependency 'multi_json', '~> 1.3'
7
- spec.add_dependency 'simple_oauth', '~> 0.1.6'
8
- spec.add_development_dependency 'oj'
7
+ spec.add_dependency 'simple_oauth', '~> 0.2'
8
+ spec.add_development_dependency 'json'
9
+ spec.add_development_dependency 'kramdown'
9
10
  spec.add_development_dependency 'pry'
10
11
  spec.add_development_dependency 'pry-nav'
11
12
  spec.add_development_dependency 'rake'
12
- spec.add_development_dependency 'redcarpet'
13
13
  spec.add_development_dependency 'rspec'
14
14
  spec.add_development_dependency 'simplecov'
15
15
  spec.add_development_dependency 'timecop'
metadata CHANGED
@@ -1,15 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: twitter
3
- version: !ruby/object:Gem::Version
4
- hash: 47
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
6
- segments:
7
- - 4
8
- - 4
9
- - 0
10
- version: 4.4.0
5
+ version: 4.4.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - John Nunemaker
14
9
  - Wynn Netherland
15
10
  - Erik Michaels-Ober
@@ -17,208 +12,226 @@ authors:
17
12
  autorequire:
18
13
  bindir: bin
19
14
  cert_chain: []
20
-
21
- date: 2012-11-30 00:00:00 Z
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
24
- name: faraday
25
- prerelease: false
26
- requirement: &id001 !ruby/object:Gem::Requirement
27
- none: false
28
- requirements:
15
+ date: 2012-12-08 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
29
20
  - - ~>
30
- - !ruby/object:Gem::Version
31
- hash: 27
32
- segments:
33
- - 0
34
- - 8
35
- version: "0.8"
21
+ - !ruby/object:Gem::Version
22
+ version: '0.8'
23
+ none: false
24
+ name: faraday
36
25
  type: :runtime
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
39
- name: multi_json
40
26
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: '0.8'
42
32
  none: false
43
- requirements:
33
+ - !ruby/object:Gem::Dependency
34
+ version_requirements: !ruby/object:Gem::Requirement
35
+ requirements:
44
36
  - - ~>
45
- - !ruby/object:Gem::Version
46
- hash: 9
47
- segments:
48
- - 1
49
- - 3
50
- version: "1.3"
37
+ - !ruby/object:Gem::Version
38
+ version: '1.3'
39
+ none: false
40
+ name: multi_json
51
41
  type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: simple_oauth
55
42
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
57
48
  none: false
58
- requirements:
49
+ - !ruby/object:Gem::Dependency
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
59
52
  - - ~>
60
- - !ruby/object:Gem::Version
61
- hash: 23
62
- segments:
63
- - 0
64
- - 1
65
- - 6
66
- version: 0.1.6
53
+ - !ruby/object:Gem::Version
54
+ version: '0.2'
55
+ none: false
56
+ name: simple_oauth
67
57
  type: :runtime
68
- version_requirements: *id003
69
- - !ruby/object:Gem::Dependency
70
- name: oj
71
58
  prerelease: false
72
- requirement: &id004 !ruby/object:Gem::Requirement
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: '0.2'
73
64
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
65
+ - !ruby/object:Gem::Dependency
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ none: false
72
+ name: json
81
73
  type: :development
82
- version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
- name: pry
85
74
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ none: false
81
+ - !ruby/object:Gem::Dependency
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
87
  none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- hash: 3
92
- segments:
93
- - 0
94
- version: "0"
88
+ name: kramdown
95
89
  type: :development
96
- version_requirements: *id005
97
- - !ruby/object:Gem::Dependency
98
- name: pry-nav
99
90
  prerelease: false
100
- requirement: &id006 !ruby/object:Gem::Requirement
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ none: false
97
+ - !ruby/object:Gem::Dependency
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
101
103
  none: false
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- hash: 3
106
- segments:
107
- - 0
108
- version: "0"
104
+ name: pry
109
105
  type: :development
110
- version_requirements: *id006
111
- - !ruby/object:Gem::Dependency
112
- name: rake
113
106
  prerelease: false
114
- requirement: &id007 !ruby/object:Gem::Requirement
107
+ requirement: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ none: false
113
+ - !ruby/object:Gem::Dependency
114
+ version_requirements: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
115
119
  none: false
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- hash: 3
120
- segments:
121
- - 0
122
- version: "0"
120
+ name: pry-nav
123
121
  type: :development
124
- version_requirements: *id007
125
- - !ruby/object:Gem::Dependency
126
- name: redcarpet
127
122
  prerelease: false
128
- requirement: &id008 !ruby/object:Gem::Requirement
123
+ requirement: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ none: false
129
+ - !ruby/object:Gem::Dependency
130
+ version_requirements: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
129
135
  none: false
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- hash: 3
134
- segments:
135
- - 0
136
- version: "0"
136
+ name: rake
137
137
  type: :development
138
- version_requirements: *id008
139
- - !ruby/object:Gem::Dependency
140
- name: rspec
141
138
  prerelease: false
142
- requirement: &id009 !ruby/object:Gem::Requirement
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ none: false
145
+ - !ruby/object:Gem::Dependency
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ! '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
143
151
  none: false
144
- requirements:
145
- - - ">="
146
- - !ruby/object:Gem::Version
147
- hash: 3
148
- segments:
149
- - 0
150
- version: "0"
152
+ name: rspec
151
153
  type: :development
152
- version_requirements: *id009
153
- - !ruby/object:Gem::Dependency
154
- name: simplecov
155
154
  prerelease: false
156
- requirement: &id010 !ruby/object:Gem::Requirement
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ none: false
161
+ - !ruby/object:Gem::Dependency
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ! '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
157
167
  none: false
158
- requirements:
159
- - - ">="
160
- - !ruby/object:Gem::Version
161
- hash: 3
162
- segments:
163
- - 0
164
- version: "0"
168
+ name: simplecov
165
169
  type: :development
166
- version_requirements: *id010
167
- - !ruby/object:Gem::Dependency
168
- name: timecop
169
170
  prerelease: false
170
- requirement: &id011 !ruby/object:Gem::Requirement
171
+ requirement: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ none: false
177
+ - !ruby/object:Gem::Dependency
178
+ version_requirements: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ! '>='
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
171
183
  none: false
172
- requirements:
173
- - - ">="
174
- - !ruby/object:Gem::Version
175
- hash: 3
176
- segments:
177
- - 0
178
- version: "0"
184
+ name: timecop
179
185
  type: :development
180
- version_requirements: *id011
181
- - !ruby/object:Gem::Dependency
182
- name: webmock
183
186
  prerelease: false
184
- requirement: &id012 !ruby/object:Gem::Requirement
187
+ requirement: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ! '>='
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ none: false
193
+ - !ruby/object:Gem::Dependency
194
+ version_requirements: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ! '>='
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
185
199
  none: false
186
- requirements:
187
- - - ">="
188
- - !ruby/object:Gem::Version
189
- hash: 3
190
- segments:
191
- - 0
192
- version: "0"
200
+ name: webmock
193
201
  type: :development
194
- version_requirements: *id012
195
- - !ruby/object:Gem::Dependency
196
- name: yard
197
202
  prerelease: false
198
- requirement: &id013 !ruby/object:Gem::Requirement
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ! '>='
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ none: false
209
+ - !ruby/object:Gem::Dependency
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - ! '>='
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
199
215
  none: false
200
- requirements:
201
- - - ">="
202
- - !ruby/object:Gem::Version
203
- hash: 3
204
- segments:
205
- - 0
206
- version: "0"
216
+ name: yard
207
217
  type: :development
208
- version_requirements: *id013
218
+ prerelease: false
219
+ requirement: !ruby/object:Gem::Requirement
220
+ requirements:
221
+ - - ! '>='
222
+ - !ruby/object:Gem::Version
223
+ version: '0'
224
+ none: false
209
225
  description: A Ruby interface to the Twitter API.
210
- email:
226
+ email:
211
227
  - nunemaker@gmail.com
212
228
  - wynn.netherland@gmail.com
213
229
  - sferik@gmail.com
214
230
  - steve.richert@gmail.com
215
231
  executables: []
216
-
217
232
  extensions: []
218
-
219
233
  extra_rdoc_files: []
220
-
221
- files:
234
+ files:
222
235
  - .yardopts
223
236
  - CHANGELOG.md
224
237
  - CONTRIBUTING.md
@@ -353,7 +366,6 @@ files:
353
366
  - spec/fixtures/media_timeline.json
354
367
  - spec/fixtures/members.json
355
368
  - spec/fixtures/memberships.json
356
- - spec/fixtures/no_user_matches.json
357
369
  - spec/fixtures/not_acceptable.json
358
370
  - spec/fixtures/not_following.json
359
371
  - spec/fixtures/not_found.json
@@ -458,41 +470,31 @@ files:
458
470
  - spec/twitter/user_spec.rb
459
471
  - spec/twitter_spec.rb
460
472
  homepage: http://sferik.github.com/twitter/
461
- licenses:
473
+ licenses:
462
474
  - MIT
463
475
  post_install_message:
464
476
  rdoc_options: []
465
-
466
- require_paths:
477
+ require_paths:
467
478
  - lib
468
- required_ruby_version: !ruby/object:Gem::Requirement
479
+ required_ruby_version: !ruby/object:Gem::Requirement
480
+ requirements:
481
+ - - ! '>='
482
+ - !ruby/object:Gem::Version
483
+ version: '0'
469
484
  none: false
470
- requirements:
471
- - - ">="
472
- - !ruby/object:Gem::Version
473
- hash: 3
474
- segments:
475
- - 0
476
- version: "0"
477
- required_rubygems_version: !ruby/object:Gem::Requirement
478
- none: false
479
- requirements:
480
- - - ">="
481
- - !ruby/object:Gem::Version
482
- hash: 23
483
- segments:
484
- - 1
485
- - 3
486
- - 6
485
+ required_rubygems_version: !ruby/object:Gem::Requirement
486
+ requirements:
487
+ - - ! '>='
488
+ - !ruby/object:Gem::Version
487
489
  version: 1.3.6
490
+ none: false
488
491
  requirements: []
489
-
490
492
  rubyforge_project:
491
- rubygems_version: 1.8.24
493
+ rubygems_version: 1.8.23
492
494
  signing_key:
493
495
  specification_version: 3
494
496
  summary: A Ruby interface to the Twitter API.
495
- test_files:
497
+ test_files:
496
498
  - spec/fixtures/about_me.json
497
499
  - spec/fixtures/activity_summary.json
498
500
  - spec/fixtures/all.json
@@ -530,7 +532,6 @@ test_files:
530
532
  - spec/fixtures/media_timeline.json
531
533
  - spec/fixtures/members.json
532
534
  - spec/fixtures/memberships.json
533
- - spec/fixtures/no_user_matches.json
534
535
  - spec/fixtures/not_acceptable.json
535
536
  - spec/fixtures/not_following.json
536
537
  - spec/fixtures/not_found.json
@@ -1 +0,0 @@
1
- {"errors":[{"code":17,"message":"No user matches for specified terms"}]}