Project

omnizip

0.0
The project is in a healthy, maintained state
Omnizip is an extractor/compressor library that implements a comprehensive set of data compression algorithms and archive formats, in pure Ruby. Supports LZMA, ZIP, 7z, RAR, XZ, CPIO, ISO 9660, PAR and more.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 0.2
~> 2.4
~> 1.0
~> 3.3
~> 0.2, >= 0.2.4
~> 1.15
 Project Readme

Omnizip

Compression and archive toolkit for Ruby: LZMA/LZMA2, Zstandard, BZip2, PPMd7/8, Deflate/Deflate64 codecs; ZIP, 7z, RAR4/RAR5, TAR, CPIO, ISO, XAR, RPM, OLE, PAR2 formats; deterministic creation, AES encryption, PAR2 recovery records, format conversion and repair. Where a prebuilt binary exists the codecs and archives run on the omnizip-rs Rust engine — with zero compilation for the user; everywhere else the gem stays fully functional on its pure-Ruby core.

Installation

gem install omnizip          # picks a prebuilt Rust cdylib per platform

Supported prebuilt platforms: x86_64/aarch64/arm Linux (glibc + musl), arm64/x86_64 macOS, x64/arm64 Windows (ucrt). JRuby and TruffleRuby bind through the bundled ffi gem; MRI uses stdlib Fiddle. Escape hatches:

  • OMNIZIP_NO_RUST=1 — force the pure-Ruby core everywhere.

  • OMNIZIP_FFI_DYLIB=/path/to/libomnizip_ffi — load a specific build.

  • rake rust:build — build and vendor the cdylib from a checkout.

A Rust-side failure falls back to the Ruby core mid-operation, so acceleration is never worse than pure Ruby.

External code must require "omnizip". Files under lib/omnizip/** are internal — requiring them directly bypasses the autoload chain.

Command line

omnizip compress input.txt output.lzma --level 9
omnizip archive create backup.7z documents/ photos/
omnizip archive extract backup.7z output/
omnizip archive list backup.7z
omnizip archive verify backup.rar
omnizip archive repair damaged.rar
omnizip parity create backup.rar --percent 10
omnizip parity verify backup.par2
omnizip parity repair backup.par2
omnizip profile list
omnizip metadata archive.rar

Ruby API

One-liners

require "omnizip"

Omnizip.compress_file("input.txt", "output.zip")
Omnizip.extract_archive("archive.zip", "output/")
Omnizip.list_archive("archive.zip")

In-memory archives

Omnizip::Buffer creates and reads ZIP and 7z archives entirely in memory:

buffer = Omnizip::Buffer.create(:zip) do |archive|
  archive.add("readme.txt", "Hello World")
end
names = Omnizip::Backends.archive_entry_names(buffer.to_s)

Archive files

Omnizip::Zip::File.open("in.zip") { |z| z.extract("a.txt", "out.txt") }
Omnizip::Zip::File.open("out.zip", create: true) do |z|
  z.add_file("a.txt")
end

names = Omnizip::Backends.archive_entry_names("archive.rar")
data  = Omnizip::Backends.archive_read_entry("archive.rar", "doc.txt",
                                             password: "secret")

Codecs directly

compressed = Omnizip::Algorithms::Lzma.compress(data, level: 9)
plain      = Omnizip::Algorithms::Lzma.decompress(compressed)

Omnizip::Algorithms::Zstandard.compress(data, level: 19)
Omnizip::Algorithms::Bzip2.compress(data)
Omnizip::Algorithms::Ppmd7.compress(data, order: 8)

SDK-compatible LZMA

File.open("out.lzma", "wb") do |f|
  Omnizip::Algorithms::LZMA::Encoder.new(f, sdk_compatible: true)
    .encode_stream("Hello, World!")
end

Profiles, conversion, streaming, repair

Content-class profiles pick the codec automatically (Omnizip::Profile::DEFAULT and friends); Omnizip::Converter moves archives between formats; the chunked reader/writer processes inputs far larger than RAM; Omnizip::ArchiveRepairCommand routes structural repair. See the guides below.

Development

bundle install
bundle exec rspec                       # suite
bundle exec rspec spec/omnizip/algorithms/lzma_spec.rb   # one file
bundle exec rubocop                     # lint
rake rust:build                         # vendor the Rust cdylib locally
rake docs:build                         # render docs/site via Coradoc
rake docs:links                         # lychee link check

Copyright (c) Ribose Inc. Released under the MIT License; see the LICENSE file. The Rust engine (omnizip-rs) is MIT OR Apache-2.0.