Module: OneApm::Probe::FrameworkLoader

Included in:
OneApm::Probe
Defined in:
lib/one_apm/probe/framework_loader.rb

Instance Method Summary collapse

Instance Method Details

#init(options = {}) ⇒ Object



7
8
9
# File 'lib/one_apm/probe/framework_loader.rb', line 7

def init(options = {})
  instance.init_plugin options
end

#instanceObject



11
12
13
# File 'lib/one_apm/probe/framework_loader.rb', line 11

def instance
  @instance ||= new_instance
end

#load_framework_class(framework) ⇒ Object



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

def load_framework_class(framework)
  begin
    require "one_apm/frameworks/#{framework}"
  rescue LoadError
  end
  OneApm::Probe::Frameworks.const_get(framework.to_s.capitalize)
end

#load_test_frameworkObject



32
33
34
35
36
# File 'lib/one_apm/probe/framework_loader.rb', line 32

def load_test_framework
  config = File.expand_path(File.join('..', '..', '..', '..', 'test', 'config', 'oneapm.yml'), __FILE__)
  require 'config/test_control'
  OneApm::Probe::Frameworks::Test.new(local_env, config)
end

#local_envObject



28
29
30
# File 'lib/one_apm/probe/framework_loader.rb', line 28

def local_env
  @local_env ||= OneApm::LocalEnvironment.new
end

#new_instanceObject



15
16
17
18
19
20
21
# File 'lib/one_apm/probe/framework_loader.rb', line 15

def new_instance
  if OneApm::Manager.config[:framework] == :test
    load_test_framework
  else
    load_framework_class(Manager.config[:framework]).new(local_env)
  end
end

#oneapm_rootObject



46
47
48
# File 'lib/one_apm/probe/framework_loader.rb', line 46

def oneapm_root
  File.expand_path(File.join('..', '..', '..', '..'), __FILE__)
end

#resetObject



23
24
25
26
# File 'lib/one_apm/probe/framework_loader.rb', line 23

def reset
  @instance = nil
  @local_env = nil
end