twitter 5.1.1 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.yardopts +2 -0
  3. data/CHANGELOG.md +10 -1
  4. data/CONTRIBUTING.md +2 -2
  5. data/README.md +30 -20
  6. data/Rakefile +26 -5
  7. data/lib/twitter/arguments.rb +0 -1
  8. data/lib/twitter/base.rb +13 -16
  9. data/lib/twitter/basic_user.rb +3 -3
  10. data/lib/twitter/client.rb +7 -8
  11. data/lib/twitter/configuration.rb +5 -5
  12. data/lib/twitter/core_ext/enumerable.rb +0 -2
  13. data/lib/twitter/core_ext/kernel.rb +0 -2
  14. data/lib/twitter/creatable.rb +0 -1
  15. data/lib/twitter/cursor.rb +7 -10
  16. data/lib/twitter/direct_message.rb +1 -1
  17. data/lib/twitter/entity/uri.rb +2 -2
  18. data/lib/twitter/enumerable.rb +1 -2
  19. data/lib/twitter/error.rb +4 -6
  20. data/lib/twitter/error/already_favorited.rb +1 -1
  21. data/lib/twitter/error/already_posted.rb +1 -1
  22. data/lib/twitter/error/already_retweeted.rb +1 -1
  23. data/lib/twitter/error/too_many_requests.rb +2 -2
  24. data/lib/twitter/factory.rb +2 -6
  25. data/lib/twitter/geo.rb +1 -1
  26. data/lib/twitter/geo/point.rb +3 -5
  27. data/lib/twitter/geo_factory.rb +1 -5
  28. data/lib/twitter/geo_results.rb +5 -8
  29. data/lib/twitter/identity.rb +1 -2
  30. data/lib/twitter/list.rb +4 -5
  31. data/lib/twitter/media/photo.rb +1 -2
  32. data/lib/twitter/media_factory.rb +1 -5
  33. data/lib/twitter/null_object.rb +4 -6
  34. data/lib/twitter/oembed.rb +1 -1
  35. data/lib/twitter/place.rb +4 -5
  36. data/lib/twitter/profile_banner.rb +1 -3
  37. data/lib/twitter/rate_limit.rb +1 -3
  38. data/lib/twitter/relationship.rb +1 -2
  39. data/lib/twitter/rest/api/direct_messages.rb +13 -14
  40. data/lib/twitter/rest/api/favorites.rb +10 -11
  41. data/lib/twitter/rest/api/friends_and_followers.rb +36 -36
  42. data/lib/twitter/rest/api/help.rb +8 -9
  43. data/lib/twitter/rest/api/lists.rb +62 -63
  44. data/lib/twitter/rest/api/oauth.rb +3 -4
  45. data/lib/twitter/rest/api/places_and_geo.rb +9 -10
  46. data/lib/twitter/rest/api/saved_searches.rb +5 -6
  47. data/lib/twitter/rest/api/search.rb +2 -3
  48. data/lib/twitter/rest/api/spam_reporting.rb +1 -2
  49. data/lib/twitter/rest/api/suggested_users.rb +4 -5
  50. data/lib/twitter/rest/api/timelines.rb +17 -18
  51. data/lib/twitter/rest/api/trends.rb +10 -11
  52. data/lib/twitter/rest/api/tweets.rb +15 -16
  53. data/lib/twitter/rest/api/undocumented.rb +6 -7
  54. data/lib/twitter/rest/api/users.rb +51 -52
  55. data/lib/twitter/rest/api/utils.rb +23 -30
  56. data/lib/twitter/rest/client.rb +8 -9
  57. data/lib/twitter/rest/request/multipart_with_file.rb +0 -1
  58. data/lib/twitter/rest/response/parse_error_json.rb +0 -2
  59. data/lib/twitter/rest/response/parse_json.rb +0 -2
  60. data/lib/twitter/rest/response/raise_error.rb +1 -3
  61. data/lib/twitter/search_results.rb +12 -15
  62. data/lib/twitter/settings.rb +2 -2
  63. data/lib/twitter/size.rb +2 -2
  64. data/lib/twitter/source_user.rb +1 -1
  65. data/lib/twitter/streaming/client.rb +71 -18
  66. data/lib/twitter/streaming/connection.rb +1 -3
  67. data/lib/twitter/streaming/deleted_tweet.rb +8 -0
  68. data/lib/twitter/streaming/event.rb +8 -8
  69. data/lib/twitter/streaming/friend_list.rb +2 -9
  70. data/lib/twitter/streaming/message_parser.rb +13 -7
  71. data/lib/twitter/streaming/response.rb +0 -2
  72. data/lib/twitter/streaming/stall_warning.rb +7 -0
  73. data/lib/twitter/suggestion.rb +0 -1
  74. data/lib/twitter/token.rb +2 -3
  75. data/lib/twitter/trend_results.rb +5 -8
  76. data/lib/twitter/tweet.rb +16 -24
  77. data/lib/twitter/user.rb +30 -32
  78. data/lib/twitter/version.rb +2 -5
  79. data/spec/fixtures/track_streaming_user.json +2 -1
  80. data/spec/helper.rb +6 -2
  81. data/spec/twitter/base_spec.rb +9 -9
  82. data/spec/twitter/basic_user_spec.rb +6 -6
  83. data/spec/twitter/configuration_spec.rb +4 -4
  84. data/spec/twitter/cursor_spec.rb +27 -27
  85. data/spec/twitter/direct_message_spec.rb +36 -36
  86. data/spec/twitter/entity/uri_spec.rb +27 -27
  87. data/spec/twitter/error_spec.rb +21 -21
  88. data/spec/twitter/geo/point_spec.rb +9 -9
  89. data/spec/twitter/geo/polygon_spec.rb +5 -5
  90. data/spec/twitter/geo_factory_spec.rb +7 -7
  91. data/spec/twitter/geo_results_spec.rb +11 -11
  92. data/spec/twitter/geo_spec.rb +5 -5
  93. data/spec/twitter/identifiable_spec.rb +9 -9
  94. data/spec/twitter/list_spec.rb +38 -38
  95. data/spec/twitter/media/photo_spec.rb +54 -54
  96. data/spec/twitter/media_factory_spec.rb +5 -5
  97. data/spec/twitter/null_object_spec.rb +6 -6
  98. data/spec/twitter/oembed_spec.rb +65 -65
  99. data/spec/twitter/place_spec.rb +89 -60
  100. data/spec/twitter/profile_banner_spec.rb +3 -3
  101. data/spec/twitter/rate_limit_spec.rb +18 -18
  102. data/spec/twitter/relationship_spec.rb +16 -16
  103. data/spec/twitter/rest/api/direct_messages_spec.rb +61 -61
  104. data/spec/twitter/rest/api/favorites_spec.rb +93 -93
  105. data/spec/twitter/rest/api/friends_and_followers_spec.rb +349 -349
  106. data/spec/twitter/rest/api/geo_spec.rb +33 -33
  107. data/spec/twitter/rest/api/help_spec.rb +24 -24
  108. data/spec/twitter/rest/api/lists_spec.rb +487 -487
  109. data/spec/twitter/rest/api/oauth_spec.rb +30 -30
  110. data/spec/twitter/rest/api/saved_searches_spec.rb +40 -40
  111. data/spec/twitter/rest/api/search_spec.rb +16 -16
  112. data/spec/twitter/rest/api/spam_reporting_spec.rb +9 -9
  113. data/spec/twitter/rest/api/suggested_users_spec.rb +23 -23
  114. data/spec/twitter/rest/api/timelines_spec.rb +58 -58
  115. data/spec/twitter/rest/api/trends_spec.rb +26 -26
  116. data/spec/twitter/rest/api/tweets_spec.rb +284 -284
  117. data/spec/twitter/rest/api/undocumented_spec.rb +51 -51
  118. data/spec/twitter/rest/api/users_spec.rb +360 -360
  119. data/spec/twitter/rest/client_spec.rb +99 -103
  120. data/spec/twitter/saved_search_spec.rb +16 -16
  121. data/spec/twitter/search_results_spec.rb +44 -44
  122. data/spec/twitter/settings_spec.rb +8 -8
  123. data/spec/twitter/size_spec.rb +5 -5
  124. data/spec/twitter/source_user_spec.rb +6 -6
  125. data/spec/twitter/streaming/client_spec.rb +53 -49
  126. data/spec/twitter/streaming/deleted_tweet_spec.rb +23 -0
  127. data/spec/twitter/streaming/event_spec.rb +20 -22
  128. data/spec/twitter/streaming/friend_list_spec.rb +11 -0
  129. data/spec/twitter/streaming/message_parser_spec.rb +54 -0
  130. data/spec/twitter/suggestion_spec.rb +11 -11
  131. data/spec/twitter/target_user_spec.rb +6 -6
  132. data/spec/twitter/token_spec.rb +4 -4
  133. data/spec/twitter/trend_results_spec.rb +30 -30
  134. data/spec/twitter/trend_spec.rb +20 -20
  135. data/spec/twitter/tweet_spec.rb +170 -173
  136. data/spec/twitter/user_spec.rb +179 -179
  137. data/twitter.gemspec +2 -2
  138. metadata +21 -4
  139. metadata.gz.sig +2 -1
