Sha256: 218c3bd8af5d6f2b0f28829d346ee3d788c11c138533fb1043c6f706bbf28494
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
require 'appsignal/careful_logger' module Appsignal class Config include Appsignal::CarefulLogger DEFAULT_CONFIG = { :ignore_exceptions => [], :endpoint => 'https://push.appsignal.com/1', :slow_request_threshold => 200 }.freeze attr_reader :configurations, :project_path, :env def initialize(project_path, env, logger=Appsignal.logger) @project_path = project_path @env = env.to_sym @logger = logger @configurations = {} end def load return unless load_configurations_from_disk return unless used_unique_api_keys return unless current_environment_present DEFAULT_CONFIG.merge(configurations[env]) end protected def load_configurations_from_disk file = File.join(project_path, 'config', 'appsignal.yml') unless File.exists?(file) carefully_log_error "config not found at: '#{file}'" return false end @configurations = YAML.load(ERB.new(IO.read(file)).result) configurations.each { |k,v| v.symbolize_keys! } configurations.symbolize_keys! true end def used_unique_api_keys keys = configurations.each_value.map { |config| config[:api_key] }.compact if keys.uniq.count < keys.count carefully_log_error('Duplicate API keys found in appsignal.yml') false else true end end def current_environment_present return true if configurations[env].present? carefully_log_error "config for '#{env}' not found" false end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
appsignal-0.5.1 | lib/appsignal/config.rb |