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-12-09 01:28:56 +08:00
|
|
|
def widgetdir
|
|
|
|
@widgetdir ||= Pathname.new('~/Library/Widgets').expand_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def widgetdir=(_widgetdir)
|
|
|
|
@widgetdir = _widgetdir
|
|
|
|
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-12-08 13:32:41 +08:00
|
|
|
def colorpickerdir
|
|
|
|
@colorpickerdir ||= Pathname.new('~/Library/ColorPickers').expand_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def colorpickerdir=(_colorpickerdir)
|
|
|
|
@colorpickerdir = _colorpickerdir
|
|
|
|
end
|
|
|
|
|
2013-12-14 08:13:19 +08:00
|
|
|
def servicedir
|
|
|
|
@servicedir ||= Pathname.new('~/Library/Services').expand_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def servicedir=(_servicedir)
|
|
|
|
@servicedir = _servicedir
|
|
|
|
end
|
|
|
|
|
2014-01-06 04:30:53 +08:00
|
|
|
def binarydir
|
|
|
|
@binarydir ||= Pathname.new('/usr/local/bin').expand_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def binarydir=(_binarydir)
|
|
|
|
@binarydir = _binarydir
|
|
|
|
end
|
|
|
|
|
2014-01-14 01:21:44 +08:00
|
|
|
def input_methoddir
|
|
|
|
@input_methoddir ||= Pathname.new('~/Library/Input Methods').expand_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def input_methoddir=(_input_methoddir)
|
|
|
|
@input_methoddir = _input_methoddir
|
|
|
|
end
|
|
|
|
|
2014-01-28 23:17:50 +08:00
|
|
|
def screen_saverdir
|
|
|
|
@screen_saverdir ||= Pathname.new('~/Library/Screen Savers').expand_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def screen_saverdir=(_screen_saverdir)
|
|
|
|
@screen_saverdir = _screen_saverdir
|
|
|
|
end
|
|
|
|
|
2013-09-23 22:32:46 +08:00
|
|
|
def default_tap
|
2014-04-26 01:01:32 +08:00
|
|
|
@default_tap ||= 'phinze/homebrew-cask'
|
2013-09-23 22:32:46 +08:00
|
|
|
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|
|
2014-04-26 01:01:32 +08:00
|
|
|
user, repo, title = tap_and_title.split('/')
|
2013-09-23 22:32:46 +08:00
|
|
|
title == cask_title
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
if cask_with_tap
|
2014-04-26 01:01:32 +08:00
|
|
|
user, repo, cask = cask_with_tap.split('/')
|
|
|
|
# bug/todo: handle old-style 1-slash form: phinze-cask/name
|
|
|
|
repo = 'homebrew-' + repo unless repo.match(/^homebrew-/)
|
|
|
|
tapspath.join(user, repo, 'Casks', "#{cask}.rb")
|
2013-09-23 22:32:46 +08:00
|
|
|
else
|
|
|
|
tapspath.join(default_tap, 'Casks', "#{cask_title}.rb")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|