lib/railsthemes/tar.rb in railsthemes-1.2.0 vs lib/railsthemes/tar.rb in railsthemes-2.0.0.pre
- old
+ new
@@ -31,11 +31,11 @@
tarfile.rewind
tarfile
end
# gzips the underlying string in the given StringIO,
- # returning a new StringIO representing the
+ # returning a new StringIO representing the
# compressed file.
def self.gzip(tarfile)
gz = StringIO.new("")
z = Zlib::GzipWriter.new(gz)
z.write tarfile.string
@@ -47,13 +47,12 @@
end
# un-gzips the given IO, returning the
# decompressed version as a StringIO
def self.ungzip(tarfile)
- z = Zlib::GzipReader.new(tarfile)
- unzipped = StringIO.new(z.read)
- z.close
- unzipped
+ Zlib::GzipReader.open(tarfile) do |f|
+ StringIO.new(f.read)
+ end
end
# untars the given IO into the specified
# directory
def self.untar(io, destination)