mirror of
https://github.com/inspec/inspec
synced 2024-12-20 10:03:28 +00:00
5875864f45
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
33 lines
751 B
Ruby
33 lines
751 B
Ruby
# encoding: utf-8
|
|
require 'rubygems/package'
|
|
require 'zlib'
|
|
|
|
module Vulcano::Targets
|
|
class TarHelper
|
|
|
|
def structure input
|
|
files = Array.new
|
|
Gem::Package::TarReader.new( Zlib::GzipReader.open input ) do |tar|
|
|
files = tar.map{|entry| entry.full_name }
|
|
end
|
|
return files
|
|
end
|
|
|
|
def content input
|
|
content = {}
|
|
Gem::Package::TarReader.new( Zlib::GzipReader.open input ) do |tar|
|
|
tar.each do |entry|
|
|
if entry.directory?
|
|
#nothing to do
|
|
elsif entry.file?
|
|
content[entry.full_name] = entry.read
|
|
elsif entry.header.typeflag == '2'
|
|
# ignore symlinks for now
|
|
end
|
|
end
|
|
end
|
|
return content
|
|
end
|
|
|
|
end
|
|
end
|