lib/covered/config.rb in covered-0.16.1 vs lib/covered/config.rb in covered-0.16.2
- old
+ new
@@ -32,13 +32,15 @@
if ::File.exist?(path)
return path
end
end
- def self.load(root: Dir.pwd, coverage: ENV['COVERAGE'])
- return nil unless coverage
-
+ def self.coverage
+ ENV['COVERAGE']
+ end
+
+ 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)
@@ -52,14 +54,24 @@
@root = root
@coverage = coverage
@policy = nil
end
+ def record?
+ !!@coverage
+ end
+
+ attr :coverage
+
def policy
@policy ||= Policy.new.tap{|policy| make_policy(policy)}.freeze
end
+ def output
+ policy.output
+ end
+
def enable
policy.enable
end
def disable
@@ -70,9 +82,13 @@
policy.flush
end
def call(output)
policy.call(output)
+ end
+
+ def each(&block)
+ policy.each(&block)
end
# Override this method to implement your own policy.
def make_policy(policy)
policy.cache!