Ratch  Ratch::ZlibUtils

[Validate]
Generated with Newfish 0.1.0

ZlibUtils

Public Class Methods

extended(base) click to toggle source
    # File lib/ratch/utils/zlib.rb, line 11
11:     def self.extended(base)
12:       included(base)
13:     end
included(base) click to toggle source
   # File lib/ratch/utils/zlib.rb, line 7
7:     def self.included(base)
8:       require 'zlib'
9:     end

Public Instance Methods

gzip(file, tofile=nil, options={}) click to toggle source

Create a gzip file.

    # File lib/ratch/utils/zlib.rb, line 16
16:     def gzip(file, tofile=nil, options={})
17:       noop, verbose = *util_options(options)
18: 
19:       tofile ||= File.basename(file) + '.gz'
20: 
21:       puts "gzip #{file}" if verbose
22: 
23:       file   = localize(file)
24:       tofile = localize(tofile)
25: 
26:       Zlib::GzipWriter.open(tofile) do |gz|
27:         gz.write(File.read(file))
28:       end unless noop
29: 
30:       return tofile
31:     end
ungzip(file, options={}) click to toggle source

Unpack a gzip file.

    # File lib/ratch/utils/zlib.rb, line 34
34:     def ungzip(file, options={})
35:       noop, verbose = *util_options(options)
36: 
37:       fname = File.basename(file).chomp(File.extname(file))
38: 
39:       puts "ungzip #{file}" if verbose
40: 
41:       fname = localize(fname)
42:       file  = localize(file)
43: 
44:       Zlib::GzipReader.open(file) do |gz|
45:         File.open(fname, 'wb'){ |f| f << gz.read }
46:       end unless noop
47: 
48:       return fname
49:     end

Disabled; run with --debug to generate this.