Method: Inspec::Targets::ZipHelper#structure

Defined in:
lib/inspec/targets/zip.rb

#structure(input) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/inspec/targets/zip.rb', line 32

def structure(input)
  files = []
  rootdir = ''

  ::Zip::InputStream.open(input) do |io|
    while (entry = io.get_next_entry)
      pn = Pathname(entry.name)
      rootdir = pn.dirname.to_s if pn.basename.to_s == 'inspec.yml' || pn.basename.to_s == 'metadata.rb'
      files.push(entry.name)
    end
  end

  # stores the rootdir of metadata.rb or inspec.yml
  rootdir += '/' if !rootdir.empty?
  [files, rootdir]
end