Hi

On Mon, May 17, 2010 at 3:49 PM, Martin Hansen <mail / maasha.dk> wrote:
> Hello,
>
>
> I am interested in opening a single data stream to multiple (possibly
> gzipped) files, and was wondering if you could do that elegantly in
> Ruby. I have some dodgy old Perl code that works, but it isn't really
> elegant/robust/portable:
>
> http://pastie.org/963613

There are bindings in ruby for zlib:
http://ruby-doc.org/core/classes/Zlib/GzipReader.html
And facets has a wrapper around it:
http://facets.rubyforge.org/apidoc/api/more/classes/Zlib.html
Maybe you could reimplement the Perl code trying to decompress always
and trapping the exception when the file is not compressed? Something
like this:

irb1.9 -rfacets/zlib -rzlib -rstringio
irb(main):001:0> Zlib.decompress("plain text")
Zlib::GzipFile::Error: not in gzip format



-- 
Luis Parravicini
http://ktulu.com.ar/blog/