Crystal bindings to the Brotli compression library.
-
Add the dependency to your
shard.yml
:dependencies: brotli: github: naqvis/brotli.cr
-
Run
shards install
require "brotli"
brotli
shard provides both Compress::Brotli::Reader
and Compress::Brotli::Writer
, as well as Compress::Brotli#decode
and Compress::Brotli#encode
methods for quick usage.
Refer to specs
for sample usage.
require "brotli"
string = File.open("file.br") do |file|
Compress::Brotli::Reader.open(file) do |brotli|
brotli.gets_to_end
end
end
pp string
require "brotli"
File.write("file.txt", "abcd")
File.open("./file.txt", "r") do |input_file|
File.open("./file.br", "w") do |output_file|
Compress::Brotli::Writer.open(output_file) do |brotli|
IO.copy(input_file, brotli)
end
end
end
To run all tests:
crystal spec
- Fork it (https://github.com/naqvis/brotli.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Ali Naqvi - creator and maintainer