Class: Mutant::LineTrace

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/mutant/line_trace.rb

Overview

Line tracer

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(&block) ⇒ Traces

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run block

Returns:

  • (Traces)


25
26
27
28
29
30
31
# File 'lib/mutant/line_trace.rb', line 25

def self.call(&block)
  traces = Hash.new { |hash, file| hash[file] = Set.new }
  TracePoint.trace(:return, :line) do |point|
    traces[point.path] << point.lineno
  end.tap(&block).disable
  new(IceNine.deep_freeze(traces))
end

Instance Method Details

#cover?(file, lineno) ⇒ Boolean

Test if trace coveres file at lineno

Parameters:

  • file (String)
  • lineno (Fixnum)

Returns:

  • (Boolean)


15
16
17
# File 'lib/mutant/line_trace.rb', line 15

def cover?(file, lineno)
  contents.fetch(file) { return false }.include?(lineno)
end