33 lines
576 B
Ruby
33 lines
576 B
Ruby
|
|
#!/usr/bin/env ruby
|
||
|
|
#
|
||
|
|
require "erb"
|
||
|
|
require "yaml"
|
||
|
|
require "ostruct"
|
||
|
|
|
||
|
|
class Generator
|
||
|
|
|
||
|
|
CONFIG = "config.yml"
|
||
|
|
|
||
|
|
def initialize
|
||
|
|
@config = YAML.load_file(File.new(CONFIG))
|
||
|
|
end
|
||
|
|
|
||
|
|
def render(template)
|
||
|
|
ERB.new(template).result(binding)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
templates = {
|
||
|
|
"templates/00_list/flavor.feature.erb" => "flavor.feature"
|
||
|
|
}
|
||
|
|
generator = Generator.new
|
||
|
|
|
||
|
|
templates.each do |input, output|
|
||
|
|
if File.exists?(input)
|
||
|
|
data = generator.render(File.read(input))
|
||
|
|
File.open(output, "w") {|f| f.write(data)}
|
||
|
|
else
|
||
|
|
puts "WARN: file '#{input}' does not exist"
|
||
|
|
end
|
||
|
|
end
|