31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/bblib/cli/color.rb', line 31
def self.colorize(text, color = :none, background: false, light: false)
color = SEVERITY_COLORS[color.to_s.downcase.to_sym] if SEVERITY_COLORS.include?(color.to_s.downcase.to_sym)
if color.to_s.start_with?('light_')
color = color.to_s.split('_', 2).last.to_sym
light = true
end
light = true if color == :grey || color == :gray
color = COLOR_CODES[color] if COLOR_CODES.include?(color)
color = COLOR_CODES[:default] unless color.is_a?(Integer)
color += 10 if background
"\e[#{light ? 1 : 0};#{color}m#{text}\e[0m"
end
|