twitter 8.0.0 → 8.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 887f3f7456fa0b9203510120f02368de184dacf83d110b8c0b8a5c28e89bfd74
4
- data.tar.gz: 328625a02d50b6fb1bc4167badb0089c249a1c7f89379fba88694bacc247b7c9
3
+ metadata.gz: 966e4a2335655909757eeb68dda4f8c057dc20664c469bf42012a2b9c2fd80e9
4
+ data.tar.gz: 8df69c8494097b2e342dd30d0d3a16cc20cae9532ab0c889767d58a5eab40246
5
5
  SHA512:
6
- metadata.gz: f4da2b78382449b35b00181f71ea6e48de2e169c9e1c5107c414d2384c721a0cb4328b7981dc9f987a5c947e593974b1fb811ef76d10a277dfb471d93c039d97
7
- data.tar.gz: b02e8884564113c6e28ff5852826e35861c1ce7dee1db57925c0c6f09f5dfebf9879030c786b44910a910a224592ba8c42045bddbac187e68e03d4e29bf4608c
6
+ metadata.gz: d6c38b3c3382b0b0e1c01d91358a416ebc9c22efff9d88725376503eb7a73f43b7c0eda371e80647007c4f9d7b0238e753a0fa9f5cd26659ab63691bf2eaa84e
7
+ data.tar.gz: c66bdbf9d66c76f48756f267466107a82dd71539ea8904563485644da5bc793c88dad9fc153b254574e907560215d529ae60de09fe1930c064c66815a37c0bc9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ 8.1.0
2
+ -----
3
+ * [Update runtime dependencies](https://github.com/sferik/twitter-ruby/commit/25e8a3c623ef7d6b67b38276ad3d2f0b7e925f07)
4
+ * [Drop support for Ruby 3.0](https://github.com/sferik/twitter-ruby/commit/4ef27b3dd66d9f0a875be4918cf61600aeb85d96)
5
+ * [Update post-install message](https://github.com/sferik/twitter-ruby/commit/882381494dabeb8ff43ad150449a99d950b0a211)
6
+
7
+ 8.0.1
8
+ -----
9
+ * [Add post-install message](https://github.com/sferik/twitter/commit/154e66b3655b41226ca8b6cbf52e2866a9e5b2d0)
10
+
1
11
  8.0.0
2
12
  -----
3
13
  * [Fix filter limit issue](https://github.com/sferik/twitter/commit/be91024f7af7e94dd6578e08937975443dc09487)
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006-2020 Erik Berlin, John Nunemaker, Wynn Netherland, Steve Richert, Steve Agalloco
1
+ Copyright (c) 2006-2024 Erik Berlin, John Nunemaker, Wynn Netherland, Steve Richert, Steve Agalloco
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,36 +1,35 @@
1
1
  # The Twitter Ruby Gem
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/twitter.svg)][gem]
4
- [![Build Status](https://travis-ci.org/sferik/twitter.svg?branch=master)][travis]
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/09362621ad91e8f599b3/maintainability)][maintainability]
6
- [![Inline docs](http://inch-ci.org/github/sferik/twitter.svg?style=shields)][inchpages]
3
+ ## 📣 This gem is no longer maintained
4
+ The Twitter Ruby Gem is no longer maintained and will not support Twitter API v2.
7
5
 
8
- [gem]: https://rubygems.org/gems/twitter
9
- [travis]: https://travis-ci.org/sferik/twitter
10
- [maintainability]: https://codeclimate.com/github/sferik/twitter/maintainability
11
- [inchpages]: http://inch-ci.org/github/sferik/twitter
6
+ ## 🎉 Here’s the good news
7
+ We recommend switching to the [X gem][x], which supports both v1.1 and v2 to make
8
+ the transition easier. It’s a robust, modern libary that is designed to ensure
9
+ you’ll be able to easily integrate any new changes Twitter/X may roll out.
12
10
 
13
- A Ruby interface to the Twitter API.
11
+ [x]: https://sferik.github.io/x-ruby/
14
12
 
15
- ## Installation
16
- gem install twitter
13
+ ## 💖 Sponsoring
14
+ The [X gem][x] is free to use, but with new API pricing tiers, it actually costs
15
+ money to develop and maintain. By contributing to the project, you help us:
17
16
 
18
- ## CLI
19
- Looking for the Twitter command-line interface? It was [removed][] from this
20
- gem in version 0.5.0 and now exists as a [separate project][t].
17
+ 1. 🛠 Maintain the library: Keeping it up-to-date and secure.
18
+ 2. 🌈 Add new features: Enhancements that make your life easier.
19
+ 3. 💬 Provide support: Faster responses to issues and feature requests.
21
20
 
22
- [removed]: https://github.com/sferik/twitter/commit/dd2445e3e2c97f38b28a3f32ea902536b3897adf
23
- [t]: https://github.com/sferik/t
21
+ ⭐️ Bonus: Sponsors will get priority support and influence over the project
22
+ roadmap. We will also list your name or your company’s logo on our GitHub page.
24
23
 
25
- ## Documentation
26
- [http://rdoc.info/gems/twitter][documentation]
24
+ Building and maintaining an open-source project like this takes a considerable
25
+ amount of time and effort. Your sponsorship can help sustain this project. Even
26
+ a small monthly donation makes a huge difference!
27
27
 
28
- [documentation]: http://rdoc.info/gems/twitter
28
+ Thanks for considering sponsorship. Together we can make the X gem even better!
29
29
 
30
- ## Examples
31
- [https://github.com/sferik/twitter/tree/master/examples][examples]
30
+ #### 🤑 [Sponsor today!][sponsor]
32
31
 
33
- [examples]: https://github.com/sferik/twitter/tree/master/examples
32
+ [sponsor]: https://github.com/sponsors/sferik
34
33
 
35
34
  ## Announcements
36
35
  You should [follow @gem][follow] on Twitter for announcements and updates about
@@ -38,230 +37,8 @@ this library.
38
37
 
39
38
  [follow]: https://twitter.com/gem
40
39
 
41
- ## Mailing List
42
- Please direct questions about this library to the [mailing list].
43
-
44
- [mailing list]: https://groups.google.com/group/twitter-ruby-gem
45
-
46
- ## Apps Wiki
47
- Does your project or organization use this gem? Add it to the [apps
48
- wiki][apps]!
49
-
50
- [apps]: https://github.com/sferik/twitter/wiki/apps
51
-
52
- ## Configuration
53
- Twitter API v1.1 requires you to authenticate via OAuth, so you'll need to
54
- [register your application with Twitter][register]. Once you've registered an
55
- application, make sure to set the correct access level, otherwise you may see
56
- the error:
57
-
58
- [register]: https://apps.twitter.com/
59
-
60
- Read-only application cannot POST
61
-
62
- Your new application will be assigned a consumer key/secret pair and you will
63
- be assigned an OAuth access token/secret pair for that application. You'll need
64
- to configure these values before you make a request or else you'll get the
65
- error:
66
-
67
- Bad Authentication data
68
-
69
- You can pass configuration options as a block to `Twitter::REST::Client.new`.
70
-
71
- ```ruby
72
- client = Twitter::REST::Client.new do |config|
73
- config.consumer_key = "YOUR_CONSUMER_KEY"
74
- config.consumer_secret = "YOUR_CONSUMER_SECRET"
75
- config.access_token = "YOUR_ACCESS_TOKEN"
76
- config.access_token_secret = "YOUR_ACCESS_SECRET"
77
- end
78
- ```
79
-
80
- ## Usage Examples
81
- After configuring a `client`, you can do the following things.
82
-
83
- **Tweet (as the authenticated user)**
84
-
85
- ```ruby
86
- client.update("I'm tweeting with @gem!")
87
- ```
88
- **Follow a user (by screen name or user ID)**
89
-
90
- ```ruby
91
- client.follow("gem")
92
- client.follow(213747670)
93
- ```
94
- **Fetch a user (by screen name or user ID)**
95
-
96
- ```ruby
97
- client.user("gem")
98
- client.user(213747670)
99
- ```
100
- **Fetch a cursored list of followers with profile details (by screen name or user ID, or by implicit authenticated user)**
101
-
102
- ```ruby
103
- client.followers("gem")
104
- client.followers(213747670)
105
- client.followers
106
- ```
107
- **Fetch a cursored list of friends with profile details (by screen name or user ID, or by implicit authenticated user)**
108
-
109
- ```ruby
110
- client.friends("gem")
111
- client.friends(213747670)
112
- client.friends
113
- ```
114
-
115
- **Fetch the timeline of Tweets by a user**
116
-
117
- ```ruby
118
- client.user_timeline("gem")
119
- client.user_timeline(213747670)
120
- ```
121
- **Fetch the timeline of Tweets from the authenticated user's home page**
122
-
123
- ```ruby
124
- client.home_timeline
125
- ```
126
- **Fetch the timeline of Tweets mentioning the authenticated user**
127
-
128
- ```ruby
129
- client.mentions_timeline
130
- ```
131
- **Fetch a particular Tweet by ID**
132
-
133
- ```ruby
134
- client.status(27558893223)
135
- ```
136
- **Collect the three most recent marriage proposals to @justinbieber**
137
-
138
- ```ruby
139
- client.search("to:justinbieber marry me", result_type: "recent").take(3).collect do |tweet|
140
- "#{tweet.user.screen_name}: #{tweet.text}"
141
- end
142
- ```
143
- **Find a Japanese-language Tweet tagged #ruby (excluding retweets)**
144
-
145
- ```ruby
146
- client.search("#ruby -rt", lang: "ja").first.text
147
- ```
148
- For more usage examples, please see the full [documentation][].
149
-
150
- ## Streaming
151
- Site Streams are restricted to whitelisted accounts. To apply for access,
152
- [follow the steps in the Site Streams documentation][site-streams]. [User
153
- Streams][user-streams] do not require prior approval.
154
-
155
- [site-streams]: https://dev.twitter.com/streaming/sitestreams#applyingforaccess
156
- [user-streams]: https://dev.twitter.com/streaming/userstreams
157
-
158
- **Configuration works just like `Twitter::REST::Client`**
159
-
160
- ```ruby
161
- client = Twitter::Streaming::Client.new do |config|
162
- config.consumer_key = "YOUR_CONSUMER_KEY"
163
- config.consumer_secret = "YOUR_CONSUMER_SECRET"
164
- config.access_token = "YOUR_ACCESS_TOKEN"
165
- config.access_token_secret = "YOUR_ACCESS_SECRET"
166
- end
167
- ```
168
-
169
- **Stream a random sample of all tweets**
170
-
171
- ```ruby
172
- client.sample do |object|
173
- puts object.text if object.is_a?(Twitter::Tweet)
174
- end
175
- ```
176
-
177
- **Stream mentions of coffee or tea**
178
-
179
- ```ruby
180
- topics = ["coffee", "tea"]
181
- client.filter(track: topics.join(",")) do |object|
182
- puts object.text if object.is_a?(Twitter::Tweet)
183
- end
184
- ```
185
-
186
- **Stream tweets, events, and direct messages for the authenticated user**
187
-
188
- ```ruby
189
- client.user do |object|
190
- case object
191
- when Twitter::Tweet
192
- puts "It's a tweet!"
193
- when Twitter::DirectMessage
194
- puts "It's a direct message!"
195
- when Twitter::Streaming::StallWarning
196
- warn "Falling behind!"
197
- end
198
- end
199
- ```
200
-
201
- An `object` may be one of the following:
202
- * `Twitter::Tweet`
203
- * `Twitter::DirectMessage`
204
- * `Twitter::Streaming::DeletedTweet`
205
- * `Twitter::Streaming::Event`
206
- * `Twitter::Streaming::FriendList`
207
- * `Twitter::Streaming::StallWarning`
208
-
209
- ## Ads
210
-
211
- We recommend using the [Twitter Ads SDK for Ruby][ads] to interact with the Twitter Ads API.
212
-
213
- [ads]: http://twitterdev.github.io/twitter-ruby-ads-sdk/
214
-
215
- ## Object Graph
216
- ![Entity-relationship diagram][erd]
217
-
218
- [erd]: https://cdn.rawgit.com/sferik/twitter/master/etc/erd.svg "Entity-relationship diagram"
219
-
220
- This entity-relationship diagram is generated programatically. If you add or
221
- remove any Twitter objects, please regenerate the ERD with the following
222
- command:
223
-
224
- bundle exec rake erd
225
-
226
- ## Supported Ruby Versions
227
- This library aims to support and is [tested against][travis] the following Ruby
228
- versions:
229
-
230
- * Ruby 2.7
231
- * Ruby 3.0
232
- * Ruby 3.1
233
- * Ruby 3.2
234
-
235
- If something doesn't work on one of these versions, it's a bug.
236
-
237
- This library may inadvertently work (or seem to work) on other Ruby versions,
238
- however support will only be provided for the versions listed above.
239
-
240
- If you would like this library to support another Ruby version or
241
- implementation, you may volunteer to be a maintainer. Being a maintainer
242
- entails making sure all tests run and pass on that implementation. When
243
- something breaks on your implementation, you will be responsible for providing
244
- patches in a timely fashion. If critical issues for a particular implementation
245
- exist at the time of a major release, support for that Ruby version may be
246
- dropped.
247
-
248
- ## Versioning
249
- This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
250
- of this scheme should be reported as bugs. Specifically, if a minor or patch
251
- version is released that breaks backward compatibility, that version should be
252
- immediately yanked and/or a new version should be immediately released that
253
- restores compatibility. Breaking changes to the public API will only be
254
- introduced with new major versions. As a result of this policy, you can (and
255
- should) specify a dependency on this gem using the [Pessimistic Version
256
- Constraint][pvc] with two digits of precision. For example:
257
-
258
- spec.add_dependency 'twitter', '~> 6.0'
259
-
260
- [semver]: http://semver.org/
261
- [pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
262
-
263
40
  ## Copyright
264
- Copyright (c) 2006-2016 Erik Berlin, John Nunemaker, Wynn Netherland, Steve Richert, Steve Agalloco.
41
+ Copyright (c) 2006-2024 Erik Berlin, John Nunemaker, Wynn Netherland, Steve Richert, Steve Agalloco.
265
42
  See [LICENSE][] for details.
266
43
 
267
44
  [license]: LICENSE.md
@@ -14,7 +14,7 @@ module Twitter
14
14
  # @return [Twitter::Client]
15
15
  def initialize(options = {})
16
16
  options.each do |key, value|
17
- instance_variable_set("@#{key}", value)
17
+ instance_variable_set(:"@#{key}", value)
18
18
  end
19
19
  yield(self) if block_given?
20
20
  end
@@ -32,8 +32,8 @@ module Twitter
32
32
  # @return [Hash]
33
33
  def credentials
34
34
  {
35
- consumer_key: consumer_key,
36
- consumer_secret: consumer_secret,
35
+ consumer_key:,
36
+ consumer_secret:,
37
37
  token: access_token,
38
38
  token_secret: access_token_secret,
39
39
  }
@@ -35,10 +35,10 @@ module Twitter
35
35
  {id: attrs[:id].to_i,
36
36
  created_at: Time.at(attrs[:created_timestamp].to_i / 1000.0),
37
37
  sender: {id: sender_id},
38
- sender_id: sender_id,
38
+ sender_id:,
39
39
  recipient: {id: recipient_id},
40
- recipient_id: recipient_id,
41
- text: text}
40
+ recipient_id:,
41
+ text:}
42
42
  end
43
43
  end
44
44
  end
@@ -32,7 +32,7 @@ module Twitter
32
32
  {
33
33
  id: attrs[:id].to_i,
34
34
  created_at: Time.at(attrs[:created_timestamp].to_i / 1000.0),
35
- text: text,
35
+ text:,
36
36
  name: attrs[:name],
37
37
  entities: attrs.dig(:message_data, :entities),
38
38
  }
@@ -4,7 +4,7 @@ module Twitter
4
4
 
5
5
  # @return [Enumerator]
6
6
  def each(start = 0, &block)
7
- return to_enum(:each, start) unless block_given?
7
+ return to_enum(:each, start) unless block
8
8
 
9
9
  Array(@collection[start..]).each(&block)
10
10
  unless finished?
@@ -17,7 +17,7 @@ module Twitter
17
17
  json_options = {
18
18
  welcome_message: {
19
19
  message_data: {
20
- text: text,
20
+ text:,
21
21
  },
22
22
  },
23
23
  }
@@ -36,7 +36,7 @@ module Twitter
36
36
  }
37
37
  json_options = {
38
38
  message_data: {
39
- text: text,
39
+ text:,
40
40
  },
41
41
  }
42
42
  welcome_message_wrapper = perform_request_with_object(:json_put, "/1.1/direct_messages/welcome_messages/update.json", json_options.merge!(options), Twitter::DirectMessages::WelcomeMessageWrapper, params)
@@ -52,7 +52,7 @@ module Twitter
52
52
 
53
53
  def welcome_message_list(options = {})
54
54
  limit = options.fetch(:count, 20)
55
- welcome_message_wrappers = perform_get_with_cursor("/1.1/direct_messages/welcome_messages/list.json", options.merge!(no_default_cursor: true, count: 50, limit: limit), :welcome_messages, Twitter::DirectMessages::WelcomeMessageWrapper)
55
+ welcome_message_wrappers = perform_get_with_cursor("/1.1/direct_messages/welcome_messages/list.json", options.merge!(no_default_cursor: true, count: 50, limit:), :welcome_messages, Twitter::DirectMessages::WelcomeMessageWrapper)
56
56
  welcome_message_wrappers.collect(&:welcome_message)
57
57
  end
58
58
 
@@ -61,7 +61,7 @@ module Twitter
61
61
  def create_welcome_message_rule(welcome_message_id, options = {})
62
62
  json_options = {
63
63
  welcome_message_rule: {
64
- welcome_message_id: welcome_message_id,
64
+ welcome_message_id:,
65
65
  },
66
66
  }
67
67
  rule_wrapper = perform_request_with_object(:json_post, "/1.1/direct_messages/welcome_messages/rules/new.json", json_options.merge!(options), Twitter::DirectMessages::WelcomeMessageRuleWrapper)
@@ -81,7 +81,7 @@ module Twitter
81
81
 
82
82
  def welcome_message_rule_list(options = {})
83
83
  limit = options.fetch(:count, 20)
84
- rule_wrappers = perform_get_with_cursor("/1.1/direct_messages/welcome_messages/rules/list.json", options.merge!(no_default_cursor: true, count: 50, limit: limit), :welcome_message_rules, Twitter::DirectMessages::WelcomeMessageRuleWrapper)
84
+ rule_wrappers = perform_get_with_cursor("/1.1/direct_messages/welcome_messages/rules/list.json", options.merge!(no_default_cursor: true, count: 50, limit:), :welcome_message_rules, Twitter::DirectMessages::WelcomeMessageRuleWrapper)
85
85
  rule_wrappers.collect(&:welcome_message_rule)
86
86
  end
87
87
  end
@@ -25,7 +25,7 @@ module Twitter
25
25
  # @option options [String] :cursor Specifies the cursor position of results to retrieve.
26
26
  def direct_messages_events(options = {})
27
27
  limit = options.fetch(:count, 20)
28
- perform_get_with_cursor("/1.1/direct_messages/events/list.json", options.merge!(no_default_cursor: true, count: 50, limit: limit), :events, Twitter::DirectMessageEvent)
28
+ perform_get_with_cursor("/1.1/direct_messages/events/list.json", options.merge!(no_default_cursor: true, count: 50, limit:), :events, Twitter::DirectMessageEvent)
29
29
  end
30
30
 
31
31
  # Returns all Direct Messages for the authenticated user (both sent and received) within the last 30 days. Sorted in reverse-chronological order.
@@ -149,7 +149,7 @@ module Twitter
149
149
  # @param ids [Enumerable<Integer>] A collection of direct message IDs.
150
150
  def destroy_direct_message(*ids)
151
151
  pmap(ids) do |id|
152
- perform_requests(:delete, "/1.1/direct_messages/events/destroy.json", id: id)
152
+ perform_requests(:delete, "/1.1/direct_messages/events/destroy.json", id:)
153
153
  end
154
154
  nil
155
155
  end
@@ -207,7 +207,7 @@ module Twitter
207
207
  def create_direct_message_event_with_media(user, text, media, options = {})
208
208
  media_id = upload(media, media_category_prefix: "dm")[:media_id]
209
209
  options = options.dup
210
- options[:event] = {type: "message_create", message_create: {target: {recipient_id: extract_id(user)}, message_data: {text: text, attachment: {type: "media", media: {id: media_id}}}}}
210
+ options[:event] = {type: "message_create", message_create: {target: {recipient_id: extract_id(user)}, message_data: {text:, attachment: {type: "media", media: {id: media_id}}}}}
211
211
  response = Twitter::REST::Request.new(self, :json_post, "/1.1/direct_messages/events/new.json", options).perform
212
212
  Twitter::DirectMessageEvent.new(response[:event])
213
213
  end
@@ -215,7 +215,7 @@ module Twitter
215
215
  private
216
216
 
217
217
  def format_json_options(user_id, text, options)
218
- {event: {type: "message_create", message_create: {target: {recipient_id: user_id}, message_data: {text: text}.merge(options)}}}
218
+ {event: {type: "message_create", message_create: {target: {recipient_id: user_id}, message_data: {text:}.merge(options)}}}
219
219
  end
220
220
  end
221
221
  end
@@ -325,7 +325,7 @@ module Twitter
325
325
  # @option options [String] :mode ('public') Whether your list is public or private. Values can be 'public' or 'private'.
326
326
  # @option options [String] :description The description to give the list.
327
327
  def create_list(name, options = {})
328
- perform_post_with_object("/1.1/lists/create.json", options.merge(name: name), Twitter::List)
328
+ perform_post_with_object("/1.1/lists/create.json", options.merge(name:), Twitter::List)
329
329
  end
330
330
 
331
331
  # Show the specified list
@@ -26,7 +26,7 @@ module Twitter
26
26
  request_config[:request_method] = :json_post if request_config[:request_method].nil? || request_config[:request_method] == :post
27
27
  request_config[:product] ||= "30day"
28
28
  path = "/1.1/tweets/search/#{request_config[:product]}/#{dev_environment}.json"
29
- request = Twitter::REST::Request.new(self, request_config[:request_method], path, options.merge(query: query))
29
+ request = Twitter::REST::Request.new(self, request_config[:request_method], path, options.merge(query:))
30
30
  Twitter::PremiumSearchResults.new(request, request_config)
31
31
  end
32
32
  end
@@ -63,7 +63,7 @@ module Twitter
63
63
  # @param query [String] The query of the search the user would like to save.
64
64
  # @param options [Hash] A customizable set of options.
65
65
  def create_saved_search(query, options = {})
66
- perform_post_with_object("/1.1/saved_searches/create.json", options.merge(query: query), Twitter::SavedSearch)
66
+ perform_post_with_object("/1.1/saved_searches/create.json", options.merge(query:), Twitter::SavedSearch)
67
67
  end
68
68
 
69
69
  # Destroys saved searches for the authenticated user
@@ -185,12 +185,12 @@ module Twitter
185
185
  # @param collection [Array]
186
186
  # @param max_id [Integer, NilClass]
187
187
  # @return [Array<Twitter::Tweet>]
188
- def collect_with_max_id(collection = [], max_id = nil, &block)
188
+ def collect_with_max_id(collection = [], max_id = nil, &)
189
189
  tweets = yield(max_id)
190
190
  return collection if tweets.nil?
191
191
 
192
192
  collection += tweets
193
- tweets.empty? ? collection.flatten : collect_with_max_id(collection, tweets.last.id - 1, &block)
193
+ tweets.empty? ? collection.flatten : collect_with_max_id(collection, tweets.last.id - 1, &)
194
194
  end
195
195
  end
196
196
  end
@@ -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:), Twitter::Tweet)
158
158
  end
159
159
 
160
160
  # Retweets the specified Tweets as the authenticating user
@@ -10,8 +10,10 @@ module Twitter
10
10
  #
11
11
  # @see https://developer.twitter.com/en/docs/media/upload-media/uploading-media/media-best-practices
12
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
13
+ ext = File.extname(media)
14
+ return chunk_upload(media, "video/mp4", "#{media_category_prefix}_video") if ext == ".mp4"
15
+ return chunk_upload(media, "video/quicktime", "#{media_category_prefix}_video") if ext == ".mov"
16
+ return chunk_upload(media, "image/gif", "#{media_category_prefix}_gif") if ext == ".gif" && File.size(media) > 5_000_000
15
17
 
16
18
  Twitter::REST::Request.new(self, :multipart_post, "https://upload.twitter.com/1.1/media/upload.json", key: :media, file: media).perform
17
19
  end
@@ -26,8 +28,8 @@ module Twitter
26
28
  Timeout.timeout(timeouts&.fetch(:upload, nil), Twitter::Error::TimeoutError) do
27
29
  init = Twitter::REST::Request.new(self, :post, "https://upload.twitter.com/1.1/media/upload.json",
28
30
  command: "INIT",
29
- media_type: media_type,
30
- media_category: media_category,
31
+ media_type:,
32
+ media_category:,
31
33
  total_bytes: media.size).perform
32
34
  append_media(media, init[:media_id])
33
35
  media.close
@@ -42,7 +44,7 @@ module Twitter
42
44
  seg ||= -1
43
45
  Twitter::REST::Request.new(self, :multipart_post, "https://upload.twitter.com/1.1/media/upload.json",
44
46
  command: "APPEND",
45
- media_id: media_id,
47
+ media_id:,
46
48
  segment_index: seg += 1,
47
49
  key: :media,
48
50
  file: StringIO.new(chunk)).perform
@@ -53,13 +55,15 @@ module Twitter
53
55
  # @see https://developer.twitter.com/en/docs/media/upload-media/api-reference/get-media-upload-status
54
56
  def finalize_media(media_id)
55
57
  response = Twitter::REST::Request.new(self, :post, "https://upload.twitter.com/1.1/media/upload.json",
56
- command: "FINALIZE", media_id: media_id).perform
58
+ command: "FINALIZE", media_id:).perform
59
+ failed_or_succeeded = %w[failed succeeded]
60
+
57
61
  loop do
58
- return response if !response[:processing_info] || %w[failed succeeded].include?(response[:processing_info][:state])
62
+ return response if !response[:processing_info] || failed_or_succeeded.include?(response[:processing_info][:state])
59
63
 
60
64
  sleep(response[:processing_info][:check_after_secs])
61
65
  response = Twitter::REST::Request.new(self, :get, "https://upload.twitter.com/1.1/media/upload.json",
62
- command: "STATUS", media_id: media_id).perform
66
+ command: "STATUS", media_id:).perform
63
67
  end
64
68
  response
65
69
  end
@@ -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:), 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
@@ -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:))
341
341
  true
