aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-10-20 01:05:34 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-11-02 17:14:50 +0100
commitbcd414fd10a0e401cfb1de95cc9b2940b1df0ff6 (patch)
tree66cb8d9e83caf74e8f2aed00f412d419d1f46042 /railties/lib/rails
parentb8a0fabe184f6c8f926f7869341ca40b6395606a (diff)
downloadrails-bcd414fd10a0e401cfb1de95cc9b2940b1df0ff6.tar.gz
rails-bcd414fd10a0e401cfb1de95cc9b2940b1df0ff6.tar.bz2
rails-bcd414fd10a0e401cfb1de95cc9b2940b1df0ff6.zip
Add support for templates for rails plugin new
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/generators/app_base.rb18
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb16
-rw-r--r--railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb11
3 files changed, 30 insertions, 15 deletions
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
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index 16150c306a..8c6ec41e4d 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -217,7 +217,6 @@ module Rails
end
def create_root
- set_default_accessors!
super
end
@@ -299,9 +298,7 @@ module Rails
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}"
+ super
end
def bundle_if_dev_or_edge
@@ -338,17 +335,6 @@ module Rails
builder.send(meth, *args) if builder.respond_to?(meth)
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
-
# Define file as an alias to create_file for backwards compatibility.
def file(*args, &block)
create_file(*args, &block)
diff --git a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
index 06ef158a51..9785a6938a 100644
--- a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
+++ b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
@@ -82,6 +82,9 @@ module Rails
class_option :builder, :type => :string, :aliases => "-b",
:desc => "Path to a plugin builder (can be a filesystem path or URL)"
+ class_option :template, :type => :string, :aliases => "-m",
+ :desc => "Path to an application template (can be a filesystem path or URL)"
+
class_option :skip_gemfile, :type => :boolean, :default => false,
:desc => "Don't create a Gemfile"
@@ -147,6 +150,14 @@ module Rails
build(:test_dummy_clean)
end
+ def finish_template
+ build(:leftovers)
+ end
+
+ def apply_rails_template
+ super
+ end
+
protected
def self.banner