2013-09-23 22:32:46 +08:00
|
|
|
module Cask::Locations
|
|
|
|
def self.included(base)
|
|
|
|
base.extend(ClassMethods)
|
|
|
|
end
|
|
|
|
|
|
|
|
module ClassMethods
|
|
|
|
def tapspath
|
2013-11-17 09:16:37 +08:00
|
|
|
HOMEBREW_REPOSITORY.join "Library", "Taps"
|
2013-09-23 22:32:46 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def caskroom
|
|
|
|
@@caskroom ||= Pathname('/opt/homebrew-cask/Caskroom')
|
|
|
|
end
|
|
|
|
|
|
|
|
def caskroom=(caskroom)
|
|
|
|
@@caskroom = caskroom
|
|
|
|
end
|
|
|
|
|
|
|
|
def appdir
|
|
|
|
@appdir ||= Pathname.new('~/Applications').expand_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def appdir=(_appdir)
|
|
|
|
@appdir = _appdir
|
|
|
|
end
|
|
|
|
|
|
|
|
def prefpanedir
|
|
|
|
@prefpanedir ||= Pathname.new('~/Library/PreferencePanes').expand_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def prefpanedir=(_prefpanedir)
|
|
|
|
@prefpanedir = _prefpanedir
|
|
|
|
end
|
|
|
|
|
2013-11-15 02:09:29 +08:00
|
|
|
def qlplugindir
|
|
|
|
@qlplugindir ||= Pathname.new('~/Library/QuickLook').expand_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def qlplugindir=(_qlplugindir)
|
|
|
|
@qlplugindir = _qlplugindir
|
|
|
|
end
|
|
|
|
|
2013-11-26 21:38:43 +08:00
|
|
|
def fontdir
|
|
|
|
@fontdir ||= Pathname.new('~/Library/Fonts').expand_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def fontdir=(_fontdir)
|
|
|
|
@fontdir = _fontdir
|
|
|
|
end
|
|
|
|
|
2013-09-23 22:32:46 +08:00
|
|
|
def default_tap
|
|
|
|
@default_tap ||= 'phinze-cask'
|
|
|
|
end
|
|
|
|
|
|
|
|
def default_tap=(_tap)
|
|
|
|
@default_tap = _tap
|
|
|
|
end
|
|
|
|
|
|
|
|
def path(cask_title)
|
|
|
|
if cask_title.include?('/')
|
|
|
|
cask_with_tap = cask_title
|
|
|
|
else
|
|
|
|
cask_with_tap = all_titles.detect { |tap_and_title|
|
|
|
|
_, title = tap_and_title.split('/')
|
|
|
|
title == cask_title
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
if cask_with_tap
|
|
|
|
tap, cask = cask_with_tap.split('/')
|
|
|
|
tapspath.join(tap, 'Casks', "#{cask}.rb")
|
|
|
|
else
|
|
|
|
tapspath.join(default_tap, 'Casks', "#{cask_title}.rb")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|