Module: Busted::Traceable

Included in:
Profiler::Default, Profiler::Sandwich
Defined in:
lib/busted/traceable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#report=(value) ⇒ Object (writeonly)

Sets the attribute report

Parameters:

  • value

    the value to set the attribute report to.



7
8
9
# File 'lib/busted/traceable.rb', line 7

def report=(value)
  @report = value
end

#traceObject (readonly)

Returns the value of attribute trace.



6
7
8
# File 'lib/busted/traceable.rb', line 6

def trace
  @trace
end

#tracerObject (readonly)

Returns the value of attribute tracer.



6
7
8
# File 'lib/busted/traceable.rb', line 6

def tracer
  @tracer
end

Instance Method Details

#finish_tracerObject



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

def finish_tracer
  return unless trace?

  tracer.finish

  report[:traces] = tracer.report
end

#start_tracerObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/busted/traceable.rb', line 13

def start_tracer
  return unless trace?

  unless Tracer.exists?
    fail Tracer::MissingCommandError, "tracer requires dtrace"
  end

  unless CurrentProcess.privileged?
    fail Errno::EPERM, "dtrace requires root privileges"
  end

  @tracer = Tracer.new

  tracer.start
end

#trace?Boolean

Returns:

  • (Boolean)


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

def trace?
  trace
end