# module Puppet::Util::Colors

### Constants

BG_BLUE
BG_CYAN
BG_GREEN
BG_HBLUE
BG_HCYAN
BG_HGREEN
BG_HMAGENTA
BG_HRED
BG_HWHITE
BG_HYELLOW
BG_MAGENTA
BG_RED
BG_WHITE
BG_YELLOW
BLACK
BLUE
CYAN
Colormap
GREEN
HBLACK
HBLUE
HCYAN
HGREEN
HMAGENTA
HRED
HWHITE
HYELLOW
MAGENTA
RED
RESET
WHITE
YELLOW

### Public Instance Methods

colorize(color, str) click to toggle source

    # File lib/puppet/util/colors.rb, line 102
    def colorize(color, str)
      case Puppet[:color]
      when true, :ansi, "ansi", "yes"
        if console_has_color?
          console_color(color, str)
        else
          str
        end
      when :html, "html"
        html_color(color, str)
      else
        str
      end
    end

console_color(color, str) click to toggle source

    # File lib/puppet/util/colors.rb, line 117
    def console_color(color, str)
      Colormap[color][:console] +
      str.gsub(RESET[:console], Colormap[color][:console]) +
      RESET[:console]
    end

console_has_color?() click to toggle source

    # File lib/puppet/util/colors.rb, line 87
    def console_has_color?
      false
    end

html_color(color, str) click to toggle source

    # File lib/puppet/util/colors.rb, line 123
    def html_color(color, str)
      span = '<span style="%s">' % Colormap[color][:html]
      "#{span}%s</span>" % str.gsub(/<span .*?<\/span>/, "</span>\\0#{span}")
    end