homebrew-cask/lib/hbc/container/naked.rb

17 lines
454 B
Ruby
Raw Normal View History

class Hbc::Container::Naked < Hbc::Container::Base
naked pkg support + major container refactor `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
2013-09-22 10:44:49 +08:00
def self.me?(criteria)
# Either inherit from this class and override self.me?,
# or use this class directly as "container :type => :naked",
# in which case self.me? is not called.
false
naked pkg support + major container refactor `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
2013-09-22 10:44:49 +08:00
end
def extract
@command.run!('/usr/bin/ditto', :args => ['--', @path, @cask.staged_path.join(target_file)])
naked pkg support + major container refactor `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
2013-09-22 10:44:49 +08:00
end
def target_file
URI.decode(File.basename(@cask.url.path))
naked pkg support + major container refactor `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
2013-09-22 10:44:49 +08:00
end
end