From 93c8df589660c4a70fe5ee10b5e9b8816a04fdc9 Mon Sep 17 00:00:00 2001 From: Bob Potter Date: Wed, 29 Feb 2012 22:01:44 -0600 Subject: [PATCH] Support the -t option --- lib/foreman/export/god.rb | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/foreman/export/god.rb b/lib/foreman/export/god.rb index 60f4163..3d172af 100644 --- a/lib/foreman/export/god.rb +++ b/lib/foreman/export/god.rb @@ -8,6 +8,7 @@ class Foreman::Export::God < Foreman::Export::Base app = self.app || File.basename(engine.directory) + base_template = export_template("god", "base.god.erb", template_root) base_config = ERB.new(base_template).result(binding) write_file(File.join(location, "#{app}.god"), base_config) @@ -22,16 +23,8 @@ class Foreman::Export::God < Foreman::Export::Base end private - def template_path - Pathname.new(File.dirname(__FILE__)).join('..', '..', '..', 'data', 'templates') - end - - def base_template - IO.read(base_template_path) - end - - def base_template_path - base_template = File.join(template_path, "base.god.erb") + def template_root + template_root = self.template || File.expand_path("../../../../data/templates", __FILE__) end def extension_template(name) @@ -44,7 +37,7 @@ class Foreman::Export::God < Foreman::Export::Base def load_extensions h = {} - Dir.glob(template_path.join('extensions') + "*.erb").each do |extension_path| + Dir.glob(File.join(template_root, 'extensions',"*.erb")).each do |extension_path| extension_name = extension_path.split("/").last.match(/(.*?).god.erb$/)[1] h[extension_name] = extension_path end