@@ -15,14 +15,14 @@ module Twitter
15
15
  # @authentication Requires user context
16
16
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
17
17
  #
18
- # @overload following_followers_of(options={})
18
+ # @overload following_followers_of(options = {})
19
19
  # Returns users following followers of the specified user
20
20
  #
21
21
  # @param options [Hash] A customizable set of options.
22
22
  # @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
23
23
  # @return [Twitter::Cursor]
24
24
  #
25
- # @overload following_followers_of(user, options={})
25
+ # @overload following_followers_of(user, options = {})
26
26
  # Returns users following followers of the authenticated user
27
27
  #
28
28
  # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
@@ -30,7 +30,7 @@ module Twitter
30
30
  # @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
31
31
  # @return [Twitter::Cursor]
32
32
  def following_followers_of(*args)
33
- cursor_from_response_with_user(:users, Twitter::User, :get, "/users/following_followers_of.json", args)
33
+ cursor_from_response_with_user(:users, Twitter::User, :get, '/users/following_followers_of.json', args)
34
34
  end
35
35
 
36
36
  # Returns Tweets count for a URI
@@ -41,11 +41,10 @@ module Twitter
41
41
  # @return [Integer]
42
42
  # @param uri [String, URI] A URI.
43
43
  # @param options [Hash] A customizable set of options.
