twitter 7.0.0 → 8.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -4
  3. data/README.md +4 -6
  4. data/lib/twitter/base.rb +11 -11
  5. data/lib/twitter/basic_user.rb +3 -2
  6. data/lib/twitter/client.rb +3 -3
  7. data/lib/twitter/creatable.rb +2 -2
  8. data/lib/twitter/cursor.rb +3 -3
  9. data/lib/twitter/direct_message.rb +4 -5
  10. data/lib/twitter/direct_message_event.rb +3 -3
  11. data/lib/twitter/direct_messages/welcome_message.rb +3 -3
  12. data/lib/twitter/direct_messages/welcome_message_rule.rb +2 -2
  13. data/lib/twitter/direct_messages/welcome_message_rule_wrapper.rb +3 -3
  14. data/lib/twitter/direct_messages/welcome_message_wrapper.rb +3 -3
  15. data/lib/twitter/entities.rb +6 -6
  16. data/lib/twitter/entity/hashtag.rb +1 -1
  17. data/lib/twitter/entity/symbol.rb +1 -1
  18. data/lib/twitter/entity/uri.rb +1 -1
  19. data/lib/twitter/entity/user_mention.rb +1 -1
  20. data/lib/twitter/entity.rb +1 -1
  21. data/lib/twitter/enumerable.rb +1 -3
  22. data/lib/twitter/error.rb +7 -6
  23. data/lib/twitter/factory.rb +1 -1
  24. data/lib/twitter/geo/point.rb +1 -1
  25. data/lib/twitter/geo/polygon.rb +1 -1
  26. data/lib/twitter/geo.rb +2 -2
  27. data/lib/twitter/geo_factory.rb +3 -3
  28. data/lib/twitter/geo_results.rb +2 -2
  29. data/lib/twitter/headers.rb +4 -4
  30. data/lib/twitter/identity.rb +2 -2
  31. data/lib/twitter/language.rb +1 -1
  32. data/lib/twitter/list.rb +3 -2
  33. data/lib/twitter/media/animated_gif.rb +1 -1
  34. data/lib/twitter/media/photo.rb +2 -2
  35. data/lib/twitter/media/video.rb +3 -3
  36. data/lib/twitter/media/video_info.rb +2 -2
  37. data/lib/twitter/media_factory.rb +4 -4
  38. data/lib/twitter/metadata.rb +1 -1
  39. data/lib/twitter/null_object.rb +4 -4
  40. data/lib/twitter/oembed.rb +2 -1
  41. data/lib/twitter/place.rb +3 -3
  42. data/lib/twitter/premium_search_results.rb +5 -5
  43. data/lib/twitter/profile.rb +8 -8
  44. data/lib/twitter/profile_banner.rb +2 -2
  45. data/lib/twitter/rate_limit.rb +4 -4
  46. data/lib/twitter/relationship.rb +2 -1
  47. data/lib/twitter/rest/account_activity.rb +3 -3
  48. data/lib/twitter/rest/api.rb +19 -19
  49. data/lib/twitter/rest/client.rb +4 -4
  50. data/lib/twitter/rest/direct_messages/welcome_messages.rb +13 -13
  51. data/lib/twitter/rest/direct_messages.rb +17 -17
  52. data/lib/twitter/rest/favorites.rb +15 -19
  53. data/lib/twitter/rest/form_encoder.rb +27 -0
  54. data/lib/twitter/rest/friends_and_followers.rb +21 -21
  55. data/lib/twitter/rest/help.rb +6 -18
  56. data/lib/twitter/rest/lists.rb +32 -32
  57. data/lib/twitter/rest/oauth.rb +8 -8
  58. data/lib/twitter/rest/places_and_geo.rb +6 -6
  59. data/lib/twitter/rest/premium_search.rb +3 -3
  60. data/lib/twitter/rest/request.rb +28 -21
  61. data/lib/twitter/rest/saved_searches.rb +6 -6
  62. data/lib/twitter/rest/search.rb +3 -3
  63. data/lib/twitter/rest/spam_reporting.rb +3 -3
  64. data/lib/twitter/rest/suggested_users.rb +5 -5
  65. data/lib/twitter/rest/timelines.rb +7 -7
  66. data/lib/twitter/rest/trends.rb +7 -7
  67. data/lib/twitter/rest/tweets.rb +19 -23
  68. data/lib/twitter/rest/undocumented.rb +7 -7
  69. data/lib/twitter/rest/upload_utils.rb +13 -13
  70. data/lib/twitter/rest/users.rb +32 -32
  71. data/lib/twitter/rest/utils.rb +17 -17
  72. data/lib/twitter/saved_search.rb +2 -2
  73. data/lib/twitter/search_results.rb +6 -6
  74. data/lib/twitter/settings.rb +2 -1
  75. data/lib/twitter/size.rb +2 -2
  76. data/lib/twitter/source_user.rb +1 -1
  77. data/lib/twitter/streaming/client.rb +14 -14
  78. data/lib/twitter/streaming/connection.rb +4 -5
  79. data/lib/twitter/streaming/message_parser.rb +6 -6
  80. data/lib/twitter/streaming/response.rb +11 -10
  81. data/lib/twitter/suggestion.rb +3 -3
  82. data/lib/twitter/target_user.rb +1 -1
  83. data/lib/twitter/trend.rb +3 -2
  84. data/lib/twitter/trend_results.rb +5 -5
  85. data/lib/twitter/tweet.rb +3 -3
  86. data/lib/twitter/user.rb +9 -9
  87. data/lib/twitter/utils.rb +2 -2
  88. data/lib/twitter/variant.rb +2 -1
  89. data/lib/twitter/version.rb +3 -3
  90. data/lib/twitter.rb +36 -36
  91. data/twitter.gemspec +19 -18
  92. metadata +23 -22
  93. data/lib/twitter/configuration.rb +0 -27
