Class: PolicyManager::ZipGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/policy_manager/exporter/zip_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(input_dir, output_file) ⇒ ZipGenerator

Initialize with the directory to zip and the location of the output archive.



17
18
19
20
# File 'lib/policy_manager/exporter/zip_generator.rb', line 17

def initialize(input_dir, output_file)
  @input_dir = input_dir
  @output_file = output_file
end

Instance Method Details

#writeObject

Zip the input directory.



23
24
25
26
27
28
29
# File 'lib/policy_manager/exporter/zip_generator.rb', line 23

def write
  entries = Dir.entries(@input_dir) - %w(. ..)

  ::Zip::File.open(@output_file, ::Zip::File::CREATE) do |zipfile|
    write_entries entries, '', zipfile
  end
end