Class: Hbc::Container::Tar

Inherits:
Base
  • Object
show all
Defined in:
Library/Homebrew/cask/lib/hbc/container/tar.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#extract_nested_container, #extract_nested_inside, #initialize, #verbose?

Constructor Details

This class inherits a constructor from Hbc::Container::Base

Class Method Details

.me?(criteria) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
# File 'Library/Homebrew/cask/lib/hbc/container/tar.rb', line 8

def self.me?(criteria)
  criteria.magic_number(/^.{257}ustar/n) ||
    # or compressed tar (bzip2/gzip/lzma/xz)
    IO.popen(["/usr/bin/tar", "-t", "-f", criteria.path.to_s], err: "/dev/null") { |io| !io.read(1).nil? }
end

Instance Method Details

#extractObject



14
15
16
17
18
19
# File 'Library/Homebrew/cask/lib/hbc/container/tar.rb', line 14

def extract
  Dir.mktmpdir do |unpack_dir|
    @command.run!("/usr/bin/tar", args: ["-x", "-f", @path, "-C", unpack_dir])
    @command.run!("/usr/bin/ditto", args: ["--", unpack_dir, @cask.staged_path])
  end
end