Class: Cfhighlander::Util::ZipFileGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/util/zip.util.rb

Overview

Instance Method Summary collapse

Constructor Details

#initialize(input_dir, output_file) ⇒ ZipFileGenerator

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



11
12
13
14
# File 'lib/util/zip.util.rb', line 11

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

Instance Method Details

#writeObject

Zip the input directory.



17
18
19
20
21
22
23
# File 'lib/util/zip.util.rb', line 17

def write
  entries = Dir.entries(@input_dir) - %w(. ..)
  puts "DEBUG: Compressing #{@input_dir} to #{@output_file}"
  Zip::File.open(@output_file, ::Zip::File::CREATE) do |zipfile|
    write_entries entries, '', zipfile
  end
end