Method: Inspec::ZipProvider#extract

Defined in:
lib/inspec/file_provider.rb

#extract(destination_path = '.') ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/inspec/file_provider.rb', line 108

def extract(destination_path = '.')
  FileUtils.mkdir_p(destination_path)

  Zip::File.open(@path) do |archive|
    archive.each do |file|
      final_path = File.join(destination_path, file.name)

      # This removes the top level directory (and any other files) to ensure
      # extracted files do not conflict.
      FileUtils.remove_entry(final_path) if File.exist?(final_path)

      archive.extract(file, final_path)
    end
  end
end