From e755ecacf904d9376323df32eb837cee9fbfb07f Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 27 Dec 2010 01:36:16 +0000 Subject: [PATCH] Update rdoc of zlib. Add description about gzip(1) compatible output. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/zlib/zlib.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 9a04c61bf3..2d63570cac 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -2852,7 +2852,7 @@ rb_gzfile_ecopts(struct gzfile *gz, VALUE opts) * Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should * be used with an instance of IO, or IO-like, object. * - * For example: + * Following two example generate the same result. * * Zlib::GzipWriter.open('hoge.gz') do |gz| * gz.write 'jugemu jugemu gokou no surikire...' @@ -2864,8 +2864,14 @@ rb_gzfile_ecopts(struct gzfile *gz, VALUE opts) * gz.close * end * - * # TODO: test these. Are they equivalent? Can GzipWriter.new take a - * # block? + * To make like gzip(1) does, run following: + * + * orig = 'hoge.txt' + * Zlib::GzipWriter.open('hoge.gz') do |gz| + * gz.mtime = File.mtime(orig) + * gz.orig_name = orig + * gz.write IO.binread(orig) + * end * * NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close * GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter