class Covered::Coverage
def self.for(path, code = nil, line_offset = 1)
def self.for(path, code = nil, line_offset = 1) self.new(Source.new(path, code, line_offset)) end
def self.source(path, code = nil, line_offset = 1)
def self.source(path, code = nil, line_offset = 1) Source.new(path, code, line_offset) end
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(source, counts = [])
def initialize(source, counts = []) @source = source @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 path
def path @source.path 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) @source.read(&block) 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