Class: WTT::Core::TraceService

Inherits:
Object
  • Object
show all
Defined in:
lib/wtt/core/trace_service.rb

Overview

Service for gathering coverage information and sending it back via DRB.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTraceService

Returns a new instance of TraceService.



10
11
12
13
14
15
16
17
18
# File 'lib/wtt/core/trace_service.rb', line 10

def initialize
  @coverage = Hash.new { |h, k| h[k] = [] }
  @trace = TracePoint.new(:line) do |tp|
    if should_include_file?(tp.path)
      old_count = @coverage[tp.path][tp.lineno].to_i
      @coverage[tp.path][tp.lineno] = old_count + 1
    end
  end
end

Instance Attribute Details

#coverageObject (readonly)

Returns the value of attribute coverage.



8
9
10
# File 'lib/wtt/core/trace_service.rb', line 8

def coverage
  @coverage
end

Instance Method Details

#start_traceObject



20
21
22
23
# File 'lib/wtt/core/trace_service.rb', line 20

def start_trace
  reset_coverage
  @trace.enable
end

#stop_traceObject



25
26
27
# File 'lib/wtt/core/trace_service.rb', line 25

def stop_trace
  @trace.disable
end