342
342
  end
343
343
 
@@ -163,7 +163,7 @@ module Twitter
163
163
  # @return nil
164
164
  def perform_requests(request_method, path, ids)
165
165
  ids.each do |id|
166
- perform_request(request_method, path, id: id)
166
+ perform_request(request_method, path, id:)
167
167
  end
168
168
  nil
169
169
  end
@@ -34,8 +34,8 @@ module Twitter
34
34
  # @option options [String] :track Includes additional Tweets matching the specified keywords. Phrases of keywords are specified by a comma-separated list.
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
- def filter(options = {}, &block)
38
- request(:post, "https://stream.twitter.com:443/1.1/statuses/filter.json", options, &block)
37
+ def filter(options = {}, &)
38
+ request(:post, "https://stream.twitter.com:443/1.1/statuses/filter.json", options, &)
39
39
  end
40
40
 
41
41
  # Returns all public statuses
@@ -46,8 +46,8 @@ module Twitter
46
46
  # @param options [Hash] A customizable set of options.
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
- def firehose(options = {}, &block)
50
- request(:get, "https://stream.twitter.com:443/1.1/statuses/firehose.json", options, &block)
49
+ def firehose(options = {}, &)
50
+ request(:get, "https://stream.twitter.com:443/1.1/statuses/firehose.json", options, &)
51
51
  end
