Sha256: e3f4ddc19bb0a414f184ff3aa4c97b9383d6368cf86fccaccb57be8213789a93

Contents?: true

Size: 1021 Bytes

Versions: 2

Compression:

Stored size: 1021 Bytes

Contents

module ScoutRailsProxy
  class Config
    def initialize(config_path = nil)
      @config_path = config_path
    end
    
    def settings
      return @settings if @settings
      load_file
    end
    
    def config_path
      @config_path || File.join(ScoutRailsProxy::Agent.instance.environment.root,"config","scout_rails_proxy.yml")
    end
    
    def config_file
      File.expand_path(config_path)
    end
    
    def load_file
      if !File.exist?(config_file)
        ScoutRailsProxy::Agent.instance.logger.warn "No config file found at [#{config_file}]."
        @settings = {}
      else
        @settings = YAML.load(ERB.new(File.read(config_file)).result(binding))[ScoutRailsProxy::Agent.instance.environment.env] || {} 
      end  
    rescue Exception => e
      ScoutRailsProxy::Agent.instance.logger.warn "Unable to load the config file."
      ScoutRailsProxy::Agent.instance.logger.warn e.message
      ScoutRailsProxy::Agent.instance.logger.warn e.backtrace
      @settings = {}
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
scout_rails_proxy-1.0.6 lib/scout_rails_proxy/config.rb
scout_rails_proxy_proxy-1.0.5 lib/scout_rails_proxy/config.rb