class Covered::Policy

Configures coverage collection, filtering, persistence and reports.

def call(...)

Arguments are forwarded to each report.
Generate all configured reports.
def call(...)
	@reports.each do |report|
		report.call(self, ...)
	end
end

def capture

@returns [Covered::Forks] The memoized capture pipeline.
The runtime capture pipeline for this policy.
def capture
	@capture ||= Forks.new(
		Capture.new(@output)
	)
end

def finish

Finish collecting coverage.
def finish
	capture.finish
end

def freeze

@returns [Covered::Policy] This frozen policy.
Freeze the policy and eagerly build the capture pipeline.
def freeze
	return self if frozen?
	
	capture
	@reports.freeze
	
	super
end

def include(...)

Arguments are forwarded to {Covered::Include#initialize}.
Include files matching the given pattern in coverage results.
def include(...)
	@output = Include.new(@output, ...)
end

def initialize

Initialize a policy with an empty file collection.
def initialize
	super(Files.new)
	
	@reports = []
	@capture = nil
end

def only(...)

Arguments are forwarded to {Covered::Only#initialize}.
Restrict coverage results to files matching the given pattern.
def only(...)
	@output = Only.new(@output, ...)
end

def persist!(...)

Arguments are forwarded to {Covered::Persist#initialize}.
Persist coverage results to a database.
def persist!(...)
	@output = Persist.new(@output, ...)
end

def reports!(reports)

@parameter reports [String | Boolean | Array | Object | Nil] The reports to configure.
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(...)

Arguments are forwarded to {Covered::Root#initialize}.
Restrict coverage results to the given project root.
def root(...)
	@output = Root.new(@output, ...)
end

def skip(...)

Arguments are forwarded to {Covered::Skip#initialize}.
Exclude files matching the given pattern from coverage results.
def skip(...)
	@output = Skip.new(@output, ...)
end

def start

Start collecting coverage.
def start
	capture.start
end