Module: TingYun::Frameworks::ClassMethods

Included in:
Framework
Defined in:
lib/ting_yun/frameworks/class_methods.rb

Instance Method Summary collapse

Instance Method Details

#instanceObject



10
11
12
13
14
15
16
17
18
# File 'lib/ting_yun/frameworks/class_methods.rb', line 10

def instance
  framework = TingYun::Agent.config[:framework]
  if framework == :test
    @instance ||= load_test_framework
  else
    @instance ||= load_framework_class(framework).new(local_env)
  end

end

#load_framework_class(framework) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/ting_yun/frameworks/class_methods.rb', line 27

def load_framework_class(framework)
  begin
    require 'ting_yun/frameworks/' + framework.to_s
  rescue LoadError
    #to avoid error
  end
  TingYun::Frameworks.const_get(framework.to_s.capitalize)
end

#load_test_frameworkObject



20
21
22
23
24
# File 'lib/ting_yun/frameworks/class_methods.rb', line 20

def load_test_framework
  config = File.expand_path(File.join('..','..', 'test','config','tingyun.yml'), __FILE__)
  require 'config/test'
  TingYun::Frameworks::Test.new(local_env, config)
end

#local_envObject



36
37
38
# File 'lib/ting_yun/frameworks/class_methods.rb', line 36

def local_env
  @local_env ||= TingYun::Support::LocalEnvironment.new
end

#resetObject

clear out memoized Framework and LocalEnv instances



41
42
43
44
# File 'lib/ting_yun/frameworks/class_methods.rb', line 41

def reset
  @instance = nil
  @local_env = nil
end