Method: Jax::Util::Tar#gzip

Defined in:
lib/jax/util/tar.rb

#gzip(tarfile) ⇒ Object

gzips the underlying string in the given StringIO, returning a new StringIO representing the compressed file.



36
37
38
39
40
41
42
43
44
45
# File 'lib/jax/util/tar.rb', line 36

def gzip(tarfile)
  gz = StringIO.new("")
  z = Zlib::GzipWriter.new(gz)
  z.write tarfile.string
  z.close # this is necessary!
  
  # z was closed to write the gzip footer, so
  # now we need a new StringIO
  StringIO.new gz.string
end