Sha256: c707faaa8c669e124780ff112e1fa69e81aeb5580226203f413756e7333cf281
Contents?: true
Size: 847 Bytes
Versions: 6
Compression:
Stored size: 847 Bytes
Contents
# encoding: utf-8 # author: Christoph Hartmann # author: Dominik Richter require 'rubygems/package' module Inspec::Archive class TarArchiveGenerator def archive(base_dir, files, archive) File.open(archive, 'wb') do |file| Zlib::GzipWriter.wrap(file) do |gz| Gem::Package::TarWriter.new(gz) do |tar| files.each do |input_filename| path = Pathname.new(base_dir).join(input_filename) stat = File.stat(path) if path.directory? tar.mkdir(input_filename, stat.mode) else tar.add_file_simple(input_filename, stat.mode, stat.size) do |io| io.write(File.binread(path)) end end end end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems