From bcd414fd10a0e401cfb1de95cc9b2940b1df0ff6 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 20 Oct 2010 01:05:34 +0200 Subject: Add support for templates for rails plugin new --- railties/lib/rails/generators/app_base.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'railties/lib/rails/generators/app_base.rb') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index d66b1345c1..ecaf92c683 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -54,8 +54,26 @@ module Rails valid_const? empty_directory '.' + set_default_accessors! FileUtils.cd(destination_root) unless options[:pretend] end + + def apply_rails_template + apply rails_template if rails_template + rescue Thor::Error, LoadError, Errno::ENOENT => e + raise Error, "The template [#{rails_template}] could not be loaded. Error: #{e}" + end + + def set_default_accessors! + self.rails_template = case options[:template] + when /^http:\/\// + options[:template] + when String + File.expand_path(options[:template], Dir.pwd) + else + options[:template] + end + end end end end -- cgit v1.2.3