6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/services/config_service.rb', line 6
def load_config(config_file_name)
app_root = (defined? APP_ROOT)? APP_ROOT : File.expand_path('.')
config_file = nil
if config_file_name.starts_with?('/')
config_file = config_file_name if File.exist?(config_file_name)
else
['conf', 'config'].each do |sub_path|
if File.exist?("#{app_root}/#{sub_path}/#{config_file_name}")
config_file = "#{app_root}/#{sub_path}/#{config_file_name}"
break
end
end
end
raise("#{Time.now.strftime("%m/%d/%Y %H:%M:%S.%3N %z")} ERROR: ConfigService#load_config #{config_file_name} file not found.") unless config_file
HashUtils.hash_to_open_struct(YAML.load(ERB.new(File.new(config_file).read).result))
end
|