All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
30 lines
610 B
Ruby
30 lines
610 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'yaml'
|
|
|
|
# Config - loads and manages the app's configuration
|
|
class Config
|
|
|
|
DEFAULT_CONFIG = 'config/defaults.yaml'
|
|
ENVIRONMENT_CONFIG = ENV.fetch('RACK_ENV', 'development')
|
|
|
|
def initialize(config_path = "config/#{ENVIRONMENT_CONFIG}.yaml")
|
|
@data = YAML.load_file(DEFAULT_CONFIG)
|
|
|
|
# merge in user-defined configuration if it exists
|
|
@data.merge!(YAML.load_file(config_path)) if File.exist?(config_path)
|
|
end
|
|
|
|
def get(key)
|
|
bits = key.split('.')
|
|
value = @data
|
|
|
|
bits.each do |bit|
|
|
value = value[bit]
|
|
end
|
|
|
|
return value
|
|
end
|
|
|
|
end
|