Class: Packmule::Archiver::Zip

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

Overview

Zipper

Class Method Summary collapse

Class Method Details

.create(options) ⇒ Object

Zips the stuff



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/packmule/archiver/zip.rb', line 17

def self.create(options)
  # Make sure the archive doesn't exist..
  if ::FileTest.exists? "./#{options[:filename]}.zip"
    puts "#{options[:filename]}.zip already exists, skipping"
    return false
  end

  # Get the needed Zip stuff
  gem 'rubyzip'
  require 'zip'

  # Create the archive
  ::Zip::File.open("./#{options[:filename]}.zip", 'w') do |z|
    Dir["#{options[:dir]}/**/**"].each do |file|
      z.add(file.sub("#{options[:dir]}/", ''), file) if not options[:ignore].include?(file.sub("#{options[:dir]}/", ''))
    end # Dir
  end # Zip block

  puts " - #{options[:filename]}.zip created"
  return true
end