Module: Clack::Colors
- Defined in:
- lib/clack/colors.rb
Overview
ANSI color codes for terminal output styling. Colors are automatically disabled when:
-
Output is not a TTY (piped/redirected)
-
NO_COLOR environment variable is set
-
FORCE_COLOR environment variable forces colors on
Foreground Colors (standard) collapse
-
.blue(text) ⇒ String
Apply blue foreground color (ANSI 34).
-
.cyan(text) ⇒ String
Apply cyan foreground color (ANSI 36).
-
.gray(text) ⇒ String
Apply gray foreground color (ANSI 90).
-
.green(text) ⇒ String
Apply green foreground color (ANSI 32).
-
.magenta(text) ⇒ String
Apply magenta foreground color (ANSI 35).
-
.red(text) ⇒ String
Apply red foreground color (ANSI 31).
-
.white(text) ⇒ String
Apply white foreground color (ANSI 37).
-
.yellow(text) ⇒ String
Apply yellow foreground color (ANSI 33).
Text Styles collapse
-
.bold(text) ⇒ String
Apply bold style (ANSI 1).
-
.dim(text) ⇒ String
Apply dim/faint style (ANSI 2).
-
.hidden(text) ⇒ String
Apply hidden/invisible style (ANSI 8).
-
.inverse(text) ⇒ String
Apply inverse/reverse video style (ANSI 7).
-
.italic(text) ⇒ String
Apply italic style (ANSI 3).
-
.strikethrough(text) ⇒ String
Apply strikethrough style (ANSI 9).
-
.underline(text) ⇒ String
Apply underline style (ANSI 4).
Bright Foreground Colors (high contrast) collapse
-
.bright_blue(text) ⇒ String
Apply bright blue foreground color (ANSI 94).
-
.bright_cyan(text) ⇒ String
Apply bright cyan foreground color (ANSI 96).
-
.bright_green(text) ⇒ String
Apply bright green foreground color (ANSI 92).
-
.bright_magenta(text) ⇒ String
Apply bright magenta foreground color (ANSI 95).
-
.bright_red(text) ⇒ String
Apply bright red foreground color (ANSI 91).
-
.bright_white(text) ⇒ String
Apply bright white foreground color (ANSI 97).
-
.bright_yellow(text) ⇒ String
Apply bright yellow foreground color (ANSI 93).
Class Method Summary collapse
Class Method Details
.blue(text) ⇒ String
Apply blue foreground color (ANSI 34).
43 |
# File 'lib/clack/colors.rb', line 43 def blue(text) = wrap(text, "34") |
.bold(text) ⇒ String
Apply bold style (ANSI 1).
67 |
# File 'lib/clack/colors.rb', line 67 def bold(text) = wrap(text, "1") |
.bright_blue(text) ⇒ String
Apply bright blue foreground color (ANSI 94).
121 |
# File 'lib/clack/colors.rb', line 121 def bright_blue(text) = wrap(text, "94") |
.bright_cyan(text) ⇒ String
Apply bright cyan foreground color (ANSI 96).
101 |
# File 'lib/clack/colors.rb', line 101 def bright_cyan(text) = wrap(text, "96") |
.bright_green(text) ⇒ String
Apply bright green foreground color (ANSI 92).
106 |
# File 'lib/clack/colors.rb', line 106 def bright_green(text) = wrap(text, "92") |
.bright_magenta(text) ⇒ String
Apply bright magenta foreground color (ANSI 95).
126 |
# File 'lib/clack/colors.rb', line 126 def bright_magenta(text) = wrap(text, "95") |
.bright_red(text) ⇒ String
Apply bright red foreground color (ANSI 91).
116 |
# File 'lib/clack/colors.rb', line 116 def bright_red(text) = wrap(text, "91") |
.bright_white(text) ⇒ String
Apply bright white foreground color (ANSI 97).
131 |
# File 'lib/clack/colors.rb', line 131 def bright_white(text) = wrap(text, "97") |
.bright_yellow(text) ⇒ String
Apply bright yellow foreground color (ANSI 93).
111 |
# File 'lib/clack/colors.rb', line 111 def bright_yellow(text) = wrap(text, "93") |
.cyan(text) ⇒ String
Apply cyan foreground color (ANSI 36).
23 |
# File 'lib/clack/colors.rb', line 23 def cyan(text) = wrap(text, "36") |
.dim(text) ⇒ String
Apply dim/faint style (ANSI 2).
62 |
# File 'lib/clack/colors.rb', line 62 def dim(text) = wrap(text, "2") |
.enabled? ⇒ Boolean
11 |
# File 'lib/clack/colors.rb', line 11 def enabled? = Environment.colors_supported? |
.gray(text) ⇒ String
Apply gray foreground color (ANSI 90).
18 |
# File 'lib/clack/colors.rb', line 18 def gray(text) = wrap(text, "90") |
.green(text) ⇒ String
Apply green foreground color (ANSI 32).
28 |
# File 'lib/clack/colors.rb', line 28 def green(text) = wrap(text, "32") |
.hidden(text) ⇒ String
Apply hidden/invisible style (ANSI 8).
92 |
# File 'lib/clack/colors.rb', line 92 def hidden(text) = wrap(text, "8") |
.inverse(text) ⇒ String
Apply inverse/reverse video style (ANSI 7).
82 |
# File 'lib/clack/colors.rb', line 82 def inverse(text) = wrap(text, "7") |
.italic(text) ⇒ String
Apply italic style (ANSI 3).
72 |
# File 'lib/clack/colors.rb', line 72 def italic(text) = wrap(text, "3") |
.magenta(text) ⇒ String
Apply magenta foreground color (ANSI 35).
48 |
# File 'lib/clack/colors.rb', line 48 def magenta(text) = wrap(text, "35") |
.red(text) ⇒ String
Apply red foreground color (ANSI 31).
38 |
# File 'lib/clack/colors.rb', line 38 def red(text) = wrap(text, "31") |
.strikethrough(text) ⇒ String
Apply strikethrough style (ANSI 9).
87 |
# File 'lib/clack/colors.rb', line 87 def strikethrough(text) = wrap(text, "9") |
.underline(text) ⇒ String
Apply underline style (ANSI 4).
77 |
# File 'lib/clack/colors.rb', line 77 def underline(text) = wrap(text, "4") |
.white(text) ⇒ String
Apply white foreground color (ANSI 37).
53 |
# File 'lib/clack/colors.rb', line 53 def white(text) = wrap(text, "37") |
.yellow(text) ⇒ String
Apply yellow foreground color (ANSI 33).
33 |
# File 'lib/clack/colors.rb', line 33 def yellow(text) = wrap(text, "33") |