Class: Yamlint::Output::Colored

Inherits:
Base
  • Object
show all
Defined in:
lib/yamlint/output/colored.rb

Constant Summary collapse

COLORS =
{
  reset: "\e[0m",
  bold: "\e[1m",
  red: "\e[31m",
  yellow: "\e[33m",
  cyan: "\e[36m",
  dim: "\e[2m"
}.freeze

Instance Method Summary collapse

Instance Method Details

#format(filepath, problems) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/yamlint/output/colored.rb', line 15

def format(filepath, problems)
  return '' if problems.empty?

  lines = ["#{COLORS[:bold]}#{filepath}#{COLORS[:reset]}"]
  problems.each do |problem|
    lines << format_problem(problem)
  end
  lines.join("\n")
end

#format_summary(total_files, total_problems) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/yamlint/output/colored.rb', line 25

def format_summary(total_files, total_problems)
  if total_problems.zero?
    format_success_summary(total_files)
  else
    format_failure_summary(total_files, total_problems)
  end
end