Class: ZipUtil

Inherits:
Object
  • Object
show all
Defined in:
lib/jenkins_util/zip_util.rb

Class Method Summary collapse

Class Method Details

.compress(*sources, destination) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/jenkins_util/zip_util.rb', line 19

def self.compress(*sources, destination)
  Zip::File.open(destination, ::Zip::File::CREATE) do |zip_archive|
    sources.each do |source|
      write_path_to_archive(zip_archive, source)
    end
  end
end

.uncompress(source, destination) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/jenkins_util/zip_util.rb', line 27

def self.uncompress(source, destination)
  Zip::File.open(source) do |zip_file|
    zip_file.each do |entry|
      path = File.join(destination, entry.name)
      LoggerUtil.log.debug("Extracting #{path}")
      entry.extract(File.join(destination, entry.name))
    end
  end
end