diff options
author | José Valim <jose.valim@gmail.com> | 2009-08-07 15:34:10 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-08-07 17:17:51 +0200 |
commit | 55575e21655023259d0dae22bc1b148b34168d92 (patch) | |
tree | 9df9d486c182686d0282e52ce1ec1d6eadee68d5 /railties/lib/generators/rails/app | |
parent | aed135d3e261cbee153a35fcfbeb47e2e02b12e4 (diff) | |
download | rails-55575e21655023259d0dae22bc1b148b34168d92.tar.gz rails-55575e21655023259d0dae22bc1b148b34168d92.tar.bz2 rails-55575e21655023259d0dae22bc1b148b34168d92.zip |
Allow rails templates relative to the current path to be given.
Diffstat (limited to 'railties/lib/generators/rails/app')
-rw-r--r-- | railties/lib/generators/rails/app/app_generator.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/railties/lib/generators/rails/app/app_generator.rb b/railties/lib/generators/rails/app/app_generator.rb index c8044d13b1..c80a344e0d 100644 --- a/railties/lib/generators/rails/app/app_generator.rb +++ b/railties/lib/generators/rails/app/app_generator.rb @@ -49,7 +49,7 @@ module Rails::Generators self.destination_root = File.expand_path(app_path, destination_root) empty_directory '.' - app_name # Sets the app name + set_default_accessors! FileUtils.cd(destination_root) end @@ -164,9 +164,9 @@ module Rails::Generators end def apply_rails_template - apply options[:template] if options[:template] + apply rails_template if rails_template rescue Thor::Error, LoadError, Errno::ENOENT => e - raise Error, "The template [#{options[:template]}] could not be loaded. Error: #{e}" + raise Error, "The template [#{rails_template}] could not be loaded. Error: #{e}" end def freeze? @@ -175,6 +175,21 @@ module Rails::Generators protected + attr_accessor :rails_template + + def set_default_accessors! + app_name # Cache app name + + self.rails_template = case options[:template] + when /^http:\/\// + options[:template] + when String + File.expand_path(options[:template], Dir.pwd) + else + options[:template] + end + end + # Define file as an alias to create_file for backwards compatibility. # def file(*args, &block) |