52
52
 
53
53
  # Returns a small random sample of all public statuses
@@ -55,8 +55,8 @@ module Twitter
55
55
  # @see https://dev.twitter.com/streaming/reference/get/statuses/sample
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
- def sample(options = {}, &block)
59
- request(:get, "https://stream.twitter.com:443/1.1/statuses/sample.json", options, &block)
58
+ def sample(options = {}, &)
59
+ request(:get, "https://stream.twitter.com:443/1.1/statuses/sample.json", options, &)
60
60
  end
61
61
 
62
62
  # Streams messages for a set of users
@@ -71,10 +71,10 @@ module Twitter
71
71
  # @option options [String] :with Specifies whether to return information for just the users specified in the follow parameter, or include messages from accounts they follow.
72
72
  # @option options [String] :replies Specifies whether stall warnings should be delivered.
73
73
  # @yield [Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning] A stream of Twitter objects.
74
- def site(*args, &block)
74
+ def site(*args, &)
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(",")), &)
78
78
  end
79
79
 
80
80
  # Streams messages for a single user
@@ -89,13 +89,13 @@ module Twitter
89
89
  # @option options [String] :track Includes additional Tweets matching the specified keywords. Phrases of keywords are specified by a comma-separated list.
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
- def user(options = {}, &block)
93
- request(:get, "https://userstream.twitter.com:443/1.1/user.json", options, &block)
92
+ def user(options = {}, &)
93
+ request(:get, "https://userstream.twitter.com:443/1.1/user.json", options, &)
94
94
  end