@@ -1,11 +1,11 @@
1
- require 'twitter/arguments'
2
- require 'twitter/error'
3
- require 'twitter/oembed'
4
- require 'twitter/rest/request'
5
- require 'twitter/rest/upload_utils'
6
- require 'twitter/rest/utils'
7
- require 'twitter/tweet'
8
- require 'twitter/utils'
1
+ require "twitter/arguments"
2
+ require "twitter/error"
3
+ require "twitter/oembed"
4
+ require "twitter/rest/request"
5
+ require "twitter/rest/upload_utils"
6
+ require "twitter/rest/utils"
7
+ require "twitter/tweet"
8
+ require "twitter/utils"
9
9
 
10
10
  module Twitter
11
11
  module REST
@@ -79,7 +79,7 @@ module Twitter
79
79
  def statuses(*args)
80
80
  arguments = Twitter::Arguments.new(args)
81
81
  flat_pmap(arguments.each_slice(MAX_TWEETS_PER_REQUEST)) do |tweets|
82
- perform_post_with_objects('/1.1/statuses/lookup.json', arguments.options.merge(id: tweets.collect { |u| extract_id(u) }.join(',')), Twitter::Tweet)
82
+ perform_post_with_objects("/1.1/statuses/lookup.json", arguments.options.merge(id: tweets.collect { |u| extract_id(u) }.join(",")), Twitter::Tweet)
83
83
  end
84
84
  end
85
85
 
@@ -154,7 +154,7 @@ module Twitter
154
154
  hash = options.dup
155
155
  hash[:in_reply_to_status_id] = hash.delete(:in_reply_to_status).id unless hash[:in_reply_to_status].nil?
156
156
  hash[:place_id] = hash.delete(:place).woeid unless hash[:place].nil?
157
- perform_post_with_object('/1.1/statuses/update.json', hash.merge(status: status), Twitter::Tweet)
157
+ perform_post_with_object("/1.1/statuses/update.json", hash.merge(status: status), Twitter::Tweet)
158
158
  end
159
159
 
160
160
  # Retweets the specified Tweets as the authenticating user
@@ -173,11 +173,9 @@ module Twitter
173
173
  def retweet(*args)
174
174
  arguments = Twitter::Arguments.new(args)
175
175
  pmap(arguments) do |tweet|
176
- begin
177
- post_retweet(extract_id(tweet), arguments.options)
178
- rescue Twitter::Error::AlreadyRetweeted, Twitter::Error::NotFound
179
- next
180
- end
176
+ post_retweet(extract_id(tweet), arguments.options)
177
+ rescue Twitter::Error::AlreadyRetweeted, Twitter::Error::NotFound
178
+ next
181
179
  end.compact
182
180
  end
183
181
 
@@ -228,7 +226,7 @@ module Twitter
228
226
  media_ids = pmap(array_wrap(media)) do |medium|
229
227
  upload(medium)[:media_id]
230
228
  end
231
- update!(status, options.merge(media_ids: media_ids.join(',')))
229
+ update!(status, options.merge(media_ids: media_ids.join(",")))
232
230
  end
233
231
 
234
232
  # Returns oEmbed for a Tweet
@@ -252,7 +250,7 @@ module Twitter
252
250
  def oembed(tweet, options = {})
253
251
  options = options.dup
254
252
  options[:id] = extract_id(tweet)
255
- perform_get_with_object('/1.1/statuses/oembed.json', options, Twitter::OEmbed)
253
+ perform_get_with_object("/1.1/statuses/oembed.json", options, Twitter::OEmbed)
256
254
  end
257
255
 
258
256
  # Returns oEmbeds for Tweets
@@ -296,7 +294,7 @@ module Twitter
296
294
  def retweeters_ids(*args)
297
295
  arguments = Twitter::Arguments.new(args)
