Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add "zstd-ruby/stream_writer" and "zstd-ruby/stream_reader" loading #85

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,45 @@ Zstd.read_skippable_frame(compressed_data_with_skippable_frame)
# => "sample data"
```

### Stream Writer and Reader Wrapper
** EXPERIMENTAL *

* These features are experimental and may be subject to API changes in future releases.
* There may be performance and compatibility issues, so extensive testing is required before production use.
* If you have any questions, encounter bugs, or have suggestions, please report them via [GitHub issues](https://github.com/SpringMT/zstd-ruby/issues).

#### Zstd::StreamWriter

```
require 'stringio'
require 'zstd-ruby'

io = StringIO.new
stream = Zstd::StreamWriter.new(io)
stream.write("abc")
stream.finish

io.rewind
# Retrieve the compressed data
compressed_data = io.read
```

#### Zstd::StreamReader

```
require 'stringio'
require 'zstd-ruby' # Add the appropriate require statement if necessary

io = StringIO.new(compressed_data)
reader = Zstd::StreamReader.new(io)

# Read and output the decompressed data
puts reader.read(10) # 'abc'
puts reader.read(10) # 'def'
puts reader.read(10) # '' (end of data)
```


## JRuby
This gem does not support JRuby.

Expand Down
2 changes: 2 additions & 0 deletions lib/zstd-ruby.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require "zstd-ruby/version"
require "zstd-ruby/zstdruby"
require "zstd-ruby/stream_writer"
require "zstd-ruby/stream_reader"

module Zstd
end
2 changes: 0 additions & 2 deletions spec/zstd-ruby-stream_reader_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
require "spec_helper"
require 'zstd-ruby'
require 'zstd-ruby/stream_writer'
require 'zstd-ruby/stream_reader'
require 'pry'

RSpec.describe Zstd::StreamReader do
Expand Down
1 change: 0 additions & 1 deletion spec/zstd-ruby-stream_writer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require "spec_helper"
require 'zstd-ruby'
require 'zstd-ruby/stream_writer'

RSpec.describe Zstd::StreamWriter do
describe 'write' do
Expand Down