95
95
 
96
96
  # Set a Proc to be run when connection established.
97
97
  def before_request(&block)
98
- if block_given?
98
+ if block
99
99
  @before_request = block
100
100
  self
101
101
  elsif instance_variable_defined?(:@before_request)
@@ -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:, 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)
@@ -135,12 +135,12 @@ module Twitter
135
135
  # @param users [Array]
136
136
  # @return [Array<Integer>]
137
137
  def collect_user_ids(users)
138
- users.collect do |user|
138
+ users.filter_map do |user|
139
139
  case user
140
140
  when Integer then user
141
141
  when Twitter::User then user.id
142
142
  end
143
- end.compact
143
+ end
144
144
  end
145
145
  end
146
146
  end
data/lib/twitter/utils.rb CHANGED
@@ -8,7 +8,7 @@ module Twitter
8
8
  # @param enumerable [Enumerable]
9
9
  # @return [Array, Enumerator]
10
10
  def flat_pmap(enumerable, &block)
11
- return to_enum(:flat_pmap, enumerable) unless block_given?
11
+ return to_enum(:flat_pmap, enumerable) unless block
12
12
 
13
13
  pmap(enumerable, &block).flatten(1)
14
14
  end
@@ -19,7 +19,7 @@ module Twitter
19
19
  # @param enumerable [Enumerable]
