CoveredSourceCoveredConfig

class Config

Definitions

def start

Start coverage tracking.

Implementation

def start
	# Save and setup the environment:
	@environment = ENV.to_h
	autostart!
	
	# Start coverage tracking:
	policy.start
end

def finish

Finish coverage tracking.

Implementation

def finish
	# Finish coverage tracking:
	policy.finish
	
	# Restore the environment:
	ENV.replace(@environment)
	@environment = nil
end

def call(output)

Generate coverage reports to the given output.

Implementation

def call(output)
	policy.call(output)
end

def ignore_paths

Which paths to ignore when computing coverage for a given project.

Signature

returns Array(String)

An array of relative paths to ignore.

Implementation

def ignore_paths
	["test/", "fixtures/", "spec/", "vendor/", "config/"]
end

def include_patterns

Which paths to include when computing coverage for a given project.

Signature

returns Array(String)

An array of relative patterns to include, e.g. "lib/**/*.rb".

Implementation

def include_patterns
	["lib/**/*.rb"]
end

def make_policy(policy)

Override this method to implement your own policy.

Implementation

def make_policy(policy)
	# Only files in the root would be tracked:
	policy.root(@root)
	
	patterns = ignore_paths.map do |path|
		File.join(@root, path)
	end
	
	# We will ignore any files in the test or spec directory:
	policy.skip(Regexp.union(patterns))
	
	# We will include all files under lib, even if they aren't loaded:
	include_patterns.each do |pattern|
		policy.include(pattern)
	end
	
	policy.persist!
	
	policy.reports!(@reports)
end