module RSpec::Core::Formatters::ConsoleCodes

def configuration_color(code)

Other tags:
    Private: -
def configuration_color(code)
  RSpec.configuration.__send__(:"#{code}_color")
end

def console_code_for(code_or_symbol)

Returns:
  • (Fixnum) - a console code

Parameters:
  • code_or_symbol (Symbol, Fixnum) -- Symbol or code to check
def console_code_for(code_or_symbol)
  if RSpec.configuration.respond_to?(:"#{code_or_symbol}_color")
    console_code_for configuration_color(code_or_symbol)
  elsif VT100_CODE_VALUES.key?(code_or_symbol)
    code_or_symbol
  else
    VT100_CODES.fetch(code_or_symbol) do
      console_code_for(:white)
    end
  end
end

def wrap(text, code_or_symbol)

Returns:
  • (String) - the wrapped text

Parameters:
  • code_or_symbol (Symbol, Fixnum) -- the desired control code
  • text (String) -- the text to wrap
def wrap(text, code_or_symbol)
  if RSpec.configuration.color_enabled?
    "\e[#{console_code_for(code_or_symbol)}m#{text}\e[0m"
  else
    text
  end
end