snappy
Version, currently 0.2.09 versions
github.com/naqvis/snappy
Snappy compression format reader/writer for Crystal
22 stars
3 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
snappy:
github: naqvis/snappy
version: ~> 0.2.0Then run:
shards installshard.yml
- Crystal
>= 0.36.0- License
- MIT
- Author
- Ali Naqvi
Dependencies
This version declares no dependencies.
README
Crystal Snappy
Pure Crystal implementation of Snappy compression format. This implementation supports more common case Snappy Framing Format.
Installation
-
Add the dependency to your
shard.yml:dependencies: snappy: github: naqvis/snappy -
Run
shards install
Usage
require "snappy"
Module provides both Compress::Snappy::Reader and Compress::Snappy::Writer for use with streams like IO and/or files. It also provides Compress::Snappy#decode and Compress::Snappy#encode for uncompressing and compressing block formats.
Example: decompress a snappy file
require "snappy"
File.write("file.sz", Bytes[255, 6, 0, 0, 115, 78, 97, 80, 112, 89, 1, 8, 0, 0, 104, 16, 130, 162, 97, 98, 99, 100])
string = File.open("file.sz") do |file|
Compress::Snappy::Reader.open(file) do |sz|
sz.gets_to_end
end
end
string # => "abcd"
Example: compress a file to snappy format
require "snappy"
File.write("file.txt", "abcd")
File.open("./file.txt", "r") do |input_file|
File.open("./file.sz", "w") do |output_file|
Compress::Snappy::Writer.open(output_file) do |sz|
IO.copy(input_file, sz)
end
end
end
Refer to specs for usage examples.
Development
To run all tests:
crystal spec
Contributing
- Fork it (https://github.com/naqvis/snappy/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
Contributors
- Ali Naqvi - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.2.0- Tagged
- Aug 20, 2026
- Commit
c6a7d7ae8435- Crystal
>= 0.36.0- Indexed
- yes
Dependents
Repository
github.com/naqvis/snappy
Metadata
- Created
- Aug 12, 2026
- Updated
- Oct 20, 2026
- Synced
- Oct 19, 2026
- Versions
- 9