Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a rake task to apply a template to an existing application.

Example : rake rails:template LOCATION=~/template.rb
  • Loading branch information...
commit f7f113610e7cdca8ef03e206f2cbeb8400cdfefa 1 parent 2dc5d12
@lifo lifo authored
View
2  railties/CHANGELOG
@@ -1,5 +1,7 @@
*2.3.0 [Edge]*
+* Add a rake task to apply a template to an existing application : rake rails:template LOCATION=~/template.rb [Pratik]
+
* Add "-m/--template" option to Rails generator to apply a template to the generated application. [Jeremy McAnally]
This has been extracted from rg - http://github.com/jeremymcanally/rg
View
2  railties/lib/rails_generator/generators/applications/app/app_generator.rb
@@ -40,7 +40,7 @@ def manifest
def after_generate
if options[:template]
- Rails::TemplateRunner.new(@destination_root, options[:template])
+ Rails::TemplateRunner.new(options[:template], @destination_root)
end
end
View
4 railties/lib/rails_generator/generators/applications/app/template_runner.rb
@@ -9,8 +9,8 @@ module Rails
class TemplateRunner
attr_reader :root
- def initialize(root, template) # :nodoc:
- @root = Dir.pwd + "/" + root
+ def initialize(template, root = '') # :nodoc:
+ @root = File.join(Dir.pwd, root)
puts "applying template: #{template}"
View
6 railties/lib/tasks/framework.rake
@@ -80,6 +80,12 @@ namespace :rails do
desc "Update both configs, scripts and public/javascripts from Rails"
task :update => [ "update:scripts", "update:javascripts", "update:configs", "update:application_controller" ]
+ desc "Applies the template supplied by LOCATION=/path/to/template"
+ task :template do
+ require 'rails_generator/generators/applications/app/template_runner'
+ Rails::TemplateRunner.new(ENV["LOCATION"])
+ end
+
namespace :update do
desc "Add new scripts to the application script/ directory"
task :scripts do
Please sign in to comment.
Something went wrong with that request. Please try again.