44
- def tweet_count(uri, options={})
45
- connection = Faraday.new("https://cdn.api.twitter.com", connection_options.merge(:builder => middleware))
46
- connection.get("/1/urls/count.json", options.merge(:url => uri.to_s)).body[:count]
44
+ def tweet_count(uri, options = {})
45
+ connection = Faraday.new('https://cdn.api.twitter.com', connection_options.merge(:builder => middleware))
46
+ connection.get('/1/urls/count.json', options.merge(:url => uri.to_s)).body[:count]
47
47
  end
48
-
49
48
  end
50
49
  end
51
50
  end
@@ -29,9 +29,9 @@ module Twitter
29
29
  # @option options [Integer] :end_sleep_time The hour that sleep time should end if it is enabled. The value for this parameter should be provided in {http://en.wikipedia.org/wiki/ISO_8601 ISO8601} format (i.e. 00-23). The time is considered to be in the same timezone as the user's time_zone setting.
30
30
  # @option options [String] :time_zone The timezone dates and times should be displayed in for the user. The timezone must be one of the {http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html Rails TimeZone} names.
31
31
  # @option options [String] :lang The language which Twitter should render in for this user. The language must be specified by the appropriate two letter ISO 639-1 representation. Currently supported languages are provided by {https://dev.twitter.com/docs/api/1.1/get/help/languages GET help/languages}.
32
- def settings(options={})
32
+ def settings(options = {})
33
33
  request_method = options.size.zero? ? :get : :post
34
- response = send(request_method.to_sym, "/1.1/account/settings.json", options)
34
+ response = send(request_method.to_sym, '/1.1/account/settings.json', options)
35
35
  # https://dev.twitter.com/issues/59
36
36
  response.update(:trend_location => Array(response[:trend_location]).first)
37
37
  Twitter::Settings.from_response(response)
@@ -46,10 +46,10 @@ module Twitter
46
46
  # @return [Twitter::User] The authenticated user.
47
47
  # @param options [Hash] A customizable set of options.
48
48
  # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
49
- def verify_credentials(options={})
50
- object_from_response(Twitter::User, :get, "/1.1/account/verify_credentials.json", options)
49
+ def verify_credentials(options = {})
50
+ object_from_response(Twitter::User, :get, '/1.1/account/verify_credentials.json', options)
51
51
  end
