36 lines
748 B
Ruby
Executable File
36 lines
748 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
#
|
|
require "erb"
|
|
require "yaml"
|
|
require "ostruct"
|
|
require "fileutils"
|
|
|
|
class Generator < OpenStruct
|
|
|
|
CONFIG = "config.yml"
|
|
|
|
def initialize
|
|
super(:config => YAML.load_file(File.new(ENV["CONFIG"] || CONFIG)))
|
|
end
|
|
|
|
def render(template)
|
|
ERB.new(template).result(binding)
|
|
end
|
|
end
|
|
|
|
templates = {
|
|
"templates/api_v2/00_list/flavor.feature.erb" => "features/api_v2/00_list/flavor.feature"
|
|
}
|
|
generator = Generator.new
|
|
|
|
templates.each do |input, output|
|
|
if File.exists?(input)
|
|
data = generator.render(File.read(input))
|
|
dir = File.dirname(output)
|
|
FileUtils.mkdir_p(dir) unless File.exists?(dir)
|
|
File.open(output, "w") {|f| f.write(data)}
|
|
else
|
|
puts "WARN: file '#{input}' does not exist"
|
|
end
|
|
end
|