module RSpec::Core::Formatters::ConsoleCodes
Public Instance Methods
console_code_for(code_or_symbol)
click to toggle source
Patch so it returns nothing if code_or_symbol is nil, and that it uses code_or_symbol if it can't be found in VT100_CODE_VALUES to allow for customization
# File lib/super_diff/rspec/monkey_patches.rb, line 59 def console_code_for(code_or_symbol) if code_or_symbol if (config_method = config_colors_to_methods[code_or_symbol]) console_code_for RSpec.configuration.__send__(config_method) elsif RSpec::Core::Formatters::ConsoleCodes::VT100_CODE_VALUES.key?(code_or_symbol) code_or_symbol else RSpec::Core::Formatters::ConsoleCodes::VT100_CODES.fetch(code_or_symbol) do code_or_symbol end end end end
wrap(text, code_or_symbol)
click to toggle source
Patch so it does not apply a color if code_or_symbol is nil
# File lib/super_diff/rspec/monkey_patches.rb, line 74 def wrap(text, code_or_symbol) if RSpec.configuration.color_enabled? && code = console_code_for(code_or_symbol) "\e[#{code}m#{text}\e[0m" else text end end