Skip to content

brianmario/bzip2-ruby

Repository files navigation

Ruby C bindings to libbzip2

Installation

First make sure you’ve got Gemcutter in your sources list:

gem sources -a http://gemcutter.org

Then go ahead and install it as usual:

sudo gem install bzip2-ruby

You may need to specify:

--with-bz2-dir=<include file directory for libbzip2>

Or in a Gemfile

gem 'bzip2-ruby'

Usage

The full documentation is hosted on rdoc.info.

Here's a quick overview, hower:

require'bzip2'# Quick shortcutsdata=Bzip2.compress'string'Bzip2.uncompressdata# Creating a bz2 compressed filewriter=Bzip2::Writer.newFile.open('file')writer << 'data1'writer.puts'data2'writer.print'data3'writer.printf'%s','data4'writer.closeBzip2::Writer.open('file'){ |f| f << data}# Reading a bz2 compressed filereader=Bzip2::Reader.newFile.open('file')reader.gets# => "data1data2\n"reader.read# => 'data3data4'reader.readline# => raises Bzip2::EOZErrorBzip2::Reader.open('file'){ |f| putsf.read}

Copying

This extension module is copyrighted free software by Guy Decoux You can redistribute it and/or modify it under the same term as Ruby. Guy Decoux <[email protected]> 

Modifications from origin version

  • Switch to Jeweler
  • Renamed BZ2 module/namespace to Bzip2
  • Renamed compiled binary from "bz2" to "bzip2"
  • Renamed gem from "bz2" to "bzip2-ruby"
  • Converted original tests to rspec
  • 1.9 compatibility

About

Original libbz2 ruby C bindings from Guy Decoux, with some new love

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 6