1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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

Example : rake rails:template LOCATION=~/template.rb
This commit is contained in:
Pratik Naik 2008-12-07 03:40:23 +01:00
parent 2dc5d12c91
commit f7f113610e
4 changed files with 11 additions and 3 deletions

View file

@ -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 file

@ -40,7 +40,7 @@ class AppGenerator < Rails::Generator::Base
def after_generate
if options[:template]
Rails::TemplateRunner.new(@destination_root, options[:template])
Rails::TemplateRunner.new(options[:template], @destination_root)
end
end

View file

@ -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 file

@ -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