diff options
| author | AnastasiaSulyagina | 2016-08-18 22:11:42 +0300 |
|---|---|---|
| committer | AnastasiaSulyagina | 2016-08-19 14:50:14 +0300 |
| commit | e81f4ab7deeb40308f240be5ea00091fc8786d7a (patch) | |
| tree | b5418f9149de71c0f05f90cb2b39ab47f46e27b4 /Library/Homebrew/cask/lib/hbc/cli/audit.rb | |
| parent | 5c7c9de669025bbe4cad9829be39c5cf3b31ad25 (diff) | |
| download | brew-e81f4ab7deeb40308f240be5ea00091fc8786d7a.tar.bz2 | |
init
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/cli/audit.rb')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/audit.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/audit.rb b/Library/Homebrew/cask/lib/hbc/cli/audit.rb new file mode 100644 index 000000000..289547b44 --- /dev/null +++ b/Library/Homebrew/cask/lib/hbc/cli/audit.rb @@ -0,0 +1,52 @@ +class Hbc::CLI::Audit < Hbc::CLI::Base + def self.help + "verifies installability of Casks" + end + + def self.run(*args) + failed_casks = new(args, Hbc::Auditor).run + return if failed_casks.empty? + raise Hbc::CaskError, "audit failed for casks: #{failed_casks.join(' ')}" + end + + def initialize(args, auditor) + @args = args + @auditor = auditor + end + + def run + casks_to_audit.each_with_object([]) do |cask, failed| + failed << cask unless audit(cask) + end + end + + def audit(cask) + odebug "Auditing Cask #{cask}" + @auditor.audit(cask, audit_download: audit_download?, + check_token_conflicts: check_token_conflicts?) + end + + def audit_download? + @args.include?("--download") + end + + def check_token_conflicts? + @args.include?("--token-conflicts") + 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 ||= self.class.cask_tokens_from(@args) + end + + def self.needs_init? + true + end +end |
