Skip to content

Commit

Permalink
Merge pull request #85 from SpringMT/feature/add-stream-wrpper-loadin…
Browse files Browse the repository at this point in the history
…g-and-documents

feat: add "zstd-ruby/stream_writer" and "zstd-ruby/stream_reader" loading
  • Loading branch information
SpringMT authored Apr 26, 2024
2 parents 1f4340f + 3cdb57b commit 7e73b59
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
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

0 comments on commit 7e73b59

Please sign in to comment.