module RSpec::Core::Source::SyntaxHighlighter::CodeRayImplementation

@private

Constants

RESET_CODE

Public Class Methods

highlight_syntax(lines) click to toggle source
# File lib/rspec/core/source/syntax_highlighter.rb, line 44
def self.highlight_syntax(lines)
  highlighted = begin
    CodeRay.encode(lines.join("\n"), :ruby, :terminal)
  rescue Support::AllExceptionsExceptOnesWeMustNotRescue
    return lines
  end

  highlighted.split("\n").map do |line|
    line.sub(/\S/) { |char| char.insert(0, RESET_CODE) }
  end
end