Permalink
Browse files

Add a Usage section to the README and a bit about adding it to a Gemfile

  • Loading branch information...
1 parent 6432853 commit 52e4ed2e6b60f2facc7c90df2c029c23c678a17b @alexcrichton alexcrichton committed Oct 12, 2010
Showing with 37 additions and 2 deletions.
  1. +37 −2 README.rdoc
View
@@ -9,13 +9,48 @@ First make sure you’ve got Gemcutter in your sources list:
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}[http://rdoc.info/github/brianmario/bzip2-ruby/master/frames].
+
+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 <ts@moulon.inra.fr>

0 comments on commit 52e4ed2

Please sign in to comment.