Module: DeepCover::Analyser::Base
- Included in:
- DeepCover::Analyser
- Defined in:
- lib/deep_cover/analyser/base.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #covered_code ⇒ Object
-
#each_node(from = covered_code.root, &block) ⇒ Object
Iterates on nodes in the subset.
- #initialize(source, **options) ⇒ Object
-
#node_children(node) ⇒ Object
Looking exclusively at our subset of nodes, returns the node’s direct descendants.
-
#node_runs(node) ⇒ Object
Returns the number of runs of the node (assumed to be in our subset).
- #node_runs_map ⇒ Object
-
#results ⇒ Object
Analyser-specific output.
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/deep_cover/analyser/base.rb', line 5 def end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
5 6 7 |
# File 'lib/deep_cover/analyser/base.rb', line 5 def source @source end |
Instance Method Details
#covered_code ⇒ Object
49 50 51 |
# File 'lib/deep_cover/analyser/base.rb', line 49 def covered_code @source.covered_code end |
#each_node(from = covered_code.root, &block) ⇒ Object
Iterates on nodes in the subset. Yields the node and it’s children (within the subset)
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/deep_cover/analyser/base.rb', line 35 def each_node(from = covered_code.root, &block) return to_enum(:each_node) unless block_given? begin yield from unless from.is_a?(Node::Root) rescue ProblemWithDiagnostic raise rescue StandardError, SystemStackError => e raise ProblemWithDiagnostic.new(covered_code, from.diagnostic_expression, e) end node_children(from).each do |child| each_node(child, &block) end end |
#initialize(source, **options) ⇒ Object
7 8 9 10 |
# File 'lib/deep_cover/analyser/base.rb', line 7 def initialize(source, **) @source = to_source(source, **) = end |
#node_children(node) ⇒ Object
Looking exclusively at our subset of nodes, returns the node’s direct descendants
13 14 15 |
# File 'lib/deep_cover/analyser/base.rb', line 13 def node_children(node) @source.node_children(node) end |
#node_runs(node) ⇒ Object
Returns the number of runs of the node (assumed to be in our subset)
18 19 20 |
# File 'lib/deep_cover/analyser/base.rb', line 18 def node_runs(node) @source.node_runs(node) end |
#node_runs_map ⇒ Object
22 23 24 25 26 |
# File 'lib/deep_cover/analyser/base.rb', line 22 def node_runs_map each_node.map do |node| [node, node_runs(node)] end.to_h end |
#results ⇒ Object
Analyser-specific output
29 30 31 |
# File 'lib/deep_cover/analyser/base.rb', line 29 def results node_runs_map end |