Class: Covered::Policy
Overview
Configures coverage collection, filtering, persistence and reports.
Defined Under Namespace
Classes: Autoload
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#reports ⇒ Object
readonly
Returns the value of attribute reports.
- #The configured report objects or autoloaders.(configuredreportobjects) ⇒ Object readonly
- #The current output pipeline.(currentoutputpipeline.) ⇒ Object readonly
Attributes inherited from Wrapper
Instance Method Summary collapse
-
#call ⇒ Object
Generate all configured reports.
-
#capture ⇒ Object
The runtime capture pipeline for this policy.
-
#finish ⇒ Object
Finish collecting coverage.
-
#freeze ⇒ Object
Freeze the policy and eagerly build the capture pipeline.
-
#include ⇒ Object
Include files matching the given pattern in coverage results.
-
#initialize ⇒ Policy
constructor
Initialize a policy with an empty file collection.
-
#only ⇒ Object
Restrict coverage results to files matching the given pattern.
-
#persist! ⇒ Object
Persist coverage results to a database.
-
#reports!(reports) ⇒ Object
Configure reports from names, booleans, arrays or report objects.
-
#root ⇒ Object
Restrict coverage results to the given project root.
-
#skip ⇒ Object
Exclude files matching the given pattern from coverage results.
-
#start ⇒ Object
Start collecting coverage.
Methods inherited from Wrapper
#accept?, #add, #clear, #each, #expand_path, #mark, #relative_path, #to_h
Methods inherited from Base
#accept?, #add, #clear, #each, #expand_path, #mark, #relative_path
Constructor Details
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
24 25 26 |
# File 'lib/covered/policy.rb', line 24 def output @output end |
#reports ⇒ Object (readonly)
Returns the value of attribute reports.
86 87 88 |
# File 'lib/covered/policy.rb', line 86 def reports @reports end |
#The configured report objects or autoloaders.(configuredreportobjects) ⇒ Object (readonly)
86 |
# File 'lib/covered/policy.rb', line 86 attr :reports |
#The current output pipeline.(currentoutputpipeline.) ⇒ Object (readonly)
24 |
# File 'lib/covered/policy.rb', line 24 attr :output |
Instance Method Details
#call ⇒ Object
Generate all configured reports. Arguments are forwarded to each report.
162 163 164 165 166 |
# File 'lib/covered/policy.rb', line 162 def call(...) @reports.each do |report| report.call(self, ...) end end |
#capture ⇒ Object
The runtime capture pipeline for this policy.
69 70 71 72 73 |
# File 'lib/covered/policy.rb', line 69 def capture @capture ||= Forks.new( Capture.new(@output) ) end |
#finish ⇒ Object
Finish collecting coverage.
81 82 83 |
# File 'lib/covered/policy.rb', line 81 def finish capture.finish end |
#freeze ⇒ Object
Freeze the policy and eagerly build the capture pipeline.
28 29 30 31 32 33 34 35 |
# File 'lib/covered/policy.rb', line 28 def freeze return self if frozen? capture @reports.freeze super end |
#include ⇒ Object
Include files matching the given pattern in coverage results. Arguments are forwarded to Include#initialize.
39 40 41 |
# File 'lib/covered/policy.rb', line 39 def include(...) @output = Include.new(@output, ...) end |
#only ⇒ Object
Restrict coverage results to files matching the given pattern. Arguments are forwarded to Only#initialize.
51 52 53 |
# File 'lib/covered/policy.rb', line 51 def only(...) @output = Only.new(@output, ...) end |
#persist! ⇒ Object
Persist coverage results to a database. Arguments are forwarded to Covered::Persist#initialize.
63 64 65 |
# File 'lib/covered/policy.rb', line 63 def persist!(...) @output = Persist.new(@output, ...) end |
#reports!(reports) ⇒ Object
Configure reports from names, booleans, arrays or report objects.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/covered/policy.rb', line 135 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 |
#root ⇒ Object
Restrict coverage results to the given project root. Arguments are forwarded to Root#initialize.
57 58 59 |
# File 'lib/covered/policy.rb', line 57 def root(...) @output = Root.new(@output, ...) end |
#skip ⇒ Object
Exclude files matching the given pattern from coverage results. Arguments are forwarded to Skip#initialize.
45 46 47 |
# File 'lib/covered/policy.rb', line 45 def skip(...) @output = Skip.new(@output, ...) end |
#start ⇒ Object
Start collecting coverage.
76 77 78 |
# File 'lib/covered/policy.rb', line 76 def start capture.start end |