Class: WTT::Core::TraceService
- Inherits:
-
Object
- Object
- WTT::Core::TraceService
- Defined in:
- lib/wtt/core/trace_service.rb
Overview
Service for gathering coverage information and sending it back via DRB.
Instance Attribute Summary collapse
-
#coverage ⇒ Object
readonly
Returns the value of attribute coverage.
Instance Method Summary collapse
-
#initialize ⇒ TraceService
constructor
A new instance of TraceService.
- #start_trace ⇒ Object
- #stop_trace ⇒ Object
Constructor Details
#initialize ⇒ TraceService
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
#coverage ⇒ Object (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_trace ⇒ Object
20 21 22 23 |
# File 'lib/wtt/core/trace_service.rb', line 20 def start_trace reset_coverage @trace.enable end |
#stop_trace ⇒ Object
25 26 27 |
# File 'lib/wtt/core/trace_service.rb', line 25 def stop_trace @trace.disable end |