Class: TestProf::EventProf::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/test_prof/event_prof.rb

Overview

EventProf configuration

Constant Summary collapse

INSTRUMENTERS =

Map of supported instrumenters

{
  active_support: 'ActiveSupport'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



33
34
35
36
37
38
39
# File 'lib/test_prof/event_prof.rb', line 33

def initialize
  @event = ENV['EVENT_PROF']
  @instrumenter = :active_support
  @top_count = (ENV['EVENT_PROF_TOP'] || 5).to_i
  @per_example = false
  @rank_by = (ENV['EVENT_PROF_RANK'] || :time).to_sym
end

Instance Attribute Details

#eventObject

Returns the value of attribute event.



30
31
32
# File 'lib/test_prof/event_prof.rb', line 30

def event
  @event
end

#instrumenterObject

Returns the value of attribute instrumenter.



30
31
32
# File 'lib/test_prof/event_prof.rb', line 30

def instrumenter
  @instrumenter
end

#per_exampleObject

Returns the value of attribute per_example.



30
31
32
# File 'lib/test_prof/event_prof.rb', line 30

def per_example
  @per_example
end

#rank_byObject

Returns the value of attribute rank_by.



30
31
32
# File 'lib/test_prof/event_prof.rb', line 30

def rank_by
  @rank_by
end

#top_countObject

Returns the value of attribute top_count.



30
31
32
# File 'lib/test_prof/event_prof.rb', line 30

def top_count
  @top_count
end

Instance Method Details

#per_example?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/test_prof/event_prof.rb', line 41

def per_example?
  per_example == true
end

#resolve_instrumenterObject

Raises:

  • (ArgumentError)


45
46
47
48
49
50
51
52
# File 'lib/test_prof/event_prof.rb', line 45

def resolve_instrumenter
  return instrumenter if instrumenter.is_a?(Module)

  raise ArgumentError, "Unknown instrumenter: #{instrumenter}" unless
    INSTRUMENTERS.key?(instrumenter)

  Instrumentations.const_get(INSTRUMENTERS[instrumenter])
end