Class: Inspec::ZipProvider

Inherits:
FileProvider show all
Defined in:
lib/inspec/file_provider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FileProvider

for_path, #relative_provider

Constructor Details

#initialize(path) ⇒ ZipProvider

Returns a new instance of ZipProvider.



73
74
75
76
77
78
79
80
81
82
# File 'lib/inspec/file_provider.rb', line 73

def initialize(path)
  @path = path
  @contents = {}
  @files = []
  ::Zip::InputStream.open(@path) do |io|
    while (entry = io.get_next_entry)
      @files.push(entry.name.sub(%r{/+$}, ''))
    end
  end
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



71
72
73
# File 'lib/inspec/file_provider.rb', line 71

def files
  @files
end

Instance Method Details

#read(file) ⇒ Object



84
85
86
# File 'lib/inspec/file_provider.rb', line 84

def read(file)
  @contents[file] ||= read_from_zip(file)
end