Module: SimpleCov::StaticCoverageExtractor::MethodCollector
- Included in:
- Visitor
- Defined in:
- lib/simplecov/static_coverage_extractor/method_collector.rb
Overview
Visitor mixin that collects method tuples and tracks the lexical class /
module nesting that names them, in the shape Ruby's Coverage reports
methods. Module and Class are both namespaces here, since Coverage reports
both as the constant.
Instance Method Summary collapse
- #visit_class_node(node) ⇒ Object
-
#visit_def_node(node) ⇒ Object
def name(...)anddef self.name(...)both produce DefNode. - #visit_module_node(node) ⇒ Object
Instance Method Details
#visit_class_node(node) ⇒ Object
10 11 12 |
# File 'lib/simplecov/static_coverage_extractor/method_collector.rb', line 10 def visit_class_node(node) with_class(constant_name(node.constant_path)) { super } end |
#visit_def_node(node) ⇒ Object
def name(...) and def self.name(...) both produce DefNode. The class
context is the surrounding lexical class or module, or Object at the top
level, matching Coverage's convention.
21 22 23 24 25 26 |
# File 'lib/simplecov/static_coverage_extractor/method_collector.rb', line 21 def visit_def_node(node) class_name = @class_stack.last || "Object" key = [class_name, node.name, node.start_line, node.start_column, node.end_line, node.end_column] @methods[key] = 0 super end |
#visit_module_node(node) ⇒ Object
14 15 16 |
# File 'lib/simplecov/static_coverage_extractor/method_collector.rb', line 14 def visit_module_node(node) with_class(constant_name(node.constant_path)) { super } end |