mirror of
https://github.com/donl/homebrew-cask-versions.git
synced 2026-07-17 06:16:47 -06:00
* was already done, but inconsistently * this style follows homebrew Formula * covers user-facing messages, test titles, comments * some related minor orthography is included, such as the consistent spelling of our project name as "homebrew-cask" * grammar nits
49 lines
984 B
Ruby
49 lines
984 B
Ruby
class Cask::CLI::Audit < Cask::CLI::Base
|
|
def self.help
|
|
'verifies installability of Casks'
|
|
end
|
|
|
|
def self.run(*args)
|
|
retval = new(args, Cask::Auditor).run
|
|
# retval is ternary: true/false/nil
|
|
if retval.nil?
|
|
raise CaskError.new("audit failed")
|
|
elsif ! retval
|
|
raise CaskError.new("some audits failed")
|
|
end
|
|
end
|
|
|
|
def initialize(args, auditor)
|
|
@args = args
|
|
@auditor = auditor
|
|
end
|
|
|
|
def run
|
|
count = 0
|
|
casks_to_audit.each do |cask|
|
|
count += 1 if audit(cask)
|
|
end
|
|
count == 0 ? nil : count == casks_to_audit.length
|
|
end
|
|
|
|
def audit(cask)
|
|
odebug "Auditing Cask #{cask}"
|
|
@auditor.audit(cask, :audit_download => audit_download?)
|
|
end
|
|
|
|
def audit_download?
|
|
@args.include?('--download')
|
|
end
|
|
|
|
def casks_to_audit
|
|
if cask_list.empty?
|
|
Cask.all
|
|
else
|
|
cask_list.map { |arg| Cask.load(arg) }
|
|
end
|
|
end
|
|
|
|
def cask_list
|
|
@cask_list ||= @args.reject { |a| a == '--download' }
|
|
end
|
|
end
|