class Include
Includes coverage for files matching a glob pattern.
Definitions
def initialize(output, pattern, base = "")
Initialize an include filter for the given glob pattern.
Signature
-
parameter
outputCovered::Base The output to wrap.
-
parameter
patternString The glob pattern to include.
-
parameter
baseString The base path used to expand the glob.
Implementation
def initialize(output, pattern, base = "")
super(output)
@pattern = pattern
@base = base
end
attr :pattern
Signature
-
attribute
String The glob pattern to include.
def glob
Resolve the include pattern to real file paths.
Signature
-
returns
Set(String) The real paths matched by the include pattern.
Implementation
def glob
paths = Set.new
root = self.expand_path(@base)
pattern = File.expand_path(@pattern, root)
Dir.glob(pattern) do |path|
unless File.directory?(path)
paths << File.realpath(path)
end
end
return paths
end
def each(&block)
Enumerate existing coverage and synthesize empty coverage for unmatched included files.
Signature
-
yields
{|coverage| ...} Each existing or synthesized coverage object.
-
parameter
coverageCovered::Coverage The current coverage object.
-
parameter
Implementation
def each(&block)
paths = glob
super do |coverage|
paths.delete(coverage.path)
yield coverage
end
paths.each do |path|
yield Coverage.for(path)
end
end