29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/cosmos/config/meta_config_parser.rb', line 29
def self.load(filename)
data = nil
if File.exist?(filename)
path = filename
else
path = Cosmos.data_path("config/#{filename}")
end
tf = Tempfile.new("temp.yaml")
output = ERB.new(File.read(path)).result(binding)
tf.write(output)
tf.close
begin
data = Psych.load_file(tf.path)
rescue => error
error_file = "ERROR_#{filename}"
File.open(error_file, 'w') { |file| file.puts output }
raise error.exception("#{error.message}\n\nParsed output written to #{File.expand_path(error_file)}\n")
end
tf.unlink
data
end
|