Class: Inspec::ZipProvider
- Inherits:
-
FileProvider
- Object
- FileProvider
- Inspec::ZipProvider
- Defined in:
- lib/inspec/file_provider.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
-
#initialize(path) ⇒ ZipProvider
constructor
A new instance of ZipProvider.
- #read(file) ⇒ Object
Methods inherited from FileProvider
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
#files ⇒ Object (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 |