module GreenHat::ShellHelper::StringColor
Helper to colorize and make outtput easier to read
Public Class Methods
do(key, entry)
click to toggle source
# 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)
click to toggle source
General Key/Value Coloring
# 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)
click to toggle source
Add Color
?
# File lib/greenhat/shell/color_string.rb, line 17 def self.pastel?(key) [:severity].any? key end
severity(value)
click to toggle source
# 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