mirror of
https://github.com/donl/homebrew-cask-versions.git
synced 2026-07-17 06:16:47 -06:00
`Cask::Installer` was already much too complex, so I took this opportunity to throw a `Cask::Container` abstraction around the extraction part of the package install step. It goes like this: a Cask's URL points to a Container of some sort. The containers we currently support are: dmg, zip, tar, and (new) naked. Naked refers to a raw file that just needs to be copied in place. This currently just means a pkg file, but in the future it may expand. A Container knows how to do two things: identify a path as being its type (`Container.me?`) and extracting the contents of its container to the proper destination for a Cask (`Container#extract`). The first Cask we have that supports the naked pkg type is `heroku-toolbelt`. (Thanks to @sheerun for the Cask definition.) Other miscellania batched in with this refactor: - switched to an explicit require strategy rather than globbing - `Cask::Installer` is instantiated now to match its interface with other similar collaorators - simplified zip and tar identification to shorter strings rather than exact matches of full `file -Izb` output - `Cask::SystemCommand` gets explicit output redirection options - many rogue backticks replaced to properly use `SystemCommand` - fixed misnamed test file `link_checker_spec.rb` - remove some extraneous `after` clauses in tests; leaning more on `test/support/cleanup.rb` to uninstall for us - pkg uninstall `:files` gets a `-rf` to support removing dirs refs #839 and #1043
24 lines
537 B
Ruby
24 lines
537 B
Ruby
class Cask::Container; end
|
|
|
|
require 'cask/container/base'
|
|
require 'cask/container/criteria'
|
|
require 'cask/container/dmg'
|
|
require 'cask/container/naked'
|
|
require 'cask/container/tar'
|
|
require 'cask/container/zip'
|
|
|
|
class Cask::Container
|
|
def self.containers
|
|
[
|
|
Cask::Container::Dmg,
|
|
Cask::Container::Tar,
|
|
Cask::Container::Zip,
|
|
Cask::Container::Naked,
|
|
]
|
|
end
|
|
|
|
def self.for_path(path, command)
|
|
criteria = Cask::Container::Criteria.new(path, command)
|
|
containers.find { |c| c.me?(criteria) }
|
|
end
|
|
end
|