output path
This commit is contained in:
parent
c3ec9f31f2
commit
281a42605f
@ -3,13 +3,14 @@
|
||||
require "erb"
|
||||
require "yaml"
|
||||
require "ostruct"
|
||||
require "fileutils"
|
||||
|
||||
class Generator
|
||||
class Generator < OpenStruct
|
||||
|
||||
CONFIG = "config.yml"
|
||||
|
||||
def initialize
|
||||
@config = YAML.load_file(File.new(CONFIG))
|
||||
super(:config => YAML.load_file(File.new(ENV["CONFIG"] || CONFIG)))
|
||||
end
|
||||
|
||||
def render(template)
|
||||
@ -18,13 +19,15 @@ class Generator
|
||||
end
|
||||
|
||||
templates = {
|
||||
"templates/00_list/flavor.feature.erb" => "flavor.feature"
|
||||
"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"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user