# Pr-zlib 1.0.0 - A Pure Ruby zlib library

**URL:** <https://www.ruby-forum.com/t/pr-zlib-1-0-0-a-pure-ruby-zlib-library/170169>\
**Category:** Ruby\
**Created:** [June 13, 2009, 6:03am UTC](https://www.ruby-forum.com/t/pr-zlib-1-0-0-a-pure-ruby-zlib-library/170169 "2009-06-13T06:03:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [June 13, 2009, 6:03am UTC](https://www.ruby-forum.com/t/pr-zlib-1-0-0-a-pure-ruby-zlib-library/170169/1 "2009-06-13T06:03:22Z")

</div>

Hi all,

The Pure Team is pleased to announce the release of pr-zlib 1.0.0.

= What is it?

The pr-zlib library is actually two separate libraries packaged  
together.  
The first, rbzlib.rb, is a pure Ruby port of zlib.h (the C library).  
It’s a  
module that you can mixin and use as you see fit. The second, zlib.rb,  
is a  
pure Ruby version of the Ruby interface to the zlib C library that ships  
as  
part of the Ruby standard library.

= How do I get it?

gem install pr-zlib

Or, just go the RubyForge project page at  
[http://www.rubyforge.org/projects/pure](http://www.rubyforge.org/projects/pure), download the source and run  
either  
‘rake install’ or ‘rake install\_as\_zlib’ (which will install the library  
as  
‘zlib’ instead of ‘pr/zlib’).

= How do I use it?

require ‘pr/zlib’

# The rest is the same as the zlib that ships with the Ruby stdlib.

= Why? (Also in the README)

First, building the zlib C library on MS Windows with Visual C++ is very  
difficult. However, certain libraries depend on zlib, most notably  
rubygems.  
By providing a pure Ruby version we eliminate any compiler or platform  
compatibility issues.

Second, even some Unix distributions, such as Debian, do not ship with  
the  
zlib library by default. By creating a pure Ruby version of the zlib  
library  
we eliminate the need to install a 3rd party C library, and eliminate a  
potential weak link in the dependency chain.

Third, by creating pure Ruby versions of the library and the interface  
we  
are more likely to receive patches, feature requests, documentation  
updates,  
etc, from the Ruby community (I hope) since not everyone who knows Ruby  
also  
knows C.

Last, the zlib interface that ships as part of the stdlib is a little on  
the  
clunky side IMO. By providing a pure Ruby version, authors can create  
their  
own interface as they see fit.

= What about Zliby?

Two things. First, Michael has not released the version of the code that  
supports Zlib::GzipWriter. Second, Zliby merges the code into a single  
file.  
The pr-zlib splits the code into its two parts - rbzlib.rb and zlib.rb.  
The  
former is a module that can be used separately. As I mentioned earlier,  
that  
means users can create their own interface if they prefer.

= Feeling Generous?

If you think this is a useful library, and would like to see more time  
spent  
on others like it, please consider a contribution:

[http://pledgie.com/campaigns/4706](http://pledgie.com/campaigns/4706) (Daniel’s general drive)

removed\_email\_address@domain.invalid (Heesob on Paypal)

Enjoy!

The Pure Team (Daniel B. and Park H.)

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [June 13, 2009, 10:54am UTC](https://www.ruby-forum.com/t/pr-zlib-1-0-0-a-pure-ruby-zlib-library/170169/2 "2009-06-13T10:54:54Z")

</div>

On Jun 13, 12:02 am, “Daniel B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> part of the Ruby standard library.
> 
> require ‘pr/zlib’
> 
> # The rest is the same as the zlib that ships with the Ruby stdlib.

I wonder if this would be more desirable actually in the standard  
library for the reasons you give.

> potential weak link in the dependency chain.
> 
> Third, by creating pure Ruby versions of the library and the interface we  
> are more likely to receive patches, feature requests, documentation updates,  
> etc, from the Ruby community (I hope) since not everyone who knows Ruby also  
> knows C.
> 
> Last, the zlib interface that ships as part of the stdlib is a little on the  
> clunky side IMO. By providing a pure Ruby version, authors can create their  
> own interface as they see fit.

Good show, gents.

Maybe some benchmarks?

T.

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [June 13, 2009, 4:06pm UTC](https://www.ruby-forum.com/t/pr-zlib-1-0-0-a-pure-ruby-zlib-library/170169/3 "2009-06-13T16:06:32Z")

</div>

On Sat, Jun 13, 2009 at 10:54 AM, trans[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> library for the reasons you give.  
> +1 and kudos to the pure team 🙂  
> Robert

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [June 14, 2009, 5:05am UTC](https://www.ruby-forum.com/t/pr-zlib-1-0-0-a-pure-ruby-zlib-library/170169/4 "2009-06-14T05:05:08Z")

</div>

> I wonder if this would be more desirable actually in the standard  
> library for the reasons you give.

or perhaps included with rubygems as a backup?  
=r

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [June 21, 2009, 4:07am UTC](https://www.ruby-forum.com/t/pr-zlib-1-0-0-a-pure-ruby-zlib-library/170169/5 "2009-06-21T04:07:13Z")

</div>

> Or, just go the RubyForge project page at  
> [http://www.rubyforge.org/projects/pure](http://www.rubyforge.org/projects/pure), download the source and run  
> either  
> ‘rake install’ or ‘rake install\_as\_zlib’ (which will install the library  
> as  
> ‘zlib’ instead of ‘pr/zlib’).

Thanks much–just used it to overcome a

C:\installs\ruby\_trunk\_installed\bin\>gem list  
C:/installs/ruby\_trunk\_installed/lib/ruby/1.9.1/rubygems/spec\_fetcher.rb:1:in  
`require’: no such file to load – zlib (LoadError)

and it worked and gems installed successfully using it. Sweet.

-=r

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [June 14, 2009, 5:41am UTC](https://www.ruby-forum.com/t/pr-zlib-1-0-0-a-pure-ruby-zlib-library/170169/6 "2009-06-14T05:41:57Z")

</div>

> or perhaps included with rubygems as a backup?  
> [http://rubyforge.org/tracker/index.php?func=detail&aid=22220&group\_id=126&atid=578](http://rubyforge.org/tracker/index.php?func=detail&aid=22220&group_id=126&atid=578)

Originally I was going to use zliby, but I think what we’ll do is try to  
load pr/zlib if zlib can’t be found. So, you’ll have to install one or  
the other first at some point, but at least you’ll have a choice.

Regards,

Dan
