tuxedo-r 0.0.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 +7 -0
- data/LICENSE +21 -0
- data/README.md +82 -0
- data/exe/tuxedo +21 -0
- data/lib/tuxedo/r/native_platforms.rb +25 -0
- data/lib/tuxedo/r/version.rb +7 -0
- data/lib/tuxedo/r.rb +86 -0
- metadata +56 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d3ef4978fb6767194f84dfe48a5feb20ae18a6eade2ed2a1bc79b4db6da8d5be
|
|
4
|
+
data.tar.gz: d5187f0bc4e71f4e20eedf688e06e7b0753c884e6390b2e40a764e0cf0773430
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f4e6c091ed2132834bb4f988efd112b924ab6817858ef873837e5620ff352795569b2598deeed124e34e0a18e2ea9b2e240b9d56d9920c27ea4a77edf0bfd50c
|
|
7
|
+
data.tar.gz: 6ad7f399013bfe7eaac961d7faee13a926895bfc1e829b0a2f0b8da7eb61bcf9242f2f84097194700c68cd9bba85e7709f90693330eabc438abb9c719b176dba
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Danimar Ribeiro
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# tuxedo-r
|
|
2
|
+
|
|
3
|
+
[Tuxedo](https://github.com/danimaribeiro/tuxedo) is a fast Ruby code
|
|
4
|
+
formatter written in Rust. `tuxedo-r` is the Ruby gem that installs it: each
|
|
5
|
+
platform-specific gem carries a precompiled native binary, so no Rust
|
|
6
|
+
toolchain is needed. The name is deliberately ambiguous: the "R" stands for
|
|
7
|
+
both **Ruby** (the language it formats, and the language of this wrapper) and
|
|
8
|
+
**Rust** (the language the `tuxedo` binary itself is written in).
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
group :development, :test do
|
|
14
|
+
gem "tuxedo-r", require: false
|
|
15
|
+
end
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
bundle install
|
|
20
|
+
bundle exec tuxedo format --check .
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Without Bundler:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
gem install tuxedo-r
|
|
27
|
+
tuxedo format .
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
RubyGems automatically resolves and installs the platform-specific gem that
|
|
31
|
+
matches your machine (for example `tuxedo-r-x86_64-linux`). This release
|
|
32
|
+
ships a precompiled binary for x86_64 Linux (glibc) only; on any other
|
|
33
|
+
platform, see [Unsupported platforms](#unsupported-platforms). The
|
|
34
|
+
[documentation](https://danimar.dev/tuxedo/docs.html) covers what
|
|
35
|
+
the formatter does, its command line and its configuration.
|
|
36
|
+
|
|
37
|
+
### Requirements
|
|
38
|
+
|
|
39
|
+
Ruby 3.1 or newer and RubyGems 3.3.22 or newer (`gem update --system`).
|
|
40
|
+
`required_ruby_version` is the Ruby that runs the `tuxedo` shim, not the
|
|
41
|
+
Ruby syntax `tuxedo` accepts. On Alpine and other musl hosts, RubyGems
|
|
42
|
+
older than 3.3.22 resolves the glibc gem, whose binary will not run.
|
|
43
|
+
|
|
44
|
+
### Unsupported platforms
|
|
45
|
+
|
|
46
|
+
If a precompiled binary isn't available for your platform yet, set
|
|
47
|
+
`TUXEDO_INSTALL_DIR` to a directory containing a `tuxedo` executable (for
|
|
48
|
+
example, one you built yourself from the
|
|
49
|
+
[Rust crate](https://github.com/danimaribeiro/tuxedo)):
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
export TUXEDO_INSTALL_DIR=/path/to/tuxedo/target/release
|
|
53
|
+
bundle exec tuxedo format --check .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## How it works
|
|
57
|
+
|
|
58
|
+
- The `tuxedo-r` gem itself ships no binary — it's the platform-independent
|
|
59
|
+
"meta" gem.
|
|
60
|
+
- `tuxedo-r-<platform>` gems (built by `rake package`, see
|
|
61
|
+
[`rakelib/package.rake`](https://github.com/danimaribeiro/tuxedo/blob/main/ruby/rakelib/package.rake))
|
|
62
|
+
each bundle a `tuxedo` binary compiled for that target triple, under
|
|
63
|
+
`exe/<platform>/tuxedo`.
|
|
64
|
+
- The `exe/tuxedo` script installed onto your `PATH` is plain Ruby (RubyGems
|
|
65
|
+
requires gem executables to be Ruby scripts) — it just finds the right
|
|
66
|
+
binary for the current platform and `exec`s it, forwarding all arguments and
|
|
67
|
+
the exit status.
|
|
68
|
+
|
|
69
|
+
## Development
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cd ruby
|
|
73
|
+
bundle install
|
|
74
|
+
bundle exec rake test
|
|
75
|
+
|
|
76
|
+
# Build the tuxedo binary for every supported platform (requires `cross`
|
|
77
|
+
# for cross-compiled targets: cargo install cross)
|
|
78
|
+
bundle exec rake build:all
|
|
79
|
+
|
|
80
|
+
# Package all platform gems into pkg/
|
|
81
|
+
bundle exec rake package
|
|
82
|
+
```
|
data/exe/tuxedo
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# RubyGems executable shims assume a gem's executables are Ruby scripts, so
|
|
5
|
+
# this file exists purely to locate and exec the real, compiled `tuxedo`
|
|
6
|
+
# binary for the current platform.
|
|
7
|
+
|
|
8
|
+
require "tuxedo/r"
|
|
9
|
+
|
|
10
|
+
begin
|
|
11
|
+
command = [Tuxedo::R.executable, *ARGV]
|
|
12
|
+
if Gem.win_platform?
|
|
13
|
+
# `exec` can fail to locate the binary on Windows; `system` is more reliable there.
|
|
14
|
+
system(*command, exception: true)
|
|
15
|
+
else
|
|
16
|
+
exec(*command)
|
|
17
|
+
end
|
|
18
|
+
rescue Tuxedo::R::UnsupportedPlatformException, Tuxedo::R::ExecutableNotFoundException => e
|
|
19
|
+
warn "ERROR: #{e.message}"
|
|
20
|
+
exit 1
|
|
21
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Tuxedo
|
|
4
|
+
module R
|
|
5
|
+
module NativePlatforms
|
|
6
|
+
# rubygems platform name => rust target triple
|
|
7
|
+
#
|
|
8
|
+
# Keep this in sync with the build matrix in
|
|
9
|
+
# tuxedo/.github/workflows/release.yml
|
|
10
|
+
TARGETS = {
|
|
11
|
+
"arm64-darwin" => "aarch64-apple-darwin",
|
|
12
|
+
"x86_64-darwin" => "x86_64-apple-darwin",
|
|
13
|
+
"x86_64-linux" => "x86_64-unknown-linux-gnu",
|
|
14
|
+
"aarch64-linux" => "aarch64-unknown-linux-gnu",
|
|
15
|
+
"x86_64-linux-musl" => "x86_64-unknown-linux-musl",
|
|
16
|
+
"aarch64-linux-musl" => "aarch64-unknown-linux-musl",
|
|
17
|
+
"x64-mingw-ucrt" => "x86_64-pc-windows-msvc",
|
|
18
|
+
}.freeze
|
|
19
|
+
|
|
20
|
+
def self.binary_name(platform)
|
|
21
|
+
platform.to_s.include?("mingw") ? "tuxedo.exe" : "tuxedo"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/tuxedo/r.rb
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "r/version"
|
|
4
|
+
require_relative "r/native_platforms"
|
|
5
|
+
|
|
6
|
+
module Tuxedo
|
|
7
|
+
# The "R" is deliberately ambiguous: this is the Ruby wrapper around a
|
|
8
|
+
# Rust-compiled `tuxedo` binary.
|
|
9
|
+
module R
|
|
10
|
+
DEFAULT_DIR = File.expand_path(File.join(__dir__, "..", "..", "exe"))
|
|
11
|
+
GEM_NAME = "tuxedo-r"
|
|
12
|
+
|
|
13
|
+
# Raised when the host platform has no precompiled tuxedo binary published.
|
|
14
|
+
class UnsupportedPlatformException < StandardError
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Raised when the tuxedo executable could not be found where expected.
|
|
18
|
+
class ExecutableNotFoundException < StandardError
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Raised when TUXEDO_INSTALL_DIR is set but does not exist.
|
|
22
|
+
class DirectoryNotFoundException < StandardError
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class << self
|
|
26
|
+
# e.g. "x86_64-linux"; on Alpine, `version` carries the musl
|
|
27
|
+
# distinction, without which this would misname the host.
|
|
28
|
+
def platform
|
|
29
|
+
[:cpu, :os, :version].map { |m| Gem::Platform.local.send(m) }.compact.join("-")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Absolute path to the tuxedo binary that should be executed on this host.
|
|
33
|
+
#
|
|
34
|
+
# Resolution order:
|
|
35
|
+
# 1. TUXEDO_INSTALL_DIR env var, if set (escape hatch for local dev / CI
|
|
36
|
+
# builds that want to use a freshly-built binary instead of the one
|
|
37
|
+
# vendored into the installed platform gem).
|
|
38
|
+
# 2. The platform-specific binary bundled into the matching
|
|
39
|
+
# tuxedo-r-<platform> gem.
|
|
40
|
+
def executable(exe_path: DEFAULT_DIR)
|
|
41
|
+
tuxedo_install_dir = ENV["TUXEDO_INSTALL_DIR"]
|
|
42
|
+
|
|
43
|
+
if tuxedo_install_dir
|
|
44
|
+
unless File.directory?(tuxedo_install_dir)
|
|
45
|
+
raise DirectoryNotFoundException, <<~MESSAGE
|
|
46
|
+
TUXEDO_INSTALL_DIR is set to #{tuxedo_install_dir}, but that directory does not exist.
|
|
47
|
+
MESSAGE
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
warn "NOTE: using TUXEDO_INSTALL_DIR to find the tuxedo executable: #{tuxedo_install_dir}"
|
|
51
|
+
exe_file = File.expand_path(File.join(tuxedo_install_dir, "tuxedo"))
|
|
52
|
+
else
|
|
53
|
+
if NativePlatforms::TARGETS.keys.none? { |p| Gem::Platform.match_gem?(Gem::Platform.new(p), GEM_NAME) }
|
|
54
|
+
raise UnsupportedPlatformException, <<~MESSAGE
|
|
55
|
+
#{GEM_NAME} does not have a precompiled binary for the #{platform} platform.
|
|
56
|
+
See https://github.com/danimaribeiro/tuxedo/tree/main/ruby#unsupported-platforms for options.
|
|
57
|
+
MESSAGE
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
exe_file = Dir.glob(File.expand_path(File.join(exe_path, "*", "tuxedo{,.exe}"))).find do |f|
|
|
61
|
+
Gem::Platform.match_gem?(Gem::Platform.new(File.basename(File.dirname(f))), GEM_NAME)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
if exe_file.nil? || !File.exist?(exe_file)
|
|
66
|
+
raise ExecutableNotFoundException, <<~MESSAGE
|
|
67
|
+
Cannot find the tuxedo executable for #{platform} in #{exe_path}.
|
|
68
|
+
|
|
69
|
+
If you're using Bundler, make sure your lockfile includes this platform:
|
|
70
|
+
|
|
71
|
+
bundle lock --add-platform #{platform}
|
|
72
|
+
bundle install
|
|
73
|
+
|
|
74
|
+
If you're still seeing this after that, check whether
|
|
75
|
+
`bundle config force_ruby_platform` is set to `true`.
|
|
76
|
+
|
|
77
|
+
This version of #{GEM_NAME} may not ship a binary for #{platform} at all; see
|
|
78
|
+
https://github.com/danimaribeiro/tuxedo/tree/main/ruby#unsupported-platforms for options.
|
|
79
|
+
MESSAGE
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
exe_file
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: tuxedo-r
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Danimar Ribeiro
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-09-24 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: |
|
|
14
|
+
Tuxedo is a Ruby code formatter written in Rust, distributed as a
|
|
15
|
+
precompiled native binary wrapped in this Ruby gem (the "R" is both Ruby and
|
|
16
|
+
Rust). It is `bundle exec`-compatible, and a linter is planned.
|
|
17
|
+
email:
|
|
18
|
+
executables:
|
|
19
|
+
- tuxedo
|
|
20
|
+
extensions: []
|
|
21
|
+
extra_rdoc_files: []
|
|
22
|
+
files:
|
|
23
|
+
- LICENSE
|
|
24
|
+
- README.md
|
|
25
|
+
- exe/tuxedo
|
|
26
|
+
- lib/tuxedo/r.rb
|
|
27
|
+
- lib/tuxedo/r/native_platforms.rb
|
|
28
|
+
- lib/tuxedo/r/version.rb
|
|
29
|
+
homepage: https://github.com/danimaribeiro/tuxedo
|
|
30
|
+
licenses:
|
|
31
|
+
- MIT
|
|
32
|
+
metadata:
|
|
33
|
+
documentation_uri: https://danimar.dev/tuxedo/docs.html
|
|
34
|
+
source_code_uri: https://github.com/danimaribeiro/tuxedo
|
|
35
|
+
changelog_uri: https://github.com/danimaribeiro/tuxedo/blob/main/CHANGELOG.md
|
|
36
|
+
rubygems_mfa_required: 'true'
|
|
37
|
+
post_install_message:
|
|
38
|
+
rdoc_options: []
|
|
39
|
+
require_paths:
|
|
40
|
+
- lib
|
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
42
|
+
requirements:
|
|
43
|
+
- - ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: 3.1.0
|
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
- - ">="
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: 3.3.22
|
|
51
|
+
requirements: []
|
|
52
|
+
rubygems_version: 3.5.22
|
|
53
|
+
signing_key:
|
|
54
|
+
specification_version: 4
|
|
55
|
+
summary: 'A self-contained `tuxedo` executable: a fast Ruby formatter written in Rust.'
|
|
56
|
+
test_files: []
|