Class: ProfileIt::Config
- Inherits:
-
Object
- Object
- ProfileIt::Config
- Defined in:
- lib/profile_it/config.rb
Constant Summary collapse
- DEFAULTS =
{ 'host' => 'https://profileit.io', 'log_level' => 'info', # changed from info for dev 'name' => 'LOCAL APP' }
Instance Method Summary collapse
- #config_file ⇒ Object
- #config_path ⇒ Object
-
#initialize(config_path = nil) ⇒ Config
constructor
A new instance of Config.
- #load_file ⇒ Object
- #settings ⇒ Object
Constructor Details
#initialize(config_path = nil) ⇒ Config
Returns a new instance of Config.
9 10 11 |
# File 'lib/profile_it/config.rb', line 9 def initialize(config_path = nil) @config_path = config_path end |
Instance Method Details
#config_file ⇒ Object
22 23 24 |
# File 'lib/profile_it/config.rb', line 22 def config_file File.(config_path) end |
#config_path ⇒ Object
18 19 20 |
# File 'lib/profile_it/config.rb', line 18 def config_path @config_path || File.join(ProfileIt::Agent.instance.environment.root,"config","profile_it.yml") end |
#load_file ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/profile_it/config.rb', line 26 def load_file begin if !File.exist?(config_file) ProfileIt::Agent.instance.logger.warn "No config file found at [#{config_file}]." @settings = {} else @settings = YAML.load(ERB.new(File.read(config_file)).result(binding))[ProfileIt::Agent.instance.environment.env] || {} end rescue Exception => e ProfileIt::Agent.instance.logger.warn "Unable to load the config file." ProfileIt::Agent.instance.logger.warn e. ProfileIt::Agent.instance.logger.warn e.backtrace @settings = {} end @settings = DEFAULTS.merge(@settings) end |
#settings ⇒ Object
13 14 15 16 |
# File 'lib/profile_it/config.rb', line 13 def settings return @settings if @settings load_file end |