Module: FiberAudit::Reporters::Text::ANSI
- Defined in:
- lib/fiber_audit/reporters/text.rb
Overview
ANSI owns all escape sequences. Color is applied only to severity labels.
Constant Summary collapse
- RESET =
"\e[0m"- BOLD =
"\e[1m"- DIM =
"\e[2m"- RED =
"\e[31m"- YELLOW =
"\e[33m"- MAGENTA =
"\e[35m"- CYAN =
"\e[36m"- WHITE =
"\e[37m"- SEVERITY_COLORS =
{ critical: RED, high: YELLOW, medium: MAGENTA, low: CYAN, info: CYAN }.freeze
Class Method Summary collapse
Class Method Details
.colorize(text, color_code) ⇒ Object
47 48 49 |
# File 'lib/fiber_audit/reporters/text.rb', line 47 def colorize(text, color_code) "#{color_code}#{text}#{RESET}" end |
.severity_label(severity, color:) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/fiber_audit/reporters/text.rb', line 51 def severity_label(severity, color:) label = severity.to_s.upcase return label unless color color_code = SEVERITY_COLORS[severity.to_sym] || WHITE colorize(label, color_code) end |