20
20
  # @return [Array, Enumerator]
21
21
  def pmap(enumerable, &block)
22
- return to_enum(:pmap, enumerable) unless block_given?
22
+ return to_enum(:pmap, enumerable) unless block
23
23
 
24
24
  if enumerable.count == 1
25
25
  enumerable.collect(&block)
@@ -9,7 +9,7 @@ module Twitter
9
9
 
10
10
  # @return [Integer]
11
11
  def minor
12
- 0
12
+ 1
13
13
  end
14
14
 
15
15
  # @return [Integer]
@@ -24,12 +24,7 @@ module Twitter
24
24
 
25
25
  # @return [Hash]
26
26
  def to_h
27
- {
28
- major: major,
29
- minor: minor,
30
- patch: patch,
31
- pre: pre,
32
- }
27
+ {major:, minor:, patch:, pre:}
33
28
  end
34
29
 
35
30
  # @return [Array]
data/twitter.gemspec CHANGED
@@ -3,15 +3,15 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require "twitter/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.add_dependency "addressable", "~> 2.3"
6
+ spec.add_dependency "addressable", "~> 2.8"
7
7
  spec.add_dependency "buftok", "~> 0.3.0"
8
8
  spec.add_dependency "equalizer", "~> 0.0.11"
9
- spec.add_dependency "http", "~> 5.1"
9
+ spec.add_dependency "http", "~> 5.2"
10
10
  spec.add_dependency "http-form_data", "~> 2.3"
