Class: TravisBuildTools::ZipFileGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/travis-build-tools/zip_file_generator.rb

Instance Method Summary collapse

Constructor Details

#initializeZipFileGenerator

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



16
17
# File 'lib/travis-build-tools/zip_file_generator.rb', line 16

def initialize()
end

Instance Method Details

#unzip_file(file, directory) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/travis-build-tools/zip_file_generator.rb', line 28

def unzip_file(file, directory)
  Zip::File.open(file) do |zip_file|
    zip_file.each do |f|
      extraction_location = File.join(directory, f.name)
      FileUtils.mkdir_p(directory)
      zip_file.extract(f, extraction_location)
    end
  end
end

#write(inputDir, outputFile) ⇒ Object

Zip the input directory.



20
21
22
23
24
25
26
# File 'lib/travis-build-tools/zip_file_generator.rb', line 20

def write(inputDir, outputFile)
  entries = Dir.entries(inputDir); entries.delete("."); entries.delete("..")
  io = Zip::File.open(outputFile, Zip::File::CREATE);
   
  writeEntries(entries, "", io, inputDir)
  io.close();
end