class AppInsights::ConfigLoader

Attributes

filename[R]
settings[R]

Public Class Methods

new(root, filename = nil) click to toggle source
# File lib/appinsights/config_loader.rb, line 7
def initialize(root, filename = nil)
  @root = root
  @filename = filename || default_file
  @filename = File.join(@root, @filename) if @filename

  unless @filename && File.exist?(@filename)
    fail AppInsights::ConfigFileNotFound
  end

  @settings = TOML.load_file @filename

  AppInsights::Context.configure @settings['ai']
  AppInsights::Middlewares.configure @settings['middleware']
end

Private Instance Methods

default_file() click to toggle source
# File lib/appinsights/config_loader.rb, line 24
def default_file
  default_paths.compact.find { |path| File.exist? File.join(@root, path) }
end
default_paths() click to toggle source
# File lib/appinsights/config_loader.rb, line 28
def default_paths
  @default_paths ||= [
    ENV['AI_CONFIG_RPATH'],
    './config/application_insights.toml',
    './application_insights.toml'
  ]
end