52
- alias current_user verify_credentials
52
+ alias_method :current_user, :verify_credentials
53
53
 
54
54
  # Sets which device Twitter delivers updates to for the authenticating user
55
55
  #
@@ -60,8 +60,8 @@ module Twitter
60
60
  # @return [Twitter::User] The authenticated user.
61
61
  # @param device [String] Must be one of: 'sms', 'none'.
62
62
  # @param options [Hash] A customizable set of options.
63
- def update_delivery_device(device, options={})
64
- object_from_response(Twitter::User, :post, "/1.1/account/update_delivery_device.json", options.merge(:device => device))
63
+ def update_delivery_device(device, options = {})
64
+ object_from_response(Twitter::User, :post, '/1.1/account/update_delivery_device.json', options.merge(:device => device))
65
65
  end
66
66
 
67
67
  # Sets values that users are able to set under the "Account" tab of their settings page
@@ -77,8 +77,8 @@ module Twitter
77
77
  # @option options [String] :url URL associated with the profile. Will be prepended with "http://" if not present. Maximum of 100 characters.
78
78
  # @option options [String] :location The city or country describing where the user of the account is located. The contents are not normalized or geocoded in any way. Maximum of 30 characters.
79
79
  # @option options [String] :description A description of the user owning the account. Maximum of 160 characters.
80
- def update_profile(options={})
81
- object_from_response(Twitter::User, :post, "/1.1/account/update_profile.json", options)
80
+ def update_profile(options = {})
81
+ object_from_response(Twitter::User, :post, '/1.1/account/update_profile.json', options)
82
82
  end
83
83
 
84
84
  # Updates the authenticating user's profile background image
@@ -91,8 +91,8 @@ module Twitter
91
91
  # @param image [File] The background image for the profile, base64-encoded. Must be a valid GIF, JPG, or PNG image of less than 800 kilobytes in size. Images with width larger than 2048 pixels will be forcibly scaled down. The image must be provided as raw multipart data, not a URL.
92
92
  # @param options [Hash] A customizable set of options.
93
93
  # @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.
94
- def update_profile_background_image(image, options={})
95
- object_from_response(Twitter::User, :post, "/1.1/account/update_profile_background_image.json", options.merge(:image => image))
94
+ def update_profile_background_image(image, options = {})
95
+ object_from_response(Twitter::User, :post, '/1.1/account/update_profile_background_image.json', options.merge(:image => image))
96
96
  end
97
97
 
98
98
  # Sets one or more hex values that control the color scheme of the authenticating user's profile
@@ -108,8 +108,8 @@ module Twitter
108
108
  # @option options [String] :profile_link_color Profile link color.
109
109
  # @option options [String] :profile_sidebar_fill_color Profile sidebar's background color.
110
110
  # @option options [String] :profile_sidebar_border_color Profile sidebar's border color.
111
- def update_profile_colors(options={})
112
- object_from_response(Twitter::User, :post, "/1.1/account/update_profile_colors.json", options)
111
+ def update_profile_colors(options = {})
112
+ object_from_response(Twitter::User, :post, '/1.1/account/update_profile_colors.json', options)
113
113
  end
114
114
 
115
115
  # Updates the authenticating user's profile image
@@ -123,8 +123,8 @@ module Twitter
123
123
  # @return [Twitter::User] The authenticated user.
124
124
  # @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.
125
125
  # @param options [Hash] A customizable set of options.
126
- def update_profile_image(image, options={})
127
- object_from_response(Twitter::User, :post, "/1.1/account/update_profile_image.json", options.merge(:image => image))
126
+ def update_profile_image(image, options = {})
127
+ object_from_response(Twitter::User, :post, '/1.1/account/update_profile_image.json', options.merge(:image => image))
128
128
  end
129
129
 
130
130
  # Returns an array of user objects that the authenticating user is blocking
@@ -136,8 +136,8 @@ module Twitter
136
136
  # @return [Array<Twitter::User>] User objects that the authenticating user is blocking.
137
137
  # @param options [Hash] A customizable set of options.
138
138
  # @option options [Integer] :page Specifies the page of results to retrieve.
139
- def blocking(options={})
140
- cursor_from_response(:users, Twitter::User, :get, "/1.1/blocks/list.json", options)
139
+ def blocking(options = {})
140
+ cursor_from_response(:users, Twitter::User, :get, '/1.1/blocks/list.json', options)
141
141
  end
