Class: Covered::Wrapper

Inherits:
Base
  • Object
show all
Defined in:
lib/covered/wrapper.rb

Overview

Wraps another coverage output.

Direct Known Subclasses

Capture, Filter, Forks, Include, Persist, Policy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output = Base.new) ⇒ Wrapper

Initialize the wrapper with the given output.



65
66
67
# File 'lib/covered/wrapper.rb', line 65

def initialize(output = Base.new)
	@output = output
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



70
71
72
# File 'lib/covered/wrapper.rb', line 70

def output
  @output
end

#The wrapped output.(wrappedoutput.) ⇒ Object (readonly)



70
# File 'lib/covered/wrapper.rb', line 70

attr :output

Instance Method Details

#accept?(path) ⇒ Boolean

Whether the wrapped output accepts the given path.

Returns:

  • (Boolean)


90
91
92
# File 'lib/covered/wrapper.rb', line 90

def accept?(path)
	@output.accept?(path)
end

#add(coverage) ⇒ Object

Add coverage to the wrapped output.



104
105
106
# File 'lib/covered/wrapper.rb', line 104

def add(coverage)
	@output.add(coverage)
end

#clearObject

Clear coverage on the wrapped output.



78
79
80
# File 'lib/covered/wrapper.rb', line 78

def clear
	@output.clear
end

#each {|Coverage| ... } ⇒ Object

Yields:

  • (Coverage)

    the path to the file, and the execution counts.



109
110
111
# File 'lib/covered/wrapper.rb', line 109

def each(&block)
	@output.each(&block)
end

#expand_path(path) ⇒ Object

Expand a path using the wrapped output.



123
124
125
# File 'lib/covered/wrapper.rb', line 123

def expand_path(path)
	@output.expand_path(path)
end

#finishObject

Finish tracking coverage on the wrapped output.



83
84
85
# File 'lib/covered/wrapper.rb', line 83

def finish
	@output.finish
end

#mark(path, lineno, value) ⇒ Object

Mark coverage on the wrapped output.



98
99
100
# File 'lib/covered/wrapper.rb', line 98

def mark(path, lineno, value)
	@output.mark(path, lineno, value)
end

#relative_path(path) ⇒ Object

Convert a path using the wrapped output.



116
117
118
# File 'lib/covered/wrapper.rb', line 116

def relative_path(path)
	@output.relative_path(path)
end

#startObject

Start tracking coverage on the wrapped output.



73
74
75
# File 'lib/covered/wrapper.rb', line 73

def start
	@output.start
end

#to_hObject

Convert all coverage data to a hash keyed by path.



129
130
131
# File 'lib/covered/wrapper.rb', line 129

def to_h
	to_enum(:each).collect{|coverage| [coverage.path, coverage]}.to_h
end