11
- spec.add_dependency "llhttp-ffi", "~> 0.4.0"
11
+ spec.add_dependency "llhttp-ffi", "~> 0.5.0"
12
12
  spec.add_dependency "memoizable", "~> 0.4.0"
13
- spec.add_dependency "multipart-post", "~> 2.0"
14
- spec.add_dependency "naught", "~> 1.0"
13
+ spec.add_dependency "multipart-post", "~> 2.4"
14
+ spec.add_dependency "naught", "~> 1.1"
15
15
  spec.add_dependency "simple_oauth", "~> 0.3.0"
16
16
  spec.authors = ["Erik Berlin", "John Nunemaker", "Wynn Netherland", "Steve Richert", "Steve Agalloco"]
17
17
  spec.description = "A Ruby interface to the Twitter API."
@@ -21,8 +21,37 @@ Gem::Specification.new do |spec|
21
21
  spec.licenses = %w[MIT]
22
22
  spec.metadata["rubygems_mfa_required"] = "true"
23
23
  spec.name = "twitter"
24
+ spec.post_install_message = "📣 Attention Twitter Ruby Gem User!
25
+ If you're seeing this message, that means you're using the old Twitter Ruby gem
26
+ which is no longer maintained and will not support Twitter API v2.
27
+
28
+ 🎉 Here's the good news:
29
+ We recommend switching to the X gem, which supports both API v1.1 and v2. It's
30
+ a robust, modern libary that is designed to ensure you'll be able to easily
31
+ integrate forthcoming API changes.
32
+
33
+ 🔗 For more details, visit: https://sferik.github.io/x-ruby/
34
+
35
+ 🤔 Please consider sponsoring
36
+ The X gem is free to use, but with new API pricing tiers, it actually costs
37
+ money to develop and maintain. By contributing to the project, you help:
38
+
39
+ 1. 🛠 Maintain the library: Keeping it up-to-date and secure.
40
+ 2. 🌈 Add new features: Enhancements that make your life easier.
41
+ 3. 💬 Provide support: Faster responses to issues and feature requests.
42
+ ⭐️ Bonus: Sponsors will get priority influence over the project roadmap.
43
+ Your company's logo will also be displayed on the project's GitHub page.
44
+
45
+ 🔗 To sponsor, visit: https://github.com/sponsors/sferik
46
+
47
+ Building and maintaining an open-source project like this takes a considerable
48
+ amount of time and effort. Your sponsorship can help sustain this project. Even
49
+ a small monthly donation makes a big difference!
50
+
51
+ 💖 Thanks for considering sponsorship. Together we can make the X gem even better!
52
+ "
24
53
  spec.require_paths = %w[lib]
