Class: Morpheus::Morpkg::ZipFileGenerator
- Inherits:
 - 
      Object
      
        
- Object
 - Morpheus::Morpkg::ZipFileGenerator
 
 
- Defined in:
 - lib/morpheus/morpkg.rb
 
Overview
This is a simple example which uses rubyzip to recursively generate a zip file from the contents of a specified directory. The directory itself is not included in the archive, rather just its contents.
Usage:
directoryToZip = "/tmp/input"
outputFile = "/tmp/out.zip"
zf = ZipFileGenerator.new(directoryToZip, outputFile)
zf.write()
  Instance Method Summary collapse
- 
  
    
      #initialize(inputDir, outputFile)  ⇒ ZipFileGenerator 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Initialize with the directory to zip and the location of the output archive.
 - 
  
    
      #write  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Zip the input directory.
 
Constructor Details
#initialize(inputDir, outputFile) ⇒ ZipFileGenerator
Initialize with the directory to zip and the location of the output archive.
      85 86 87 88  | 
    
      # File 'lib/morpheus/morpkg.rb', line 85 def initialize(inputDir, outputFile) @inputDir = inputDir @outputFile = outputFile end  | 
  
Instance Method Details
#write ⇒ Object
Zip the input directory.
      91 92 93 94 95 96  | 
    
      # File 'lib/morpheus/morpkg.rb', line 91 def write() entries = Dir.entries(@inputDir); entries.delete("."); entries.delete("..") io = Zip::File.open(@outputFile, Zip::File::CREATE); writeEntries(entries, "", io) io.close(); end  |