Class: Nuker::TarGzUtil

Inherits:
Object
  • Object
show all
Defined in:
lib/nuker/tar_gz_util.rb

Class Method Summary collapse

Class Method Details

.pack(files) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/nuker/tar_gz_util.rb', line 8

def pack(files)
  stream = StringIO.new
  begin
    tgz = Zlib::GzipWriter.new(stream)
    tar = Archive::Tar::Minitar::Output.new(tgz)
    files.each do |entry|
      Archive::Tar::Minitar.pack_file(entry, tar)
    end
  ensure
    tar.close if tar # Closes both tar and tgz.
  end
  stream.string
end