twitter 5.9.0 → 5.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35ccffc8468f91442ccd9eeebff411dbebf92b0a
4
- data.tar.gz: cca2da3dc5ddff38608dbd836c3d159e4477bbe2
3
+ metadata.gz: 8ed9a45b1f841e8fd80f06a88cdb71d73448c27b
4
+ data.tar.gz: 28ec0e841594b0e1c7b26a262ae1d8451157f1c0
5
5
  SHA512:
6
- metadata.gz: ef86cf848faf9325291bc7ab2405f925bbb9f187f53765d969b173cc5ec340b3252ced4ca6f5bd3257aec418414b8ebf98dc2c645bf5ae200148ac735f63463c
7
- data.tar.gz: 81f7b4ae2818191008017355e69d1476413055b4e87f9a1c1953445aeacfc5e2267e3b255e6f403a4f41131b19f4268eaa8a058d5ba0648d735318040b7f5a60
6
+ metadata.gz: 7a1171a26b33386f6bc0a5d5fc71dd7c9250f4b8e45efe50465b8d795436dedf6fb767b026be8882c2e370bf8c4ef5d371b3c4aed0a3a99a67268bb147bce6f9
7
+ data.tar.gz: 046690ce229a2af4d4d762602b1e64f694d0a2fcd138324a6dd0d430545c5967c15cde11b8181e250d5bdb64631ba3754aacd642f3fc309f81c17d002b751dce
data/.yardopts CHANGED
@@ -12,4 +12,5 @@ examples/AllTweets.md
12
12
  examples/Configuration.md
13
13
  examples/RateLimiting.md
14
14
  examples/Search.md
15
+ examples/Streaming.md
15
16
  examples/Update.md
