lz4rip 0.1.2 → 0.2.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: 57c8a45c7f389dd4f6b324e147fcbf7cbfec93ca2746226120ea3290741ba761
4
- data.tar.gz: b651348f2fce6405b8dabdb7208359eebdd28565a44bf9948a1ca4dcc1317e62
3
+ metadata.gz: 2f66c12c967a06a207c9e8e742fac306280863bf655bd7b4318a2265d08c1cdf
4
+ data.tar.gz: be95ea7eb336509e7077737f0d4703dc500931f1608fdc2f52dc3b170904b16d
5
5
  SHA512:
6
- metadata.gz: 170650658b63413bd2b03659b168a9f77b5e434db3a8cbca52a7155282e5b7f7b0e16123e6ccbcb4aa48e15cc13d17993f902477a501cb80100b3f3375b14add
7
- data.tar.gz: f8b9b5c1fa3f9fdc043af195137999f8d301ae2b4b984a4cc780f190dbc49dad21256fbf5a056804b86f5fea56c0c3fc7e97602ae384765bcb35afd88bb91f28
6
+ metadata.gz: 2fc02b8f797989ca99f23e97658dab9442c4fbb70ab03ff3436a73b5026b78d20c1bbf240e4febba0baed905863b225655f03c627d6db4ddee128224b419c82c
7
+ data.tar.gz: 92b2aa66f6282317c5b805f77cf47715288c8debc013520e5dffc78fb7d9c102f62f330906042b062b93aa2104ca21c5b1b0830edd87852b585f6451f4146efd
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.2.0] - 2026-08-07
6
+
7
+ - Release the Ruby GVL around large frame/block compression and frame
8
+ decompression calls.
9
+ - Update the `lz4rip` crate dependency to 0.11.3.
10
+ - Replace Magnus with direct `rb-sys` bindings, add TruffleRuby build support,
11
+ and lower the Ruby requirement to 3.4.
12
+ - Add `max_decompressed_size:` to `Lz4rip::FrameCodec#decompress`, with the
13
+ cap enforced across concatenated frame output.
14
+ - Add RubyDoc metadata and move API reference details from `README.md` into
15
+ YARD comments.
16
+
5
17
  ## [0.1.2] - 2026-08-05
6
18
 
7
19
  - Update `lz4rip` crate dependency from 0.11.1 to 0.11.2.
