Coder Social home page Coder Social logo

bzip2-ruby's Introduction

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 shortcuts
data = Bzip2.compress 'string'
Bzip2.uncompress data

# Creating a bz2 compressed file
writer = Bzip2::Writer.new File.open('file')
writer << 'data1'
writer.puts 'data2'
writer.print 'data3'
writer.printf '%s', 'data4'
writer.close

Bzip2::Writer.open('file'){ |f| f << data }

# Reading a bz2 compressed file
reader = Bzip2::Reader.new File.open('file')
reader.gets # => "data1data2\n"
reader.read # => 'data3data4'

reader.readline # => raises Bzip2::EOZError

Bzip2::Reader.open('file'){ |f| puts f.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

bzip2-ruby's People

Contributors

brianmario avatar alexcrichton avatar koraktor avatar brixen avatar colindean avatar chewi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.