142
142
 
143
143
  # Returns an array of numeric user ids the authenticating user is blocking
@@ -146,13 +146,13 @@ module Twitter
146
146
  # @rate_limited Yes
147
147
  # @authentication Requires user context
148
148
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
149
- # @return [Array] Numeric user ids the authenticating user is blocking.
150
- # @overload block(options={})
149
+ # @return [Twitter::Cursor] Numeric user IDs the authenticating user is blocking.
150
+ # @overload block(options = {})
151
151
  # @param options [Hash] A customizable set of options.
152
152
  def blocked_ids(*args)
153
153
  arguments = Twitter::Arguments.new(args)
154
154
  merge_user!(arguments.options, arguments.pop)
155
- cursor_from_response(:ids, nil, :get, "/1.1/blocks/ids.json", arguments.options)
155
+ cursor_from_response(:ids, nil, :get, '/1.1/blocks/ids.json', arguments.options)
156
156
  end
157
157
 
158
158
  # Returns true if the authenticating user is blocking a target user
@@ -164,16 +164,16 @@ module Twitter
164
164
  # @return [Boolean] true if the authenticating user is blocking the target user, otherwise false.
165
165
  # @param user [Integer, String, URI, Twitter::User] A Twitter user ID, screen name, URI, or object.
166
166
  # @param options [Hash] A customizable set of options.
167
- def block?(user, options={})
167
+ def block?(user, options = {})
168
168
  merge_default_cursor!(options)
169
169
  user_id = case user
170
- when Integer
171
- user
172
- when String, URI, Addressable::URI
173
- user(user).id
174
- when Twitter::User
175
- user.id
176
- end
170
+ when Integer
171
+ user
172
+ when String, URI, Addressable::URI
173
+ user(user).id
174
+ when Twitter::User
175
+ user.id
176
+ end
177
177
  blocked_ids(options).map(&:to_i).include?(user_id)
178
178
  end
179
179
 
@@ -191,7 +191,7 @@ module Twitter
191
191
  # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
192
192
  # @param options [Hash] A customizable set of options.
193
193
  def block(*args)
194
- threaded_user_objects_from_response(:post, "/1.1/blocks/create.json", args)
194
+ threaded_user_objects_from_response(:post, '/1.1/blocks/create.json', args)
195
195
  end
196
196
 
197
197
  # Un-blocks the users specified by the authenticating user
@@ -207,7 +207,7 @@ module Twitter
207
207
  # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
208
208
  # @param options [Hash] A customizable set of options.
209
209
  def unblock(*args)
210
- threaded_user_objects_from_response(:post, "/1.1/blocks/destroy.json", args)
210
+ threaded_user_objects_from_response(:post, '/1.1/blocks/destroy.json', args)
211
211
  end
212
212
 
213
213
  # Returns extended information for up to 100 users
@@ -228,7 +228,7 @@ module Twitter
228
228
  arguments = Twitter::Arguments.new(args)
229
229
  method = arguments.options.delete(:method) || :post
230
230
  arguments.flatten.each_slice(MAX_USERS_PER_REQUEST).threaded_map do |users|
231
- objects_from_response(Twitter::User, method, "/1.1/users/lookup.json", merge_users(arguments.options, users))
231
+ objects_from_response(Twitter::User, method, '/1.1/users/lookup.json', merge_users(arguments.options, users))
232
232
  end.flatten
233
233
  end
234
234
 
@@ -237,13 +237,13 @@ module Twitter
237
237
  # @authentication Requires user context
238
238
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
239
239
  # @return [Twitter::User] The requested user.
240
- # @overload user(options={})
240
+ # @overload user(options = {})
241
241
  # Returns extended information for the authenticated user
242
242
  #
243
243
  # @param options [Hash] A customizable set of options.
244
244
  # @option options [Boolean] :include_entities The tweet entities node will be disincluded when set to false.
245
245
  # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
246
- # @overload user(user, options={})
246
+ # @overload user(user, options = {})
247
247
  # Returns extended information for a given user
248
248
  #
249
249
  # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
@@ -254,7 +254,7 @@ module Twitter
254
254
  arguments = Twitter::Arguments.new(args)
255
255
  if arguments.last
256
256
  merge_user!(arguments.options, arguments.pop)
