Class: Tarchiver::Gzipper

Inherits:
Compressor show all
Defined in:
lib/tarchiver/compressors/gzip.rb

Class Method Summary collapse

Class Method Details

.compress(archive_path, tar_path, options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/tarchiver/compressors/gzip.rb', line 4

def self.compress(archive_path, tar_path, options)
  tgz_path = "#{archive_path}.tgz"
  begin
    Zlib::GzipWriter.open(tgz_path) do |gz|
      ::File.open(tar_path, "rb") do |tar|
        while buffer = tar.read(options[:blocksize])
          gz.write(buffer)
        end
      end
    end
  rescue => error
    puts "GZip could not complete zipping for the following reason:\n#{error.message}" if options[:verbose]
    return Tarchiver::Helpers.terminate(error, options)
  end
  tgz_path
end

.open(path) ⇒ Object



21
22
23
# File 'lib/tarchiver/compressors/gzip.rb', line 21

def self.open(path)
  Zlib::GzipReader.open(path)
end