Module: TestProf

Extended by:
Logging
Defined in:
lib/test_prof.rb,
lib/test_prof/logging.rb,
lib/test_prof/version.rb,
lib/test_prof/tag_prof.rb,
lib/test_prof/ruby_prof.rb,
lib/test_prof/event_prof.rb,
lib/test_prof/stack_prof.rb,
lib/test_prof/any_fixture.rb,
lib/test_prof/rspec_stamp.rb,
lib/test_prof/factory_prof.rb,
lib/test_prof/factory_doctor.rb,
lib/test_prof/tag_prof/rspec.rb,
lib/test_prof/factory_default.rb,
lib/test_prof/event_prof/rspec.rb,
lib/test_prof/rspec_stamp/rspec.rb,
lib/test_prof/ext/float_duration.rb,
lib/test_prof/rspec_stamp/parser.rb,
lib/test_prof/factory_doctor/rspec.rb,
lib/test_prof/recipes/rspec/sample.rb,
lib/test_prof/recipes/minitest/sample.rb,
lib/test_prof/recipes/rspec/before_all.rb,
lib/test_prof/factory_prof/factory_girl_patch.rb,
lib/test_prof/factory_doctor/factory_girl_patch.rb,
lib/test_prof/factory_default/factory_girl_patch.rb

Overview

rubocop: disable Metrics/CyclomaticComplexity

Defined Under Namespace

Modules: AnyFixture, BeforeAll, EventProf, FactoryDefault, FactoryDoctor, FactoryProf, FloatDuration, Logging, MinitestSample, RSpecStamp, RspecSample, RubyProf, StackProf, TagProf Classes: Configuration

Constant Summary collapse

VERSION =
"0.2.0"

Constants included from Logging

Logging::COLORS

Class Method Summary collapse

Methods included from Logging

build_log_msg, colorize, log

Class Method Details

.activate(env_var, val = nil) ⇒ Object

Run block only if provided env var is present and equal to the provided value (if any). Contains workaround for applications using Spring.



49
50
51
52
53
54
55
# File 'lib/test_prof.rb', line 49

def activate(env_var, val = nil)
  if defined?(::Spring)
    ::Spring.after_fork { activate!(env_var, val) { yield } }
  else
    activate!(env_var, val) { yield }
  end
end

.artifact_path(filename) ⇒ Object

Return a path to store artifact



63
64
65
66
67
68
69
70
71
72
# File 'lib/test_prof.rb', line 63

def artifact_path(filename)
  FileUtils.mkdir_p(config.output_dir)

  with_timestamps(
    ::File.join(
      config.output_dir,
      filename
    )
  )
end

.asset_path(filename) ⇒ Object

Return absolute path to asset



58
59
60
# File 'lib/test_prof.rb', line 58

def asset_path(filename)
  ::File.expand_path(filename, ::File.join(::File.dirname(__FILE__), "..", "assets"))
end

.configObject



28
29
30
# File 'lib/test_prof.rb', line 28

def config
  @config ||= Configuration.new
end

.configure {|config| ... } ⇒ Object

Yields:



32
33
34
# File 'lib/test_prof.rb', line 32

def configure
  yield config
end

.require(gem_name, msg) ⇒ Object

Require gem and shows a custom message if it fails to load



38
39
40
41
42
43
44
# File 'lib/test_prof.rb', line 38

def require(gem_name, msg)
  Kernel.require gem_name
  true
rescue LoadError
  log :error, msg
  false
end