Module: Cistern::Coverage

Defined in:
lib/cistern/coverage.rb

Class Method Summary collapse

Class Method Details

.find_caller_before(file) ⇒ Object

returns the first caller_locations entry before entries in ‘file`



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cistern/coverage.rb', line 20

def self.find_caller_before(file)
  enum = caller_locations.each

  call = nil

  # seek to the first entry from within `file`
  while (call = enum.next)
    break if call.path.end_with? file
  end

  # seek to the first entry thats not within `file`
  while (call = enum.next)
    break unless call.path.end_with? file
  end

  # the call location that called in to `file`
  call
end