homebrew-cask-versions/lib/hbc/container/cab.rb
Roland Walker b40b0c99e1 strip constants from homebrew-fork global.rb
and corresponding testing_env.rb.
* recast HOMEBREW_BREW_FILE as Hbc.homebrew_executable,
  defined in Hbc::Locations
* recast HOMEBREW_REPOSITORY as Hbc.homebrew_repository
* recast HOMEBREW_PREFIX as Hbc.homebrew_prefix
* remove HOMEBREW_LIBRARY
* recast existing Hbc.tapspath as Hbc.homebrew_tapspath
  to match new methods

fixes #8705
2015-01-07 09:09:53 -05:00

21 lines
793 B
Ruby

require 'tmpdir'
class Hbc::Container::Cab < Hbc::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 = Hbc.homebrew_prefix.join('bin/cabextract')
if ! Pathname.new(cabextract).exist?
raise Hbc::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