Module: Cask::Checkable

Included in:
Audit, Auditor, Cask::Cmd::Doctor
Defined in:
brew/Library/Homebrew/cask/checkable.rb

Instance Method Summary collapse

Instance Method Details

#add_error(message) ⇒ Object



13
14
15
# File 'brew/Library/Homebrew/cask/checkable.rb', line 13

def add_error(message)
  errors << message
end

#add_warning(message) ⇒ Object



17
18
19
# File 'brew/Library/Homebrew/cask/checkable.rb', line 17

def add_warning(message)
  warnings << message
end

#errorsObject



5
6
7
# File 'brew/Library/Homebrew/cask/checkable.rb', line 5

def errors
  @errors ||= []
end

#errors?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'brew/Library/Homebrew/cask/checkable.rb', line 21

def errors?
  errors.any?
end

#resultObject



29
30
31
32
33
34
35
36
37
# File 'brew/Library/Homebrew/cask/checkable.rb', line 29

def result
  if errors?
    Formatter.error("failed")
  elsif warnings?
    Formatter.warning("warning")
  else
    Formatter.success("passed")
  end
end

#summaryObject



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'brew/Library/Homebrew/cask/checkable.rb', line 39

def summary
  summary = ["#{summary_header}: #{result}"]

  errors.each do |error|
    summary << " #{Formatter.error("-")} #{error}"
  end

  warnings.each do |warning|
    summary << " #{Formatter.warning("-")} #{warning}"
  end

  summary.join("\n")
end

#warningsObject



9
10
11
# File 'brew/Library/Homebrew/cask/checkable.rb', line 9

def warnings
  @warnings ||= []
end

#warnings?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'brew/Library/Homebrew/cask/checkable.rb', line 25

def warnings?
  warnings.any?
end