# Pure Ruby Zlib::GzipWriter

**URL:** <https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694>\
**Category:** Ruby\
**Created:** [December 15, 2008, 5:40pm UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694 "2008-12-15T17:40:08Z")\
**Posts on this page:** 20\
**Page:** 2

<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:** [January 8, 2009, 6:42am UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/21 "2009-01-08T06:42:13Z")

</div>

> > I am working on translation of ruby library zlib.c to pure ruby code.
> 
> Looks like you and Charles L. are in a race. 🙂

Maybe you can collaborate? 🙂  
Let us know when somebody think it’s about done 🙂

-=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:** [January 8, 2009, 3:56pm UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/22 "2009-01-08T15:56:39Z")

</div>

On Jan 7, 11:08 pm, “Heesob P.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > you did by hand and how much you were able to automate it…?
> 
> I dit it all by hand. There is no royal road to translating C to Ruby:)
> 
> > I’ve put the deflate code i wrote on pastie -[http://pastie.org/355367](http://pastie.org/355367)

Excellent, thanks!

> bad performance in Ruby 1.8.x.  
> As long as it’s usable I’m happy. We can benchmark, profile and  
> optimize later. 🙂

regards,

Dan

---

<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:** [January 8, 2009, 7:09am UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/23 "2009-01-08T07:09:43Z")

</div>

Hi,

2009/1/8 Charles L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Daniel B. wrote:
> 
> > Sounds like you’re on track. But, you’re in a race with Park H.. 🙂
> > 
> > Dan
> 
> Heh. 🙂 Somehow I think he’s got it covered. That reimplementation of  
> zlib in ruby is actually pretty cool. I’m curious Park, as to how much  
> you did by hand and how much you were able to automate it…?

I dit it all by hand. There is no royal road to translating C to Ruby:)

