Class: TestProf::RubyProf::Configuration

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

Overview

RubyProf configuration

Constant Summary collapse

PRINTERS =
{
  'flat' => 'FlatPrinter',
  'flat_wln' => 'FlatPrinterWithLineNumbers',
  'graph' => 'GraphPrinter',
  'graph_html' => 'GraphHtmlPrinter',
  'dot' => 'DotPrinter',
  '.' => 'DotPrinter',
  'call_stack' => 'CallStackPrinter',
  'call_tree' => 'CallTreePrinter',
  'multi' => 'MultiPrinter'
}.freeze
PRINTER_EXTENSTION =

Mapping from printer to report file extension NOTE: txt is not included and considered default

{
  'graph_html' => 'html',
  'dot' => 'dot',
  '.' => 'dot',
  'call_stack' => 'html'
}.freeze
LOGFILE_PREFIX =
"ruby-prof-report"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



53
54
55
56
57
58
59
60
61
62
# File 'lib/test_prof/ruby_prof.rb', line 53

def initialize
  @printer = ENV['TEST_RUBY_PROF'].to_sym if PRINTERS.key?(ENV['TEST_RUBY_PROF'])
  @printer ||= ENV.fetch('TEST_RUBY_PROF_PRINTER', :flat).to_sym
  @mode = ENV.fetch('TEST_RUBY_PROF_MODE', :wall).to_sym
  @min_percent = 1
  @include_threads = false
  @exclude_common_methods = true
  @test_prof_exclusions_enabled = true
  @custom_exclusions = {}
end

Instance Attribute Details

#custom_exclusionsObject

Returns the value of attribute custom_exclusions.



48
49
50
# File 'lib/test_prof/ruby_prof.rb', line 48

def custom_exclusions
  @custom_exclusions
end

#exclude_common_methodsObject

Returns the value of attribute exclude_common_methods.



48
49
50
# File 'lib/test_prof/ruby_prof.rb', line 48

def exclude_common_methods
  @exclude_common_methods
end

#include_threadsObject

Returns the value of attribute include_threads.



48
49
50
# File 'lib/test_prof/ruby_prof.rb', line 48

def include_threads
  @include_threads
end

#min_percentObject

Returns the value of attribute min_percent.



48
49
50
# File 'lib/test_prof/ruby_prof.rb', line 48

def min_percent
  @min_percent
end

#modeObject

Returns the value of attribute mode.



48
49
50
# File 'lib/test_prof/ruby_prof.rb', line 48

def mode
  @mode
end

#printerObject

Returns the value of attribute printer.



48
49
50
# File 'lib/test_prof/ruby_prof.rb', line 48

def printer
  @printer
end

#test_prof_exclusions_enabledObject

Returns the value of attribute test_prof_exclusions_enabled.



48
49
50
# File 'lib/test_prof/ruby_prof.rb', line 48

def test_prof_exclusions_enabled
  @test_prof_exclusions_enabled
end

Instance Method Details

#exclude_common_methods?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/test_prof/ruby_prof.rb', line 68

def exclude_common_methods?
  exclude_common_methods == true
end

#include_threads?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/test_prof/ruby_prof.rb', line 64

def include_threads?
  include_threads == true
end

#resolve_printerObject

Returns an array of printer type (ID) and class.

Raises:

  • (ArgumentError)


77
78
79
80
81
82
83
84
85
86
# File 'lib/test_prof/ruby_prof.rb', line 77

def resolve_printer
  return ['custom', printer] if printer.is_a?(Module)

  type = printer.to_s

  raise ArgumentError, "Unknown printer: #{type}" unless
    PRINTERS.key?(type)

  [type, ::RubyProf.const_get(PRINTERS[type])]
end

#test_prof_exclusions_enabled?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/test_prof/ruby_prof.rb', line 72

def test_prof_exclusions_enabled?
  @test_prof_exclusions_enabled == true
end