Class: Hbc::Container::Xz

Inherits:
Base
  • Object
show all
Defined in:
Library/Homebrew/cask/lib/hbc/container/xz.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
# File 'Library/Homebrew/cask/lib/hbc/container/xz.rb', line 8

def self.me?(criteria)
  criteria.magic_number(/^\xFD7zXZ\x00/n)
end

Instance Method Details

#extractObject



12
13
14
15
16
17
18
19
20
21
22
# File 'Library/Homebrew/cask/lib/hbc/container/xz.rb', line 12

def extract
  unless unxz = which("unxz", PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin"))
    raise CaskError, "Expected to find unxz executable. Cask '#{@cask}' must add: depends_on formula: 'xz'"
  end

  Dir.mktmpdir do |unpack_dir|
    @command.run!("/usr/bin/ditto", args: ["--", @path, unpack_dir])
    @command.run!(unxz, args: ["-q", "--", Pathname(unpack_dir).join(@path.basename)])
    @command.run!("/usr/bin/ditto", args: ["--", unpack_dir, @cask.staged_path])
  end
end