> I’ve put the deflate code i wrote on pastie - [http://pastie.org/355367](http://pastie.org/355367)
> 
> It’s about 600 lines, but needs cleaning up. Will probably be ~500 when  
> I’ve added in dynamic trees and cleaned it up a bit.
> 
> Prelim benchmarks show the current bottleneck to be the LZ77  
> implementation which is interesting. I think for it to perform  
> acceptably, a lot more of the code needs to become more idiomatic,  
> higher-level ruby.

In my test, the deflation is very slow but the inflation is endurable.  
Moreover, for the compatibility of the various Ruby version, It shows  
bad performance in Ruby 1.8.x.

Regards,

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:** [January 9, 2009, 4:24am UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/24 "2009-01-09T04:24:50Z")

</div>

2009/1/8 Daniel B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > > It’s about 600 lines, but needs cleaning up. Will probably be ~500 when
> 
> As long as it’s usable I’m happy. We can benchmark, profile and  
> optimize later. 🙂

Finally I translated the whole zlib.c to ruby code.  
You can download at [http://121.78.227.9/rbzlib/pzlib.rb](http://121.78.227.9/rbzlib/pzlib.rb)

Regards,

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:** [January 9, 2009, 6:24pm UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/25 "2009-01-09T18:24:11Z")

</div>

On Jan 8, 6:56 pm, “Charles L.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The big thing is just good specs, and the existing rubyspec ones could  
> use some work which will benefit all of us.

Agreed.

> I’ve added most of the remaining missing functionality to my version (ie  
> dynamic huffman tree’s etc), and added back in the inflate functionality  
> from zliby, and put the result up on github -[GitHub - aquasync/ruby-zlib: Pure ruby zlib implementation · GitHub](http://github.com/aquasync/ruby-zlib/tree/master)

Thanks. Unfortunately, I cannot download it. IE7 and FF3 simply do  
nothing when I click on the download link. FF2 (before I upgraded)  
gave me a “file not found” error.

This actually happens to me a lot with github, on not just on Windows.

> I’ve since added enough of the GzipWriter & GzipFile functionality that  
> the existing specs all pass (see below. note the GzipFile specs use  
> GzipWriter). Unable to push this last commit to github presently, but  
> will try later.

Ok, I’ll look for it and just copy/paste files individually when  
you’re ready.

Regards,

Dan

---

<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:** [January 9, 2009, 2:57am UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/26 "2009-01-09T02:57:08Z")

</div>

Roger P. wrote:

> Maybe you can collaborate? 🙂  
> Let us know when somebody think it’s about done 🙂
> 
> -=r

I’m not sure there’s much room for collaboration at the Zlib wrapper &  
below level, but perhaps the GzipFile and upwards (ie Reader/Writer)  
implementations can be shared.

The big thing is just good specs, and the existing rubyspec ones could  
use some work which will benefit all of us.

I’ve added most of the remaining missing functionality to my version (ie  
dynamic huffman tree’s etc), and added back in the inflate functionality  
from zliby, and put the result up on github -

> **[GitHub - aquasync/ruby-zlib: Pure ruby zlib implementation](https://github.com/aquasync/ruby-zlib/tree/master)**
>
> master

I’ve since added enough of the GzipWriter & GzipFile functionality that  
the existing specs all pass (see below. note the GzipFile specs use  
GzipWriter). Unable to push this last commit to github presently, but  
will try later.

It is likely complete enough for the purposes of creating rubygems, but  
is still missing functionality, which needs specing out (Eg wtf is  
Zlib::GzipWriter.wrap, Zlib::GzipWriter reimplements a lot of IO  
functions like puts, etc).

Zlib::Deflate#set\_dictionary

- sets the dictionary

Zlib::Deflate#deflate

- deflates some data

Zlib::Deflate::deflate

- deflates some data

Zlib::GzipFile#closed?

- returns the closed status

Zlib::GzipFile#close

- finishes the stream and closes the io

Zlib::GzipFile#comment

- returns the name
- raises an error on a closed stream

Zlib::GzipFile#orig\_name

- returns the name
- raises an error on a closed stream

Zlib::GzipWriter#mtime=

- sets mtime using Integer
- sets mtime using Time
- raises if the header was written

GzipWriter#write

- writes some compressed data

---

<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:** [January 9, 2009, 6:28pm UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/27 "2009-01-09T18:28:18Z")

</div>

Hi,

On Jan 8, 8:23 pm, “Heesob P.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > > It’s about 600 lines, but needs cleaning up. Will probably be ~500 when
> 
> > As long as it’s usable I’m happy. We can benchmark, profile and  
> > optimize later. 🙂
> 
> Finally I translated the whole zlib.c to ruby code.  
> You can download athttp://121.78.227.9/rbzlib/pzlib.rb

Looks very promising but doesn’t quite work yet:

C:\>gem install ptools  
ERROR: While executing gem … (NoMethodError)  
undefined method `ZSTREAM\_IS\_FINISHED’ for #\<Zlib::GzipReader:  
0x2f8e8bc\>

I think you need some tests. 😉

BTW, I’m assuming this is basically a wholesale replacement of zliby?  
If so, the module should be renamed from PZlib to just Zlib.  
Otherwise, Rubygems will complain about the lack of a Gem::Zlib  
definition.

Keep up the good work!

Regards,

Dan

---

<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:** [January 10, 2009, 12:27am UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/28 "2009-01-10T00:27:22Z")

</div>

Daniel B. wrote:

> Ok, I was able to download the project and I ran the specs:
> 
> C:\ruby\src\ruby-zlib\>spec specs  
> …FF…
> 
> 1. 
> 
> ‘Zlib::Deflate#params changes the deflate parameters’ FAILED  
> expected: “x\001\000\v\000\364\377abcdefghijk\002,'\027\000#  
> \364\005\<”,  
> got: “x\234KLJNIMK\317\310\314\312\316\311\005\000#  
> \364\005\<” (using ==)  
> C:/ruby/src/ruby-zlib/specs/deflate/params\_spec.rb:16
> 
> 1. 
> 
> NameError in ‘Zlib::Deflate#set\_dictionary sets the dictionary’  
> uninitialized constant Zlib::Deflate  
> C:/ruby/src/ruby-zlib/specs/deflate/set\_dictionary\_spec.rb:6  
> C:/ruby/src/ruby-zlib/specs/deflate/set\_dictionary\_spec.rb:5:in `each’  
> C:/ruby/src/ruby-zlib/specs/deflate/set\_dictionary\_spec.rb:5
> 
> Finished in 1.688 seconds
> 
> 38 examples, 2 failures
> 
> Ruby 1.8.6-p114 built with VC++ 8  
> Windows XP Pro  
> RSpec 1.1.11
> 
> Regards,
> 
> Dan

Yeah the github download functionality seems broken for me most of the  
time also… 😕

Anyway, the params failure is the only failure I get. Thats because I’ve  
not implemented the NO\_COMPRESSION mode yet, and is an easy fix. The  
other error you’re getting is odd, as Zlib::Deflate is defined, and if  
it weren’t none of the other deflate specs would have passed!

---

<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:** [January 9, 2009, 11:38pm UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/29 "2009-01-09T23:38:55Z")

</div>

On Jan 8, 6:56 pm, “Charles L.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The big thing is just good specs, and the existing rubyspec ones could  
> use some work which will benefit all of us.
> 
> I’ve added most of the remaining missing functionality to my version (ie  
> dynamic huffman tree’s etc), and added back in the inflate functionality  
> from zliby, and put the result up on github -[GitHub - aquasync/ruby-zlib: Pure ruby zlib implementation · GitHub](http://github.com/aquasync/ruby-zlib/tree/master)

Ok, I was able to download the project and I ran the specs:

C:\ruby\src\ruby-zlib\>spec specs  
…FF…

1. 

‘Zlib::Deflate#params changes the deflate parameters’ FAILED  
expected: “x\001\000\v\000\364\377abcdefghijk\002,'\027\000#  
\364\005\<”,  
got: “x\234KLJNIMK\317\310\314\312\316\311\005\000#  
\364\005\<” (using ==)  
C:/ruby/src/ruby-zlib/specs/deflate/params\_spec.rb:16

1. 

NameError in ‘Zlib::Deflate#set\_dictionary sets the dictionary’  
uninitialized constant Zlib::Deflate  
C:/ruby/src/ruby-zlib/specs/deflate/set\_dictionary\_spec.rb:6  
C:/ruby/src/ruby-zlib/specs/deflate/set\_dictionary\_spec.rb:5:in `each’  
C:/ruby/src/ruby-zlib/specs/deflate/set\_dictionary\_spec.rb:5

Finished in 1.688 seconds

38 examples, 2 failures

Ruby 1.8.6-p114 built with VC++ 8  
Windows XP Pro  
RSpec 1.1.11

Regards,

Dan

---

<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:** [January 10, 2009, 12:38am UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/30 "2009-01-10T00:38:41Z")

</div>

Hi,

2009/1/10 Daniel B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > > > > > Sounds like you’re on track. But, you’re in a race with Park H.. 🙂
> > 
> > > > In my test, the deflation is very slow but the inflation is endurable.
> 
> definition.
> 
> Keep up the good work!

I fixed some typo and renamed PZlib to Zlib and pzlib.rb to zlib.rb  
I succeeded “gem install ptools” with zlib.rb

You can download it at [http://121.78.227.9/rbzlib/zlib.rb](http://121.78.227.9/rbzlib/zlib.rb)

Regards,

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:** [January 10, 2009, 6:09am UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/31 "2009-01-10T06:09:43Z")

</div>

> Anyone knows any web application for bounties? I’m interested in  
> contribute to this one and also one for Readline!!!

Yeah I’m in for Readline 🙂  
Note that highline has a getc for windows, and cmd is also readline  
like, so I believe it is possible 🙂

-=r  
As a note I get the same error message Luis does.

---

<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:** [January 10, 2009, 11:16am UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/32 "2009-01-10T11:16:12Z")

</div>

2009/1/10 Roger P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 

I guess you are looking for ruby\_readline [1] .

You can download ruby18-rreadline-0.5.4.tbz at [2].

Regards,

Park H.

[1] [http://raa.ruby-lang.org/project/ruby\_readline](http://raa.ruby-lang.org/project/ruby_readline)  
[2]  
[http://www.filewatcher.com/m/ruby18-rreadline-0.5.4.tbz.13944.0.0.html](http://www.filewatcher.com/m/ruby18-rreadline-0.5.4.tbz.13944.0.0.html)

---

<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:** [January 10, 2009, 1:30pm UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/33 "2009-01-10T13:30:57Z")

</div>

On Jan 10, 8:15 am, Heesob P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I guess you are looking for ruby\_readline [1] .

Hello Park,

Actually I’m looking to an API-compatible replacement, which should  
work with IRB and auto complete capabilities.

Not only that, but a solution that can work across platforms,  
including Windows 🙂

There is a solution called RawLine [1] but is not API-compliant with  
ReadLine.

Thank you again for your pointer.

[1] [http://rubyforge.org/projects/rawline/](http://rubyforge.org/projects/rawline/)

---

<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:** [January 10, 2009, 5:48pm UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/34 "2009-01-10T17:48:25Z")

</div>

Hi,

2009/1/10 Luis L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > 
> 
> There is a solution called RawLine [1] but is not API-compliant with  
> ReadLine.
> 
> Thank you again for your pointer.
> 
> [1] [http://rubyforge.org/projects/rawline/](http://rubyforge.org/projects/rawline/)

I found the pure Perl implementation of the readline libraries called  
libterm-readline-perl-perl [1]

I hope some one could port it into Ruby.  
If no one port it until the end of this month, I will port it.

BTW, I succeeded “gem build” as well as “gem install” with my zlib.rb  
and rbzlib.rb.  
You should test it with the latest zlib.rb and rbzlib.rb at [2]

[1]  
[http://www.filewatcher.com/b/ftp/ftp.linux.it/debian/pool/main/libt/libterm-readline-perl-perl.0.0.html](http://www.filewatcher.com/b/ftp/ftp.linux.it/debian/pool/main/libt/libterm-readline-perl-perl.0.0.html)  
[2] [http://121.78.227.9/rbzlib/](http://121.78.227.9/rbzlib/)

Regards,  
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:** [January 10, 2009, 1:35am UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/35 "2009-01-10T01:35:30Z")

</div>

On Jan 9, 9:26 pm, “Charles L.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > ```
> > got: "x\234KLJNIMK\317\310\314\312\316\311\005\000#
> > 
> > ```
> > 
> > Finished in 1.688 seconds
> 
> Yeah the github download functionality seems broken for me most of the  
> time also… 😕
> 
> ## Anyway, the params failure is the only failure I get. Thats because I’ve not implemented the NO\_COMPRESSION mode yet, and is an easy fix. The other error you’re getting is odd, as Zlib::Deflate is defined, and if it weren’t none of the other deflate specs would have passed!
> 
> Posted viahttp://www.ruby-forum.com/.

The work-in-progress of One-Click Installer:

Luis@KEORE (D:\Users\Luis\projects\oss\ruby-zlib.git)  
$ spec specs  
…F…

1. 

‘Zlib::Deflate#params changes the deflate parameters’ FAILED  
expected: “x\001\000\v\000\364\377abcdefghijk\002,'\027\000#  
\364\005\<”,  
got: “x\234KLJNIMK\317\310\314\312\316\311\005\000#  
\364\005\<” (using ==)  
D:/Users/Luis/projects/oss/ruby-zlib.git/specs/deflate/params\_spec.rb:  
16

Finished in 1.219 seconds

38 examples, 1 failure

Luis@KEORE (D:\Users\Luis\projects\oss\ruby-zlib.git)  
$ ruby -v  
ruby 1.8.6 (2008-03-03 patchlevel 114) [i386-mingw32]

Luis@KEORE (D:\Users\Luis\projects\oss\ruby-zlib.git)  
$ spec --version  
rspec 1.1.11.6

Not bad, really not bad!

Anyone knows any web application for bounties? I’m interested in  
contribute to this one and also one for Readline!!!

Regards,

---

<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:** [January 10, 2009, 7:01pm UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/36 "2009-01-10T19:01:09Z")

</div>

On Jan 10, 2:47 pm, Heesob P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > > like, so I believe it is possible 🙂
> 
> I found the pure Perl implementation of the readline libraries called  
> libterm-readline-perl-perl [1]
> 
> I hope some one could port it into Ruby.  
> If no one port it until the end of this month, I will port it.

Well, I don’t have the time, but I can give some contribution for it,  
so 😃

> BTW, I succeeded “gem build” as well as “gem install” with my zlib.rb  
> and rbzlib.rb.  
> You should test it with the latest zlib.rb and rbzlib.rb at [2]

I’ve run the specs of Zlib for your code:

Finished in 0.328 seconds

38 examples, 25 failures

---

<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:** [January 10, 2009, 7:51pm UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/37 "2009-01-10T19:51:04Z")

</div>

On 10/01/2009, Heesob P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > > like, so I believe it is possible 🙂  
> > > > work with IRB and auto complete capabilities.
> 
> I found the pure Perl implementation of the readline libraries called  
> libterm-readline-perl-perl [1]
> 
> I hope some one could port it into Ruby.  
> If no one port it until the end of this month, I will port it.

I think the rreadline implementation is compatible. I once tried it  
because the readline on Windows was broken, and aside for renaming  
something to make irb find it it worked for me.

Thanks

Michal

---

<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:** [January 10, 2009, 7:22pm UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/38 "2009-01-10T19:22:14Z")

</div>

On 10/01/2009, Luis L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> so 😃
> 
> Finished in 0.328 seconds
> 
> 38 examples, 25 failures

I guess it’s expected. Different implementations give different  
compression results.

Of course, the spec might be more high-level but then an  
implementation that does not compress at all would likely work as  
well.

Thanks

Michal

---

<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:** [January 11, 2009, 1:27pm UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/39 "2009-01-11T13:27:22Z")

</div>

2009/1/11 Luis L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > > > > > > > contribute to this one and also one for Readline!!!  
> > > > > > > > Hello Park,  
> > > > > > > > Thank you again for your pointer.  
> > > > > > > > so 😃
> 
> It should implement the exact same compression strategies. If not, is  
> not a “drop-in” replacement.
> 
> > Of course, the spec might be more high-level but then an  
> > implementation that does not compress at all would likely work as  
> > well.
> 
> The spec is being used across IronRuby, Rubinius, JRuby and the Ruby C  
> (MRI). So the pure-ruby replacement must comply.

At last, my zlib.rb and rbzlib.rb passed rubyspec zlib test  
As before, you can download at [http://121.78.227.9/rbzlib/](http://121.78.227.9/rbzlib/)

Finished in 1.323951 seconds

77 files, 38 examples, 88 expectations, 0 failures, 0 errors

Regards,

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:** [January 11, 2009, 2:39pm UTC](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694/40 "2009-01-11T14:39:01Z")

</div>

On Jan 9, 4:26 pm, “Charles L.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > ```
> > got: "x\234KLJNIMK\317\310\314\312\316\311\005\000#
> > 
> > ```
> > 
> > Finished in 1.688 seconds
> 
> Yeah the github download functionality seems broken for me most of the  
> time also… 😕
> 
> Anyway, the params failure is the only failure I get. Thats because I’ve  
> not implemented the NO\_COMPRESSION mode yet, and is an easy fix. The  
> other error you’re getting is odd, as Zlib::Deflate is defined, and if  
> it weren’t none of the other deflate specs would have passed!

Ok, I tried again. Reading seemed to work fine. For writing it worked  
fine for small libs, but when I tried it against my largest project,  
windows-pr, I got this:

C:\Documents and Settings\djberge\workspace\windows-pr\>ruby windows-  
pr.gemspec  
C:/ruby/lib/ruby/site\_ruby/1.8/zlib/deflate.rb:859:in `log': Result too large - log (Errno::ERANGE) from C:/ruby/lib/ruby/site_ruby/1.8/zlib/deflate.rb:859:in `log2’  
from C:/ruby/lib/ruby/site\_ruby/1.8/zlib/deflate.rb:901:in  
`chooseblock' from C:/ruby/lib/ruby/site_ruby/1.8/zlib/deflate.rb:882:in `times’  
from C:/ruby/lib/ruby/site\_ruby/1.8/zlib/deflate.rb:882:in  
`chooseblock' from C:/ruby/lib/ruby/site_ruby/1.8/zlib/deflate.rb:613:in `outsym’  
from C:/ruby/lib/ruby/site\_ruby/1.8/zlib/deflate.rb:575:in  
`match' from C:/ruby/lib/ruby/site_ruby/1.8/zlib/deflate.rb:430:in `lz77\_compress’  
from C:/ruby/lib/ruby/site\_ruby/1.8/zlib/deflate.rb:490:in  
`deflate' ... 10 levels... from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/builder.rb:68:in `open’  
from C:/ruby/lib/ruby/site\_ruby/1.8/rubygems/builder.rb:68:in  
`write_package' from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/builder.rb:37:in `build’  
from windows-pr.gemspec:25

It’s about 60 files. If you’d like to try windows-pr yourself you can  
grab it via:

cvs -d :pserver:removed\_email\_address@domain.invalid:/var/cvs/win32utils login

cvs -d :pserver:removed\_email\_address@domain.invalid:/var/cvs/win32utils checkout

Regards,

Dan

[Previous page](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694.md?page=1)

[Next page](https://www.ruby-forum.com/t/pure-ruby-zlib-gzipwriter/155694.md?page=3)
