Class: Inspec::Targets::TarHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec/targets/tar.rb

Instance Method Summary collapse

Instance Method Details

#content(input) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/inspec/targets/tar.rb', line 18

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
  content
end

#structure(input) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/inspec/targets/tar.rb', line 10

def structure(input)
  files = []
  Gem::Package::TarReader.new(Zlib::GzipReader.open input) do |tar|
    files = tar.map(&:full_name)
  end
  files
end