twitter 8.2.0 → 8.3.1
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/LICENSE.md +1 -1
- data/README.md +172 -10
- data/lib/twitter/arguments.rb +14 -1
- data/lib/twitter/base.rb +72 -11
- data/lib/twitter/basic_user.rb +7 -1
- data/lib/twitter/client.rb +94 -3
- data/lib/twitter/creatable.rb +11 -2
- data/lib/twitter/cursor.rb +58 -11
- data/lib/twitter/direct_message.rb +32 -4
- data/lib/twitter/direct_message_event.rb +34 -10
- data/lib/twitter/direct_messages/welcome_message.rb +22 -1
- data/lib/twitter/direct_messages/welcome_message_rule.rb +7 -0
- data/lib/twitter/direct_messages/welcome_message_rule_wrapper.rb +26 -3
- data/lib/twitter/direct_messages/welcome_message_wrapper.rb +36 -11
- data/lib/twitter/entities.rb +84 -8
- data/lib/twitter/entity/hashtag.rb +7 -1
- data/lib/twitter/entity/symbol.rb +7 -1
- data/lib/twitter/entity/uri.rb +2 -1
- data/lib/twitter/entity/user_mention.rb +20 -1
- data/lib/twitter/entity.rb +7 -1
- data/lib/twitter/enumerable.rb +20 -3
- data/lib/twitter/error.rb +137 -61
- data/lib/twitter/factory.rb +9 -5
- data/lib/twitter/geo/point.rb +37 -5
- data/lib/twitter/geo/polygon.rb +1 -0
- data/lib/twitter/geo.rb +16 -2
- data/lib/twitter/geo_factory.rb +7 -3
- data/lib/twitter/geo_results.rb +39 -8
- data/lib/twitter/headers.rb +44 -7
- data/lib/twitter/identity.rb +13 -3
- data/lib/twitter/language.rb +21 -1
- data/lib/twitter/list.rb +101 -11
- data/lib/twitter/media/animated_gif.rb +1 -0
- data/lib/twitter/media/photo.rb +19 -3
- data/lib/twitter/media/video.rb +21 -3
- data/lib/twitter/media/video_info.rb +15 -1
- data/lib/twitter/media_factory.rb +7 -3
- data/lib/twitter/metadata.rb +14 -1
- data/lib/twitter/null_object.rb +16 -14
- data/lib/twitter/oembed.rb +56 -2
- data/lib/twitter/place.rb +74 -6
- data/lib/twitter/premium_search_results.rb +87 -18
- data/lib/twitter/profile.rb +100 -44
- data/lib/twitter/profile_banner.rb +9 -4
- data/lib/twitter/rate_limit.rb +32 -3
- data/lib/twitter/relationship.rb +8 -5
- data/lib/twitter/rest/account_activity.rb +55 -26
- data/lib/twitter/rest/api.rb +2 -0
- data/lib/twitter/rest/client.rb +18 -0
- data/lib/twitter/rest/direct_messages/welcome_messages.rb +89 -18
- data/lib/twitter/rest/direct_messages.rb +160 -96
- data/lib/twitter/rest/favorites.rb +58 -22
- data/lib/twitter/rest/form_encoder.rb +57 -17
- data/lib/twitter/rest/friends_and_followers.rb +101 -35
- data/lib/twitter/rest/help.rb +13 -3
- data/lib/twitter/rest/lists.rb +136 -47
- data/lib/twitter/rest/oauth.rb +21 -15
- data/lib/twitter/rest/places_and_geo.rb +44 -28
- data/lib/twitter/rest/premium_search.rb +17 -12
- data/lib/twitter/rest/request.rb +173 -55
- data/lib/twitter/rest/saved_searches.rb +22 -7
- data/lib/twitter/rest/search.rb +20 -16
- data/lib/twitter/rest/spam_reporting.rb +5 -1
- data/lib/twitter/rest/suggested_users.rb +15 -6
- data/lib/twitter/rest/timelines.rb +92 -52
- data/lib/twitter/rest/trends.rb +32 -13
- data/lib/twitter/rest/tweets.rb +147 -89
- data/lib/twitter/rest/undocumented.rb +10 -1
- data/lib/twitter/rest/upload_utils.rb +45 -29
- data/lib/twitter/rest/users.rb +151 -72
- data/lib/twitter/rest/utils.rb +135 -39
- data/lib/twitter/saved_search.rb +23 -2
- data/lib/twitter/search_results.rb +66 -18
- data/lib/twitter/settings.rb +37 -11
- data/lib/twitter/size.rb +37 -3
- data/lib/twitter/source_user.rb +4 -3
- data/lib/twitter/streaming/client.rb +61 -9
- data/lib/twitter/streaming/connection.rb +54 -6
- data/lib/twitter/streaming/deleted_tweet.rb +8 -0
- data/lib/twitter/streaming/event.rb +43 -1
- data/lib/twitter/streaming/friend_list.rb +1 -0
- data/lib/twitter/streaming/message_parser.rb +20 -10
- data/lib/twitter/streaming/response.rb +31 -5
- data/lib/twitter/streaming/stall_warning.rb +23 -0
- data/lib/twitter/suggestion.rb +25 -1
- data/lib/twitter/target_user.rb +2 -1
- data/lib/twitter/trend.rb +29 -1
- data/lib/twitter/trend_results.rb +50 -7
- data/lib/twitter/tweet.rb +180 -21
- data/lib/twitter/user.rb +289 -53
- data/lib/twitter/utils.rb +12 -13
- data/lib/twitter/variant.rb +12 -1
- data/lib/twitter/version.rb +66 -29
- data/lib/twitter.rb +6 -1
- metadata +23 -57
- data/.yardopts +0 -16
- data/CHANGELOG.md +0 -1040
- data/CONTRIBUTING.md +0 -49
- data/twitter.gemspec +0 -40
|
@@ -5,19 +5,43 @@ require "twitter/null_object"
|
|
|
5
5
|
require "twitter/utils"
|
|
6
6
|
|
|
7
7
|
module Twitter
|
|
8
|
+
# Represents a collection of trending topics
|
|
8
9
|
class TrendResults
|
|
9
|
-
include
|
|
10
|
-
include
|
|
11
|
-
include
|
|
10
|
+
include Creatable
|
|
11
|
+
include Enumerable
|
|
12
|
+
include Utils
|
|
12
13
|
include Memoizable
|
|
14
|
+
|
|
15
|
+
# The raw attributes hash
|
|
16
|
+
#
|
|
17
|
+
# @api public
|
|
18
|
+
# @example
|
|
19
|
+
# results.attrs
|
|
13
20
|
# @return [Hash]
|
|
14
21
|
attr_reader :attrs
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
|
|
23
|
+
# @!method to_h
|
|
24
|
+
# Returns the attributes as a hash
|
|
25
|
+
# @api public
|
|
26
|
+
# @example
|
|
27
|
+
# results.to_h
|
|
28
|
+
# @return [Hash]
|
|
29
|
+
alias_method :to_h, :attrs
|
|
30
|
+
|
|
31
|
+
# @!method to_hash
|
|
32
|
+
# Returns the attributes as a hash
|
|
33
|
+
# @api public
|
|
34
|
+
# @example
|
|
35
|
+
# results.to_hash
|
|
36
|
+
# @return [Hash]
|
|
37
|
+
alias_method :to_hash, :to_h
|
|
17
38
|
|
|
18
39
|
# Initializes a new TrendResults object
|
|
19
40
|
#
|
|
20
|
-
# @
|
|
41
|
+
# @api public
|
|
42
|
+
# @example
|
|
43
|
+
# Twitter::TrendResults.new(trends: [])
|
|
44
|
+
# @param attrs [Hash] The attributes hash
|
|
21
45
|
# @return [Twitter::TrendResults]
|
|
22
46
|
def initialize(attrs = {})
|
|
23
47
|
@attrs = attrs
|
|
@@ -26,25 +50,44 @@ module Twitter
|
|
|
26
50
|
end
|
|
27
51
|
end
|
|
28
52
|
|
|
29
|
-
#
|
|
53
|
+
# Returns the time when trends were retrieved
|
|
30
54
|
#
|
|
55
|
+
# @api public
|
|
56
|
+
# @example
|
|
57
|
+
# results.as_of
|
|
31
58
|
# @return [Time]
|
|
32
59
|
def as_of
|
|
33
60
|
Time.parse(@attrs[:as_of]).utc unless @attrs[:as_of].nil?
|
|
34
61
|
end
|
|
35
62
|
memoize :as_of
|
|
36
63
|
|
|
64
|
+
# Returns true if as_of is available
|
|
65
|
+
#
|
|
66
|
+
# @api public
|
|
67
|
+
# @example
|
|
68
|
+
# results.as_of?
|
|
69
|
+
# @return [Boolean]
|
|
37
70
|
def as_of?
|
|
38
71
|
!!@attrs[:as_of]
|
|
39
72
|
end
|
|
40
73
|
memoize :as_of?
|
|
41
74
|
|
|
75
|
+
# Returns the location for these trends
|
|
76
|
+
#
|
|
77
|
+
# @api public
|
|
78
|
+
# @example
|
|
79
|
+
# results.location
|
|
42
80
|
# @return [Twitter::Place, NullObject]
|
|
43
81
|
def location
|
|
44
82
|
location? ? Place.new(@attrs[:locations].first) : NullObject.new
|
|
45
83
|
end
|
|
46
84
|
memoize :location
|
|
47
85
|
|
|
86
|
+
# Returns true if location is available
|
|
87
|
+
#
|
|
88
|
+
# @api public
|
|
89
|
+
# @example
|
|
90
|
+
# results.location?
|
|
48
91
|
# @return [Boolean]
|
|
49
92
|
def location?
|
|
50
93
|
!@attrs[:locations].nil? && !@attrs[:locations].first.nil?
|
data/lib/twitter/tweet.rb
CHANGED
|
@@ -3,42 +3,189 @@ require "twitter/entities"
|
|
|
3
3
|
require "twitter/identity"
|
|
4
4
|
|
|
5
5
|
module Twitter
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
include
|
|
6
|
+
# Represents a Twitter tweet
|
|
7
|
+
class Tweet < Identity
|
|
8
|
+
include Creatable
|
|
9
|
+
include Entities
|
|
10
|
+
|
|
11
|
+
# The filter level of the tweet
|
|
12
|
+
#
|
|
13
|
+
# @api public
|
|
14
|
+
# @example
|
|
15
|
+
# tweet.filter_level
|
|
16
|
+
# @return [String]
|
|
17
|
+
|
|
18
|
+
# The screen name of the user being replied to
|
|
19
|
+
#
|
|
20
|
+
# @api public
|
|
21
|
+
# @example
|
|
22
|
+
# tweet.in_reply_to_screen_name
|
|
23
|
+
# @return [String]
|
|
24
|
+
|
|
25
|
+
# The language of the tweet
|
|
26
|
+
#
|
|
27
|
+
# @api public
|
|
28
|
+
# @example
|
|
29
|
+
# tweet.lang
|
|
30
|
+
# @return [String]
|
|
31
|
+
|
|
32
|
+
# The source of the tweet
|
|
33
|
+
#
|
|
34
|
+
# @api public
|
|
35
|
+
# @example
|
|
36
|
+
# tweet.source
|
|
37
|
+
# @return [String]
|
|
38
|
+
|
|
39
|
+
# The text of the tweet
|
|
40
|
+
#
|
|
41
|
+
# @api public
|
|
42
|
+
# @example
|
|
43
|
+
# tweet.text
|
|
9
44
|
# @return [String]
|
|
10
45
|
attr_reader :filter_level, :in_reply_to_screen_name, :lang, :source, :text
|
|
46
|
+
|
|
47
|
+
# The number of times this tweet has been favorited
|
|
48
|
+
#
|
|
49
|
+
# @api public
|
|
50
|
+
# @example
|
|
51
|
+
# tweet.favorite_count
|
|
52
|
+
# @return [Integer]
|
|
53
|
+
|
|
54
|
+
# The ID of the status being replied to
|
|
55
|
+
#
|
|
56
|
+
# @api public
|
|
57
|
+
# @example
|
|
58
|
+
# tweet.in_reply_to_status_id
|
|
59
|
+
# @return [Integer]
|
|
60
|
+
|
|
61
|
+
# The ID of the user being replied to
|
|
62
|
+
#
|
|
63
|
+
# @api public
|
|
64
|
+
# @example
|
|
65
|
+
# tweet.in_reply_to_user_id
|
|
66
|
+
# @return [Integer]
|
|
67
|
+
|
|
68
|
+
# The number of times this tweet has been quoted
|
|
69
|
+
#
|
|
70
|
+
# @api public
|
|
71
|
+
# @example
|
|
72
|
+
# tweet.quote_count
|
|
73
|
+
# @return [Integer]
|
|
74
|
+
|
|
75
|
+
# The number of replies to this tweet
|
|
76
|
+
#
|
|
77
|
+
# @api public
|
|
78
|
+
# @example
|
|
79
|
+
# tweet.reply_count
|
|
80
|
+
# @return [Integer]
|
|
81
|
+
|
|
82
|
+
# The number of times this tweet has been retweeted
|
|
83
|
+
#
|
|
84
|
+
# @api public
|
|
85
|
+
# @example
|
|
86
|
+
# tweet.retweet_count
|
|
11
87
|
# @return [Integer]
|
|
12
88
|
attr_reader :favorite_count, :in_reply_to_status_id, :in_reply_to_user_id,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
89
|
+
:quote_count, :reply_count, :retweet_count
|
|
90
|
+
|
|
91
|
+
# @!method in_reply_to_tweet_id
|
|
92
|
+
# The ID of the tweet being replied to
|
|
93
|
+
# @api public
|
|
94
|
+
# @example
|
|
95
|
+
# tweet.in_reply_to_tweet_id
|
|
96
|
+
# @return [Integer]
|
|
97
|
+
alias_method :in_reply_to_tweet_id, :in_reply_to_status_id
|
|
98
|
+
|
|
99
|
+
# Returns true if this is a reply
|
|
100
|
+
#
|
|
101
|
+
# @!method reply?
|
|
102
|
+
# @api public
|
|
103
|
+
# @example
|
|
104
|
+
# tweet.reply?
|
|
105
|
+
# @return [Boolean]
|
|
106
|
+
alias_method :reply?, :in_reply_to_user_id?
|
|
16
107
|
object_attr_reader :GeoFactory, :geo
|
|
17
108
|
object_attr_reader :Metadata, :metadata
|
|
18
109
|
object_attr_reader :Place, :place
|
|
19
110
|
object_attr_reader :Tweet, :retweeted_status
|
|
20
111
|
object_attr_reader :Tweet, :quoted_status
|
|
21
112
|
object_attr_reader :Tweet, :current_user_retweet
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
113
|
+
|
|
114
|
+
# Returns the retweeted tweet
|
|
115
|
+
#
|
|
116
|
+
# @!method retweeted_tweet
|
|
117
|
+
# @api public
|
|
118
|
+
# @example
|
|
119
|
+
# tweet.retweeted_tweet
|
|
120
|
+
# @return [Twitter::Tweet]
|
|
121
|
+
alias_method :retweeted_tweet, :retweeted_status
|
|
122
|
+
|
|
123
|
+
# Returns true if this is a retweet
|
|
124
|
+
#
|
|
125
|
+
# @!method retweet?
|
|
126
|
+
# @api public
|
|
127
|
+
# @example
|
|
128
|
+
# tweet.retweet?
|
|
129
|
+
# @return [Boolean]
|
|
130
|
+
alias_method :retweet?, :retweeted_status?
|
|
131
|
+
|
|
132
|
+
# Returns true if this has a retweeted tweet
|
|
133
|
+
#
|
|
134
|
+
# @!method retweeted_tweet?
|
|
135
|
+
# @api public
|
|
136
|
+
# @example
|
|
137
|
+
# tweet.retweeted_tweet?
|
|
138
|
+
# @return [Boolean]
|
|
139
|
+
alias_method :retweeted_tweet?, :retweeted_status?
|
|
140
|
+
|
|
141
|
+
# Returns the quoted tweet
|
|
142
|
+
#
|
|
143
|
+
# @!method quoted_tweet
|
|
144
|
+
# @api public
|
|
145
|
+
# @example
|
|
146
|
+
# tweet.quoted_tweet
|
|
147
|
+
# @return [Twitter::Tweet]
|
|
148
|
+
alias_method :quoted_tweet, :quoted_status
|
|
149
|
+
|
|
150
|
+
# Returns true if this is a quote tweet
|
|
151
|
+
#
|
|
152
|
+
# @!method quote?
|
|
153
|
+
# @api public
|
|
154
|
+
# @example
|
|
155
|
+
# tweet.quote?
|
|
156
|
+
# @return [Boolean]
|
|
157
|
+
alias_method :quote?, :quoted_status?
|
|
158
|
+
|
|
159
|
+
# Returns true if this has a quoted tweet
|
|
160
|
+
#
|
|
161
|
+
# @!method quoted_tweet?
|
|
162
|
+
# @api public
|
|
163
|
+
# @example
|
|
164
|
+
# tweet.quoted_tweet?
|
|
165
|
+
# @return [Boolean]
|
|
166
|
+
alias_method :quoted_tweet?, :quoted_status?
|
|
28
167
|
object_attr_reader :User, :user, :status
|
|
29
168
|
predicate_attr_reader :favorited, :possibly_sensitive, :retweeted,
|
|
30
|
-
|
|
169
|
+
:truncated
|
|
31
170
|
|
|
32
|
-
# Initializes a new object
|
|
171
|
+
# Initializes a new Tweet object
|
|
33
172
|
#
|
|
34
|
-
# @
|
|
173
|
+
# @api public
|
|
174
|
+
# @example
|
|
175
|
+
# Twitter::Tweet.new(id: 123, text: "Hello")
|
|
176
|
+
# @param attrs [Hash] The attributes hash containing at least :id
|
|
35
177
|
# @return [Twitter::Tweet]
|
|
36
|
-
def initialize(attrs
|
|
37
|
-
attrs[:text]
|
|
178
|
+
def initialize(attrs)
|
|
179
|
+
attrs[:text] ||= attrs[:full_text]
|
|
38
180
|
super
|
|
39
181
|
end
|
|
40
182
|
|
|
41
|
-
#
|
|
183
|
+
# Returns the full text of the tweet
|
|
184
|
+
#
|
|
185
|
+
# @api public
|
|
186
|
+
# @note May be > 280 characters
|
|
187
|
+
# @example
|
|
188
|
+
# tweet.full_text
|
|
42
189
|
# @return [String]
|
|
43
190
|
def full_text
|
|
44
191
|
if retweet?
|
|
@@ -50,11 +197,23 @@ module Twitter
|
|
|
50
197
|
end
|
|
51
198
|
memoize :full_text
|
|
52
199
|
|
|
53
|
-
#
|
|
200
|
+
# Returns the URI to the tweet
|
|
201
|
+
#
|
|
202
|
+
# @api public
|
|
203
|
+
# @example
|
|
204
|
+
# tweet.uri
|
|
205
|
+
# @return [URI::Generic]
|
|
54
206
|
def uri
|
|
55
|
-
|
|
207
|
+
URI.parse("https://twitter.com/#{user.screen_name}/status/#{id}") if user?
|
|
56
208
|
end
|
|
57
209
|
memoize :uri
|
|
58
|
-
|
|
210
|
+
|
|
211
|
+
# @!method url
|
|
212
|
+
# Returns the URL to the tweet
|
|
213
|
+
# @api public
|
|
214
|
+
# @example
|
|
215
|
+
# tweet.url
|
|
216
|
+
# @return [URI::Generic]
|
|
217
|
+
alias_method :url, :uri
|
|
59
218
|
end
|
|
60
219
|
end
|