twitter 5.12.0 → 5.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/lib/twitter/base.rb +6 -2
- data/lib/twitter/client.rb +4 -11
- data/lib/twitter/cursor.rb +5 -5
- data/lib/twitter/headers.rb +62 -0
- data/lib/twitter/media/animated_gif.rb +8 -0
- data/lib/twitter/media/video.rb +32 -0
- data/lib/twitter/media/video_info.rb +23 -0
- data/lib/twitter/media_factory.rb +2 -0
- data/lib/twitter/null_object.rb +9 -0
- data/lib/twitter/rest/api.rb +2 -0
- data/lib/twitter/rest/client.rb +14 -69
- data/lib/twitter/rest/direct_messages.rb +4 -5
- data/lib/twitter/rest/favorites.rb +3 -4
- data/lib/twitter/rest/friends_and_followers.rb +12 -12
- data/lib/twitter/rest/help.rb +5 -5
- data/lib/twitter/rest/lists.rb +21 -21
- data/lib/twitter/rest/media.rb +4 -3
- data/lib/twitter/rest/oauth.rb +4 -4
- data/lib/twitter/rest/places_and_geo.rb +4 -5
- data/lib/twitter/rest/request/multipart_with_file.rb +1 -1
- data/lib/twitter/rest/request.rb +44 -0
- data/lib/twitter/rest/saved_searches.rb +4 -5
- data/lib/twitter/rest/search.rb +3 -4
- data/lib/twitter/rest/spam_reporting.rb +0 -1
- data/lib/twitter/rest/suggested_users.rb +3 -4
- data/lib/twitter/rest/timelines.rb +3 -4
- data/lib/twitter/rest/trends.rb +4 -4
- data/lib/twitter/rest/tweets.rb +10 -12
- data/lib/twitter/rest/undocumented.rb +2 -2
- data/lib/twitter/rest/users.rb +19 -21
- data/lib/twitter/rest/utils.rb +66 -17
- data/lib/twitter/search_results.rb +5 -5
- data/lib/twitter/streaming/client.rb +4 -2
- data/lib/twitter/user.rb +0 -1
- data/lib/twitter/value.rb +40 -0
- data/lib/twitter/variant.rb +12 -0
- data/lib/twitter/version.rb +1 -1
- metadata +10 -4
- data/lib/twitter/request.rb +0 -47
data/lib/twitter/rest/users.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'twitter/arguments'
|
|
2
2
|
require 'twitter/error'
|
|
3
3
|
require 'twitter/profile_banner'
|
|
4
|
-
require 'twitter/request'
|
|
4
|
+
require 'twitter/rest/request'
|
|
5
5
|
require 'twitter/rest/utils'
|
|
6
6
|
require 'twitter/settings'
|
|
7
7
|
require 'twitter/user'
|
|
@@ -32,7 +32,7 @@ module Twitter
|
|
|
32
32
|
# @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}.
|
|
33
33
|
def settings(options = {})
|
|
34
34
|
request_method = options.size.zero? ? :get : :post
|
|
35
|
-
response =
|
|
35
|
+
response = perform_request(request_method.to_sym, '/1.1/account/settings.json', options)
|
|
36
36
|
# https://dev.twitter.com/issues/59
|
|
37
37
|
response.update(:trend_location => response.fetch(:trend_location, []).first)
|
|
38
38
|
Twitter::Settings.new(response)
|
|
@@ -48,7 +48,7 @@ module Twitter
|
|
|
48
48
|
# @param options [Hash] A customizable set of options.
|
|
49
49
|
# @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
|
|
50
50
|
def verify_credentials(options = {})
|
|
51
|
-
|
|
51
|
+
perform_get_with_object('/1.1/account/verify_credentials.json', options, Twitter::User)
|
|
52
52
|
end
|
|
53
53
|
alias_method :current_user, :verify_credentials
|
|
54
54
|
|
|
@@ -62,7 +62,7 @@ module Twitter
|
|
|
62
62
|
# @param device [String] Must be one of: 'sms', 'none'.
|
|
63
63
|
# @param options [Hash] A customizable set of options.
|
|
64
64
|
def update_delivery_device(device, options = {})
|
|
65
|
-
|
|
65
|
+
perform_post_with_object('/1.1/account/update_delivery_device.json', options.merge(:device => device), Twitter::User)
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
# Sets values that users are able to set under the "Account" tab of their settings page
|
|
@@ -79,7 +79,7 @@ module Twitter
|
|
|
79
79
|
# @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.
|
|
80
80
|
# @option options [String] :description A description of the user owning the account. Maximum of 160 characters.
|
|
81
81
|
def update_profile(options = {})
|
|
82
|
-
|
|
82
|
+
perform_post_with_object('/1.1/account/update_profile.json', options, Twitter::User)
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
# Updates the authenticating user's profile background image
|
|
@@ -93,7 +93,7 @@ module Twitter
|
|
|
93
93
|
# @param options [Hash] A customizable set of options.
|
|
94
94
|
# @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.
|
|
95
95
|
def update_profile_background_image(image, options = {})
|
|
96
|
-
|
|
96
|
+
perform_post_with_object('/1.1/account/update_profile_background_image.json', options.merge(:image => image), Twitter::User)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
# Sets one or more hex values that control the color scheme of the authenticating user's profile
|
|
@@ -110,7 +110,7 @@ module Twitter
|
|
|
110
110
|
# @option options [String] :profile_sidebar_fill_color Profile sidebar's background color.
|
|
111
111
|
# @option options [String] :profile_sidebar_border_color Profile sidebar's border color.
|
|
112
112
|
def update_profile_colors(options = {})
|
|
113
|
-
|
|
113
|
+
perform_post_with_object('/1.1/account/update_profile_colors.json', options, Twitter::User)
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
# Updates the authenticating user's profile image
|
|
@@ -125,7 +125,7 @@ module Twitter
|
|
|
125
125
|
# @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.
|
|
126
126
|
# @param options [Hash] A customizable set of options.
|
|
127
127
|
def update_profile_image(image, options = {})
|
|
128
|
-
|
|
128
|
+
perform_post_with_object('/1.1/account/update_profile_image.json', options.merge(:image => image), Twitter::User)
|
|
129
129
|
end
|
|
130
130
|
|
|
131
131
|
# Returns an array of user objects that the authenticating user is blocking
|
|
@@ -138,7 +138,7 @@ module Twitter
|
|
|
138
138
|
# @param options [Hash] A customizable set of options.
|
|
139
139
|
# @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
|
|
140
140
|
def blocked(options = {})
|
|
141
|
-
|
|
141
|
+
perform_get_with_cursor('/1.1/blocks/list.json', options, :users, Twitter::User)
|
|
142
142
|
end
|
|
143
143
|
deprecate_alias :blocking, :blocked
|
|
144
144
|
|
|
@@ -154,7 +154,7 @@ module Twitter
|
|
|
154
154
|
def blocked_ids(*args)
|
|
155
155
|
arguments = Twitter::Arguments.new(args)
|
|
156
156
|
merge_user!(arguments.options, arguments.pop)
|
|
157
|
-
|
|
157
|
+
perform_get_with_cursor('/1.1/blocks/ids.json', arguments.options, :ids)
|
|
158
158
|
end
|
|
159
159
|
|
|
160
160
|
# Returns true if the authenticating user is blocking a target user
|
|
@@ -226,12 +226,10 @@ module Twitter
|
|
|
226
226
|
# @overload users(*users, options)
|
|
227
227
|
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
228
228
|
# @param options [Hash] A customizable set of options.
|
|
229
|
-
# @option options [Symbol, String] :method Requests users via a GET request instead of the standard POST request if set to ':get'.
|
|
230
229
|
def users(*args)
|
|
231
230
|
arguments = Twitter::Arguments.new(args)
|
|
232
|
-
request_method = arguments.options.delete(:method) || :post
|
|
233
231
|
flat_pmap(arguments.each_slice(MAX_USERS_PER_REQUEST)) do |users|
|
|
234
|
-
|
|
232
|
+
perform_post_with_objects('/1.1/users/lookup.json', merge_users(arguments.options, users), Twitter::User)
|
|
235
233
|
end
|
|
236
234
|
end
|
|
237
235
|
|
|
@@ -255,7 +253,7 @@ module Twitter
|
|
|
255
253
|
arguments = Twitter::Arguments.new(args)
|
|
256
254
|
if arguments.last || user_id?
|
|
257
255
|
merge_user!(arguments.options, arguments.pop || user_id)
|
|
258
|
-
|
|
256
|
+
perform_get_with_object('/1.1/users/show.json', arguments.options, Twitter::User)
|
|
259
257
|
else
|
|
260
258
|
verify_credentials(arguments.options)
|
|
261
259
|
end
|
|
@@ -270,7 +268,7 @@ module Twitter
|
|
|
270
268
|
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
271
269
|
def user?(user, options = {})
|
|
272
270
|
merge_user!(options, user)
|
|
273
|
-
|
|
271
|
+
perform_get('/1.1/users/show.json', options)
|
|
274
272
|
true
|
|
275
273
|
rescue Twitter::Error::NotFound
|
|
276
274
|
false
|
|
@@ -288,7 +286,7 @@ module Twitter
|
|
|
288
286
|
# @option options [Integer] :count The number of people to retrieve. Maxiumum of 20 allowed per page.
|
|
289
287
|
# @option options [Integer] :page Specifies the page of results to retrieve.
|
|
290
288
|
def user_search(query, options = {})
|
|
291
|
-
|
|
289
|
+
perform_get_with_objects('/1.1/users/search.json', options.merge(:q => query), Twitter::User)
|
|
292
290
|
end
|
|
293
291
|
|
|
294
292
|
# Returns an array of users that the specified user can contribute to
|
|
@@ -336,7 +334,7 @@ module Twitter
|
|
|
336
334
|
# @return [nil]
|
|
337
335
|
# @param options [Hash] A customizable set of options.
|
|
338
336
|
def remove_profile_banner(options = {})
|
|
339
|
-
|
|
337
|
+
perform_post('/1.1/account/remove_profile_banner.json', options)
|
|
340
338
|
true
|
|
341
339
|
end
|
|
342
340
|
deprecate_alias :profile_banner_remove, :remove_profile_banner
|
|
@@ -359,7 +357,7 @@ module Twitter
|
|
|
359
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.
|
|
360
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.
|
|
361
359
|
def update_profile_banner(banner, options = {})
|
|
362
|
-
|
|
360
|
+
perform_post('/1.1/account/update_profile_banner.json', options.merge(:banner => banner))
|
|
363
361
|
true
|
|
364
362
|
end
|
|
365
363
|
|
|
@@ -377,7 +375,7 @@ module Twitter
|
|
|
377
375
|
def profile_banner(*args)
|
|
378
376
|
arguments = Twitter::Arguments.new(args)
|
|
379
377
|
merge_user!(arguments.options, arguments.pop || user_id) unless arguments.options[:user_id] || arguments.options[:screen_name]
|
|
380
|
-
|
|
378
|
+
perform_get_with_object('/1.1/users/profile_banner.json', arguments.options, Twitter::ProfileBanner)
|
|
381
379
|
end
|
|
382
380
|
|
|
383
381
|
# Mutes the users specified by the authenticating user
|
|
@@ -422,7 +420,7 @@ module Twitter
|
|
|
422
420
|
# @param options [Hash] A customizable set of options.
|
|
423
421
|
# @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
|
|
424
422
|
def muted(options = {})
|
|
425
|
-
|
|
423
|
+
perform_get_with_cursor('/1.1/mutes/users/list.json', options, :users, Twitter::User)
|
|
426
424
|
end
|
|
427
425
|
deprecate_alias :muting, :muted
|
|
428
426
|
|
|
@@ -438,7 +436,7 @@ module Twitter
|
|
|
438
436
|
def muted_ids(*args)
|
|
439
437
|
arguments = Twitter::Arguments.new(args)
|
|
440
438
|
merge_user!(arguments.options, arguments.pop)
|
|
441
|
-
|
|
439
|
+
perform_get_with_cursor('/1.1/mutes/users/ids.json', arguments.options, :ids)
|
|
442
440
|
end
|
|
443
441
|
end
|
|
444
442
|
end
|
data/lib/twitter/rest/utils.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'addressable/uri'
|
|
2
2
|
require 'twitter/arguments'
|
|
3
|
-
require 'twitter/
|
|
3
|
+
require 'twitter/cursor'
|
|
4
|
+
require 'twitter/rest/request'
|
|
4
5
|
require 'twitter/user'
|
|
5
6
|
require 'twitter/utils'
|
|
6
7
|
|
|
@@ -30,32 +31,81 @@ module Twitter
|
|
|
30
31
|
end
|
|
31
32
|
end
|
|
32
33
|
|
|
34
|
+
# @param path [String]
|
|
35
|
+
# @param options [Hash]
|
|
36
|
+
def perform_get(path, options = {})
|
|
37
|
+
perform_request(:get, path, options)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @param path [String]
|
|
41
|
+
# @param options [Hash]
|
|
42
|
+
# @param klass [Class]
|
|
43
|
+
def perform_post(path, options = {})
|
|
44
|
+
perform_request(:post, path, options)
|
|
45
|
+
end
|
|
46
|
+
|
|
33
47
|
# @param request_method [Symbol]
|
|
48
|
+
# @param path [String]
|
|
49
|
+
# @param options [Hash]
|
|
50
|
+
def perform_request(request_method, path, options = {})
|
|
51
|
+
Twitter::REST::Request.new(self, request_method, path, options).perform
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# @param path [String]
|
|
55
|
+
# @param options [Hash]
|
|
56
|
+
# @param klass [Class]
|
|
57
|
+
def perform_get_with_object(path, options, klass)
|
|
58
|
+
perform_request_with_object(:get, path, options, klass)
|
|
59
|
+
end
|
|
60
|
+
|
|
34
61
|
# @param path [String]
|
|
35
62
|
# @param options [Hash]
|
|
36
63
|
# @param klass [Class]
|
|
37
|
-
def
|
|
38
|
-
|
|
39
|
-
request.perform_with_object(klass)
|
|
64
|
+
def perform_post_with_object(path, options, klass)
|
|
65
|
+
perform_request_with_object(:post, path, options, klass)
|
|
40
66
|
end
|
|
41
67
|
|
|
42
68
|
# @param request_method [Symbol]
|
|
43
69
|
# @param path [String]
|
|
44
70
|
# @param options [Hash]
|
|
45
71
|
# @param klass [Class]
|
|
46
|
-
def
|
|
47
|
-
|
|
48
|
-
|
|
72
|
+
def perform_request_with_object(request_method, path, options, klass)
|
|
73
|
+
response = perform_request(request_method, path, options)
|
|
74
|
+
klass.new(response)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# @param path [String]
|
|
78
|
+
# @param options [Hash]
|
|
79
|
+
# @param klass [Class]
|
|
80
|
+
def perform_get_with_objects(path, options, klass)
|
|
81
|
+
perform_request_with_objects(:get, path, options, klass)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# @param path [String]
|
|
85
|
+
# @param options [Hash]
|
|
86
|
+
# @param klass [Class]
|
|
87
|
+
def perform_post_with_objects(path, options, klass)
|
|
88
|
+
perform_request_with_objects(:post, path, options, klass)
|
|
49
89
|
end
|
|
50
90
|
|
|
51
91
|
# @param request_method [Symbol]
|
|
52
92
|
# @param path [String]
|
|
53
93
|
# @param options [Hash]
|
|
54
94
|
# @param klass [Class]
|
|
55
|
-
def
|
|
95
|
+
def perform_request_with_objects(request_method, path, options, klass)
|
|
96
|
+
perform_request(request_method, path, options).collect do |element|
|
|
97
|
+
klass.new(element)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# @param path [String]
|
|
102
|
+
# @param options [Hash]
|
|
103
|
+
# @collection_name [Symbol]
|
|
104
|
+
# @param klass [Class]
|
|
105
|
+
def perform_get_with_cursor(path, options, collection_name, klass = nil)
|
|
56
106
|
merge_default_cursor!(options)
|
|
57
|
-
request = Twitter::Request.new(self,
|
|
58
|
-
|
|
107
|
+
request = Twitter::REST::Request.new(self, :get, path, options)
|
|
108
|
+
Twitter::Cursor.new(collection_name.to_sym, klass, request)
|
|
59
109
|
end
|
|
60
110
|
|
|
61
111
|
# @param request_method [Symbol]
|
|
@@ -65,7 +115,7 @@ module Twitter
|
|
|
65
115
|
def parallel_users_from_response(request_method, path, args)
|
|
66
116
|
arguments = Twitter::Arguments.new(args)
|
|
67
117
|
pmap(arguments) do |user|
|
|
68
|
-
|
|
118
|
+
perform_request_with_object(request_method, path, merge_user(arguments.options, user), Twitter::User)
|
|
69
119
|
end
|
|
70
120
|
end
|
|
71
121
|
|
|
@@ -76,7 +126,7 @@ module Twitter
|
|
|
76
126
|
def users_from_response(request_method, path, args)
|
|
77
127
|
arguments = Twitter::Arguments.new(args)
|
|
78
128
|
merge_user!(arguments.options, arguments.pop || user_id) unless arguments.options[:user_id] || arguments.options[:screen_name]
|
|
79
|
-
|
|
129
|
+
perform_request_with_objects(request_method, path, arguments.options, Twitter::User)
|
|
80
130
|
end
|
|
81
131
|
|
|
82
132
|
# @param klass [Class]
|
|
@@ -87,7 +137,7 @@ module Twitter
|
|
|
87
137
|
def objects_from_response_with_user(klass, request_method, path, args)
|
|
88
138
|
arguments = Twitter::Arguments.new(args)
|
|
89
139
|
merge_user!(arguments.options, arguments.pop)
|
|
90
|
-
|
|
140
|
+
perform_request_with_objects(request_method, path, arguments.options, klass)
|
|
91
141
|
end
|
|
92
142
|
|
|
93
143
|
# @param klass [Class]
|
|
@@ -98,20 +148,19 @@ module Twitter
|
|
|
98
148
|
def parallel_objects_from_response(klass, request_method, path, args)
|
|
99
149
|
arguments = Twitter::Arguments.new(args)
|
|
100
150
|
pmap(arguments) do |object|
|
|
101
|
-
|
|
151
|
+
perform_request_with_object(request_method, path, arguments.options.merge(:id => extract_id(object)), klass)
|
|
102
152
|
end
|
|
103
153
|
end
|
|
104
154
|
|
|
105
155
|
# @param collection_name [Symbol]
|
|
106
156
|
# @param klass [Class]
|
|
107
|
-
# @param request_method [Symbol]
|
|
108
157
|
# @param path [String]
|
|
109
158
|
# @param args [Array]
|
|
110
159
|
# @return [Twitter::Cursor]
|
|
111
|
-
def cursor_from_response_with_user(collection_name, klass,
|
|
160
|
+
def cursor_from_response_with_user(collection_name, klass, path, args) # rubocop:disable ParameterLists
|
|
112
161
|
arguments = Twitter::Arguments.new(args)
|
|
113
162
|
merge_user!(arguments.options, arguments.pop || user_id) unless arguments.options[:user_id] || arguments.options[:screen_name]
|
|
114
|
-
|
|
163
|
+
perform_get_with_cursor(path, arguments.options, collection_name, klass)
|
|
115
164
|
end
|
|
116
165
|
|
|
117
166
|
def user_id
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'cgi'
|
|
2
2
|
require 'twitter/enumerable'
|
|
3
|
+
require 'twitter/rest/request'
|
|
3
4
|
require 'twitter/utils'
|
|
4
5
|
require 'uri'
|
|
5
6
|
|
|
@@ -15,16 +16,15 @@ module Twitter
|
|
|
15
16
|
|
|
16
17
|
# Initializes a new SearchResults object
|
|
17
18
|
#
|
|
18
|
-
# @param
|
|
19
|
-
# @param request [Twitter::Request]
|
|
19
|
+
# @param request [Twitter::REST::Request]
|
|
20
20
|
# @return [Twitter::SearchResults]
|
|
21
|
-
def initialize(
|
|
21
|
+
def initialize(request)
|
|
22
22
|
@client = request.client
|
|
23
23
|
@request_method = request.verb
|
|
24
24
|
@path = request.path
|
|
25
25
|
@options = request.options
|
|
26
26
|
@collection = []
|
|
27
|
-
self.attrs =
|
|
27
|
+
self.attrs = request.perform
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
private
|
|
@@ -49,7 +49,7 @@ module Twitter
|
|
|
49
49
|
|
|
50
50
|
# @return [Hash]
|
|
51
51
|
def fetch_next_page
|
|
52
|
-
response =
|
|
52
|
+
response = Twitter::REST::Request.new(@client, @request_method, @path, next_page).perform
|
|
53
53
|
self.attrs = response
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'http/request'
|
|
2
2
|
require 'twitter/arguments'
|
|
3
3
|
require 'twitter/client'
|
|
4
|
+
require 'twitter/headers'
|
|
4
5
|
require 'twitter/streaming/connection'
|
|
5
6
|
require 'twitter/streaming/response'
|
|
6
7
|
require 'twitter/streaming/message_parser'
|
|
@@ -106,8 +107,9 @@ module Twitter
|
|
|
106
107
|
|
|
107
108
|
def request(method, uri, params)
|
|
108
109
|
before_request.call
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
authorization = Twitter::Headers.new(self, method, uri, params).oauth_auth_header.to_s
|
|
111
|
+
headers = default_headers.merge(:authorization => authorization)
|
|
112
|
+
request = HTTP::Request.new(method, uri + '?' + to_url_params(params), headers)
|
|
111
113
|
response = Streaming::Response.new do |data|
|
|
112
114
|
if item = Streaming::MessageParser.parse(data) # rubocop:disable AssignmentInCondition, IfUnlessModifier
|
|
113
115
|
yield(item)
|
data/lib/twitter/user.rb
CHANGED
|
@@ -21,7 +21,6 @@ module Twitter
|
|
|
21
21
|
:profile_sidebar_border_color, :profile_sidebar_fill_color,
|
|
22
22
|
:profile_text_color, :time_zone
|
|
23
23
|
alias_method :favorites_count, :favourites_count
|
|
24
|
-
remove_method :favourites_count
|
|
25
24
|
alias_method :tweets_count, :statuses_count
|
|
26
25
|
object_attr_reader :Tweet, :status, :user
|
|
27
26
|
alias_method :tweet, :status
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Twitter
|
|
2
|
+
class Value
|
|
3
|
+
def self.new(*fields, &block)
|
|
4
|
+
Class.new do
|
|
5
|
+
attr_reader(:hash, *fields)
|
|
6
|
+
|
|
7
|
+
const_set :VALUE_ATTRS, fields
|
|
8
|
+
|
|
9
|
+
define_method(:initialize) do |hash|
|
|
10
|
+
unexpected_keys = hash.keys - self::VALUE_ATTRS
|
|
11
|
+
if unexpected_keys.any?
|
|
12
|
+
fail ArgumentError.new("Unexpected hash keys: #{unexpected_keys}")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
hash.values_at(*self::VALUE_ATTRS).zip(hash.values) do |field, value|
|
|
16
|
+
instance_variable_set(:"@#{field}", value)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
@hash = self.class.hash ^ hash.values.hash
|
|
20
|
+
|
|
21
|
+
freeze
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def ==(other)
|
|
25
|
+
eql?(other)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def eql?(other)
|
|
29
|
+
self.class == other.class && values == other.values
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def values
|
|
33
|
+
self.class::VALUE_ATTRS.map { |field| send(field) }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class_eval(&block) if block
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
data/lib/twitter/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: twitter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Erik Michaels-Ober
|
|
@@ -12,7 +12,7 @@ authors:
|
|
|
12
12
|
autorequire:
|
|
13
13
|
bindir: bin
|
|
14
14
|
cert_chain: []
|
|
15
|
-
date:
|
|
15
|
+
date: 2015-02-14 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
18
18
|
name: addressable
|
|
@@ -203,10 +203,14 @@ files:
|
|
|
203
203
|
- lib/twitter/geo/polygon.rb
|
|
204
204
|
- lib/twitter/geo_factory.rb
|
|
205
205
|
- lib/twitter/geo_results.rb
|
|
206
|
+
- lib/twitter/headers.rb
|
|
206
207
|
- lib/twitter/identity.rb
|
|
207
208
|
- lib/twitter/language.rb
|
|
208
209
|
- lib/twitter/list.rb
|
|
210
|
+
- lib/twitter/media/animated_gif.rb
|
|
209
211
|
- lib/twitter/media/photo.rb
|
|
212
|
+
- lib/twitter/media/video.rb
|
|
213
|
+
- lib/twitter/media/video_info.rb
|
|
210
214
|
- lib/twitter/media_factory.rb
|
|
211
215
|
- lib/twitter/metadata.rb
|
|
212
216
|
- lib/twitter/null_object.rb
|
|
@@ -216,7 +220,6 @@ files:
|
|
|
216
220
|
- lib/twitter/profile_banner.rb
|
|
217
221
|
- lib/twitter/rate_limit.rb
|
|
218
222
|
- lib/twitter/relationship.rb
|
|
219
|
-
- lib/twitter/request.rb
|
|
220
223
|
- lib/twitter/rest/api.rb
|
|
221
224
|
- lib/twitter/rest/client.rb
|
|
222
225
|
- lib/twitter/rest/direct_messages.rb
|
|
@@ -227,6 +230,7 @@ files:
|
|
|
227
230
|
- lib/twitter/rest/media.rb
|
|
228
231
|
- lib/twitter/rest/oauth.rb
|
|
229
232
|
- lib/twitter/rest/places_and_geo.rb
|
|
233
|
+
- lib/twitter/rest/request.rb
|
|
230
234
|
- lib/twitter/rest/request/multipart_with_file.rb
|
|
231
235
|
- lib/twitter/rest/response/parse_error_json.rb
|
|
232
236
|
- lib/twitter/rest/response/parse_json.rb
|
|
@@ -262,6 +266,8 @@ files:
|
|
|
262
266
|
- lib/twitter/tweet.rb
|
|
263
267
|
- lib/twitter/user.rb
|
|
264
268
|
- lib/twitter/utils.rb
|
|
269
|
+
- lib/twitter/value.rb
|
|
270
|
+
- lib/twitter/variant.rb
|
|
265
271
|
- lib/twitter/version.rb
|
|
266
272
|
- twitter.gemspec
|
|
267
273
|
homepage: http://sferik.github.com/twitter/
|
|
@@ -284,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
284
290
|
version: 1.3.5
|
|
285
291
|
requirements: []
|
|
286
292
|
rubyforge_project:
|
|
287
|
-
rubygems_version: 2.
|
|
293
|
+
rubygems_version: 2.4.5
|
|
288
294
|
signing_key:
|
|
289
295
|
specification_version: 4
|
|
290
296
|
summary: A Ruby interface to the Twitter API.
|
data/lib/twitter/request.rb
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
require 'twitter/cursor'
|
|
2
|
-
|
|
3
|
-
module Twitter
|
|
4
|
-
class Request
|
|
5
|
-
attr_accessor :client, :request_method, :path, :options
|
|
6
|
-
alias_method :verb, :request_method
|
|
7
|
-
|
|
8
|
-
# @param client [Twitter::Client]
|
|
9
|
-
# @param request_method [String, Symbol]
|
|
10
|
-
# @param path [String]
|
|
11
|
-
# @param options [Hash]
|
|
12
|
-
# @return [Twitter::Request]
|
|
13
|
-
def initialize(client, request_method, path, options = {})
|
|
14
|
-
@client = client
|
|
15
|
-
@request_method = request_method.to_sym
|
|
16
|
-
@path = path
|
|
17
|
-
@options = options
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# @return [Hash]
|
|
21
|
-
def perform
|
|
22
|
-
@client.send(@request_method, @path, @options).body
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# @param klass [Class]
|
|
26
|
-
# @param request [Twitter::Request]
|
|
27
|
-
# @return [Object]
|
|
28
|
-
def perform_with_object(klass)
|
|
29
|
-
klass.new(perform)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# @param collection_name [Symbol]
|
|
33
|
-
# @param klass [Class]
|
|
34
|
-
# @return [Twitter::Cursor]
|
|
35
|
-
def perform_with_cursor(collection_name, klass = nil)
|
|
36
|
-
Twitter::Cursor.new(perform, collection_name.to_sym, klass, self)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# @param klass [Class]
|
|
40
|
-
# @return [Array]
|
|
41
|
-
def perform_with_objects(klass)
|
|
42
|
-
perform.collect do |element|
|
|
43
|
-
klass.new(element)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|