Class: Covered::Config
- Inherits:
-
Object
- Object
- Covered::Config
- Defined in:
- lib/covered/config.rb
Constant Summary collapse
- PATH =
"config/covered.rb"
Instance Attribute Summary collapse
-
#coverage ⇒ Object
readonly
Returns the value of attribute coverage.
Class Method Summary collapse
Instance Method Summary collapse
- #call(output) ⇒ Object
- #disable ⇒ Object
- #each(&block) ⇒ Object
- #enable ⇒ Object
- #flush ⇒ Object
-
#initialize(root, coverage) ⇒ Config
constructor
A new instance of Config.
-
#make_policy(policy) ⇒ Object
Override this method to implement your own policy.
- #output ⇒ Object
- #policy ⇒ Object
- #record? ⇒ Boolean
Constructor Details
Instance Attribute Details
#coverage ⇒ Object (readonly)
Returns the value of attribute coverage.
63 64 65 |
# File 'lib/covered/config.rb', line 63 def coverage @coverage end |
Class Method Details
.coverage ⇒ Object
37 38 39 |
# File 'lib/covered/config.rb', line 37 def self.coverage ENV['COVERAGE'] end |
.load(root: Dir.pwd, coverage: self.coverage) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/covered/config.rb', line 41 def self.load(root: Dir.pwd, coverage: self.coverage) derived = Class.new(self) if path = self.path(root) config = Module.new config.module_eval(::File.read(path), path) derived.prepend(config) end return derived.new(root, coverage) end |
Instance Method Details
#call(output) ⇒ Object
85 86 87 |
# File 'lib/covered/config.rb', line 85 def call(output) policy.call(output) end |
#disable ⇒ Object
77 78 79 |
# File 'lib/covered/config.rb', line 77 def disable policy.disable end |
#each(&block) ⇒ Object
89 90 91 |
# File 'lib/covered/config.rb', line 89 def each(&block) policy.each(&block) end |
#enable ⇒ Object
73 74 75 |
# File 'lib/covered/config.rb', line 73 def enable policy.enable end |
#flush ⇒ Object
81 82 83 |
# File 'lib/covered/config.rb', line 81 def flush policy.flush end |
#make_policy(policy) ⇒ Object
Override this method to implement your own policy.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/covered/config.rb', line 94 def make_policy(policy) policy.cache! # Only files in the root would be tracked: policy.root(@root) # We will ignore any files in the test or spec directory: policy.skip(/^.*\/(test|spec|vendor|config)\//) # We will include all files under lib, even if they aren't loaded: policy.include("lib/**/*.rb") policy.persist! policy.source policy.reports!(@coverage) end |
#output ⇒ Object
69 70 71 |
# File 'lib/covered/config.rb', line 69 def output policy.output end |
#policy ⇒ Object
65 66 67 |
# File 'lib/covered/config.rb', line 65 def policy @policy ||= Policy.new.tap{|policy| make_policy(policy)}.freeze end |
#record? ⇒ Boolean
59 60 61 |
# File 'lib/covered/config.rb', line 59 def record? !!@coverage end |