Class: ArchUnit::Testing::ColorUtils
- Inherits:
-
Object
- Object
- ArchUnit::Testing::ColorUtils
- Defined in:
- lib/archunit/testing/color_utils.rb
Overview
ANSI colour helpers that degrade to plain text outside capable terminals.
Constant Summary collapse
- RESET =
"\e[0m"
Class Method Summary collapse
- .blue(text, enabled: supported?) ) ⇒ Object
- .bold(text, enabled: supported?) ) ⇒ Object
- .cyan(text, enabled: supported?) ) ⇒ Object
- .dim(text, enabled: supported?) ) ⇒ Object
- .green(text, enabled: supported?) ) ⇒ Object
- .magenta(text, enabled: supported?) ) ⇒ Object
- .red(text, enabled: supported?) ) ⇒ Object
- .supported?(output: $stdout, environment: ENV) ⇒ Boolean
- .yellow(text, enabled: supported?) ) ⇒ Object
Class Method Details
.blue(text, enabled: supported?) ) ⇒ Object
30 31 32 |
# File 'lib/archunit/testing/color_utils.rb', line 30 def blue(text, enabled: supported?) wrap('34', text, enabled:) end |
.bold(text, enabled: supported?) ) ⇒ Object
42 43 44 |
# File 'lib/archunit/testing/color_utils.rb', line 42 def bold(text, enabled: supported?) wrap('1', text, enabled:) end |
.cyan(text, enabled: supported?) ) ⇒ Object
38 39 40 |
# File 'lib/archunit/testing/color_utils.rb', line 38 def cyan(text, enabled: supported?) wrap('36', text, enabled:) end |
.dim(text, enabled: supported?) ) ⇒ Object
46 47 48 |
# File 'lib/archunit/testing/color_utils.rb', line 46 def dim(text, enabled: supported?) wrap('2', text, enabled:) end |
.green(text, enabled: supported?) ) ⇒ Object
22 23 24 |
# File 'lib/archunit/testing/color_utils.rb', line 22 def green(text, enabled: supported?) wrap('32', text, enabled:) end |
.magenta(text, enabled: supported?) ) ⇒ Object
34 35 36 |
# File 'lib/archunit/testing/color_utils.rb', line 34 def magenta(text, enabled: supported?) wrap('35', text, enabled:) end |
.red(text, enabled: supported?) ) ⇒ Object
18 19 20 |
# File 'lib/archunit/testing/color_utils.rb', line 18 def red(text, enabled: supported?) wrap('31', text, enabled:) end |
.supported?(output: $stdout, environment: ENV) ⇒ Boolean
11 12 13 14 15 16 |
# File 'lib/archunit/testing/color_utils.rb', line 11 def supported?(output: $stdout, environment: ENV) return false unless environment['NO_COLOR'].to_s.empty? return false if environment['TERM'] == 'dumb' output.respond_to?(:tty?) && output.tty? end |
.yellow(text, enabled: supported?) ) ⇒ Object
26 27 28 |
# File 'lib/archunit/testing/color_utils.rb', line 26 def yellow(text, enabled: supported?) wrap('33', text, enabled:) end |