class Covered::Root
Restricts coverage to a project root and converts paths relative to it.
def expand_path(path)
@parameter path [String] The path to expand.
Expand a path relative to this root.
def expand_path(path) File.expand_path(super, @path) end
def initialize(output, path)
@parameter output [Covered::Base] The output to wrap.
Initialize a root filter for the given path.
def initialize(output, path) super(output) @path = path end
def match?(path)
@parameter path [String] The source path.
Whether the given path is under this root.
def match?(path) path.start_with?(@path) end
def relative_path(path)
@parameter path [String] The path to relativize.
Convert a path under this root to a relative path.
def relative_path(path) if path.start_with?(@path) path.slice(@path.size+1, path.size) else super end end