25
- spec.required_ruby_version = ">= 3.0"
54
+ spec.required_ruby_version = ">= 3.1.4"
26
55
  spec.summary = spec.description
27
56
  spec.version = Twitter::Version
28
57
  end
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: 8.0.0
4
+ version: 8.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Berlin
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2023-04-30 00:00:00.000000000 Z
15
+ date: 2024-04-30 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: addressable
@@ -20,14 +20,14 @@ dependencies:
20
20
  requirements:
21
21
  - - "~>"
22
22
  - !ruby/object:Gem::Version
23
- version: '2.3'
23
+ version: '2.8'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - "~>"
29
29
  - !ruby/object:Gem::Version
30
- version: '2.3'
30
+ version: '2.8'
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: buftok
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -62,14 +62,14 @@ dependencies:
62
62
  requirements:
63
63
  - - "~>"
64
64
  - !ruby/object:Gem::Version
65
- version: '5.1'
65
+ version: '5.2'
66
66
  type: :runtime
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
69
69
  requirements:
70
70
  - - "~>"
71
71
  - !ruby/object:Gem::Version
72
- version: '5.1'
72
+ version: '5.2'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: http-form_data
75
75
  requirement: !ruby/object:Gem::Requirement
@@ -90,14 +90,14 @@ dependencies:
90
90
  requirements:
