40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/dply/app_config.rb', line 40
def render_config
load_config
require 'json'
config_data = load_yml "meta.yml", optional: true
tmp_file = "tmp/config_render.tmp"
config = lambda do |key|
value = config_data.dig(*key.split('.'))
raise "key #{key} not defined" if value.nil?
JSON.dump(value)
end
@config_map.each do |dest, src|
raise Error, %(error dest "#{dest}" is a directory) if File.directory? dest
template = File.read "dply/config/#{src}"
contents = ERB.new(template).result(binding)
File.write tmp_file, contents
FileUtils.mv tmp_file, dest
end
end
|