Class: DeepCover::Analyser::PerChar
- Inherits:
-
DeepCover::Analyser
- Object
- DeepCover::Analyser
- DeepCover::Analyser::PerChar
- Defined in:
- lib/deep_cover/analyser/per_char.rb
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
-
#results ⇒ Object
Returns an array of characters for each line of code.
Methods included from OptionallyCovered
Methods included from IgnoreUncovered
Methods included from Base
#covered_code, #each_node, #initialize, #node_children, #node_runs, #node_runs_map
Instance Method Details
#results ⇒ Object
Returns an array of characters for each line of code. Each character is either ‘ ’ (executed), ‘-’ (not executable) or ‘x’ (not covered)
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/deep_cover/analyser/per_char.rb', line 7 def results buffer = covered_code.buffer bc = buffer.source_lines.map { |line| '-' * line.size } each_node do |node| runs = node_runs(node) next if runs == nil node.proper_range.each do |pos| bc[buffer.line_for_position(pos) - buffer.first_line][buffer.column_for_position(pos)] = runs > 0 ? ' ' : 'x' end end bc.zip(buffer.source_lines) { |cov, line| cov[line.size..-1] = '' } # remove extraneous character for end lines, in any bc end |