homebrew-cask/lib/cask.rb

80 lines
1.8 KiB
Ruby
Raw Normal View History

HOMEBREW_CACHE_CASKS = HOMEBREW_CACHE.join('Casks')
class Cask; end
require 'cask/artifact'
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
require 'cask/audit'
require 'cask/auditor'
require 'cask/without_source'
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
require 'cask/checkable'
require 'cask/cli'
require 'cask/container'
require 'cask/download'
require 'cask/download_strategy'
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
require 'cask/dsl'
require 'cask/exceptions'
require 'cask/fetcher'
require 'cask/installer'
require 'cask/link_checker'
require 'cask/locations'
2014-01-06 04:30:53 +08:00
require 'cask/options'
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
require 'cask/pkg'
require 'cask/pretty_listing'
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
require 'cask/scopes'
require 'cask/source'
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
require 'cask/system_command'
require 'cask/underscore_supporting_uri'
require 'cask/url'
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
require 'plist/parser'
class Cask
include Cask::DSL
include Cask::Locations
include Cask::Scopes
2014-01-06 04:30:53 +08:00
include Cask::Options
def self.init
HOMEBREW_CACHE.mkpath unless HOMEBREW_CACHE.exist?
unless caskroom.exist?
ohai "We need to make Caskroom for the first time at #{caskroom}"
ohai "We'll set permissions properly so we won't need sudo in the future"
current_user = ENV['USER']
sudo = 'sudo' unless caskroom.parent.writable?
system "#{sudo} mkdir -p #{caskroom}"
system "#{sudo} chown -R #{current_user}:staff #{caskroom.parent}"
end
appdir.mkpath unless appdir.exist?
2013-11-29 08:45:49 +08:00
qlplugindir.mkpath unless qlplugindir.exist?
end
def self.load(query)
Cask::Source.for_query(query).load
end
def self.title
self.name.gsub(/([a-zA-Z\d])([A-Z])/,'\1-\2').gsub(/([a-zA-Z\d])([A-Z])/,'\1-\2').downcase
end
attr_reader :title
def initialize(title=self.class.title)
@title = title
end
def caskroom_path
self.class.caskroom.join(title)
end
def destination_path
caskroom_path.join(version)
end
def installed?
destination_path.exist?
end
def to_s
@title
end
end