91
91
  - - "~>"
92
92
  - !ruby/object:Gem::Version
93
- version: 0.4.0
93
+ version: 0.5.0
94
94
  type: :runtime
95
95
  prerelease: false
96
96
  version_requirements: !ruby/object:Gem::Requirement
97
97
  requirements:
98
98
  - - "~>"
99
99
  - !ruby/object:Gem::Version
100
- version: 0.4.0
100
+ version: 0.5.0
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: memoizable
103
103
  requirement: !ruby/object:Gem::Requirement
@@ -118,28 +118,28 @@ dependencies:
118
118
  requirements:
119
119
  - - "~>"
120
120
  - !ruby/object:Gem::Version
121
- version: '2.0'
121
+ version: '2.4'
122
122
  type: :runtime
123
123
  prerelease: false
124
124
  version_requirements: !ruby/object:Gem::Requirement
125
125
  requirements:
126
126
  - - "~>"
127
127
  - !ruby/object:Gem::Version
128
- version: '2.0'
128
+ version: '2.4'
129
129
  - !ruby/object:Gem::Dependency
130
130
  name: naught
131
131
  requirement: !ruby/object:Gem::Requirement
132
132
  requirements:
133
133
  - - "~>"
134
134
  - !ruby/object:Gem::Version
135
- version: '1.0'
135
+ version: '1.1'
136
136
  type: :runtime
137
137
  prerelease: false
138
138
  version_requirements: !ruby/object:Gem::Requirement
139
139
  requirements:
140
140
  - - "~>"
141
141
  - !ruby/object:Gem::Version
142
- version: '1.0'
142
+ version: '1.1'
143
143
  - !ruby/object:Gem::Dependency
144
144
  name: simple_oauth
145
145
  requirement: !ruby/object:Gem::Requirement
@@ -264,7 +264,23 @@ licenses:
264
264
  - MIT
265
265
  metadata:
266
266
  rubygems_mfa_required: 'true'
267
- post_install_message:
267
+ post_install_message: "\U0001F4E3 Attention Twitter Ruby Gem User!\nIf you're seeing
268
+ this message, that means you're using the old Twitter Ruby gem\nwhich is no longer
269
+ maintained and will not support Twitter API v2.\n\n\U0001F389 Here's the good news:\nWe
270
+ recommend switching to the X gem, which supports both API v1.1 and v2. It's\na robust,
271
+ modern libary that is designed to ensure you'll be able to easily\nintegrate forthcoming
272
+ API changes.\n\n\U0001F517 For more details, visit: https://sferik.github.io/x-ruby/\n\n\U0001F914
273
+ Please consider sponsoring\nThe X gem is free to use, but with new API pricing tiers,
274
+ it actually costs\nmoney to develop and maintain. By contributing to the project,
275
+ you help:\n\n1. \U0001F6E0 Maintain the library: Keeping it up-to-date and secure.\n2.
276
+ \U0001F308 Add new features: Enhancements that make your life easier.\n3. \U0001F4AC
277
+ Provide support: Faster responses to issues and feature requests.\n⭐️ Bonus: Sponsors
278
+ will get priority influence over the project roadmap.\nYour company's logo will
279
+ also be displayed on the project's GitHub page.\n\n\U0001F517 To sponsor, visit:
280
+ https://github.com/sponsors/sferik\n\nBuilding and maintaining an open-source project
281
+ like this takes a considerable\namount of time and effort. Your sponsorship can
282
+ help sustain this project. Even\na small monthly donation makes a big difference!\n\n\U0001F496
283
+ Thanks for considering sponsorship. Together we can make the X gem even better!\n"
268
284
  rdoc_options: []
269
285
  require_paths:
270
286
  - lib
@@ -272,14 +288,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
272
288
  requirements:
273
289
  - - ">="
274
290
  - !ruby/object:Gem::Version
275
- version: '3.0'
291
+ version: 3.1.4
276
292
  required_rubygems_version: !ruby/object:Gem::Requirement
277
293
  requirements:
278
294
  - - ">="
279
295
  - !ruby/object:Gem::Version
280
296
  version: '0'
281
297
  requirements: []
282
- rubygems_version: 3.4.12
298
+ rubygems_version: 3.5.9
283
299
  signing_key:
284
300
  specification_version: 4
285
301
  summary: A Ruby interface to the Twitter API.