https://github.com/artichoke/ruby-file-expand-path
📂 Rust port of path normalization from MRI Ruby.
https://github.com/artichoke/ruby-file-expand-path
artichoke ffi filesystem ruby ruby-language rust rust-crate windows
Last synced: 6 months ago
JSON representation
📂 Rust port of path normalization from MRI Ruby.
- Host: GitHub
- URL: https://github.com/artichoke/ruby-file-expand-path
- Owner: artichoke
- License: mit
- Created: 2021-08-04T01:09:52.000Z (about 4 years ago)
- Default Branch: trunk
- Last Pushed: 2025-04-01T00:25:17.000Z (6 months ago)
- Last Synced: 2025-04-01T01:28:24.058Z (6 months ago)
- Topics: artichoke, ffi, filesystem, ruby, ruby-language, rust, rust-crate, windows
- Language: Ruby
- Homepage: https://artichoke.github.io/ruby-file-expand-path/ruby_file_expand_path/
- Size: 2.26 MB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: COPYING
Awesome Lists containing this project
README
# ruby-file-expand-path
[](https://github.com/artichoke/ruby-file-expand-path/actions)
[](https://discord.gg/QCe2tp2)
[](https://twitter.com/artichokeruby)
[](https://crates.io/crates/ruby-file-expand-path)
[](https://docs.rs/ruby-file-expand-path)
[](https://artichoke.github.io/ruby-file-expand-path/ruby_file_expand_path/)Implements file path expansion and normalization routines from MRI Ruby.
> A new function (`normalize` or `make_absolute` or something, bikeshed away)
> should be added that will turn a relative path into an absolute path without
> touching the filesystem. ([rust-lang/rust#59117][rust-59117]).[rust-59117]: https://github.com/rust-lang/rust/issues/59117
This crate normalizes and absolutizes paths according to the logic in Ruby
v3.0.2 for [POSIX][mri-3.0.2-posix] and [Win32][mri-3.0.2-win32].[mri-3.0.2-posix]: https://github.com/ruby/ruby/blob/v3_0_2/file.c#L3690-L4037
[mri-3.0.2-win32]:
https://github.com/ruby/ruby/blob/v3_0_2/win32/file.c#L276-L616## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
ruby-file-expand-path = "0.1.0"
```Then normalize paths like:
```rust
assert_eq!(
ruby_file_expand_path::expand("/home/artichoke/scripts/../run.sh"),
Ok(b"/home/artichoke/run.sh")
);
```## License
`ruby-file-expand-path` is licensed under the [MIT License](LICENSE) (c) Ryan
Lopopolo.`ruby-file-expand-path` is derived from `ruby` @ [v3.0.2][mri-3.0.2]. `ruby` is
dual licensed under the [Ruby License or 2-clause BSD
License][mri-3.0.2-license] Copyright (c) Yukihiro Matsumoto \.
A copy of the Ruby License can be found in [`COPYING`](COPYING) in this
repository.[mri-3.0.2]: https://github.com/ruby/ruby/tree/v3_0_2
[mri-3.0.2-license]: https://github.com/ruby/ruby/blob/v3_0_2/COPYING