Class: PolicyManager::ZipGenerator
- Inherits:
-
Object
- Object
- PolicyManager::ZipGenerator
- Defined in:
- lib/policy_manager/exporter/zip_generator.rb
Instance Method Summary collapse
-
#initialize(input_dir, output_file) ⇒ ZipGenerator
constructor
Initialize with the directory to zip and the location of the output archive.
-
#write ⇒ Object
Zip the input directory.
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
#write ⇒ Object
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 |