Class: RSpec::Core::Formatters::SyntaxHighlighter
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/syntax_highlighter.rb
Overview
Provides terminal syntax highlighting of code snippets when coderay is available.
Defined Under Namespace
Modules: CodeRayImplementation, NoSyntaxHighlightingImplementation
Class Method Summary collapse
-
.attempt_to_add_rspec_terms_to_coderay_keywords ⇒ Object
rubocop:disable Lint/RescueException rubocop:disable Lint/HandleExceptions.
Instance Method Summary collapse
- #highlight(lines) ⇒ Object
-
#initialize(configuration) ⇒ SyntaxHighlighter
constructor
A new instance of SyntaxHighlighter.
Constructor Details
#initialize(configuration) ⇒ SyntaxHighlighter
Returns a new instance of SyntaxHighlighter.
8 9 10 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/syntax_highlighter.rb', line 8 def initialize(configuration) @configuration = configuration end |
Class Method Details
.attempt_to_add_rspec_terms_to_coderay_keywords ⇒ Object
rubocop:disable Lint/RescueException rubocop:disable Lint/HandleExceptions
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/syntax_highlighter.rb', line 18 def self.attempt_to_add_rspec_terms_to_coderay_keywords CodeRay::Scanners::Ruby::Patterns::IDENT_KIND.add(%w[ describe context it specify before after around let subject expect allow ], :keyword) rescue Exception # Mutating CodeRay's contants like this is not a public API # and might not always work. If we cannot add our keywords # to CodeRay it is not a big deal and not worth raising an # error over, so we ignore it. end |
Instance Method Details
#highlight(lines) ⇒ Object
12 13 14 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/syntax_highlighter.rb', line 12 def highlight(lines) implementation.highlight_syntax(lines) end |