x 0.12.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +10 -10
- data/lib/x/authenticator.rb +0 -1
- data/lib/x/bearer_token_authenticator.rb +0 -1
- data/lib/x/cgi.rb +0 -1
- data/lib/x/client.rb +0 -1
- data/lib/x/connection.rb +0 -1
- data/lib/x/errors/http_error.rb +0 -1
- data/lib/x/errors/too_many_requests.rb +0 -1
- data/lib/x/media_uploader.rb +2 -2
- data/lib/x/oauth_authenticator.rb +0 -1
- data/lib/x/redirect_handler.rb +0 -1
- data/lib/x/request_builder.rb +0 -1
- data/lib/x/response_parser.rb +0 -1
- data/lib/x/version.rb +1 -1
- data/sig/x.rbs +0 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 553e0e0e9a87126211bf62942b02cb2c7c8b6d9380ee8fd4336058038c9735b0
|
4
|
+
data.tar.gz: 34922d1e52a0c04de3c6fe090e854174d78d437c8e14b061a95ca4ab5e1a0438
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e28c53b17bb053c26326d46940eb539c4612d6f4a547b074e974c2b6ddee616bb37af6c2dd2d4d84b05a21aa2946306de074889b90bd411b2a268793e40d72a0
|
7
|
+
data.tar.gz: 79ab655009e07915cf71158bb2976301d1519093c753b6f8fc1d128781b4844e867551c3d430bb0226aa113d3c7342efdd401e08d4f3d920a7437dfa8c432ba6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## [0.12.1] - 2023-11-28
|
2
|
+
* Ensure split chunks are written as binary (c6e257f)
|
3
|
+
* Require tmpdir in X::MediaUploader (9e7c7f1)
|
4
|
+
|
1
5
|
## [0.12.0] - 2023-11-02
|
2
6
|
* Ensure Authenticator is passed to RedirectHandler (fc8557b)
|
3
7
|
* Add AUTHENTICATION_HEADER to X::Authenticator base class (85a2818)
|
data/README.md
CHANGED
@@ -41,24 +41,24 @@ x_client = X::Client.new(**x_credentials)
|
|
41
41
|
x_client.get("users/me")
|
42
42
|
# {"data"=>{"id"=>"7505382", "name"=>"Erik Berlin", "username"=>"sferik"}}
|
43
43
|
|
44
|
-
# Post
|
45
|
-
|
44
|
+
# Post
|
45
|
+
post = x_client.post("tweets", '{"text":"Hello, World! (from @gem)"}')
|
46
46
|
# {"data"=>{"edit_history_tweet_ids"=>["1234567890123456789"], "id"=>"1234567890123456789", "text"=>"Hello, World! (from @gem)"}}
|
47
47
|
|
48
|
-
# Delete the
|
49
|
-
x_client.delete("tweets/#{
|
48
|
+
# Delete the post
|
49
|
+
x_client.delete("tweets/#{post["data"]["id"]}")
|
50
50
|
# {"data"=>{"deleted"=>true}}
|
51
51
|
|
52
52
|
# Initialize an API v1.1 client
|
53
53
|
v1_client = X::Client.new(base_url: "https://api.twitter.com/1.1/", **x_credentials)
|
54
54
|
|
55
|
-
#
|
55
|
+
# Get your account settings
|
56
56
|
v1_client.get("account/settings.json")
|
57
57
|
|
58
58
|
# Initialize an X Ads API client
|
59
59
|
ads_client = X::Client.new(base_url: "https://ads-api.twitter.com/12/", **x_credentials)
|
60
60
|
|
61
|
-
#
|
61
|
+
# Get your ad accounts
|
62
62
|
ads_client.get("accounts")
|
63
63
|
```
|
64
64
|
|
@@ -66,7 +66,7 @@ See other common usage [examples](https://github.com/sferik/x-ruby/tree/main/exa
|
|
66
66
|
|
67
67
|
## History and Philosophy
|
68
68
|
|
69
|
-
This library is a rewrite of the [Twitter Ruby library](https://github.com/sferik/twitter). Over 16 years of development, that library ballooned to over 3,000 lines of code (plus 7,500 lines of tests)
|
69
|
+
This library is a rewrite of the [Twitter Ruby library](https://github.com/sferik/twitter). Over 16 years of development, that library ballooned to over 3,000 lines of code (plus 7,500 lines of tests), not counting dependencies. This library is about 500 lines of code (plus 1000 test lines) and has no runtime dependencies. That doesn’t mean new features won’t be added over time, but the benefits of more code must be weighed against the benefits of less:
|
70
70
|
|
71
71
|
* Less code is easier to maintain.
|
72
72
|
* Less code means fewer bugs.
|
@@ -76,9 +76,7 @@ In the immortal words of [Ezra Zygmuntowicz](https://github.com/ezmobius) and hi
|
|
76
76
|
|
77
77
|
> No code is faster than no code.
|
78
78
|
|
79
|
-
The
|
80
|
-
|
81
|
-
The tests for the previous version of this library executed in about 2 seconds. That sounds pretty fast until you see that tests for this library run in 2 hundredths of a second. This means you can automatically run the tests any time you write a file and receive immediate feedback. For such of workflows, 2 seconds feels painfully slow.
|
79
|
+
The tests for the previous version of this library executed in about 2 seconds. That sounds pretty fast until you see that tests for this library run in one-twentieth of a second. This means you can automatically run the tests any time you write a file and receive immediate feedback. For such of workflows, 2 seconds feels painfully slow.
|
82
80
|
|
83
81
|
This code is not littered with comments that are intended to generate documentation. Rather, this code is intended to be simple enough to serve as its own documentation. If you want to understand how something works, don’t read the documentation—it might be wrong—read the code. The code is always right.
|
84
82
|
|
@@ -103,6 +101,8 @@ Many thanks to our sponsors (listed in order of when they sponsored this project
|
|
103
101
|
<a href="https://betterstack.com"><img src="https://raw.githubusercontent.com/sferik/x-ruby/main/sponsor_logos/better_stack.svg" alt="Better Stack" width="200" align="middle"></a>
|
104
102
|
<img src="https://raw.githubusercontent.com/sferik/x-ruby/main/sponsor_logos/spacer.png" width="20" align="middle">
|
105
103
|
<a href="https://sentry.io"><img src="https://raw.githubusercontent.com/sferik/x-ruby/main/sponsor_logos/sentry.svg" alt="Sentry" width="200" align="middle"></a>
|
104
|
+
<img src="https://raw.githubusercontent.com/sferik/x-ruby/main/sponsor_logos/spacer.png" width="20" align="middle">
|
105
|
+
<a href="https://ifttt.com"><img src="https://raw.githubusercontent.com/sferik/x-ruby/main/sponsor_logos/ifttt.svg" alt="IFTTT" width="200" align="middle"></a>
|
106
106
|
|
107
107
|
## Development
|
108
108
|
|
data/lib/x/authenticator.rb
CHANGED
data/lib/x/cgi.rb
CHANGED
data/lib/x/client.rb
CHANGED
data/lib/x/connection.rb
CHANGED
data/lib/x/errors/http_error.rb
CHANGED
data/lib/x/media_uploader.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "securerandom"
|
2
|
+
require "tmpdir"
|
2
3
|
|
3
4
|
module X
|
4
|
-
# Helper module for uploading images and videos
|
5
5
|
module MediaUploader
|
6
6
|
extend self
|
7
7
|
|
@@ -72,7 +72,7 @@ module X
|
|
72
72
|
File.open(file_path, "rb") do |f|
|
73
73
|
while (chunk = f.read(chunk_size))
|
74
74
|
file_paths << "#{Dir.mktmpdir}/x#{format("%03d", file_number += 1)}".tap do |path|
|
75
|
-
File.
|
75
|
+
File.binwrite(path, chunk)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
data/lib/x/redirect_handler.rb
CHANGED
data/lib/x/request_builder.rb
CHANGED
data/lib/x/response_parser.rb
CHANGED
data/lib/x/version.rb
CHANGED
data/sig/x.rbs
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: x
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Berlin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
requirements: []
|
84
|
-
rubygems_version: 3.4.
|
84
|
+
rubygems_version: 3.4.22
|
85
85
|
signing_key:
|
86
86
|
specification_version: 4
|
87
87
|
summary: A Ruby interface to the X API.
|