output path
This commit is contained in:
parent
c3ec9f31f2
commit
281a42605f
@ -3,13 +3,14 @@
|
|||||||
require "erb"
|
require "erb"
|
||||||
require "yaml"
|
require "yaml"
|
||||||
require "ostruct"
|
require "ostruct"
|
||||||
|
require "fileutils"
|
||||||
|
|
||||||
class Generator
|
class Generator < OpenStruct
|
||||||
|
|
||||||
CONFIG = "config.yml"
|
CONFIG = "config.yml"
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@config = YAML.load_file(File.new(CONFIG))
|
super(:config => YAML.load_file(File.new(ENV["CONFIG"] || CONFIG)))
|
||||||
end
|
end
|
||||||
|
|
||||||
def render(template)
|
def render(template)
|
||||||
@ -18,13 +19,15 @@ class Generator
|
|||||||
end
|
end
|
||||||
|
|
||||||
templates = {
|
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
|
generator = Generator.new
|
||||||
|
|
||||||
templates.each do |input, output|
|
templates.each do |input, output|
|
||||||
if File.exists?(input)
|
if File.exists?(input)
|
||||||
data = generator.render(File.read(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)}
|
File.open(output, "w") {|f| f.write(data)}
|
||||||
else
|
else
|
||||||
puts "WARN: file '#{input}' does not exist"
|
puts "WARN: file '#{input}' does not exist"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user