Class: CodeRay::Encoders::DebugLint
- Defined in:
- lib/coderay/encoders/debug_lint.rb
Overview
Debug Lint Encoder
Debug encoder with additional checks for:
-
empty tokens
-
incorrect nesting
It will raise an InvalidTokenStream exception when any of the above occurs.
See also: Encoders::Debug
Constant Summary
Constants inherited from Debug
CodeRay::Encoders::Debug::FILE_EXTENSION
Constants inherited from Encoder
Instance Attribute Summary
Attributes inherited from Encoder
Attributes included from Plugin
Instance Method Summary collapse
- #begin_group(kind) ⇒ Object
- #begin_line(kind) ⇒ Object
- #end_group(kind) ⇒ Object
- #end_line(kind) ⇒ Object
- #text_token(text, kind) ⇒ Object
Methods inherited from Encoder
#<<, const_missing, #encode, #encode_tokens, file_extension, #file_extension, #initialize, #token
Methods included from Plugin
#aliases, #plugin_host, #register_for, #title
Constructor Details
This class inherits a constructor from CodeRay::Encoders::Encoder
Instance Method Details
#begin_group(kind) ⇒ Object
26 27 28 29 |
# File 'lib/coderay/encoders/debug_lint.rb', line 26 def begin_group kind @opened << kind super end |
#begin_line(kind) ⇒ Object
37 38 39 40 |
# File 'lib/coderay/encoders/debug_lint.rb', line 37 def begin_line kind @opened << kind super end |
#end_group(kind) ⇒ Object
31 32 33 34 35 |
# File 'lib/coderay/encoders/debug_lint.rb', line 31 def end_group kind raise Lint::IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_group)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind @opened.pop super end |
#end_line(kind) ⇒ Object
42 43 44 45 46 |
# File 'lib/coderay/encoders/debug_lint.rb', line 42 def end_line kind raise Lint::IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_line)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind @opened.pop super end |
#text_token(text, kind) ⇒ Object
20 21 22 23 24 |
# File 'lib/coderay/encoders/debug_lint.rb', line 20 def text_token text, kind raise Lint::EmptyToken, 'empty token for %p' % [kind] if text.empty? raise Lint::UnknownTokenKind, 'unknown token kind %p (text was %p)' % [kind, text] unless TokenKinds.has_key? kind super end |