Module: BatchKit::Helpers::Zip

Defined in:
lib/batch-kit/helpers/zip.rb

Instance Method Summary collapse

Instance Method Details

#create_zip(zip_file, *files) ⇒ Object

Creates a new zip_file, adding files to it.

Parameters:

  • zip_file (String)

    A path to the zip file to be created

  • files (String)

    One or more paths to files to be added to the zip.



16
17
18
19
20
21
22
23
24
# File 'lib/batch-kit/helpers/zip.rb', line 16

def create_zip(zip_file, *files)
    FileUtils.rm_f(zip_file)
    Zip::ZipFile.open(zip_file, Zip::ZipFile::CREATE) do |zip|
        files.each do |file|
            zip.add(File.basename(file), file)
        end
        yield zip if block_given?
    end
end