Module: Hbc::Checkable

Included in:
Audit, Hbc::CLI::Doctor
Defined in:
Library/Homebrew/cask/lib/hbc/checkable.rb

Instance Method Summary collapse

Instance Method Details

#add_error(message) ⇒ Object



11
12
13
# File 'Library/Homebrew/cask/lib/hbc/checkable.rb', line 11

def add_error(message)
  errors << message
end

#add_warning(message) ⇒ Object



15
16
17
# File 'Library/Homebrew/cask/lib/hbc/checkable.rb', line 15

def add_warning(message)
  warnings << message
end

#errorsObject



3
4
5
# File 'Library/Homebrew/cask/lib/hbc/checkable.rb', line 3

def errors
  @errors ||= []
end

#errors?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'Library/Homebrew/cask/lib/hbc/checkable.rb', line 19

def errors?
  errors.any?
end

#resultObject



27
28
29
30
31
32
33
34
35
# File 'Library/Homebrew/cask/lib/hbc/checkable.rb', line 27

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

#summaryObject



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'Library/Homebrew/cask/lib/hbc/checkable.rb', line 37

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



7
8
9
# File 'Library/Homebrew/cask/lib/hbc/checkable.rb', line 7

def warnings
  @warnings ||= []
end

#warnings?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'Library/Homebrew/cask/lib/hbc/checkable.rb', line 23

def warnings?
  warnings.any?
end