298
296
  arguments.options[:id] ||= extract_id(arguments.first)
299
- perform_get_with_cursor('/1.1/statuses/retweeters/ids.json', arguments.options, :ids)
297
+ perform_get_with_cursor("/1.1/statuses/retweeters/ids.json", arguments.options, :ids)
300
298
  end
301
299
 
302
300
  # Untweets a retweeted status as the authenticating user
@@ -315,11 +313,9 @@ module Twitter
315
313
  def unretweet(*args)
316
314
  arguments = Twitter::Arguments.new(args)
317
315
  pmap(arguments) do |tweet|
318
- begin
319
- post_unretweet(extract_id(tweet), arguments.options)
320
- rescue Twitter::Error::NotFound
321
- next
322
- end
316
+ post_unretweet(extract_id(tweet), arguments.options)
317
+ rescue Twitter::Error::NotFound
318
+ next
323
319
  end.compact
324
320
  end
325
321
 
@@ -1,8 +1,8 @@
1
- require 'twitter/arguments'
2
- require 'twitter/cursor'
3
- require 'twitter/rest/utils'
4
- require 'twitter/tweet'
5
- require 'twitter/user'
1
+ require "twitter/arguments"
2
+ require "twitter/cursor"
3
+ require "twitter/rest/utils"
4
+ require "twitter/tweet"
5
+ require "twitter/user"
6
6
 
7
7
  module Twitter
8
8
  module REST
@@ -24,7 +24,7 @@ module Twitter
24
24
  # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
25
25
  # @param options [Hash] A customizable set of options.
26
26
  def following_followers_of(*args)
27
- cursor_from_response_with_user(:users, Twitter::User, '/users/following_followers_of.json', args)
27
+ cursor_from_response_with_user(:users, Twitter::User, "/users/following_followers_of.json", args)
28
28
  end
29
29
 
30
30
  # Returns Tweets count for a URI
@@ -36,7 +36,7 @@ module Twitter
36
36
  # @param url [String, URI] A URL.
37
37
  # @param options [Hash] A customizable set of options.
38
38
  def tweet_count(url, options = {})
39
- HTTP.get('https://cdn.api.twitter.com/1/urls/count.json', params: options.merge(url: url.to_s)).parse['count']
39
+ HTTP.get("https://cdn.api.twitter.com/1/urls/count.json", params: options.merge(url: url.to_s)).parse["count"]
40
40
  end
41
41
  end
42
42
  end
@@ -1,4 +1,4 @@
1
- require 'twitter/rest/request'
1
+ require "twitter/rest/request"
2
2
 
3
3
  module Twitter
4
4
  module REST
@@ -9,11 +9,11 @@ module Twitter
9
9
  # The only supported video format is mp4.
10
10
  #
11
11
  # @see https://developer.twitter.com/en/docs/media/upload-media/uploading-media/media-best-practices
12
- def upload(media, media_category_prefix: 'tweet')
13
- return chunk_upload(media, 'video/mp4', "#{media_category_prefix}_video") if File.extname(media) == '.mp4'
14
- return chunk_upload(media, 'image/gif', "#{media_category_prefix}_gif") if File.extname(media) == '.gif' && File.size(media) > 5_000_000
12
+ def upload(media, media_category_prefix: "tweet")
13
+ return chunk_upload(media, "video/mp4", "#{media_category_prefix}_video") if File.extname(media) == ".mp4"
14
+ return chunk_upload(media, "image/gif", "#{media_category_prefix}_gif") if File.extname(media) == ".gif" && File.size(media) > 5_000_000
15
15
 
16
- Twitter::REST::Request.new(self, :multipart_post, 'https://upload.twitter.com/1.1/media/upload.json', key: :media, file: media).perform
16
+ Twitter::REST::Request.new(self, :multipart_post, "https://upload.twitter.com/1.1/media/upload.json", key: :media, file: media).perform
17
17
  end
18
18
 
19
19
  # @raise [Twitter::Error::TimeoutError] Error raised when the upload is longer than the value specified in Twitter::Client#timeouts[:upload].
@@ -24,8 +24,8 @@ module Twitter
24
24
  # @see https://developer.twitter.com/en/docs/media/upload-media/uploading-media/chunked-media-upload
25
25
  def chunk_upload(media, media_type, media_category)
26
26
  Timeout.timeout(timeouts&.fetch(:upload, nil), Twitter::Error::TimeoutError) do
