How to use Ruby's zlib?

Thanks, Gavin. I’m onto something here. I found rubyzip, which will do
what I need it to. However, I’m having a bit of trouble tracking down how
to use it properly. Any ideas?
Craig

I would like to add or move a file to a pre-existing gzipped file. Nobu
tipped me off to the fact that Ruby has built in zlib methods. I can’t,
however, find any good examples of what I want to do. Specifically, I’d
like to move all *.log files in a directory to a file named Archived.gz.
Help please?
Kindest Regards-
Craig

I’d love to say I knew how, but I don’t. If you take a look at

http://www.ruby-doc.org/stdlib/libdoc/zlib/rdoc/index.html

you can see what classes and methods are implemented. With
experimentation, you’ll probably get somewhere.

Ooops, just looked and saw that there is some documentation alongside
the source code: ext/zlib/doc/zlib.rd. That means it’s probably on
the web somewhere; try Google.

Any volunteers for converting this RD documentation into RDoc format
inside the source code? :wink:

Cheers,
Gavin

PS. GZip compresses single files, unlike ZIP, which creates compressed
archives. So getting a bunch of files into a .gz file is not feasible
without using TAR. I don’t know how people might go about creating
compressed archives with Ruby. I use: system(“tar zcvf …”)

···

From: Gavin Sinclair [mailto:gsinclair@soyabean.com.au]
On Thursday, February 19, 2004, 12:24:40 AM, Craig wrote:

(untested)

require ‘zip/zipfilesystem’

filename = “test.zip”
Zip::ZipFile.open(filename, Zip::ZipFile::CREATE) do |zip|
zip.file.open(“foo.txt”, “w”) {|f| f.write “file contents”}
zip.file.open(“bar.txt”, “w”) {|f| f.write “file contents 2”}
end

···

On Wed, Feb 18, 2004 at 11:47:33PM +0900, Moran, Craig M (BAH) wrote:

Thanks, Gavin. I’m onto something here. I found rubyzip, which will do
what I need it to. However, I’m having a bit of trouble tracking down how
to use it properly. Any ideas?


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

How do I type “for i in *.dvi do xdvi $i done” in a GUI?
– Discussion in comp.os.linux.misc on the intuitiveness of interfaces