data/Cargo.lock CHANGED
@@ -108,16 +108,15 @@ dependencies = [
108
108
  name = "lz4rip"
109
109
  version = "0.1.2"
110
110
  dependencies = [
111
- "lz4rip 0.11.2",
112
- "magnus",
111
+ "lz4rip 0.11.3",
113
112
  "rb-sys",
114
113
  ]
115
114
 
116
115
  [[package]]
117
116
  name = "lz4rip"
118
- version = "0.11.2"
117
+ version = "0.11.3"
119
118
  source = "registry+https://github.com/rust-lang/crates.io-index"
120
- checksum = "2cb69a12f600139f42d2c63d929b60733582f8bb706da4d2cd951e5beb6c649c"
119
+ checksum = "55bde261679fd1d14bcae126094d7afb98c63c1a5018d0718741b658b686e950"
121
120
  dependencies = [
122
121
  "lz4rip-core",
123
122
  "lz4rip-decode",
@@ -149,29 +148,6 @@ dependencies = [
149
148
  "lz4rip-core",
150
149
  ]
151
150
 
152
- [[package]]
153
- name = "magnus"
154
- version = "0.8.2"
155
- source = "registry+https://github.com/rust-lang/crates.io-index"
156
- checksum = "3b36a5b126bbe97eb0d02d07acfeb327036c6319fd816139a49824a83b7f9012"
157
- dependencies = [
158
- "magnus-macros",
159
- "rb-sys",
160
- "rb-sys-env",
161
- "seq-macro",
162
- ]
163
-
164
- [[package]]
165
- name = "magnus-macros"
166
- version = "0.8.0"
167
- source = "registry+https://github.com/rust-lang/crates.io-index"
168
- checksum = "47607461fd8e1513cb4f2076c197d8092d921a1ea75bd08af97398f593751892"
169
- dependencies = [
170
- "proc-macro2",
171
- "quote",
172
- "syn",
173
- ]
174
-
175
151
  [[package]]
176
152
  name = "memchr"
177
153
  version = "2.8.3"
@@ -236,12 +212,6 @@ dependencies = [
236
212
  "syn",
237
213
  ]
238
214
 
239
- [[package]]
240
- name = "rb-sys-env"
241
- version = "0.2.3"
242
- source = "registry+https://github.com/rust-lang/crates.io-index"
243
- checksum = "cca7ad6a7e21e72151d56fe2495a259b5670e204c3adac41ee7ef676ea08117a"
244
-
245
215
  [[package]]
246
216
  name = "regex"
247
217
  version = "1.13.1"
@@ -277,12 +247,6 @@ version = "2.1.3"
277
247
  source = "registry+https://github.com/rust-lang/crates.io-index"
278
248
  checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
279
249
 
280
- [[package]]
281
- name = "seq-macro"
282
- version = "0.3.6"
283
- source = "registry+https://github.com/rust-lang/crates.io-index"
284
- checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc"
285
-
286
250
  [[package]]
287
251
  name = "shell-words"
288
252
  version = "1.1.1"
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # lz4rip Ractor-safe LZ4 for Ruby
1
+ # lz4rip: Ractor-safe LZ4 for Ruby
2
2
 
3
3
  [![CI](https://github.com/paddor/lz4rip-rb/actions/workflows/ci.yml/badge.svg)](https://github.com/paddor/lz4rip-rb/actions/workflows/ci.yml)
4
4
  [![Gem Version](https://img.shields.io/gem/v/lz4rip?color=e9573f)](https://rubygems.org/gems/lz4rip)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
- [![Ruby](https://img.shields.io/badge/Ruby-%3E%3D%204.0-CC342D?logo=ruby&logoColor=white)](https://www.ruby-lang.org)
6
+ [![Ruby](https://img.shields.io/badge/Ruby-%3E%3D%203.4-CC342D?logo=ruby&logoColor=white)](https://www.ruby-lang.org)
7
7
 
8
8
  Ruby bindings for [lz4rip](https://crates.io/crates/lz4rip), a pure-Rust LZ4
9
- implementation. Built with [magnus](https://github.com/matsadler/magnus) and
10
- declared Ractor-safe so you can compress from any Ractor without a global lock.
9
+ implementation. Built as an `rb-sys` native extension and declared Ractor-safe
10
+ so you can compress from any Ractor without a global lock.
11
11
 
12
12
  ## Features
13
13
 
@@ -20,7 +20,7 @@ declared Ractor-safe so you can compress from any Ractor without a global lock.
20
20
 
21
21
  ## Install
22
22
 
23
- Requires Ruby >= 4.0 and a Rust toolchain (for building the native extension):
23
+ Requires Ruby >= 3.4 and a Rust toolchain (for building the native extension):
24
24
 
25
25
  ```sh
26
26
  gem install lz4rip
@@ -42,6 +42,7 @@ require "lz4rip"
42
42
  codec = Lz4rip::FrameCodec.new
43
43
  compressed = codec.compress("hello world " * 1000)
44
44
  original = codec.decompress(compressed)
45
+ bounded = codec.decompress(compressed, max_decompressed_size: 12_000)
45
46
  ```
46
47
 
47
48
  ### Block codec (raw LZ4 blocks)
@@ -78,6 +79,9 @@ codec = Lz4rip::BlockCodec.new(dict: dict)
78
79
 
79
80
  ### Ractor safety
80
81
 
82
+ On Ruby VMs without Ractor support, the codecs still work normally; the
83
+ Ractor-specific guarantees and examples do not apply.
84
+
81
85
  ```ruby
82
86
  codec = Lz4rip::FrameCodec.new
83
87
 
@@ -93,35 +97,9 @@ end
93
97
  ractors.each { |r| p r.value } # => :ok, :ok, :ok, :ok
94
98
  ```
95
99
 
96
- ## API
97
-
98
- | Class / Module | Method | Description |
99
- |---|---|---|
100
- | `Lz4rip::FrameCodec` | `.new(dict: nil)` | Create a frame codec, optionally with a `Dictionary` or raw `String` dict |
101
- | | `#compress(string)` | Compress to LZ4 frame |
102
- | | `#decompress(string)` | Decompress an LZ4 frame |
103
- | | `#has_dict?` | Whether a dictionary is loaded |
104
- | | `#id` | Dictionary ID (nil without dict) |
105
- | | `#size` | Dictionary size in bytes (0 without dict) |
106
- | `Lz4rip::BlockCodec` | `.new(dict: nil)` | Create a block codec, optionally with a dict `String` |
107
- | | `#compress(string)` | Compress to raw LZ4 block |
108
- | | `#decompress(string, decompressed_size:)` | Decompress a raw LZ4 block |
109
- | | `#has_dict?` | Whether a dictionary is loaded |
110
- | | `#size` | Internal state size in bytes |
111
- | `Lz4rip::Dictionary` | `.new(bytes:, id: auto)` | Immutable dictionary value object |
112
- | | `#bytes` | Frozen binary dict bytes |
113
- | | `#id` | 32-bit dictionary ID |
114
- | | `#size` | Dictionary size in bytes |
115
- | `Lz4rip::DictTrainer` | `.new(max_dict_size)` | Create a trainer (capped at 65535) |
116
- | | `#add_sample(string)` | Feed a training sample |
117
- | | `#train` | Consume the trainer, return dict bytes |
118
- | | `#sample_count` | Number of accepted samples |
119
- | | `#total_bytes` | Total bytes of accepted samples |
120
- | | `#trained?` | Whether `#train` has been called |
121
- | | `#max_dict_size` | Configured max dict size |
122
- | `Lz4rip` | `.compress_bound(size)` | Max compressed output size for a given input size |
123
- | | `.block_stream_size` | Internal compressor heap size |
124
- | `Lz4rip::DecompressError` | | Raised on decompression failure (subclass of `StandardError`) |
100
+ ## Documentation
101
+
102
+ Reference: <https://rubydoc.info/gems/lz4rip>
125
103
 
126
104
  ## License
127
105
 
@@ -2,14 +2,14 @@
2
2
  name = "lz4rip"
3
3
  version = "0.1.2"
4
4
  edition = "2021"
5
+ build = "build.rs"
5
6
 
6
7
  [lib]
7
8
  name = "lz4rip"
8
9
  crate-type = ["cdylib", "rlib"]
9
10
 
10
11
  [dependencies]
11
- lz4 = { version = "0.11.2", package = "lz4rip" }
12
- magnus = "0.8"
12
+ lz4 = { version = "0.11.3", package = "lz4rip" }
13
13
  rb-sys = "0.9"
14
14
 
15
15
  [build-dependencies]
@@ -0,0 +1,23 @@
1
+ use std::process::Command;
2
+
3
+ fn main() {
4
+ println!("cargo:rerun-if-env-changed=RUBY");
5
+ println!("cargo:rustc-check-cfg=cfg(ruby_engine, values(\"mri\", \"truffleruby\"))");
6
+
7
+ let ruby = std::env::var("RUBY").unwrap_or_else(|_| "ruby".to_string());
8
+ let output = Command::new(&ruby)
9
+ .arg("-rrbconfig")
10
+ .arg("-e")
11
+ .arg("print RbConfig::CONFIG.fetch('ruby_install_name')")
12
+ .output()
13
+ .unwrap_or_else(|err| panic!("failed to run {ruby}: {err}"));
14
+
15
+ if !output.status.success() {
16
+ panic!("failed to query Ruby engine with {ruby}");
17
+ }
18
+
19
+ match String::from_utf8_lossy(&output.stdout).trim() {
20
+ "truffleruby" => println!("cargo:rustc-cfg=ruby_engine=\"truffleruby\""),
21
+ _ => println!("cargo:rustc-cfg=ruby_engine=\"mri\""),
22
+ }
23
+ }