257
- object_from_response(Twitter::User, :get, "/1.1/users/show.json", arguments.options)
257
+ object_from_response(Twitter::User, :get, '/1.1/users/show.json', arguments.options)
258
258
  else
259
259
  verify_credentials(arguments.options)
260
260
  end
@@ -267,9 +267,9 @@ module Twitter
267
267
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
268
268
  # @return [Boolean] true if the user exists, otherwise false.
269
269
  # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
270
- def user?(user, options={})
270
+ def user?(user, options = {})
271
271
  merge_user!(options, user)
272
- get("/1.1/users/show.json", options)
272
+ get('/1.1/users/show.json', options)
273
273
  true
274
274
  rescue Twitter::Error::NotFound
275
275
  false
@@ -286,8 +286,8 @@ module Twitter
286
286
  # @param options [Hash] A customizable set of options.
287
287
  # @option options [Integer] :count The number of people to retrieve. Maxiumum of 20 allowed per page.
288
288
  # @option options [Integer] :page Specifies the page of results to retrieve.
289
- def user_search(query, options={})
290
- objects_from_response(Twitter::User, :get, "/1.1/users/search.json", options.merge(:q => query))
289
+ def user_search(query, options = {})
290
+ objects_from_response(Twitter::User, :get, '/1.1/users/search.json', options.merge(:q => query))
291
291
  end
292
292
 
293
293
  # Returns an array of users that the specified user can contribute to
@@ -297,15 +297,15 @@ module Twitter
297
297
  # @authentication Requires user context
298
298
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
299
299
  # @return [Array<Twitter::User>]
300
- # @overload contributees(options={})
300
+ # @overload contributees(options = {})
301
301
  # @param options [Hash] A customizable set of options.
302
302
  # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
303
- # @overload contributees(user, options={})
303
+ # @overload contributees(user, options = {})
304
304
  # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
305
305
  # @param options [Hash] A customizable set of options.
306
306
  # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
307
307
  def contributees(*args)
308
- user_objects_from_response(:get, "/1.1/users/contributees.json", args)
308
+ user_objects_from_response(:get, '/1.1/users/contributees.json', args)
309
309
  end
310
310
 
311
311
  # Returns an array of users who can contribute to the specified account
@@ -315,15 +315,15 @@ module Twitter
315
315
  # @authentication Requires user context
316
316
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
317
317
  # @return [Array<Twitter::User>]
318
- # @overload contributors(options={})
318
+ # @overload contributors(options = {})
319
319
  # @param options [Hash] A customizable set of options.
320
320
  # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
321
- # @overload contributors(user, options={})
321
+ # @overload contributors(user, options = {})
322
322
  # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
323
323
  # @param options [Hash] A customizable set of options.
324
324
  # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
325
325
  def contributors(*args)
326
- user_objects_from_response(:get, "/1.1/users/contributors.json", args)
326
+ user_objects_from_response(:get, '/1.1/users/contributors.json', args)
327
327
  end
328
328
 
329
329
  # Removes the authenticating user's profile banner image
@@ -334,8 +334,8 @@ module Twitter
334
334
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
335
335
  # @return [nil]
336
336
  # @param options [Hash] A customizable set of options.
337
- def remove_profile_banner(options={})
338
- post("/1.1/account/remove_profile_banner.json", options)[:body]
337
+ def remove_profile_banner(options = {})
338
+ post('/1.1/account/remove_profile_banner.json', options)[:body]
339
339
  end
340
340
  deprecate_alias :profile_banner_remove, :remove_profile_banner
341
341
 
@@ -356,8 +356,8 @@ module Twitter
356
356
  # @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.
357
357
  # @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.
358
358
  # @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.
359
- def update_profile_banner(banner, options={})
360
- post("/1.1/account/update_profile_banner.json", options.merge(:banner => banner))[:body]
359
+ def update_profile_banner(banner, options = {})
360
+ post('/1.1/account/update_profile_banner.json', options.merge(:banner => banner))[:body]
361
361
  end
362
362
 
363
363
  # Returns the available size variations of the specified user's profile banner.
@@ -368,15 +368,14 @@ module Twitter
368
368
  # @authentication Requires user context
369
369
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
370
370
  # @return [Twitter::ProfileBanner]
