Class: Busted::Tracer

Inherits:
Object
  • Object
show all
Defined in:
lib/busted/tracer.rb

Defined Under Namespace

Classes: FinishedException, MissingCommandError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTracer

Returns a new instance of Tracer.



13
14
15
# File 'lib/busted/tracer.rb', line 13

def initialize
  @lines = ""
end

Class Method Details

.exists?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/busted/tracer.rb', line 9

def self.exists?
  system "hash dtrace 2>/dev/null"
end

Instance Method Details

#finishObject



22
23
24
25
26
27
28
# File 'lib/busted/tracer.rb', line 22

def finish
  final_probe
  wait until finished?
  kill
ensure
  clean_up
end

#reportObject



30
31
32
33
34
35
36
# File 'lib/busted/tracer.rb', line 30

def report
  lines.split("\n").each_with_object({method: []}) do |line, result|
    next if line =~ /\ABusted/
    trace = line.split
    result[:method] << { class: trace[0], sourcefile: trace[1], lineno: trace[2] }
  end
end

#startObject



17
18
19
20
# File 'lib/busted/tracer.rb', line 17

def start
  spawn
  wait until started?
end