module RSpec::Core::Formatters::ConsoleCodes
def console_code_for(code_or_symbol)
-
(Fixnum)
- a console code
Parameters:
-
code_or_symbol
(Symbol, Fixnum
) -- Symbol or code to check
def console_code_for(code_or_symbol) if (config_method = CONFIG_COLORS_TO_METHODS[code_or_symbol]) console_code_for RSpec.configuration.__send__(config_method) 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)
-
(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