Class: Busted::Profiler::Default

Inherits:
Object
  • Object
show all
Includes:
Countable, Traceable
Defined in:
lib/busted/profiler/default.rb

Instance Attribute Summary collapse

Attributes included from Countable

#counter

Attributes included from Traceable

#tracer

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Countable

#finish_counter, #start_counter

Methods included from Traceable

#finish_tracer, #start_tracer, #trace?

Constructor Details

#initialize(options = {}, &block) ⇒ Default

Returns a new instance of Default.



14
15
16
17
18
19
20
# File 'lib/busted/profiler/default.rb', line 14

def initialize(options = {}, &block)
  fail LocalJumpError, "no block given" unless block

  @trace = options.fetch :trace, false
  @block = block
  @report = {}
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



8
9
10
# File 'lib/busted/profiler/default.rb', line 8

def block
  @block
end

#reportObject (readonly)

Returns the value of attribute report.



8
9
10
# File 'lib/busted/profiler/default.rb', line 8

def report
  @report
end

#traceObject (readonly)

Returns the value of attribute trace.



8
9
10
# File 'lib/busted/profiler/default.rb', line 8

def trace
  @trace
end

Class Method Details

.run(options = {}, &block) ⇒ Object



10
11
12
# File 'lib/busted/profiler/default.rb', line 10

def self.run(options = {}, &block)
  new(options, &block).run
end

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/busted/profiler/default.rb', line 22

def run
  start_tracer
  start_counter

  block.call

  finish_counter
  finish_tracer

  report
end