From 281a42605f24fa1467140b95cb2388dacf8c947d Mon Sep 17 00:00:00 2001 From: amartynov Date: Mon, 14 Jul 2014 13:05:14 +0400 Subject: [PATCH] output path --- devops-service/tests/generate_tests.rb | 9 ++++++--- .../templates/{ => api_v2}/00_list/flavor.feature.erb | 0 2 files changed, 6 insertions(+), 3 deletions(-) rename devops-service/tests/templates/{ => api_v2}/00_list/flavor.feature.erb (100%) diff --git a/devops-service/tests/generate_tests.rb b/devops-service/tests/generate_tests.rb index 8e1df84..8c8a1a6 100755 --- a/devops-service/tests/generate_tests.rb +++ b/devops-service/tests/generate_tests.rb @@ -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" diff --git a/devops-service/tests/templates/00_list/flavor.feature.erb b/devops-service/tests/templates/api_v2/00_list/flavor.feature.erb similarity index 100% rename from devops-service/tests/templates/00_list/flavor.feature.erb rename to devops-service/tests/templates/api_v2/00_list/flavor.feature.erb