Module: Dapp::Helper::Tar

Included in:
Dapp, Dimg::GitArtifact, Dimg::Image::Scratch
Defined in:
lib/dapp/helper/tar.rb

Instance Method Summary collapse

Instance Method Details

#tar_gz_read(path) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/dapp/helper/tar.rb', line 20

def tar_gz_read(path)
  File.open(path, File::RDONLY) do |f_gz|
    Zlib::GzipReader.wrap(f_gz) do |f|
      Gem::Package::TarReader.new(f) do |tar|
        yield tar if block_given?
      end
    end
  end
end

#tar_read(path) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/dapp/helper/tar.rb', line 12

def tar_read(path)
  File.open(path, File::RDONLY) do |f|
    Gem::Package::TarReader.new(f) do |tar|
      yield tar if block_given?
    end
  end
end

#tar_write(path) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/dapp/helper/tar.rb', line 4

def tar_write(path)
  File.open(path, File::RDWR | File::CREAT) do |f|
    Gem::Package::TarWriter.new(f) do |tar|
      yield tar if block_given?
    end
  end
end