27
- init = Twitter::REST::Request.new(self, :post, 'https://upload.twitter.com/1.1/media/upload.json',
28
- command: 'INIT',
27
+ init = Twitter::REST::Request.new(self, :post, "https://upload.twitter.com/1.1/media/upload.json",
28
+ command: "INIT",
29
29
  media_type: media_type,
30
30
  media_category: media_category,
31
31
  total_bytes: media.size).perform
@@ -40,8 +40,8 @@ module Twitter
40
40
  until media.eof?
41
41
  chunk = media.read(5_000_000)
42
42
  seg ||= -1
43
- Twitter::REST::Request.new(self, :multipart_post, 'https://upload.twitter.com/1.1/media/upload.json',
44
- command: 'APPEND',
43
+ Twitter::REST::Request.new(self, :multipart_post, "https://upload.twitter.com/1.1/media/upload.json",
44
+ command: "APPEND",
45
45
  media_id: media_id,
46
46
  segment_index: seg += 1,
47
47
  key: :media,
@@ -52,14 +52,14 @@ module Twitter
52
52
  # @see https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload-finalize
53
53
  # @see https://developer.twitter.com/en/docs/media/upload-media/api-reference/get-media-upload-status
54
54
  def finalize_media(media_id)
55
- response = Twitter::REST::Request.new(self, :post, 'https://upload.twitter.com/1.1/media/upload.json',
56
- command: 'FINALIZE', media_id: media_id).perform
55
+ response = Twitter::REST::Request.new(self, :post, "https://upload.twitter.com/1.1/media/upload.json",
56
+ command: "FINALIZE", media_id: media_id).perform
57
57
  loop do
58
58
  return response if !response[:processing_info] || %w[failed succeeded].include?(response[:processing_info][:state])
59
59
 
60
60
  sleep(response[:processing_info][:check_after_secs])
61
- response = Twitter::REST::Request.new(self, :get, 'https://upload.twitter.com/1.1/media/upload.json',
62
- command: 'STATUS', media_id: media_id).perform
61
+ response = Twitter::REST::Request.new(self, :get, "https://upload.twitter.com/1.1/media/upload.json",
62
+ command: "STATUS", media_id: media_id).perform
63
63
  end
64
64
  response
65
65
  end
@@ -1,11 +1,11 @@
1
- require 'twitter/arguments'
2
- require 'twitter/error'
3
- require 'twitter/profile_banner'
4
- require 'twitter/rest/request'
5
- require 'twitter/rest/utils'
6
- require 'twitter/settings'
7
- require 'twitter/user'
8
- require 'twitter/utils'
1
+ require "twitter/arguments"
2
+ require "twitter/error"
3
+ require "twitter/profile_banner"
4
+ require "twitter/rest/request"
5
+ require "twitter/rest/utils"
6
+ require "twitter/settings"
7
+ require "twitter/user"
8
+ require "twitter/utils"
9
9
 
10
10
  module Twitter
11
11
  module REST
@@ -33,8 +33,8 @@ module Twitter
33
33
  # @option options [String] :allow_contributor_request Whether to allow others to include user as contributor. Possible values include 'all' (anyone can include user), 'following' (only followers can include user) or 'none'. Also note that changes to this field require the request also include a current_password value with the user's password to successfully modify this field.
34
34
  # @option options [String] :current_password The user's password. This is only required when modifying the allow_contributor_request field.
35
35
  def settings(options = {})
36
- request_method = options.size.zero? ? :get : :post
37
- response = perform_request(request_method.to_sym, '/1.1/account/settings.json', options)
36
+ request_method = options.empty? ? :get : :post
37
+ response = perform_request(request_method.to_sym, "/1.1/account/settings.json", options)
38
38
  # https://dev.twitter.com/issues/59
39
39
  response[:trend_location] = response.fetch(:trend_location, []).first
40
40
  Twitter::Settings.new(response)
@@ -50,7 +50,7 @@ module Twitter
50
50
  # @param options [Hash] A customizable set of options.
51
51
  # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
52
52
  def verify_credentials(options = {})
53
- perform_get_with_object('/1.1/account/verify_credentials.json', options, Twitter::User)
53
+ perform_get_with_object("/1.1/account/verify_credentials.json", options, Twitter::User)
54
54
  end
55
55
 
56
56
  # Sets which device Twitter delivers updates to for the authenticating user
@@ -63,7 +63,7 @@ module Twitter
63
63
  # @param device [String] Must be one of: 'sms', 'none'.
64
64
  # @param options [Hash] A customizable set of options.
65
65
  def update_delivery_device(device, options = {})
66
- perform_post_with_object('/1.1/account/update_delivery_device.json', options.merge(device: device), Twitter::User)
66
+ perform_post_with_object("/1.1/account/update_delivery_device.json", options.merge(device: device), Twitter::User)
67
67
  end
68
68
 
69
69
  # Sets values that users are able to set under the "Account" tab of their settings page
@@ -81,7 +81,7 @@ module Twitter
81
81
  # @option options [String] :description A description of the user owning the account. Maximum of 160 characters.
82
82
  # @option options [String] :profile_link_color A hex value of the color scheme used for links on user's profile page. Must be a valid hexadecimal value, and may be either three or six characters
83
83
  def update_profile(options = {})
84
- perform_post_with_object('/1.1/account/update_profile.json', options, Twitter::User)
84
+ perform_post_with_object("/1.1/account/update_profile.json", options, Twitter::User)
85
85
  end
86
86
 
87
87
  # Updates the authenticating user's profile background image
@@ -95,7 +95,7 @@ module Twitter
95
95
  # @param options [Hash] A customizable set of options.
96
96
  # @option options [Boolean] :tile Whether or not to tile the background image. If set to true the background image will be displayed tiled. The image will not be tiled otherwise.
97
97
  def update_profile_background_image(image, options = {})
98
- post_profile_image('/1.1/account/update_profile_background_image.json', image, options)
98
+ post_profile_image("/1.1/account/update_profile_background_image.json", image, options)
99
99
  end
100
100
 
101
101
  # Updates the authenticating user's profile image
@@ -110,7 +110,7 @@ module Twitter
110
110
  # @param image [File] The avatar image for the profile, base64-encoded. Must be a valid GIF, JPG, or PNG image of less than 700 kilobytes in size. Images with width larger than 500 pixels will be scaled down. Animated GIFs will be converted to a static GIF of the first frame, removing the animation.
111
111
  # @param options [Hash] A customizable set of options.
112
112
  def update_profile_image(image, options = {})
113
- post_profile_image('/1.1/account/update_profile_image.json', image, options)
113
+ post_profile_image("/1.1/account/update_profile_image.json", image, options)
114
114
  end
115
115
 
116
116
  # Returns an array of user objects that the authenticating user is blocking
@@ -123,7 +123,7 @@ module Twitter
123
123
  # @param options [Hash] A customizable set of options.
124
124
  # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
125
125
  def blocked(options = {})
126
- perform_get_with_cursor('/1.1/blocks/list.json', options, :users, Twitter::User)
126
+ perform_get_with_cursor("/1.1/blocks/list.json", options, :users, Twitter::User)
127
127
  end
128
128
 
129
129
  # Returns an array of numeric user IDs the authenticating user is blocking
@@ -138,7 +138,7 @@ module Twitter
138
138
  def blocked_ids(*args)
139
139
  arguments = Twitter::Arguments.new(args)
140
140
  merge_user!(arguments.options, arguments.pop)
141
- perform_get_with_cursor('/1.1/blocks/ids.json', arguments.options, :ids)
141
+ perform_get_with_cursor("/1.1/blocks/ids.json", arguments.options, :ids)
142
142
  end
143
143
 
144
144
  # Returns true if the authenticating user is blocking a target user
@@ -174,7 +174,7 @@ module Twitter
174
174
  # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
175
175
  # @param options [Hash] A customizable set of options.
176
176
  def block(*args)
177
- parallel_users_from_response(:post, '/1.1/blocks/create.json', args)
177
+ parallel_users_from_response(:post, "/1.1/blocks/create.json", args)
178
178
  end
179
179
 
180
180
  # Un-blocks the users specified by the authenticating user
@@ -190,7 +190,7 @@ module Twitter
190
190
  # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
191
191
  # @param options [Hash] A customizable set of options.
192
192
  def unblock(*args)
193
- parallel_users_from_response(:post, '/1.1/blocks/destroy.json', args)
193
+ parallel_users_from_response(:post, "/1.1/blocks/destroy.json", args)
194
194
  end
195
195
 
196
196
  # Returns extended information for up to 100 users
@@ -208,7 +208,7 @@ module Twitter
208
208
  def users(*args)
209
209
  arguments = Twitter::Arguments.new(args)
210
210
  flat_pmap(arguments.each_slice(MAX_USERS_PER_REQUEST)) do |users|
211
- perform_get_with_objects('/1.1/users/lookup.json', merge_users(arguments.options, users), Twitter::User)
211
+ perform_get_with_objects("/1.1/users/lookup.json", merge_users(arguments.options, users), Twitter::User)
212
212
  end
213
213
  end
214
214
 
@@ -232,7 +232,7 @@ module Twitter
232
232
  arguments = Twitter::Arguments.new(args)
233
233
  if arguments.last || user_id?
234
234
  merge_user!(arguments.options, arguments.pop || user_id)
235
- perform_get_with_object('/1.1/users/show.json', arguments.options, Twitter::User)
235
+ perform_get_with_object("/1.1/users/show.json", arguments.options, Twitter::User)
236
236
  else
237
237
  verify_credentials(arguments.options)
238
238
  end
@@ -248,7 +248,7 @@ module Twitter
248
248
  def user?(user, options = {})
249
249
  options = options.dup
250
250
  merge_user!(options, user)
251
- perform_get('/1.1/users/show.json', options)
251
+ perform_get("/1.1/users/show.json", options)
252
252
  true
253
253
  rescue Twitter::Error::NotFound
254
254
  false
@@ -267,7 +267,7 @@ module Twitter
267
267
  # @option options [Integer] :page Specifies the page of results to retrieve.
268
268
  def user_search(query, options = {})
269
269
  options = options.dup
270
- perform_get_with_objects('/1.1/users/search.json', options.merge(q: query), Twitter::User)
270
+ perform_get_with_objects("/1.1/users/search.json", options.merge(q: query), Twitter::User)
271
271
  end
272
272
 
273
273
  # Returns an array of users that the specified user can contribute to
@@ -285,7 +285,7 @@ module Twitter
285
285
  # @param options [Hash] A customizable set of options.
286
286
  # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
287
287
  def contributees(*args)
288
- users_from_response(:get, '/1.1/users/contributees.json', args)
288
+ users_from_response(:get, "/1.1/users/contributees.json", args)
289
289
  end
290
290
 
291
291
  # Returns an array of users who can contribute to the specified account
@@ -303,7 +303,7 @@ module Twitter
303
303
  # @param options [Hash] A customizable set of options.
304
304
  # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
305
305
  def contributors(*args)
306
- users_from_response(:get, '/1.1/users/contributors.json', args)
306
+ users_from_response(:get, "/1.1/users/contributors.json", args)
307
307
  end
308
308
 
309
309
  # Removes the authenticating user's profile banner image
@@ -315,7 +315,7 @@ module Twitter
315
315
  # @return [nil]
316
316
  # @param options [Hash] A customizable set of options.
317
317
  def remove_profile_banner(options = {})
318
- perform_post('/1.1/account/remove_profile_banner.json', options)
318
+ perform_post("/1.1/account/remove_profile_banner.json", options)
319
319
  true
320
320
  end
321
321
 
@@ -337,7 +337,7 @@ module Twitter
337
337
  # @option options [Integer] :offset_left The number of pixels by which to offset the uploaded image from the left. Use with height, width, and offset_top to select the desired region of the image to use.
338
338
  # @option options [Integer] :offset_top The number of pixels by which to offset the uploaded image from the top. Use with height, width, and offset_left to select the desired region of the image to use.
339
339
  def update_profile_banner(banner, options = {})
340
- perform_post('/1.1/account/update_profile_banner.json', options.merge(banner: banner))
340
+ perform_post("/1.1/account/update_profile_banner.json", options.merge(banner: banner))
341
341
  true
342
342
  end
343
343
 
@@ -355,7 +355,7 @@ module Twitter
355
355
  def profile_banner(*args)
356
356
  arguments = Twitter::Arguments.new(args)
357
357
  merge_user!(arguments.options, arguments.pop || user_id) unless arguments.options[:user_id] || arguments.options[:screen_name]
358
- perform_get_with_object('/1.1/users/profile_banner.json', arguments.options, Twitter::ProfileBanner)
358
+ perform_get_with_object("/1.1/users/profile_banner.json", arguments.options, Twitter::ProfileBanner)
359
359
  end
360
360
 
361
361
  # Mutes the users specified by the authenticating user
@@ -371,7 +371,7 @@ module Twitter
371
371
  # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
372
372
  # @param options [Hash] A customizable set of options.
373
373
  def mute(*args)
374
- parallel_users_from_response(:post, '/1.1/mutes/users/create.json', args)
374
+ parallel_users_from_response(:post, "/1.1/mutes/users/create.json", args)
375
375
  end
376
376
 
377
377
  # Un-mutes the user specified by the authenticating user.
@@ -387,7 +387,7 @@ module Twitter
387
387
  # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
388
388
  # @param options [Hash] A customizable set of options.
389
389
  def unmute(*args)
390
- parallel_users_from_response(:post, '/1.1/mutes/users/destroy.json', args)
390
+ parallel_users_from_response(:post, "/1.1/mutes/users/destroy.json", args)
391
391
  end
392
392
 
393
393
  # Returns an array of user objects that the authenticating user is muting
@@ -400,7 +400,7 @@ module Twitter
400
400
  # @param options [Hash] A customizable set of options.
401
401
  # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
402
402
  def muted(options = {})
403
- perform_get_with_cursor('/1.1/mutes/users/list.json', options, :users, Twitter::User)
403
+ perform_get_with_cursor("/1.1/mutes/users/list.json", options, :users, Twitter::User)
404
404
  end
405
405
 
406
406
  # Returns an array of numeric user IDs the authenticating user is muting
@@ -415,7 +415,7 @@ module Twitter
415
415
  def muted_ids(*args)
416
416
  arguments = Twitter::Arguments.new(args)
417
417
  merge_user!(arguments.options, arguments.pop)
418
- perform_get_with_cursor('/1.1/mutes/users/ids.json', arguments.options, :ids)
418
+ perform_get_with_cursor("/1.1/mutes/users/ids.json", arguments.options, :ids)
419
419
  end
420
420
 
421
421
  private
@@ -1,10 +1,10 @@
1
- require 'addressable/uri'
2
- require 'twitter/arguments'
3
- require 'twitter/cursor'
4
- require 'twitter/rest/request'
5
- require 'twitter/user'
6
- require 'twitter/utils'
7
- require 'uri'
1
+ require "addressable/uri"
2
+ require "twitter/arguments"
3
+ require "twitter/cursor"
4
+ require "twitter/rest/request"
5
+ require "twitter/user"
6
+ require "twitter/utils"
7
+ require "uri"
8
8
 
9
9
  module Twitter
10
10
  module REST
@@ -23,9 +23,9 @@ module Twitter
23
23
  when ::Integer
24
24
  object
25
25
  when ::String
26
- object.split('/').last.to_i
26
+ object.split("/").last.to_i
27
27
  when URI, Addressable::URI
28
- object.path.split('/').last.to_i
28
+ object.path.split("/").last.to_i
29
29
  when Twitter::Identity
30
30
  object.id
31
31
  end
@@ -208,18 +208,18 @@ module Twitter
208
208
  def merge_user!(hash, user, prefix = nil)
209
209
  case user
210
210
  when Integer
211
- set_compound_key('user_id', user, hash, prefix)
211
+ set_compound_key("user_id", user, hash, prefix)
212
212
  when String
213
- set_compound_key('screen_name', user, hash, prefix)
213
+ set_compound_key("screen_name", user, hash, prefix)
214
214
  when URI, Addressable::URI
215
- set_compound_key('screen_name', user.path.split('/').last, hash, prefix)
215
+ set_compound_key("screen_name", user.path.split("/").last, hash, prefix)
216
216
  when Twitter::User
217
- set_compound_key('user_id', user.id, hash, prefix)
217
+ set_compound_key("user_id", user.id, hash, prefix)
218
218
  end
219
219
  end
220
220
 
221
221
  def set_compound_key(key, value, hash, prefix = nil)
222
- compound_key = [prefix, key].compact.join('_').to_sym
222
+ compound_key = [prefix, key].compact.join("_").to_sym
223
223
  hash[compound_key] = value
224
224
  hash
225
225
  end
@@ -242,8 +242,8 @@ module Twitter
242
242
  # @return [Hash]
243
243
  def merge_users!(hash, users)
244
244
  user_ids, screen_names = collect_users(users)
245
- hash[:user_id] = user_ids.join(',') unless user_ids.empty?
246
- hash[:screen_name] = screen_names.join(',') unless screen_names.empty?
245
+ hash[:user_id] = user_ids.join(",") unless user_ids.empty?
246
+ hash[:screen_name] = screen_names.join(",") unless screen_names.empty?
247
247
  end
248
248
 
249
249
  def collect_users(users) # rubocop:disable Metrics/MethodLength
@@ -254,7 +254,7 @@ module Twitter
254
254
  when Integer then user_ids << user
255
255
  when Twitter::User then user_ids << user.id
256
256
  when String then screen_names << user
257
- when URI, Addressable::URI then screen_names << user.path.split('/').last
257
+ when URI, Addressable::URI then screen_names << user.path.split("/").last
258
258
  end
259
259
  end
260
260
  [user_ids, screen_names]
@@ -1,5 +1,5 @@
1
- require 'twitter/creatable'
2
- require 'twitter/identity'
1
+ require "twitter/creatable"
2
+ require "twitter/identity"
3
3
 
4
4
  module Twitter
5
5
  class SavedSearch < Twitter::Identity
@@ -1,8 +1,8 @@
1
- require 'cgi'
2
- require 'twitter/enumerable'
3
- require 'twitter/rest/request'
4
- require 'twitter/utils'
5
- require 'uri'
1
+ require "cgi"
2
+ require "twitter/enumerable"
3
+ require "twitter/rest/request"
4
+ require "twitter/utils"
5
+ require "uri"
6
6
 
7
7
  module Twitter
8
8
  class SearchResults
@@ -71,7 +71,7 @@ module Twitter
71
71
  # query_string_to_hash("foo=bar&baz=qux") #=> {:foo=>"bar", :baz=>"qux"}
72
72
  def query_string_to_hash(query_string)
73
73
  query = CGI.parse(URI.parse(query_string).query)
74
- Hash[query.collect { |key, value| [key.to_sym, value.first] }]
74
+ query.to_h { |key, value| [key.to_sym, value.first] }
75
75
  end
76
76
  end
77
77
  end
@@ -1,4 +1,4 @@
1
- require 'twitter/base'
1
+ require "twitter/base"
2
2
 
3
3
  module Twitter
4
4
  class Settings < Twitter::Base
@@ -6,6 +6,7 @@ module Twitter
6
6
  attr_reader :sleep_time, :time_zone
7
7
  # @return [String]
8
8
  attr_reader :language, :screen_name
9
+
9
10
  object_attr_reader :Place, :trend_location
10
11
  predicate_attr_reader :allow_contributor_request,
11
12
  :allow_dm_groups_from,
data/lib/twitter/size.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'equalizer'
2
- require 'twitter/base'
1
+ require "equalizer"
2
+ require "twitter/base"
3
3
 
4
4
  module Twitter
5
5
  class Size < Twitter::Base
@@ -1,4 +1,4 @@
1
- require 'twitter/basic_user'
1
+ require "twitter/basic_user"
2
2
 
3
3
  module Twitter
4
4
  class SourceUser < Twitter::BasicUser
@@ -1,11 +1,11 @@
1
- require 'http/request'
2
- require 'twitter/arguments'
3
- require 'twitter/client'
4
- require 'twitter/headers'
5
- require 'twitter/streaming/connection'
6
- require 'twitter/streaming/message_parser'
7
- require 'twitter/streaming/response'
8
- require 'twitter/utils'
1
+ require "http/request"
2
+ require "twitter/arguments"
3
+ require "twitter/client"
4
+ require "twitter/headers"
5
+ require "twitter/streaming/connection"
6
+ require "twitter/streaming/message_parser"
7
+ require "twitter/streaming/response"
8
+ require "twitter/utils"
9
9
 
10
10
  module Twitter
11
11
  module Streaming
@@ -35,7 +35,7 @@ module Twitter
35
35
  # @option options [String] :locations Includes additional Tweets falling within the specified bounding boxes.
36
36
  # @yield [Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning] A stream of Twitter objects.
37
37
  def filter(options = {}, &block)
38
- request(:post, 'https://stream.twitter.com:443/1.1/statuses/filter.json', options, &block)
38
+ request(:post, "https://stream.twitter.com:443/1.1/statuses/filter.json", options, &block)
39
39
  end
40
40
 
41
41
  # Returns all public statuses
@@ -47,7 +47,7 @@ module Twitter
47
47
  # @option options [Integer] :count The number of messages to backfill.
48
48
  # @yield [Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning] A stream of Twitter objects.
49
49
  def firehose(options = {}, &block)
50
- request(:get, 'https://stream.twitter.com:443/1.1/statuses/firehose.json', options, &block)
50
+ request(:get, "https://stream.twitter.com:443/1.1/statuses/firehose.json", options, &block)
51
51
  end
52
52
 
53
53
  # Returns a small random sample of all public statuses
@@ -56,7 +56,7 @@ module Twitter
56
56
  # @see https://dev.twitter.com/streaming/overview/request-parameters
57
57
  # @yield [Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning] A stream of Twitter objects.
58
58
  def sample(options = {}, &block)
59
- request(:get, 'https://stream.twitter.com:443/1.1/statuses/sample.json', options, &block)
59
+ request(:get, "https://stream.twitter.com:443/1.1/statuses/sample.json", options, &block)
60
60
  end
61
61
 
62
62
  # Streams messages for a set of users
@@ -74,7 +74,7 @@ module Twitter
74
74
  def site(*args, &block)
75
75
  arguments = Arguments.new(args)
76
76
  user_ids = collect_user_ids(arguments)
77
- request(:get, 'https://sitestream.twitter.com:443/1.1/site.json', arguments.options.merge(follow: user_ids.join(',')), &block)
77
+ request(:get, "https://sitestream.twitter.com:443/1.1/site.json", arguments.options.merge(follow: user_ids.join(",")), &block)
78
78
  end
79
79
 
80
80
  # Streams messages for a single user
@@ -90,7 +90,7 @@ module Twitter
90
90
  # @option options [String] :locations Includes additional Tweets falling within the specified bounding boxes.
91
91
  # @yield [Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning] A stream of Twitter objects.
92
92
  def user(options = {}, &block)
93
- request(:get, 'https://userstream.twitter.com:443/1.1/user.json', options, &block)
93
+ request(:get, "https://userstream.twitter.com:443/1.1/user.json", options, &block)
94
94
  end
95
95
 
96
96
  # Set a Proc to be run when connection established.
@@ -114,7 +114,7 @@ module Twitter
114
114
  def request(method, uri, params)
115
115
  before_request.call
116
116
  headers = Twitter::Headers.new(self, method, uri, params).request_headers
117
- request = HTTP::Request.new(verb: method, uri: uri + '?' + to_url_params(params), headers: headers, proxy: proxy)
117
+ request = HTTP::Request.new(verb: method, uri: "#{uri}?#{to_url_params(params)}", headers: headers, proxy: proxy)
118
118
  response = Streaming::Response.new do |data|
119
119
  if item = Streaming::MessageParser.parse(data) # rubocop:disable Lint/AssignmentInCondition
120
120
  yield(item)