Module: ForemanGitTemplates::Tar

Defined in:
app/lib/foreman_git_templates/tar.rb

Class Method Summary collapse

Class Method Details

.tar(filepath) ⇒ Object



8
9
10
11
12
13
14
# File 'app/lib/foreman_git_templates/tar.rb', line 8

def tar(filepath)
  Zlib::GzipWriter.open(filepath) do |gz|
    Gem::Package::TarWriter.new(gz) do |tar|
      yield tar if block_given?
    end
  end
end

.untar(filepath) ⇒ Object



16
17
18
19
20
21
22
# File 'app/lib/foreman_git_templates/tar.rb', line 16

def untar(filepath)
  Zlib::GzipReader.open(filepath) do |gz|
    Gem::Package::TarReader.new(gz) do |tar|
      yield tar if block_given?
    end
  end
end