Module: PhusionPassenger::Utils::AnsiColors
- Extended by:
- AnsiColors
- Included in:
- AnsiColors
- Defined in:
- lib/phusion_passenger/utils/ansi_colors.rb
Constant Summary collapse
- RESET =
"\e[0m".freeze
- BOLD =
"\e[1m".freeze
- RED =
"\e[31m".freeze
- GREEN =
"\e[32m".freeze
- YELLOW =
"\e[33m".freeze
- WHITE =
"\e[37m".freeze
- BLACK_BG =
"\e[40m".freeze
- BLUE_BG =
"\e[44m".freeze
- DEFAULT_TERMINAL_COLOR =
"#{RESET}#{WHITE}#{BLACK_BG}".freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/phusion_passenger/utils/ansi_colors.rb', line 40 def self.included(klass) # When included into another class, make sure that Utils # methods are made private. public_instance_methods(false).each do |method_name| klass.send(:private, method_name) end end |
Instance Method Details
#ansi_colorize(text) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/phusion_passenger/utils/ansi_colors.rb', line 48 def ansi_colorize(text) text = text.gsub(%r{<b>(.*?)</b>}m, "#{BOLD}\\1#{DEFAULT_TERMINAL_COLOR}") text.gsub!(%r{<red>(.*?)</red>}m, "#{BOLD}#{RED}\\1#{DEFAULT_TERMINAL_COLOR}") text.gsub!(%r{<green>(.*?)</green>}m, "#{BOLD}#{GREEN}\\1#{DEFAULT_TERMINAL_COLOR}") text.gsub!(%r{<yellow>(.*?)</yellow>}m, "#{BOLD}#{YELLOW}\\1#{DEFAULT_TERMINAL_COLOR}") text.gsub!(%r{<banner>(.*?)</banner>}m, "#{BOLD}#{BLUE_BG}#{YELLOW}\\1#{DEFAULT_TERMINAL_COLOR}") return text end |
#strip_color_tags(text) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/phusion_passenger/utils/ansi_colors.rb', line 57 def (text) text = text.gsub(%r{<b>(.*?)</b>}m, "\\1") text.gsub!(%r{<red>(.*?)</red>}m, "\\1") text.gsub!(%r{<green>(.*?)</green>}m, "\\1") text.gsub!(%r{<yellow>(.*?)</yellow>}m, "\\1") text.gsub!(%r{<banner>(.*?)</banner>}m, "\\1") return text end |