Class: Bootprint::Formatters::Human

Inherits:
Object
  • Object
show all
Defined in:
lib/bootprint/formatters/human.rb

Constant Summary collapse

COLORS =
{ critical: 31, error: 31, warning: 33, info: 36 }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(report, color: false) ⇒ Human

Returns a new instance of Human.



8
9
10
11
# File 'lib/bootprint/formatters/human.rb', line 8

def initialize(report, color: false)
  @report = report
  @color = color && !ENV.key?("NO_COLOR")
end

Instance Method Details

#renderObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bootprint/formatters/human.rb', line 13

def render
  output = "Bootprint Diagnosis\nSource: #{@report.source.name}\nTarget: #{@report.target.name}\n"
  active = @report.findings
  if active.empty?
    output << "\nNo findings at the selected severity.\n"
  else
    active.each { |finding| output << render_finding(finding) }
  end
  output << "\nSummary:\n"
  @report.counts.each { |severity, count| output << format("  %-8s %d\n", severity, count) if count.positive? }
  output << "  blocking #{@report.blocking? ? 'yes' : 'no'}\n"
  output
end