2013-07-27 02:54:40 +08:00
|
|
|
HOMEBREW_CACHE_CASKS = HOMEBREW_CACHE.join('Casks')
|
|
|
|
|
2012-03-05 10:46:30 +08:00
|
|
|
class Cask; end
|
|
|
|
|
2013-09-23 22:32:46 +08:00
|
|
|
require 'cask/artifact'
|
2013-09-22 10:44:49 +08:00
|
|
|
require 'cask/audit'
|
|
|
|
require 'cask/auditor'
|
2013-12-06 09:38:23 +08:00
|
|
|
require 'cask/without_source'
|
2013-09-22 10:44:49 +08:00
|
|
|
require 'cask/checkable'
|
|
|
|
require 'cask/cli'
|
|
|
|
require 'cask/container'
|
|
|
|
require 'cask/download'
|
2013-12-06 03:26:56 +08:00
|
|
|
require 'cask/download_strategy'
|
2013-09-22 10:44:49 +08:00
|
|
|
require 'cask/dsl'
|
|
|
|
require 'cask/exceptions'
|
|
|
|
require 'cask/fetcher'
|
|
|
|
require 'cask/installer'
|
|
|
|
require 'cask/link_checker'
|
2013-09-23 22:32:46 +08:00
|
|
|
require 'cask/locations'
|
2014-01-06 04:30:53 +08:00
|
|
|
require 'cask/options'
|
2013-09-22 10:44:49 +08:00
|
|
|
require 'cask/pkg'
|
2013-11-04 02:23:08 +08:00
|
|
|
require 'cask/pretty_listing'
|
2013-09-22 10:44:49 +08:00
|
|
|
require 'cask/scopes'
|
2013-11-17 03:40:51 +08:00
|
|
|
require 'cask/source'
|
2013-09-22 10:44:49 +08:00
|
|
|
require 'cask/system_command'
|
2013-09-22 06:07:19 +08:00
|
|
|
require 'cask/underscore_supporting_uri'
|
2013-12-16 03:18:47 +08:00
|
|
|
require 'cask/url'
|
2013-09-22 10:44:49 +08:00
|
|
|
|
|
|
|
require 'plist/parser'
|
2012-03-05 10:46:30 +08:00
|
|
|
|
|
|
|
class Cask
|
2012-10-14 05:30:59 +08:00
|
|
|
include Cask::DSL
|
2013-09-23 22:32:46 +08:00
|
|
|
include Cask::Locations
|
2012-10-14 05:48:25 +08:00
|
|
|
include Cask::Scopes
|
2014-01-06 04:30:53 +08:00
|
|
|
include Cask::Options
|
2012-10-14 05:17:52 +08:00
|
|
|
|
2012-03-05 10:46:30 +08:00
|
|
|
def self.init
|
2012-10-16 08:25:35 +08:00
|
|
|
HOMEBREW_CACHE.mkpath unless HOMEBREW_CACHE.exist?
|
2013-04-07 06:14:04 +08:00
|
|
|
unless caskroom.exist?
|
|
|
|
ohai "We need to make Caskroom for the first time at #{caskroom}"
|
2013-05-27 23:35:44 +08:00
|
|
|
ohai "We'll set permissions properly so we won't need sudo in the future"
|
2013-04-07 06:14:04 +08:00
|
|
|
current_user = ENV['USER']
|
2013-06-13 03:09:16 +08:00
|
|
|
sudo = 'sudo' unless caskroom.parent.writable?
|
|
|
|
system "#{sudo} mkdir -p #{caskroom}"
|
|
|
|
system "#{sudo} chown -R #{current_user}:staff #{caskroom.parent}"
|
2013-04-07 06:14:04 +08:00
|
|
|
end
|
2012-10-16 08:25:35 +08:00
|
|
|
appdir.mkpath unless appdir.exist?
|
2013-11-29 08:45:49 +08:00
|
|
|
qlplugindir.mkpath unless qlplugindir.exist?
|
2012-03-05 10:46:30 +08:00
|
|
|
end
|
|
|
|
|
2013-11-17 03:40:51 +08:00
|
|
|
def self.load(query)
|
|
|
|
Cask::Source.for_query(query).load
|
2012-03-05 10:46:30 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.title
|
2012-12-18 07:59:58 +08:00
|
|
|
self.name.gsub(/([a-zA-Z\d])([A-Z])/,'\1-\2').gsub(/([a-zA-Z\d])([A-Z])/,'\1-\2').downcase
|
2012-03-05 10:46:30 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
attr_reader :title
|
|
|
|
def initialize(title=self.class.title)
|
|
|
|
@title = title
|
|
|
|
end
|
|
|
|
|
2013-11-11 04:48:16 +08:00
|
|
|
def caskroom_path
|
2013-12-06 09:38:23 +08:00
|
|
|
self.class.caskroom.join(title)
|
2013-11-11 04:48:16 +08:00
|
|
|
end
|
|
|
|
|
2012-03-05 10:46:30 +08:00
|
|
|
def destination_path
|
2013-12-06 09:38:23 +08:00
|
|
|
caskroom_path.join(version)
|
2012-03-05 10:46:30 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def installed?
|
2012-10-21 02:34:11 +08:00
|
|
|
destination_path.exist?
|
2012-03-05 10:46:30 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
@title
|
|
|
|
end
|
|
|
|
end
|