Comandante/Zstd
An add-on for Comandante to allow for zstd reading/writing.
Installation
- Add the dependency to your
shard.yml
:
dependencies:
comandante-zstd:
github: tghaleb/comandante-zstd
- Run
shards install
Usage
require "comandante-zstd"
This is actually a wrapper around zstd.cr.
To write a string, or any type that has a to_slice
method to file in
one go,
str = "test"
Helper.write_zstd(str, file)
To Write Strings to a file using a block, and setting compressing level,
Helper.write_zstd(file, level: 19) do |io|
io.print "test1"
io.print "test2"
end
To read a file into a string,
x = Helper.read_zstd(file)
To read line by line
results = Array(String).new
Helper.read_zstd(file) do |x|
results << x
end
module Comandante::Helper
Some helper functions