Class: TravisBuildTools::ZipFileGenerator
- Inherits:
-
Object
- Object
- TravisBuildTools::ZipFileGenerator
- Defined in:
- lib/travis-build-tools/zip_file_generator.rb
Instance Method Summary collapse
-
#initialize ⇒ ZipFileGenerator
constructor
Initialize with the directory to zip and the location of the output archive.
- #unzip_file(file, directory) ⇒ Object
-
#write(inputDir, outputFile) ⇒ Object
Zip the input directory.
Constructor Details
#initialize ⇒ ZipFileGenerator
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 |