Popularity
4.1
-
Activity
1.7
Growing
10
3
0

Programming language: Crystal
Tags: Compression    
Latest version: v0.1.1

brotli.cr alternatives and similar shards

Based on the "Compression" category

Do you think we are missing an alternative of brotli.cr or a related project?

Add another 'Compression' Shard

README

Crystal Brotli

Crystal bindings to the Brotli compression library.

Installation

  1. Add the dependency to your shard.yml:
   dependencies:
     brotli:
       github: naqvis/brotli.cr
  1. Run shards install

Usage

require "brotli"

brotli shard provides both Brotli::Reader and Brotli::Writer , as well as Brotli#decode and Brotli#encode methods for quick usage.

Refer to specs for sample usage.

Example: decompress an brotli file

require "brotli"

string = File.open("file.br") do |file|
   Brotli::Reader.open(file) do |brotli|
     brotli.gets_to_end
   end
end
pp string

Example: compress to brotli compression format

require "brotli"

File.write("file.txt", "abcd")

File.open("./file.txt", "r") do |input_file|
  File.open("./file.br", "w") do |output_file|
    Brotli::Writer.open(output_file) do |brotli|
      IO.copy(input_file, brotli)
    end
  end
end

Development

To run all tests:

crystal spec

Contributing

  1. Fork it (https://github.com/naqvis/brotli.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors