Class: Rake::Delphi::ZipTask

Inherits:
BasicTask show all
Defined in:
lib/rake/common/ziptask.rb

Instance Method Summary collapse

Methods inherited from BasicTask

#trace?

Constructor Details

#initialize(task, zipfile, files, options = nil) ⇒ ZipTask



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rake/common/ziptask.rb', line 38

def initialize(task, zipfile, files, options = nil)
    super(task)
    Logger.trace(Logger::VERBOSE, [zipfile, files])
    raise "zipfile name is not defined!" if zipfile.nil? || zipfile.empty?
    @norubyzip = nil
    @options = options || {}
    begin
        require 'zip/zip'
    rescue LoadError
        @norubyzip = true
    end
    raise "no ZIP library (rubyzip) found!" if @norubyzip
    # work with rubyzip
    Logger.trace(Logger::VERBOSE, '`rubyzip` gem is used')
    File.unlink(zipfile) if File.exists?(zipfile) && ! @options[:add]
    Zip.options[:continue_on_exists_proc] = true
    Zip::ZipFile.open(zipfile, Zip::ZipFile::CREATE) do |z|
        files.each do |f|
            zip_addfile(z, f)
        end
    end
end