16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/mona/config/loader.rb', line 16
def call(config_name)
config_name = config_name.to_s
config = Mona::Config.new
default_config_filename = File.join(
Mona.current_project.root_path,
Mona.current_project.configs_dir,
config_name,
DEFAULT_CONFIG_FILENAME
)
unless File.exist?(default_config_filename)
raise StandardError.new("Config '#{config_name}' was not found. Add it to '#{default_config_filename}'")
end
hash =
begin
YAML.load( ERB.new(File.read(default_config_filename)).result )
rescue => e
puts ERB.new(File.read(default_config_filename)).result.inspect
end
hash_to_config(
hash: hash,
config: config
)
env_config_filename = File.join(
Mona.current_project.root_path,
Mona.current_project.configs_dir,
config_name,
"#{Mona.current_project.env}.yml"
)
hash_to_config(
hash: YAML.load( ERB.new(File.read(env_config_filename)).result ),
config: config
) if File.exist?(env_config_filename)
config.send(config_name)
end
|