7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/ridgepole/cli/config.rb', line 7
def load(config, env = 'development')
config = ENV.fetch(Regexp.last_match(1)) if config =~ /\Aenv:(.+)\z/
parsed_config = if File.exist?(config)
parse_config_file(config)
elsif (expanded = File.expand_path(config)) && File.exist?(expanded)
parse_config_file(expanded)
else
YAML.safe_load(ERB.new(config).result, [], [], true)
end
unless parsed_config.is_a?(Hash)
parsed_config = parse_database_url(config)
end
if parsed_config.key?(env.to_s)
parsed_config.fetch(env.to_s)
else
parsed_config
end
end
|