@@ -1,3 +1,8 @@
1
+ 5.10.0
2
+ ------
3
+ * [Add support for extended entities](https://github.com/sferik/twitter/commit/ed7c708e4208de1df27d141678c14e23422504a0)
4
+ * [Add `Twitter::REST::Client#upload`](https://github.com/sferik/twitter/commit/f5a747b53c4866bb378d6022f309d6176620122e)
5
+
1
6
  5.9.0
2
7
  -----
3
8
  * [Use expanded URIs when available](https://github.com/sferik/twitter/commit/f1d5d1f4c0ea75ebeaf9e7eb760b9efd245a5df2)
data/README.md CHANGED
@@ -6,15 +6,15 @@
6
6
  [![Code Climate](http://img.shields.io/codeclimate/github/sferik/twitter.svg)][codeclimate]
7
7
  [![Coverage Status](http://img.shields.io/coveralls/sferik/twitter.svg)][coveralls]
8
8
  [![Gittip](http://img.shields.io/gittip/gems.svg)][gittip]
9
- [![Inline docs](http://inch-pages.github.io/github/sferik/twitter.png)][inchpages]
9
+ [![Inline docs](http://inch-ci.org/github/sferik/twitter.png)][inchpages]
10
10
 
11
11
  [gem]: https://rubygems.org/gems/twitter
12
- [travis]: http://travis-ci.org/sferik/twitter
12
+ [travis]: https://travis-ci.org/sferik/twitter
13
13
  [gemnasium]: https://gemnasium.com/sferik/twitter
14
14
  [codeclimate]: https://codeclimate.com/github/sferik/twitter
15
15
  [coveralls]: https://coveralls.io/r/sferik/twitter
16
16
  [gittip]: https://www.gittip.com/gems/
17
- [inchpages]: http://inch-pages.github.io/github/sferik/twitter
17
+ [inchpages]: http://inch-ci.org/github/sferik/twitter
18
18
 
19
19
  A Ruby interface to the Twitter API.
20
20
 
@@ -318,7 +318,7 @@ method has been removed.
318
318
  ### Trend Results
319
319
  The `#trends` method now returns an [`Enumerable`][enumerable]
320
320
  `Twitter::TrendResults` object instead of an array. This object provides
321
- methods to determinte the recency of the trend (`#as_of`), when the trend
321
+ methods to determine the recency of the trend (`#as_of`), when the trend
322
322
  started (`#created_at`), and the location of the trend (`#location`). This data
323
323
  was previously unavailable.
324
324
 
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ task :test => :spec
14
14
 
15
15
  begin
16
16
  require 'rubocop/rake_task'
17
- Rubocop::RakeTask.new
17
+ RuboCop::RakeTask.new
18
18
  rescue LoadError
19
19
  task :rubocop do
20
20
  $stderr.puts 'Rubocop is disabled'
@@ -31,7 +31,8 @@ module Twitter
31
31
  # @note Must include entities in your request for this method to work
32
32
  # @return [Array<Twitter::Media>]
33
33
  def media
34
- entities(MediaFactory, :media)
34
+ extended_entities = entities(MediaFactory, :media, :extended_entities)
35
+ extended_entities.empty? ? entities(MediaFactory, :media) : extended_entities
35
36
  end
36
37
  memoize :media
37
38
 
@@ -84,15 +85,11 @@ module Twitter
84
85
  private
85
86
 
86
87
  # @param klass [Class]
87
- # @param key [Symbol]
88
- def entities(klass, key)
89
- if @attrs[:entities].nil?
90
- warn "#{Kernel.caller.first}: To get #{key.to_s.tr('_', ' ')}, you must pass `:include_entities => true` when requesting the #{self.class}."
91
- []
92
- else
93
- @attrs[:entities].fetch(key.to_sym, []).collect do |entity|
94
- klass.new(entity)
95
- end
88
+ # @param key2 [Symbol]
89
+ # @param key1 [Symbol]
90
+ def entities(klass, key2, key1 = :entities)
91
+ @attrs.fetch(key1.to_sym, {}).fetch(key2.to_sym, []).collect do |entity|
92
+ klass.new(entity)
96
93
  end
97
94
  end
98
95
  end
@@ -49,6 +49,7 @@ module Twitter
49
49
  404 => Twitter::Error::NotFound,
50
50
  406 => Twitter::Error::NotAcceptable,
51
51
  408 => Twitter::Error::RequestTimeout,
52
+ 420 => Twitter::Error::EnhanceYourCalm,
52
53
  422 => Twitter::Error::UnprocessableEntity,
53
54
  429 => Twitter::Error::TooManyRequests,
54
55
  500 => Twitter::Error::InternalServerError,
@@ -90,7 +91,7 @@ module Twitter
90
91
 
91
92
  # Initializes a new Error object
92
93
  #
93
- # @param exception [Exception, String]
94
+ # @param message [Exception, String]
94
95
  # @param rate_limit [Hash]
95
96
  # @param code [Integer]
96
97
  # @return [Twitter::Error]
@@ -14,8 +14,8 @@ module Twitter
14
14
  # Initializes a new place
15
15
  #
16
16
  # @param attrs [Hash]
17
- # @raise [ArgumentError] Error raised when supplied argument is missing an :id key.
18
- # @return [Twitter::Identity]
17
+ # @raise [ArgumentError] Error raised when supplied argument is missing a :woeid key.
18
+ # @return [Twitter::Place]
19
19
  def initialize(attrs = {})
20
20
  attrs[:id] ||= attrs[:woeid]
21
21
  super
@@ -3,6 +3,7 @@ require 'twitter/rest/favorites'
3
3
  require 'twitter/rest/friends_and_followers'
4
4
  require 'twitter/rest/help'
5
5
  require 'twitter/rest/lists'
6
+ require 'twitter/rest/media'
6
7
  require 'twitter/rest/oauth'
7
8
  require 'twitter/rest/places_and_geo'
8
9
  require 'twitter/rest/saved_searches'
@@ -23,6 +24,7 @@ module Twitter
23
24
  include Twitter::REST::FriendsAndFollowers
24
25
  include Twitter::REST::Help
25
26
  include Twitter::REST::Lists
27
+ include Twitter::REST::Media
26
28
  include Twitter::REST::OAuth
27
29
  include Twitter::REST::PlacesAndGeo
28
30
  include Twitter::REST::SavedSearches
@@ -19,7 +19,8 @@ module Twitter
19
19
  class Client < Twitter::Client
20
20
  include Twitter::REST::API
21
21
  attr_accessor :bearer_token
22
- ENDPOINT = 'https://api.twitter.com'
22
+ URL_PREFIX = 'https://api.twitter.com'
23
+ ENDPOINT = URL_PREFIX
23
24
 
24
25
  # @param connection_options [Hash]
25
26
  # @return [Hash]
@@ -74,13 +75,13 @@ module Twitter
74
75
 
75
76
  # Perform an HTTP GET request
76
77
  def get(path, params = {})
77
- headers = request_headers(:get, path, params)
78
+ headers = request_headers(:get, URL_PREFIX + path, params)
78
79
  request(:get, path, params, headers)
79
80
  end
80
81
 
81
82
  # Perform an HTTP POST request
82
83
  def post(path, params = {})
83
- headers = params.values.any? { |value| value.respond_to?(:to_io) } ? request_headers(:post, path, params, {}) : request_headers(:post, path, params)
84
+ headers = params.values.any? { |value| value.respond_to?(:to_io) } ? request_headers(:post, URL_PREFIX + path, params, {}) : request_headers(:post, URL_PREFIX + path, params)
84
85
  request(:post, path, params, headers)
85
86
  end
86
87
 
@@ -100,7 +101,7 @@ module Twitter
100
101
  #
101
102
  # @return [Faraday::Connection]
102
103
  def connection
103
- @connection ||= Faraday.new(ENDPOINT, connection_options)
104
+ @connection ||= Faraday.new(URL_PREFIX, connection_options)
104
105
  end
105
106
 
106
107
  def request(method, path, params = {}, headers = {})
@@ -111,7 +112,7 @@ module Twitter
111
112
  raise(Twitter::Error.new(error))
112
113
  end
113
114
 
114
- def request_headers(method, path, params = {}, signature_params = params)
115
+ def request_headers(method, url, params = {}, signature_params = params)
115
116
  bearer_token_request = params.delete(:bearer_token_request)
116
117
  headers = {}
117
118
  if bearer_token_request
@@ -119,17 +120,17 @@ module Twitter
119
120
  headers[:authorization] = bearer_token_credentials_auth_header
120
121
  headers[:content_type] = 'application/x-www-form-urlencoded; charset=UTF-8'
121
122
  else
122
- headers[:authorization] = auth_header(method, path, params, signature_params)
123
+ headers[:authorization] = auth_header(method, url, params, signature_params)
123
124
  end
124
125
  headers
125
126
  end
126
127
 
127
- def auth_header(method, path, params = {}, signature_params = params)
128
+ def auth_header(method, url, params = {}, signature_params = params)
128
129
  if !user_token?
129
130
  @bearer_token = token unless bearer_token?
130
131
  bearer_auth_header
131
132
  else
132
- oauth_auth_header(method, ENDPOINT + path, signature_params).to_s
133
+ oauth_auth_header(method, url, signature_params).to_s
133
134
  end
134
135
  end
135
136
 
@@ -0,0 +1,29 @@
1
+ require 'twitter/error'
2
+ require 'twitter/rest/utils'
3
+
4
+ module Twitter
5
+ module REST
6
+ module Media
7
+ # Uploads media to attach to a tweet
8
+ #
9
+ # @see https://dev.twitter.com/docs/api/multiple-media-extended-entities
10
+ # @rate_limited No
11
+ # @authentication Requires user context
12
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
13
+ # @raise [Twitter::Error::UnacceptableIO] Error when the IO object for the media argument does not have a to_io method.
14
+ # @return [Integer] The uploaded media ID.
15
+ # @param media [File, Hash] A File object with your picture (PNG, JPEG or GIF)
16
+ # @param options [Hash] A customizable set of options.
17
+ def upload(media, options = {})
18
+ fail(Twitter::Error::UnacceptableIO.new) unless media.respond_to?(:to_io)
19
+ url_prefix = 'https://upload.twitter.com'
20
+ path = '/1.1/media/upload.json'
21
+ conn = connection.dup
22
+ conn.url_prefix = url_prefix
23
+ headers = request_headers(:post, url_prefix + path, options)
24
+ options.merge!(:media => media)
25
+ conn.post(path, options) { |request| request.headers.update(headers) }.env.body[:media_id]
26
+ end
27
+ end
28
+ end
29
+ end
@@ -11,9 +11,8 @@ module Twitter
11
11
 
12
12
  def call(request)
13
13
  request.body.each do |key, value|
14
- if value.respond_to?(:to_io)
15
- request.body[key] = Faraday::UploadIO.new(value, mime_type(value.path), value.path)
16
- end
14
+ next unless value.respond_to?(:to_io)
15
+ request.body[key] = Faraday::UploadIO.new(value, mime_type(value.path), value.path)
17
16
  end if request.body.is_a?(::Hash)
18
17
  @app.call(request)
19
18
  end
@@ -8,14 +8,13 @@ module Twitter
8
8
  def on_complete(response)
9
9
  status_code = response.status.to_i
10
10
  klass = Twitter::Error.errors[status_code]
11
- if klass
12
- error = if klass == Twitter::Error::Forbidden
13
- handle_forbidden_errors(response)
14
- else
15
- klass.from_response(response)
16
- end
17
- fail(error)
11
+ return unless klass
12
+ error = if klass == Twitter::Error::Forbidden
13
+ handle_forbidden_errors(response)
14
+ else
15
+ klass.from_response(response)
18
16
  end
17
+ fail(error)
19
18
  end
20
19
 
21
20
  private
@@ -24,7 +24,6 @@ module Twitter
24
24
  # @option options [String] :until Optional. Returns tweets generated before the given date. Date should be formatted as YYYY-MM-DD.
25
25
  # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.
26
26
  # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
27
- # @option options [Boolean, String, Integer] :include_entities The tweet entities node will be disincluded when set to false.
28
27
  # @return [Twitter::SearchResults] Return tweets that match a specified query with search metadata
29
28
  def search(q, options = {})
30
29
  options[:count] ||= MAX_TWEETS_PER_REQUEST
@@ -110,7 +110,6 @@ module Twitter
110
110
  # @option options [Boolean, String, Integer] :exclude_replies This parameter will prevent replies from appearing in the returned timeline. Using exclude_replies with the count parameter will mean you will receive up-to count tweets - this is because the count parameter retrieves that many tweets before filtering out retweets and replies.
111
111
  # @option options [Boolean, String, Integer] :include_rts Specifies that the timeline should include native retweets in addition to regular tweets. Note: If you're using the trim_user parameter in conjunction with include_rts, the retweets will no longer contain a full user object.
112
112
  # @option options [Boolean, String, Integer] :contributor_details Specifies that the contributors element should be enhanced to include the screen_name of the contributor.
113
- # @option options [Boolean, String, Integer] :include_entities The tweet entities node will be disincluded when set to false.
114
113
  def home_timeline(options = {})
115
114
  perform_with_objects(:get, '/1.1/statuses/home_timeline.json', options, Twitter::Tweet)
116
115
  end
@@ -130,7 +129,6 @@ module Twitter
130
129
  # @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.
131
130
  # @option options [Boolean, String, Integer] :exclude_replies This parameter will prevent replies from appearing in the returned timeline. Using exclude_replies with the count parameter will mean you will receive up-to count tweets - this is because the count parameter retrieves that many tweets before filtering out retweets and replies.
132
131
  # @option options [Boolean, String, Integer] :contributor_details Specifies that the contributors element should be enhanced to include the screen_name of the contributor.
133
- # @option options [Boolean, String, Integer] :include_entities The tweet entities node will be disincluded when set to false.
134
132
  def retweeted_to_me(options = {})
135
133
  retweets_from_timeline(options) do |opts|
136
134
  home_timeline(opts)
@@ -149,7 +147,6 @@ module Twitter
149
147
  # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
150
148
  # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
151
149
  # @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.
152
- # @option options [Boolean, String, Integer] :include_entities The tweet entities node will be disincluded when set to false.
153
150
  # @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
154
151
  def retweets_of_me(options = {})
155
152
  perform_with_objects(:get, '/1.1/statuses/retweets_of_me.json', options, Twitter::Tweet)
@@ -73,7 +73,6 @@ module Twitter
73
73
  # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
74
74
  # @param options [Hash] A customizable set of options.
75
75
  # @option options [Symbol, String] :method Requests users via a GET request instead of the standard POST request if set to ':get'.
76
- # @option options [Boolean] :include_entities The tweet entities node will be disincluded when set to false.
77
76
  # @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.
78
77
  def statuses(*args)
79
78
  arguments = Twitter::Arguments.new(args)
@@ -117,12 +116,14 @@ module Twitter
117
116
  # @return [Twitter::Tweet] The created Tweet.
118
117
  # @param status [String] The text of your status update, up to 140 characters.
119
118
  # @param options [Hash] A customizable set of options.
119
+ # @option options [Boolean, String, Integer] :possibly_sensitive Set to true for content which may not be suitable for every audience.
120
120
  # @option options [Twitter::Tweet] :in_reply_to_status An existing status that the update is in reply to.
121
121
  # @option options [Integer] :in_reply_to_status_id The ID of an existing status that the update is in reply to.
122
122
  # @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.
123
123
  # @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.
124
124
  # @option options [Twitter::Place] :place A place in the world. These can be retrieved from {Twitter::REST::PlacesAndGeo#reverse_geocode}.
125
125
  # @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::REST::PlacesAndGeo#reverse_geocode}.
126
+ # @option options [String] :media_ids A comma separated list of uploaded media IDs to attach to the Tweet.
126
127
  # @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
127
128
  # @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.
128
129
  def update(status, options = {})
@@ -142,12 +143,14 @@ module Twitter
142
143
  # @return [Twitter::Tweet] The created Tweet.
143
144
  # @param status [String] The text of your status update, up to 140 characters.
144
145
  # @param options [Hash] A customizable set of options.
146
+ # @option options [Boolean, String, Integer] :possibly_sensitive Set to true for content which may not be suitable for every audience.
145
147
  # @option options [Twitter::Tweet] :in_reply_to_status An existing status that the update is in reply to.
146
148
  # @option options [Integer] :in_reply_to_status_id The ID of an existing status that the update is in reply to.
147
149
  # @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.
148
150
  # @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.
149
151
  # @option options [Twitter::Place] :place A place in the world. These can be retrieved from {Twitter::REST::PlacesAndGeo#reverse_geocode}.
150
152
  # @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::REST::PlacesAndGeo#reverse_geocode}.
153
+ # @option options [String] :media_ids A comma separated list of uploaded media IDs to attach to the Tweet.
151
154
  # @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
152
155
  # @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.
153
156
  def update!(status, options = {})
@@ -136,7 +136,6 @@ module Twitter
136
136
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
137
137
  # @return [Array<Twitter::User>] User objects that the authenticating user is blocking.
138
138
  # @param options [Hash] A customizable set of options.
139
- # @option options [Boolean] :include_entities The tweet entities node will be disincluded when set to false.
140
139
  # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
141
140
  def blocked(options = {})
142
141
  perform_with_cursor(:get, '/1.1/blocks/list.json', options, :users, Twitter::User)
@@ -225,7 +224,6 @@ module Twitter
225
224
  # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
226
225
  # @param options [Hash] A customizable set of options.
227
226
  # @option options [Symbol, String] :method Requests users via a GET request instead of the standard POST request if set to ':get'.
228
- # @option options [Boolean] :include_entities The tweet entities node will be disincluded when set to false.
229
227
  def users(*args)
230
228
  arguments = Twitter::Arguments.new(args)
231
229
  request_method = arguments.options.delete(:method) || :post
@@ -243,14 +241,12 @@ module Twitter
243
241
  # Returns extended information for the authenticated user
244
242
  #
245
243
  # @param options [Hash] A customizable set of options.
246
- # @option options [Boolean] :include_entities The tweet entities node will be disincluded when set to false.
247
244
  # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
248
245
  # @overload user(user, options = {})
249
246
  # Returns extended information for a given user
250
247
  #
251
248
  # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
252
249
  # @param options [Hash] A customizable set of options.
253
- # @option options [Boolean] :include_entities The tweet entities node will be disincluded when set to false.
254
250
  # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
255
251
  def user(*args)
256
252
  arguments = Twitter::Arguments.new(args)
@@ -421,7 +417,6 @@ module Twitter
421
417
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
422
418
  # @return [Array<Twitter::User>] User objects that the authenticating user is muting.
423
419
  # @param options [Hash] A customizable set of options.
424
- # @option options [Boolean] :include_entities The tweet entities node will be disincluded when set to false.
425
420
  # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
426
421
  def muted(options = {})
427
422
  perform_with_cursor(:get, '/1.1/mutes/users/list.json', options, :users, Twitter::User)
@@ -115,7 +115,7 @@ module Twitter
115
115
  end
116
116
 
117
117
  def user_id
118
- @user_id ||= verify_credentials(:include_entities => false, :skip_status => true).id
118
+ @user_id ||= verify_credentials(:skip_status => true).id
119
119
  end
120
120
 
121
121
  def user_id?
@@ -43,9 +43,7 @@ module Twitter
43
43
  # @note Returned Hash can be merged into the previous search options list to easily access the next page.
44
44
  # @return [Hash] The parameters needed to fetch the next page.
45
45
  def next_page
46
- if next_page?
47
- query_string_to_hash(@attrs[:search_metadata][:next_results])
48
- end
46
+ query_string_to_hash(@attrs[:search_metadata][:next_results]) if next_page?
49
47
  end
50
48
 
51
49
  # @return [Hash]
@@ -89,7 +89,7 @@ module Twitter
89
89
  def website
90
90
  if website_urls?
91
91
  website_urls.first.expanded_url
92
- elsif @attrs[:url]
92
+ else
93
93
  Addressable::URI.parse(@attrs[:url])
94
94
  end
95
95
  end
@@ -25,11 +25,8 @@ module Twitter
25
25
  # @param enumerable [Enumerable]
26
26
  # @return [Array, Enumerator]
27
27
  def flat_pmap(enumerable)
28
- if block_given?
29
- pmap(enumerable, &Proc.new).flatten(1)
30
- else
31
- to_enum(:flat_pmap, enumerable)
32
- end
28
+ return to_enum(:flat_pmap, enumerable) unless block_given?
29
+ pmap(enumerable, &Proc.new).flatten(1)
33
30
  end
34
31
  module_function :flat_pmap
35
32
 
@@ -1,7 +1,7 @@
1
1
  module Twitter
2
2
  class Version
3
3
  MAJOR = 5
4
- MINOR = 9
4
+ MINOR = 10
5
5
  PATCH = 0
6
6
  PRE = nil
7
7
 
@@ -1 +1 @@
1
- {"created_at":"Wed Apr 06 19:13:37 +0000 2011","id":55709764298092545,"id_str":"55709764298092545","text":"The problem with your code is that it's doing exactly what you told it to do.","source":"\u003ca href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\"\u003eTwitter for iPhone\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":7505382,"id_str":"7505382","name":"Erik Michaels-Ober","screen_name":"sferik","location":"San Francisco","description":"Write code. Not too much. Mostly Ruby.","url":"https:\/\/github.com\/sferik","entities":{"url":{"urls":[{"url":"https:\/\/github.com\/sferik","expanded_url":null,"indices":[0,25]}]},"description":{"urls":[]}},"protected":false,"followers_count":2479,"friends_count":200,"listed_count":132,"created_at":"Mon Jul 16 12:59:01 +0000 2007","favourites_count":4421,"utc_offset":-28800,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":false,"statuses_count":8730,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"000000","profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/677717672\/bb0b3653dcf0644e344823e0a2eb3382.png","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/677717672\/bb0b3653dcf0644e344823e0a2eb3382.png","profile_background_tile":false,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1759857427\/image1326743606_normal.png","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1759857427\/image1326743606_normal.png","profile_banner_url":"https:\/\/si0.twimg.com\/profile_banners\/7505382\/1349499693","profile_link_color":"0084B4","profile_sidebar_border_color":"000000","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":{"type":"Point","coordinates":[37.78349999,-122.39362884]},"coordinates":{"type":"Point","coordinates":[-122.39362884,37.78349999]},"place":{"id":"5c92ab5379de3839","url":"https:\/\/api.twitter.com\/1.1\/geo\/id\/5c92ab5379de3839.json","place_type":"neighborhood","name":"South Beach","full_name":"South Beach, San Francisco","country_code":"US","country":"United States","bounding_box":{"type":"Polygon","coordinates":[[[-122.403482,37.777529],[-122.387436,37.777529],[-122.387436,37.794486],[-122.403482,37.794486]]]},"attributes":{}},"contributors":null,"retweet_count":316,"entities":{"hashtags":[],"urls":[],"user_mentions":[]},"favorited":false,"retweeted":false}
1
+ {"created_at":"Fri Mar 28 21:34:45 +0000 2014","id":449660889793581056,"id_str":"449660889793581056","text":"\"I hope you'll keep...building bonds of friendship that will enrich your lives &amp; enrich our world\" \u2014FLOTUS in China, http:\/\/t.co\/fxmuQN9JL9","source":"\u003ca href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\"\u003eTwitter for iPhone\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":1093090866,"id_str":"1093090866","name":"The First Lady","screen_name":"FLOTUS","location":"Washington, DC","description":"This account is run by the Office of First Lady Michelle Obama. Tweets from the First Lady are signed \u2013mo. Tweets may be archived. More at http:\/\/t.co\/9DxP65hB","url":"http:\/\/t.co\/RvRZspIO8c","entities":{"url":{"urls":[{"url":"http:\/\/t.co\/RvRZspIO8c","expanded_url":"http:\/\/www.whitehouse.gov","display_url":"whitehouse.gov","indices":[0,22]}]},"description":{"urls":[{"url":"http:\/\/t.co\/9DxP65hB","expanded_url":"http:\/\/wh.gov\/privacy","display_url":"wh.gov\/privacy","indices":[139,159]}]}},"protected":false,"followers_count":875307,"friends_count":21,"listed_count":5338,"created_at":"Tue Jan 15 20:03:17 +0000 2013","favourites_count":0,"utc_offset":-14400,"time_zone":"Eastern Time (US & Canada)","geo_enabled":false,"verified":true,"statuses_count":812,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"0084B4","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/766168824\/6d7e9bac6f5904ab0843bd1e9d935695.jpeg","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/766168824\/6d7e9bac6f5904ab0843bd1e9d935695.jpeg","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/453354757499781120\/WsSISQK__normal.jpeg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/453354757499781120\/WsSISQK__normal.jpeg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/1093090866\/1396923217","profile_link_color":"0084B4","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":222,"favorite_count":295,"entities":{"hashtags":[],"symbols":[],"urls":[],"user_mentions":[],"media":[{"id":449660809380380673,"id_str":"449660809380380673","indices":[121,143],"media_url":"http:\/\/pbs.twimg.com\/media\/Bj2EH6yIQAEYvxu.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/Bj2EH6yIQAEYvxu.jpg","url":"http:\/\/t.co\/fxmuQN9JL9","display_url":"pic.twitter.com\/fxmuQN9JL9","expanded_url":"http:\/\/twitter.com\/FLOTUS\/status\/449660889793581056\/photo\/1","type":"photo","sizes":{"medium":{"w":600,"h":399,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":640,"h":426,"resize":"fit"},"small":{"w":340,"h":226,"resize":"fit"}}}]},"extended_entities":{"media":[{"id":449660809380380673,"id_str":"449660809380380673","indices":[121,143],"media_url":"http:\/\/pbs.twimg.com\/media\/Bj2EH6yIQAEYvxu.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/Bj2EH6yIQAEYvxu.jpg","url":"http:\/\/t.co\/fxmuQN9JL9","display_url":"pic.twitter.com\/fxmuQN9JL9","expanded_url":"http:\/\/twitter.com\/FLOTUS\/status\/449660889793581056\/photo\/1","type":"photo","sizes":{"medium":{"w":600,"h":399,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":640,"h":426,"resize":"fit"},"small":{"w":340,"h":226,"resize":"fit"}}},{"id":449660806754738177,"id_str":"449660806754738177","indices":[121,143],"media_url":"http:\/\/pbs.twimg.com\/media\/Bj2EHxAIIAE8dtg.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/Bj2EHxAIIAE8dtg.jpg","url":"http:\/\/t.co\/fxmuQN9JL9","display_url":"pic.twitter.com\/fxmuQN9JL9","expanded_url":"http:\/\/twitter.com\/FLOTUS\/status\/449660889793581056\/photo\/1","type":"photo","sizes":{"medium":{"w":600,"h":399,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":640,"h":426,"resize":"fit"},"small":{"w":340,"h":226,"resize":"fit"}}},{"id":449660808537333761,"id_str":"449660808537333761","indices":[121,143],"media_url":"http:\/\/pbs.twimg.com\/media\/Bj2EH3pIYAE4LQn.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/Bj2EH3pIYAE4LQn.jpg","url":"http:\/\/t.co\/fxmuQN9JL9","display_url":"pic.twitter.com\/fxmuQN9JL9","expanded_url":"http:\/\/twitter.com\/FLOTUS\/status\/449660889793581056\/photo\/1","type":"photo","sizes":{"small":{"w":340,"h":227,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":640,"h":427,"resize":"fit"},"medium":{"w":600,"h":400,"resize":"fit"}}},{"id":449660877097406464,"id_str":"449660877097406464","indices":[121,143],"media_url":"http:\/\/pbs.twimg.com\/media\/Bj2EL3DIEAAzGAX.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/Bj2EL3DIEAAzGAX.jpg","url":"http:\/\/t.co\/fxmuQN9JL9","display_url":"pic.twitter.com\/fxmuQN9JL9","expanded_url":"http:\/\/twitter.com\/FLOTUS\/status\/449660889793581056\/photo\/1","type":"photo","sizes":{"medium":{"w":600,"h":399,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":640,"h":426,"resize":"fit"},"small":{"w":340,"h":226,"resize":"fit"}}}]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"}
@@ -0,0 +1 @@
1
+ {"image":{"w":428,"h":428,"image_type":"image\/png"},"media_id":470030289822314497,"media_id_string":"470030289822314497","size":68900}
@@ -1,13 +1,5 @@
1
1
  require 'simplecov'
2
2
  require 'coveralls'
3
-
4
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
5
-
6
- SimpleCov.start do
7
- add_filter '/spec/'
8
- minimum_coverage(99.15)
9
- end
10
-
11
3
  require 'twitter'
12
4
  require 'rspec'
13
5
  require 'stringio'
@@ -24,35 +16,35 @@ RSpec.configure do |config|
24
16
  end
25
17
 
26
18
  def a_delete(path)
27
- a_request(:delete, Twitter::REST::Client::ENDPOINT + path)
19
+ a_request(:delete, Twitter::REST::Client::URL_PREFIX + path)
28
20
  end
29
21
 
30
22
  def a_get(path)
31
- a_request(:get, Twitter::REST::Client::ENDPOINT + path)
23
+ a_request(:get, Twitter::REST::Client::URL_PREFIX + path)
32
24
  end
33
25
 
34
26
  def a_post(path)
35
- a_request(:post, Twitter::REST::Client::ENDPOINT + path)
27
+ a_request(:post, Twitter::REST::Client::URL_PREFIX + path)
36
28
  end
37
29
 
38
30
  def a_put(path)
39
- a_request(:put, Twitter::REST::Client::ENDPOINT + path)
31
+ a_request(:put, Twitter::REST::Client::URL_PREFIX + path)
40
32
  end
41
33
 
42
34
  def stub_delete(path)
43
- stub_request(:delete, Twitter::REST::Client::ENDPOINT + path)
35
+ stub_request(:delete, Twitter::REST::Client::URL_PREFIX + path)
44
36
  end
45
37
 
46
38
  def stub_get(path)
47
- stub_request(:get, Twitter::REST::Client::ENDPOINT + path)
39
+ stub_request(:get, Twitter::REST::Client::URL_PREFIX + path)
48
40
  end
49
41
 
50
42
  def stub_post(path)
51
- stub_request(:post, Twitter::REST::Client::ENDPOINT + path)
43
+ stub_request(:post, Twitter::REST::Client::URL_PREFIX + path)
52
44
  end
53
45
 
54
46
  def stub_put(path)
55
- stub_request(:put, Twitter::REST::Client::ENDPOINT + path)
47
+ stub_request(:put, Twitter::REST::Client::URL_PREFIX + path)
56
48
  end
57
49
 
58
50
  def fixture_path