371
- # @overload profile_banner(options={})
372
- # @overload profile_banner(user, options={})
371
+ # @overload profile_banner(options = {})
372
+ # @overload profile_banner(user, options = {})
373
373
  # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
374
374
  def profile_banner(*args)
375
375
  arguments = Twitter::Arguments.new(args)
376
376
  merge_user!(arguments.options, arguments.pop || screen_name) unless arguments.options[:user_id] || arguments.options[:screen_name]
377
- object_from_response(Twitter::ProfileBanner, :get, "/1.1/users/profile_banner.json", arguments.options)
377
+ object_from_response(Twitter::ProfileBanner, :get, '/1.1/users/profile_banner.json', arguments.options)
378
378
  end
379
-
380
379
  end
381
380
  end
382
381
  end
@@ -8,27 +8,21 @@ module Twitter
8
8
  module API
9
9
  module Utils
10
10
  DEFAULT_CURSOR = -1
11
- URI_SUBSTRING = "://"
11
+ URI_SUBSTRING = '://'
12
12
 
13
13
  class << self
14
-
15
14
  def included(base)
16
15
  base.extend(ClassMethods)
17
16
  end
18
-
19
17
  end
20
18
 
21
19
  module ClassMethods
22
-
23
- private
24
-
25
20
  def deprecate_alias(new_name, old_name)
26
21
  define_method(new_name) do |*args, &block|
27
- warn "#{Kernel.caller.first}: [DEPRECATION] ##{new_name} it deprecated. Use ##{old_name} instead."
22
+ warn "#{Kernel.caller.first}: [DEPRECATION] ##{new_name} is deprecated. Use ##{old_name} instead."
28
23
  send(old_name, *args, &block)
29
24
  end
30
25
  end
31
-
32
26
  end
33
27
 
34
28
  private
@@ -42,9 +36,9 @@ module Twitter
42
36
  when ::Integer
43
37
  object
44
38
  when ::String
45
- object.split("/").last.to_i
39
+ object.split('/').last.to_i
46
40
  when URI
47
- object.path.split("/").last.to_i
41
+ object.path.split('/').last.to_i
48
42
  when Twitter::Identity
49
43
  object.id
50
44
  end
@@ -76,7 +70,7 @@ module Twitter
76
70
  # @param path [String]
77
71
  # @param args [Array]
78
72
  # @return [Array]
79
- def objects_from_response_with_user(klass, request_method, path, args)
73
+ def objects_from_response_with_user(klass, request_method, path, args) # rubocop:disable ParameterLists
80
74
  arguments = Twitter::Arguments.new(args)
81
75
  merge_user!(arguments.options, arguments.pop)
82
76
  objects_from_response(klass, request_method, path, arguments.options)
@@ -87,7 +81,7 @@ module Twitter
87
81
  # @param path [String]
88
82
  # @param options [Hash]
89
83
  # @return [Array]
90
- def objects_from_response(klass, request_method, path, options={})
84
+ def objects_from_response(klass, request_method, path, options = {}) # rubocop:disable ParameterLists
91
85
  response = send(request_method.to_sym, path, options)[:body]
92
86
  objects_from_array(klass, response)
93
87
  end
@@ -106,7 +100,7 @@ module Twitter
106
100
  # @param path [String]
107
101
  # @param args [Array]
108
102
  # @return [Array]
109
- def threaded_objects_from_response(klass, request_method, path, args)
103
+ def threaded_objects_from_response(klass, request_method, path, args) # rubocop:disable ParameterLists
110
104
  arguments = Twitter::Arguments.new(args)
111
105
  arguments.flatten.threaded_map do |object|
112
106
  id = extract_id(object)
@@ -119,7 +113,7 @@ module Twitter
119
113
  # @param path [String]
120
114
  # @param options [Hash]
121
115
  # @return [Object]
122
- def object_from_response(klass, request_method, path, options={})
116
+ def object_from_response(klass, request_method, path, options = {}) # rubocop:disable ParameterLists
123
117
  response = send(request_method.to_sym, path, options)
124
118
  klass.from_response(response)
125
119
  end
@@ -130,7 +124,7 @@ module Twitter
130
124
  # @param path [String]
131
125
  # @param args [Array]
132
126
  # @return [Twitter::Cursor]
133
- def cursor_from_response_with_user(collection_name, klass, request_method, path, args)
127
+ def cursor_from_response_with_user(collection_name, klass, request_method, path, args) # rubocop:disable ParameterLists
134
128
  arguments = Twitter::Arguments.new(args)
