Module: GreenHat::ShellHelper::StringColor
- Defined in:
- lib/greenhat/shell/color_string.rb
Overview
Helper to colorize and make outtput easier to read
Class Method Summary collapse
- .do(key, entry) ⇒ Object
-
.pastel(key, value) ⇒ Object
General Key/Value Coloring.
-
.pastel?(key) ⇒ Boolean
Add Color?.
-
.severity(value) ⇒ Object
—-.
Class Method Details
.do(key, entry) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/greenhat/shell/color_string.rb', line 5 def self.do(key, entry) LogBot.debug('Unknown Format', entry.class) if ENV['DEBUG'] && !entry.instance_of?(String) # Other Helpful colorizers if pastel?(key) pastel(key, entry) else entry.to_s end end |
.pastel(key, value) ⇒ Object
General Key/Value Coloring
22 23 24 25 26 27 28 |
# File 'lib/greenhat/shell/color_string.rb', line 22 def self.pastel(key, value) case key when :severity then severity(value) else value.to_s end end |
.pastel?(key) ⇒ Boolean
Add Color?
17 18 19 |
# File 'lib/greenhat/shell/color_string.rb', line 17 def self.pastel?(key) [:severity].any? key end |
.severity(value) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/greenhat/shell/color_string.rb', line 31 def self.severity(value) case value.to_s.downcase.to_sym when :debug then value.pastel(:blue) when :info then value.pastel(:cyan) when :warn then value.pastel(:yellow) when :fatal, :error then value.pastel(:bright_red) else value.to_s end end |