Module: Ucode::Audit::Formatters::Color
- Defined in:
- lib/ucode/audit/formatters/color.rb
Overview
Minimal ANSI helper. Formatters route every color emphasis through this module so the NO_COLOR env var is honored uniformly.
Follows the no-color.org convention: when ENV is set to any non-empty value, all color methods return the input string unchanged.
Constant Summary collapse
- RESET =
"\e[0m"- BOLD =
"\e[1m"- DIM =
"\e[2m"- RED =
"\e[31m"- GREEN =
"\e[32m"- CYAN =
"\e[36m"
Class Method Summary collapse
- .bold(text) ⇒ Object
- .cyan(text) ⇒ Object
- .dim(text) ⇒ Object
- .enabled? ⇒ Boolean
- .green(text) ⇒ Object
- .red(text) ⇒ Object
Class Method Details
.bold(text) ⇒ Object
26 27 28 |
# File 'lib/ucode/audit/formatters/color.rb', line 26 def bold(text) enabled? ? "#{BOLD}#{text}#{RESET}" : text end |
.cyan(text) ⇒ Object
34 35 36 |
# File 'lib/ucode/audit/formatters/color.rb', line 34 def cyan(text) enabled? ? "#{CYAN}#{text}#{RESET}" : text end |
.dim(text) ⇒ Object
30 31 32 |
# File 'lib/ucode/audit/formatters/color.rb', line 30 def dim(text) enabled? ? "#{DIM}#{text}#{RESET}" : text end |
.enabled? ⇒ Boolean
22 23 24 |
# File 'lib/ucode/audit/formatters/color.rb', line 22 def enabled? ENV["NO_COLOR"].nil? || ENV["NO_COLOR"].empty? end |