2016-09-24 13:52:43 +02:00
|
|
|
module Hbc
|
|
|
|
module Locations
|
|
|
|
def self.included(base)
|
|
|
|
base.extend(ClassMethods)
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
module ClassMethods
|
|
|
|
def legacy_caskroom
|
|
|
|
@legacy_caskroom ||= Pathname.new("/opt/homebrew-cask/Caskroom")
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def default_caskroom
|
|
|
|
@default_caskroom ||= homebrew_prefix.join("Caskroom")
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def caskroom
|
|
|
|
@caskroom ||= begin
|
|
|
|
if Utils.path_occupied?(legacy_caskroom)
|
|
|
|
opoo <<-EOS.undent
|
|
|
|
The default Caskroom location has moved to #{default_caskroom}.
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
Please migrate your Casks to the new location and delete #{legacy_caskroom},
|
|
|
|
or if you would like to keep your Caskroom at #{legacy_caskroom}, add the
|
|
|
|
following to your HOMEBREW_CASK_OPTS:
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
--caskroom=#{legacy_caskroom}
|
|
|
|
|
|
|
|
For more details on each of those options, see https://github.com/caskroom/homebrew-cask/issues/21913.
|
|
|
|
EOS
|
|
|
|
legacy_caskroom
|
|
|
|
else
|
|
|
|
default_caskroom
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def caskroom=(caskroom)
|
|
|
|
@caskroom = caskroom
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def legacy_cache
|
|
|
|
@legacy_cache ||= homebrew_cache.join("Casks")
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def cache
|
|
|
|
@cache ||= homebrew_cache.join("Cask")
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
attr_writer :appdir
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def appdir
|
|
|
|
@appdir ||= Pathname.new("/Applications").expand_path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
attr_writer :prefpanedir
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def prefpanedir
|
|
|
|
@prefpanedir ||= Pathname.new("~/Library/PreferencePanes").expand_path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
attr_writer :qlplugindir
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def qlplugindir
|
|
|
|
@qlplugindir ||= Pathname.new("~/Library/QuickLook").expand_path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-10-23 17:32:19 +02:00
|
|
|
attr_writer :dictionarydir
|
|
|
|
|
|
|
|
def dictionarydir
|
|
|
|
@dictionarydir ||= Pathname.new("~/Library/Dictionaries").expand_path
|
|
|
|
end
|
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
attr_writer :fontdir
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def fontdir
|
|
|
|
@fontdir ||= Pathname.new("~/Library/Fonts").expand_path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
attr_writer :colorpickerdir
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def colorpickerdir
|
|
|
|
@colorpickerdir ||= Pathname.new("~/Library/ColorPickers").expand_path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
attr_writer :servicedir
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def servicedir
|
|
|
|
@servicedir ||= Pathname.new("~/Library/Services").expand_path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
attr_writer :binarydir
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def binarydir
|
|
|
|
@binarydir ||= homebrew_prefix.join("bin")
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
attr_writer :input_methoddir
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def input_methoddir
|
|
|
|
@input_methoddir ||= Pathname.new("~/Library/Input Methods").expand_path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
attr_writer :internet_plugindir
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def internet_plugindir
|
|
|
|
@internet_plugindir ||= Pathname.new("~/Library/Internet Plug-Ins").expand_path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
attr_writer :audio_unit_plugindir
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def audio_unit_plugindir
|
|
|
|
@audio_unit_plugindir ||= Pathname.new("~/Library/Audio/Plug-Ins/Components").expand_path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
attr_writer :vst_plugindir
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def vst_plugindir
|
|
|
|
@vst_plugindir ||= Pathname.new("~/Library/Audio/Plug-Ins/VST").expand_path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
attr_writer :vst3_plugindir
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def vst3_plugindir
|
|
|
|
@vst3_plugindir ||= Pathname.new("~/Library/Audio/Plug-Ins/VST3").expand_path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
attr_writer :screen_saverdir
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def screen_saverdir
|
|
|
|
@screen_saverdir ||= Pathname.new("~/Library/Screen Savers").expand_path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
attr_writer :default_tap
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def default_tap
|
|
|
|
@default_tap ||= Tap.fetch("caskroom", "homebrew-cask")
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def path(query)
|
2016-10-08 13:25:38 +02:00
|
|
|
query_path = Pathname.new(query)
|
|
|
|
|
2016-10-17 23:46:23 -04:00
|
|
|
return query_path if query_path.absolute?
|
|
|
|
return query_path if query_path.exist? && query_path.extname == ".rb"
|
2016-10-08 13:25:38 +02:00
|
|
|
|
2016-10-14 20:03:34 +02:00
|
|
|
query_without_extension = query.sub(/\.rb$/i, "")
|
2016-10-08 13:25:38 +02:00
|
|
|
|
|
|
|
token_with_tap = if query =~ %r{\A[^/]+/[^/]+/[^/]+\Z}
|
2016-10-14 20:11:33 +02:00
|
|
|
query_without_extension
|
|
|
|
else
|
2016-10-23 14:44:14 +02:00
|
|
|
all_tokens.detect do |tap_and_token|
|
2016-10-14 20:11:33 +02:00
|
|
|
tap_and_token.split("/")[2] == query_without_extension
|
2016-10-23 14:44:14 +02:00
|
|
|
end
|
2016-10-14 20:11:33 +02:00
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
if token_with_tap
|
|
|
|
user, repo, token = token_with_tap.split("/")
|
2016-10-08 13:25:38 +02:00
|
|
|
tap = Tap.fetch(user, repo)
|
2016-09-24 13:52:43 +02:00
|
|
|
else
|
2016-10-08 13:25:38 +02:00
|
|
|
token = query_without_extension
|
|
|
|
tap = Hbc.default_tap
|
2016-09-24 13:52:43 +02:00
|
|
|
end
|
2016-10-08 13:25:38 +02:00
|
|
|
|
|
|
|
return query_path if tap.cask_dir.nil?
|
|
|
|
tap.cask_dir.join("#{token}.rb")
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def tcc_db
|
|
|
|
@tcc_db ||= Pathname.new("/Library/Application Support/com.apple.TCC/TCC.db")
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def pre_mavericks_accessibility_dotfile
|
|
|
|
@pre_mavericks_accessibility_dotfile ||= Pathname.new("/private/var/db/.AccessibilityAPIEnabled")
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def x11_executable
|
|
|
|
@x11_executable ||= Pathname.new("/usr/X11/bin/X")
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def x11_libpng
|
|
|
|
@x11_libpng ||= [Pathname.new("/opt/X11/lib/libpng.dylib"), Pathname.new("/usr/X11/lib/libpng.dylib")]
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def homebrew_cache
|
|
|
|
@homebrew_cache ||= HOMEBREW_CACHE
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def homebrew_cache=(path)
|
|
|
|
@homebrew_cache = path ? Pathname.new(path) : path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def homebrew_executable
|
|
|
|
@homebrew_executable ||= HOMEBREW_BREW_FILE
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def homebrew_prefix
|
|
|
|
# where Homebrew links
|
|
|
|
@homebrew_prefix ||= HOMEBREW_PREFIX
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def homebrew_prefix=(path)
|
|
|
|
@homebrew_prefix = path ? Pathname.new(path) : path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def homebrew_repository
|
|
|
|
# where Homebrew's .git dir is found
|
|
|
|
@homebrew_repository ||= HOMEBREW_REPOSITORY
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def homebrew_repository=(path)
|
|
|
|
@homebrew_repository = path ? Pathname.new(path) : path
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|