Class/Module Index [+]

Quicksearch

PhusionPassenger::Utils::AnsiColors

Public Class Methods

included(klass) click to toggle source
# File lib/phusion_passenger/utils/ansi_colors.rb, line 47
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
new(type = :auto) click to toggle source
# File lib/phusion_passenger/utils/ansi_colors.rb, line 43
def self.new(type = :auto)
  AnsiColorsPrinter.new(type)
end

Public Instance Methods

ansi_colorize(text) click to toggle source
# File lib/phusion_passenger/utils/ansi_colors.rb, line 55
def ansi_colorize(text)
  text = text.gsub(%{<b>(.*?)</b>}, "#{BOLD}\\1#{DEFAULT_TERMINAL_COLOR}")
  text.gsub!(%{<dgray>(.*?)</dgray>}, "#{BOLD}#{DGRAY}\\1#{DEFAULT_TERMINAL_COLOR}")
  text.gsub!(%{<gray>(.*?)</gray>}, "#{BOLD}#{GRAY}\\1#{DEFAULT_TERMINAL_COLOR}")
  text.gsub!(%{<red>(.*?)</red>}, "#{BOLD}#{RED}\\1#{DEFAULT_TERMINAL_COLOR}")
  text.gsub!(%{<orange>(.*?)</orange>}, "#{BOLD}#{ORANGE}\\1#{DEFAULT_TERMINAL_COLOR}")
  text.gsub!(%{<green>(.*?)</green>}, "#{BOLD}#{GREEN}\\1#{DEFAULT_TERMINAL_COLOR}")
  text.gsub!(%{<yellow>(.*?)</yellow>}, "#{BOLD}#{YELLOW}\\1#{DEFAULT_TERMINAL_COLOR}")
  text.gsub!(%{<banner>(.*?)</banner>}, "#{BOLD}#{BLUE_BG}#{YELLOW}\\1#{DEFAULT_TERMINAL_COLOR}")
  text
end
strip_color_tags(text) click to toggle source
# File lib/phusion_passenger/utils/ansi_colors.rb, line 67
def strip_color_tags(text)
  text = text.gsub(%{<b>(.*?)</b>}, "\\1")
  text = text.gsub(%{<dgray>(.*?)</dgray>}, "\\1")
  text = text.gsub(%{<gray>(.*?)</gray>}, "\\1")
  text.gsub!(%{<red>(.*?)</red>}, "\\1")
  text.gsub!(%{<orange>(.*?)</orange>}, "\\1")
  text.gsub!(%{<green>(.*?)</green>}, "\\1")
  text.gsub!(%{<yellow>(.*?)</yellow>}, "\\1")
  text.gsub!(%{<banner>(.*?)</banner>}, "\\1")
  text
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.