Module: DeepCover::Analyser::Base
- Includes:
- Tools::Covered
- 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_covered?(node) ⇒ Boolean
-
#node_runs(node) ⇒ Object
Returns the number of runs of the node (assumed to be in our subset).
- #node_runs_map ⇒ Object
- #node_stat_contributions(nodes) ⇒ Object
- #node_stat_type(node) ⇒ Object
-
#results ⇒ Object
Analyser-specific output.
- #stats ⇒ Object
Methods included from Tools::Covered
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/deep_cover/analyser/base.rb', line 7 def @options end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/deep_cover/analyser/base.rb', line 7 def source @source end |
Instance Method Details
#covered_code ⇒ Object
81 82 83 |
# File 'lib/deep_cover/analyser/base.rb', line 81 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)
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/deep_cover/analyser/base.rb', line 67 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
9 10 11 12 |
# File 'lib/deep_cover/analyser/base.rb', line 9 def initialize(source, **) @source = to_source(source, **) @options = end |
#node_children(node) ⇒ Object
Looking exclusively at our subset of nodes, returns the node’s direct descendants
15 16 17 |
# File 'lib/deep_cover/analyser/base.rb', line 15 def node_children(node) @source.node_children(node) end |
#node_covered?(node) ⇒ Boolean
24 25 26 |
# File 'lib/deep_cover/analyser/base.rb', line 24 def node_covered?(node) covered?(node_runs(node)) end |
#node_runs(node) ⇒ Object
Returns the number of runs of the node (assumed to be in our subset)
20 21 22 |
# File 'lib/deep_cover/analyser/base.rb', line 20 def node_runs(node) @source.node_runs(node) end |
#node_runs_map ⇒ Object
28 29 30 31 32 |
# File 'lib/deep_cover/analyser/base.rb', line 28 def node_runs_map each_node.map do |node| [node, node_runs(node)] end.to_h end |
#node_stat_contributions(nodes) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/deep_cover/analyser/base.rb', line 51 def node_stat_contributions(nodes) if respond_to? :node_stat_contribution nodes.sum { |n| node_stat_contribution(n) } else nodes.size end end |
#node_stat_type(node) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/deep_cover/analyser/base.rb', line 39 def node_stat_type(node) return :not_executable unless node.executable? case node_runs(node) when nil :ignored when 0 :not_executed else :executed end end |
#results ⇒ Object
Analyser-specific output
35 36 37 |
# File 'lib/deep_cover/analyser/base.rb', line 35 def results node_runs_map end |