Ratch  Ratch::TarUtils

Included Modules

[Validate]
Generated with Newfish 0.1.0

TarUtils

Utility methods for working with tarballs archives.

Public Class Methods

extended(base) click to toggle source
    # File lib/ratch/utils/tar.rb, line 20
20:     def self.extended(base)
21:       included(base)
22:     end
included(base) click to toggle source

When included include GZipUtils too.

    # File lib/ratch/utils/tar.rb, line 13
13:     def self.included(base)
14:       #require 'zlib'
15:       include ZLibUtils
16:       require 'archive/tar/minitar'
17:     end

Public Instance Methods

tar(folder, file=nil, options={}) click to toggle source

Tar

    # File lib/ratch/utils/tar.rb, line 25
25:     def tar(folder, file=nil, options={})
26:       noop, verbose = *util_options(options)
27:       file ||= File.basename(File.expand_path(folder)) + '.tar'
28:       cmd = "tar -cf #{file} #{folder}"
29:       puts cmd if verbose
30:       unless noop
31:         locally do
32:           gzIO = File.open(file, 'wb')
33:           Archive::Tar::Minitar.pack(folder, gzIO)
34:         end
35:       end
36:       path(file)
37:     end
tar_gzip(folder, file=nil, options={}) click to toggle source

Tar Gzip

    # File lib/ratch/utils/tar.rb, line 55
55:     def tar_gzip(folder, file=nil, options={})
56:       noop, verbose = *util_options(options)
57:       file ||= File.basename(File.expand_path(folder)) + '.tar.gz' # '.tgz' which ?
58:       cmd = "tar --gzip -czf #{file} #{folder}"
59:       puts cmd if verbose
60:       unless noop
61:         locally do #folder, file = localize(folder), localize(file)
62:           gzIO = Zlib::GzipWriter.new(File.open(file, 'wb'))
63:           Archive::Tar::Minitar.pack(folder, gzIO)
64:         end
65:       end
66:       path(file)
67:     end
Also aliased as: tar_z
tar_z(folder, file=nil, options={}) click to toggle source
untar(file, options={}) click to toggle source

Untar

    # File lib/ratch/utils/tar.rb, line 40
40:     def untar(file, options={})
41:       noop, verbose = *util_options(options)
42:       #file ||= File.basename(File.expand_path(folder)) + '.tar'
43:       cmd = "untar #{file}"
44:       puts cmd if verbose
45:       unless noop
46:         locally do
47:           gzIO = File.open(file, 'wb')
48:           Archive::Tar::Minitar.unpack(gzIO)
49:         end
50:       end
51:       path(file)
52:     end
untar_gzip(file, options={}) click to toggle source

Untar Gzip

FIXME: Write unified untar_gzip function.

    # File lib/ratch/utils/tar.rb, line 74
74:     def untar_gzip(file, options={})
75:       untar(ungzip(file, options), options)
76:     end
Also aliased as: untar_z
untar_z(file, options={}) click to toggle source

Disabled; run with --debug to generate this.