Class: Covered::Capture

Inherits:
Wrapper show all
Defined in:
lib/covered/capture.rb

Instance Attribute Summary

Attributes inherited from Wrapper

#output

Instance Method Summary collapse

Methods inherited from Wrapper

#accept?, #each, #expand_path, #mark, #relative_path, #to_h

Methods inherited from Base

#accept?, #each, #expand_path, #mark, #relative_path

Constructor Details

#initialize(output) ⇒ Capture

Returns a new instance of Capture.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/covered/capture.rb', line 27

def initialize(output)
	super(output)
	
	begin
		@trace = TracePoint.new(:line, :call, :c_call) do |event|
			if path = event.path
				@output.mark(path, event.lineno, 1)
			end
		end
	rescue
		warn "Line coverage disabled: #{$!}"
		@trace = nil
	end
end

Instance Method Details

#disableObject



48
49
50
51
52
# File 'lib/covered/capture.rb', line 48

def disable
	@trace&.disable
	
	super
end

#enableObject



42
43
44
45
46
# File 'lib/covered/capture.rb', line 42

def enable
	super
	
	@trace&.enable
end