Class: Hbc::Container::GenericUnar

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

Direct Known Subclasses

Rar, SevenZip, Sit

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
13
# File 'Library/Homebrew/cask/lib/hbc/container/generic_unar.rb', line 8

def self.me?(criteria)
  return false unless lsar = which("lsar", PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin"))
  criteria.command.run(lsar,
                       args:         ["-l", "-t", "--", criteria.path],
                       print_stderr: false).stdout.chomp.end_with?("passed, 0 failed.")
end

Instance Method Details

#extractObject



15
16
17
18
19
20
21
22
23
24
# File 'Library/Homebrew/cask/lib/hbc/container/generic_unar.rb', line 15

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

  Dir.mktmpdir do |unpack_dir|
    @command.run!(unar, args: ["-force-overwrite", "-quiet", "-no-directory", "-output-directory", unpack_dir, "--", @path])
    @command.run!("/usr/bin/ditto", args: ["--", unpack_dir, @cask.staged_path])
  end
end