class DeepCover::Analyser::PerChar

Public Class Methods

human_name() click to toggle source
# File lib/deep_cover/analyser/per_char.rb, line 5
def self.human_name
  'Chars'
end

Public Instance Methods

buffer() click to toggle source
# File lib/deep_cover/analyser/per_char.rb, line 34
def buffer
  covered_code.buffer
end
node_stat_contribution(node) click to toggle source
# File lib/deep_cover/analyser/per_char.rb, line 24
def node_stat_contribution(node)
  node.executed_locs.sum(&:size)
end
results() click to toggle source

Returns an array of characters for each line of code. Each character is either ' ' (executed), '-' (not executable) or 'x' (not covered)

# File lib/deep_cover/analyser/per_char.rb, line 11
def results
  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
stats() click to toggle source
Calls superclass method
# File lib/deep_cover/analyser/per_char.rb, line 28
def stats
  s = super
  actual_total = buffer.source.size
  s.with not_executable: actual_total - s.total
end