mirror of
https://github.com/donl/homebrew-cask-versions.git
synced 2026-07-16 22:06:43 -06:00
* convert existing Cask:: namespace to Hbc:: * move Homebrew-fork code under Hbc:: * move freestanding classes such as Tty and TopologicalHash under Hbc:: * recast HOMEBREW_CASK_ constants as HBC_ * modify our Homebrew Formula for backward compatibility * devscripts and dev docs
49 lines
1,001 B
Ruby
49 lines
1,001 B
Ruby
class Hbc::CLI::Audit < Hbc::CLI::Base
|
|
def self.help
|
|
'verifies installability of Casks'
|
|
end
|
|
|
|
def self.run(*args)
|
|
retval = new(args, Hbc::Auditor).run
|
|
# retval is ternary: true/false/nil
|
|
if retval.nil?
|
|
raise Hbc::CaskError.new("audit failed")
|
|
elsif ! retval
|
|
raise Hbc::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_tokens.empty?
|
|
Hbc.all
|
|
else
|
|
cask_tokens.map { |token| Hbc.load(token) }
|
|
end
|
|
end
|
|
|
|
def cask_tokens
|
|
@cask_tokens ||= @args.reject { |a| a == '--download' }
|
|
end
|
|
end
|