Class: Cask::Auditor Private

Inherits:
Object show all
Defined in:
cask/auditor.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Helper class for auditing all available languages of a cask.

Constant Summary collapse

LANGUAGE_BLOCK_LIMIT =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

10

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cask, audit_download: nil, audit_online: nil, audit_strict: nil, audit_signing: nil, audit_token_conflicts: nil, audit_new_cask: nil, quarantine: nil, any_named_args: nil, language: nil, only: [], except: []) ⇒ Auditor

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns a new instance of Auditor.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'cask/auditor.rb', line 15

def initialize(
  cask,
  audit_download: nil,
  audit_online: nil,
  audit_strict: nil,
  audit_signing: nil,
  audit_token_conflicts: nil,
  audit_new_cask: nil,
  quarantine: nil,
  any_named_args: nil,
  language: nil,
  only: [],
  except: []
)
  @cask = cask
  @audit_download = audit_download
  @audit_online = audit_online
  @audit_new_cask = audit_new_cask
  @audit_strict = audit_strict
  @audit_signing = audit_signing
  @quarantine = quarantine
  @audit_token_conflicts = audit_token_conflicts
  @any_named_args = any_named_args
  @language = language
  @only = only
  @except = except
end

Instance Attribute Details

#caskObject (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



13
14
15
# File 'cask/auditor.rb', line 13

def cask
  @cask
end

#languageObject (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



13
14
15
# File 'cask/auditor.rb', line 13

def language
  @language
end

Class Method Details

.audit(cask, **options) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



9
10
11
# File 'cask/auditor.rb', line 9

def self.audit(cask, **options)
  new(cask, **options).audit
end

Instance Method Details

#auditObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'cask/auditor.rb', line 45

def audit
  errors = Set.new

  if !language && language_blocks
    sample_languages = if language_blocks.length > LANGUAGE_BLOCK_LIMIT && !@audit_new_cask
      sample_keys = language_blocks.keys.sample(LANGUAGE_BLOCK_LIMIT)
      ohai "Auditing a sample of available languages for #{cask}: " \
           "#{sample_keys.map { |lang| lang[0].to_s }.to_sentence}"
      language_blocks.select { |k| sample_keys.include?(k) }
    else
      language_blocks
    end

    sample_languages.each_key do |l|
      audit = audit_languages(l)
      if audit.summary.present? && output_summary?(audit)
        ohai "Auditing language: #{l.map { |lang| "'#{lang}'" }.to_sentence}" if output_summary?
        puts audit.summary
      end
      errors += audit.errors
    end
  else
    audit = audit_cask_instance(cask)
    puts audit.summary if audit.summary.present? && output_summary?(audit)
    errors += audit.errors
  end

  errors
end