8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/erb-process.rb', line 8
def ERBProcess.process variables, template, env = "DEV"
@variables = variables
@template = template
env = env.chomp
yml = YAML.load_file(@variables)
config = {}
yml.each_key do |key|
if yml[key].has_key?(env.downcase)
config[key] = yml[key][env.downcase]
else
warn "WARNING: "<< @variables<<" does not have a "<<key<<" for environment "<<env
end
end
content = File.read(File.expand_path(@template))
t = ERB.new(content)
return t.result(binding)
end
|