Module: RSpec::Core::Formatters::ConsoleCodes
- Defined in:
- lib/super_diff/rspec/monkey_patches.rb
Class Method Summary collapse
-
.console_code_for(code_or_symbol) ⇒ Object
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.
-
.wrap(text, code_or_symbol) ⇒ Object
Patch so it does not apply a color if code_or_symbol is nil.
Class Method Details
.console_code_for(code_or_symbol) ⇒ Object
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
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/super_diff/rspec/monkey_patches.rb', line 54 def self.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) ⇒ Object
Patch so it does not apply a color if code_or_symbol is nil
69 70 71 72 73 74 75 |
# File 'lib/super_diff/rspec/monkey_patches.rb', line 69 def self.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 |