homebrew-cask-versions/lib/cask/container/cab.rb
Roland Walker 967aa22793 recast method destination_path as staged_path
* part of DSL 1.0 review
* `destination_path` was always a bit vague (it refers to
  Cask-specific, version-specific location under
  `/opt/homebrew-cask/Caskroom`)
* here renamed `staged_path` to match upcoming command verb
  `brew cask stage`
* rename also intended to reduce confusion when we implement
  copying as a configurable alternative to symlinking
* transitional `destination_path` methods to remain while
  Casks are converted (this was documented as a part of the
  DSL, and used by 39 Casks in main repo)
* unrelated variables containing "stage" recast for clarity
2014-10-18 12:23:36 -04:00

21 lines
786 B
Ruby

require 'tmpdir'
class Cask::Container::Cab < Cask::Container::Base
def self.me?(criteria)
(criteria.file.include? 'application/octet-stream;' or
criteria.file.include? 'application/vnd.ms-cab-compressed;') and
! criteria.cabextract.nil? and
criteria.cabextract.include? 'All done, no errors'
end
def extract
cabextract = HOMEBREW_PREFIX.join('bin/cabextract')
if ! Pathname.new(cabextract).exist?
raise CaskError.new "Expected to find cabextract executable. Cask '#{@cask}' must add: depends_on :formula => 'cabextract'"
end
Dir.mktmpdir do |unpack_dir|
@command.run!(cabextract, :args => ['-d', unpack_dir, '--', @path])
@command.run!('/usr/bin/ditto', :args => ['--', unpack_dir, @cask.staged_path])
end
end
end