class Covered::Coverage
def [] lineno
def [] lineno @counts[lineno] end
def annotate(lineno, annotation)
def annotate(lineno, annotation) @annotations[lineno] ||= [] @annotations[lineno] << annotation end
def executable_count
def executable_count executable_lines.count end
def executable_lines
def executable_lines @executable_lines ||= @counts.compact end
def executed_count
def executed_count executed_lines.count end
def executed_lines
def executed_lines @executed_lines ||= executable_lines.reject(&:zero?) end
def freeze
def freeze return self if frozen? @counts.freeze @annotations.freeze executable_lines executed_lines super end
def initialize(path, counts = [])
def initialize(path, counts = []) @path = path @counts = counts @total = 0 @annotations = {} @executable_lines = nil @executed_lines = nil end
def mark(lineno, value = 1)
def mark(lineno, value = 1) @total += value if @counts[lineno] @counts[lineno] += value else @counts[lineno] = value end end
def missing_count
def missing_count executable_count - executed_count end
def print(output)
def print(output) output.puts "** #{executed_count}/#{executable_count} lines executed; #{percentage.to_f.round(2)}% covered." end
def read(&block)
def read(&block) if block_given? File.open(@path, "r", &block) else File.read(@path) end end
def to_a
def to_a @counts end
def to_s
def to_s "\#<#{self.class} path=#{@path} #{percentage.to_f.round(2)}% covered>" end
def zero?
def zero? @total.zero? end