Class: SpecsProcessor
- Inherits:
-
Parser::AST::Processor
- Object
- Parser::AST::Processor
- SpecsProcessor
- Defined in:
- lib/ducalis/documentation.rb
Overview
This class could be used to dynamically generate documentation from cops spec. It recognizes bad and good examples by signal words like ‘raises`. Additional information for documentation could be passed by setting `DETAILS` constant.
Constant Summary collapse
- LINE_BEGIN_OPEN_SQUARE_BRACKET =
“/[/1, 2, 3]n”
/\A\[/.freeze
- CLOSE_SQUARE_BRACKET_END_LINE =
“[1, 2, 3/]n/”
/\]\z/.freeze
- LINE_BEGIN_QUOTE =
“/‘/idddqd’,”
/\A[\'|\"]/.freeze
- QUOTE_COMMA_END_LINE =
“‘iddqd/’,/”
/[\'|\"]\,?\z/.freeze
Instance Attribute Summary collapse
-
#cases ⇒ Object
readonly
Returns the value of attribute cases.
Instance Method Summary collapse
-
#initialize ⇒ SpecsProcessor
constructor
A new instance of SpecsProcessor.
- #on_send(node) ⇒ Object
- #process(node) ⇒ Object
Constructor Details
#initialize ⇒ SpecsProcessor
Returns a new instance of SpecsProcessor.
16 17 18 19 20 |
# File 'lib/ducalis/documentation.rb', line 16 def initialize(*) super @cases = [] @nesting = [] end |
Instance Attribute Details
#cases ⇒ Object (readonly)
Returns the value of attribute cases.
9 10 11 |
# File 'lib/ducalis/documentation.rb', line 9 def cases @cases end |
Instance Method Details
#on_send(node) ⇒ Object
28 29 30 31 32 |
# File 'lib/ducalis/documentation.rb', line 28 def on_send(node) _, name, _body = *node cases << [current_it, source_code(node)] if name == :inspect_source super end |
#process(node) ⇒ Object
22 23 24 25 26 |
# File 'lib/ducalis/documentation.rb', line 22 def process(node) @nesting.push(node) super @nesting.pop end |