135
129
  merge_user!(arguments.options, arguments.pop || screen_name) unless arguments.options[:user_id] || arguments.options[:screen_name]
136
130
  cursor_from_response(collection_name, klass, request_method, path, arguments.options)
@@ -142,7 +136,7 @@ module Twitter
142
136
  # @param path [String]
143
137
  # @param options [Hash]
144
138
  # @return [Twitter::Cursor]
145
- def cursor_from_response(collection_name, klass, request_method, path, options)
139
+ def cursor_from_response(collection_name, klass, request_method, path, options) # rubocop:disable ParameterLists
146
140
  merge_default_cursor!(options)
147
141
  response = send(request_method.to_sym, path, options)
148
142
  Twitter::Cursor.from_response(response, collection_name.to_sym, klass, self, request_method, path, options)
@@ -150,7 +144,7 @@ module Twitter
150
144
 
151
145
  def handle_forbidden_error(klass, error)
152
146
  error = error.message == klass::MESSAGE ? klass.new : error
153
- raise error
147
+ fail error
154
148
  end
155
149
 
156
150
  def merge_default_cursor!(options)
@@ -166,7 +160,7 @@ module Twitter
166
160
  # @param hash [Hash]
167
161
  # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
168
162
  # @return [Hash]
169
- def merge_user(hash, user, prefix=nil)
163
+ def merge_user(hash, user, prefix = nil)
170
164
  merge_user!(hash.dup, user, prefix)
171
165
  end
172
166
 
@@ -175,25 +169,25 @@ module Twitter
175
169
  # @param hash [Hash]
176
170
  # @param user [Integer, String, URI, Twitter::User] A Twitter user ID, screen name, URI, or object.
177
171
  # @return [Hash]
178
- def merge_user!(hash, user, prefix=nil)
172
+ def merge_user!(hash, user, prefix = nil)
179
173
  case user
180
174
  when Integer
181
- set_compound_key("user_id", user, hash, prefix)
175
+ set_compound_key('user_id', user, hash, prefix)
182
176
  when String
183
177
  if user[URI_SUBSTRING]
184
- set_compound_key("screen_name", user.split("/").last, hash, prefix)
178
+ set_compound_key('screen_name', user.split('/').last, hash, prefix)
185
179
  else
186
- set_compound_key("screen_name", user, hash, prefix)
180
+ set_compound_key('screen_name', user, hash, prefix)
187
181
  end
188
182
  when URI, Addressable::URI
189
- set_compound_key("screen_name", user.path.split("/").last, hash, prefix)
183
+ set_compound_key('screen_name', user.path.split('/').last, hash, prefix)
190
184
  when Twitter::User
191
- set_compound_key("user_id", user.id, hash, prefix)
185
+ set_compound_key('user_id', user.id, hash, prefix)
192
186
  end
193
187
  end
194
188
 
195
- def set_compound_key(key, value, hash, prefix=nil)
196
- compound_key = [prefix, key].compact.join("_").to_sym
189
+ def set_compound_key(key, value, hash, prefix = nil) # rubocop:disable ParameterLists
190
+ compound_key = [prefix, key].compact.join('_').to_sym
197
191
  hash[compound_key] = value
198
192
  hash
199
193
  end
@@ -219,7 +213,7 @@ module Twitter
219
213
  hash
220
214
  end
221
215
 
222
- def collect_user_ids_and_screen_names(users)
216
+ def collect_user_ids_and_screen_names(users) # rubocop:disable MethodLength
223
217
  user_ids, screen_names = [], []
224
218
  users.flatten.each do |user|
225
219
  case user
@@ -227,19 +221,18 @@ module Twitter
227
221
  user_ids << user
228
222
  when String
229
223
  if user[URI_SUBSTRING]
230
- screen_names << user.split("/").last
224
+ screen_names << user.split('/').last
231
225
  else
232
226
  screen_names << user
233
227
  end
234
228
  when URI
235
- screen_names << user.path.split("/").last
229
+ screen_names << user.path.split('/').last
236
230
  when Twitter::User
237
231
  user_ids << user.id
238
232
  end
239
233
  end
240
234
  [user_ids, screen_names]
241
235
  end
242
-
243
236
  end
244
237
  end
245
238
  end