Sha256: b565ffedf06fdfc3b0ca700ac7531585c55b61cbcb56924ae56320ba97210efa

Contents?: true

Size: 1.15 KB

Versions: 17

Compression:

Stored size: 1.15 KB

Contents

module ScoutRails
  class Config   
    DEFAULTS =  {
        'host' => 'scoutapp.com',
        'log_level' => 'info'
    }

    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(ScoutRails::Agent.instance.environment.root,"config","scout_rails.yml")
    end
    
    def config_file
      File.expand_path(config_path)
    end
    
    def load_file
      begin
        if !File.exist?(config_file)
          ScoutRails::Agent.instance.logger.warn "No config file found at [#{config_file}]."
          @settings = {}
        else
          @settings = YAML.load(ERB.new(File.read(config_file)).result(binding))[ScoutRails::Agent.instance.environment.env] || {} 
        end  
      rescue Exception => e
        ScoutRails::Agent.instance.logger.warn "Unable to load the config file."
        ScoutRails::Agent.instance.logger.warn e.message
        ScoutRails::Agent.instance.logger.warn e.backtrace
        @settings = {}
      end
      @settings = DEFAULTS.merge(@settings)
    end
  end # Config
end # ScoutRails

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
scout_rails-1.1.5.pre6 lib/scout_rails/config.rb
scout_rails-1.1.5.pre5 lib/scout_rails/config.rb
scout_rails-1.1.5.pre4 lib/scout_rails/config.rb
scout_rails-1.1.5.pre3 lib/scout_rails/config.rb
scout_rails-1.1.5.pre lib/scout_rails/config.rb
scout_rails-1.1.4.pre lib/scout_rails/config.rb
scout_rails-1.1.3 lib/scout_rails/config.rb
scout_rails-1.1.2 lib/scout_rails/config.rb
scout_rails-1.1.1 lib/scout_rails/config.rb
scout_rails-1.1.1.pre lib/scout_rails/config.rb
scout_rails-1.1.0 lib/scout_rails/config.rb
scout_rails-1.0.9 lib/scout_rails/config.rb
scout_rails-1.0.8 lib/scout_rails/config.rb
scout_rails-1.0.8.pre.3 lib/scout_rails/config.rb
scout_rails-1.0.7 lib/scout_rails/config.rb
scout_rails-1.0.6 lib/scout_rails/config.rb
scout_rails-1.0.5 lib/scout_rails/config.rb