class Covered::Policy
Configures coverage collection, filtering, persistence and reports.
def call(...)
Generate all configured reports.
def call(...) @reports.each do |report| report.call(self, ...) end end
def capture
The runtime capture pipeline for this policy.
def capture @capture ||= Forks.new( Capture.new(@output) ) end
def finish
def finish capture.finish end
def freeze
Freeze the policy and eagerly build the capture pipeline.
def freeze return self if frozen? capture @reports.freeze super end
def include(...)
Include files matching the given pattern in coverage results.
def include(...) @output = Include.new(@output, ...) end
def initialize
def initialize super(Files.new) @reports = [] @capture = nil end
def only(...)
Restrict coverage results to files matching the given pattern.
def only(...) @output = Only.new(@output, ...) end
def persist!(...)
Persist coverage results to a database.
def persist!(...) @output = Persist.new(@output, ...) end
def reports!(reports)
Configure reports from names, booleans, arrays or report objects.
def reports!(reports) if reports.nil? return elsif reports.is_a?(String) names = reports.split(",") names.each do |name| begin klass = Covered.const_get(name) @reports << klass.new rescue NameError @reports << Autoload.new(name) end end elsif reports == true @reports << Covered::BriefSummary.new elsif reports == false @reports.clear elsif reports.is_a?(Array) @reports.concat(reports) else @reports << reports end end
def root(...)
Restrict coverage results to the given project root.
def root(...) @output = Root.new(@output, ...) end
def skip(...)
Exclude files matching the given pattern from coverage results.
def skip(...) @output = Skip.new(@output, ...) end
def start
def start capture.start end