Sha256: 36188f6dd8c082421ce664496b93750cdd91bef7ec1016a2da6f3305de95857c

Contents?: true

Size: 1.38 KB

Versions: 9

Compression:

Stored size: 1.38 KB

Contents

module NewRelic
  class Control
    module ClassMethods
      # Access the Control singleton, lazy initialized
      def instance
        @instance ||= new_instance
      end

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

      # Create the concrete class for environment specific behavior:
      def new_instance
        if local_env.framework == :test
          load_test_framework
        else
          load_framework_class(local_env.framework).new(local_env)
        end
      end

      # nb this does not 'load test' the framework, it loads the 'test framework'
      def load_test_framework
        config = File.expand_path(File.join('..','..','..','..', "test","config","newrelic.yml"), __FILE__)
        require "config/test_control"
        NewRelic::Control::Frameworks::Test.new(local_env, config)
      end

      def load_framework_class(framework)
        begin
          require "new_relic/control/frameworks/#{framework}"
        rescue LoadError
          # maybe it is already loaded by some external system
          # i.e. rpm_contrib or user extensions?
        end
        NewRelic::Control::Frameworks.const_get(framework.to_s.capitalize)
      end

      # The root directory for the plugin or gem
      def newrelic_root
        File.expand_path(File.join("..", "..", "..", ".."), __FILE__)
      end
    end
    extend ClassMethods
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
ghazel-newrelic_rpm-3.1.0.1 lib/new_relic/control/class_methods.rb
newrelic_rpm-3.1.0 lib/new_relic/control/class_methods.rb
newrelic_rpm-3.1.0.beta5 lib/new_relic/control/class_methods.rb
newrelic_rpm-3.1.0.beta4 lib/new_relic/control/class_methods.rb
newrelic_rpm-3.1.0.djlogging2 lib/new_relic/control/class_methods.rb
newrelic_rpm-3.1.0.djlogging lib/new_relic/control/class_methods.rb
newrelic_rpm-3.1.0.beta3 lib/new_relic/control/class_methods.rb
newrelic_rpm-3.1.0.beta2 lib/new_relic/control/class_methods.rb
newrelic_rpm-3.1.0.beta1 lib/new_relic/control/class_methods.rb