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

#binread, for_path, #relative_provider

Constructor Details

#initialize(path) ⇒ ZipProvider

Returns a new instance of ZipProvider.



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/inspec/file_provider.rb', line 96

def initialize(path)
  @path = path
  @contents = {}
  @files = []
  walk_zip(@path) do |io|
    while (entry = io.get_next_entry)
      name = entry.name.sub(%r{/+$}, '')
      @files.push(name) unless name.empty?
    end
  end
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



94
95
96
# File 'lib/inspec/file_provider.rb', line 94

def files
  @files
end

Instance Method Details

#read(file) ⇒ Object



108
109
110
# File 'lib/inspec/file_provider.rb', line 108

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