2006-02-27 04:38:39 +00:00
|
|
|
namespace :rails do
|
|
|
|
namespace :freeze do
|
2010-02-03 07:31:57 +00:00
|
|
|
desc "The rails:freeze:gems is deprecated, please use bundle install instead"
|
2006-02-27 04:38:39 +00:00
|
|
|
task :gems do
|
2010-03-14 18:27:18 +00:00
|
|
|
abort "The rails:freeze:gems is deprecated, please use bundle install instead"
|
2006-02-27 04:38:39 +00:00
|
|
|
end
|
2005-10-15 15:00:15 +00:00
|
|
|
|
2010-02-03 07:31:57 +00:00
|
|
|
desc 'The freeze:edge command has been deprecated, specify the path setting in your app Gemfile instead and bundle install'
|
2006-02-27 04:38:39 +00:00
|
|
|
task :edge do
|
2010-03-14 18:27:18 +00:00
|
|
|
abort 'The freeze:edge command has been deprecated, specify the path setting in your app Gemfile instead and bundle install'
|
2006-02-27 04:38:39 +00:00
|
|
|
end
|
2005-10-15 15:00:15 +00:00
|
|
|
end
|
|
|
|
|
2010-02-03 07:31:57 +00:00
|
|
|
desc 'The unfreeze command has been deprecated, please use bundler commands instead'
|
2006-02-27 04:38:39 +00:00
|
|
|
task :unfreeze do
|
2010-03-14 18:27:18 +00:00
|
|
|
abort 'The unfreeze command has been deprecated, please use bundler commands instead'
|
2006-02-27 04:38:39 +00:00
|
|
|
end
|
|
|
|
|
2006-04-07 18:21:52 +00:00
|
|
|
desc "Update both configs, scripts and public/javascripts from Rails"
|
2009-07-16 09:17:19 +00:00
|
|
|
task :update => [ "update:configs", "update:javascripts", "update:scripts", "update:application_controller" ]
|
2005-11-07 18:09:31 +00:00
|
|
|
|
2008-12-07 02:40:23 +00:00
|
|
|
desc "Applies the template supplied by LOCATION=/path/to/template"
|
|
|
|
task :template do
|
2009-04-20 16:01:32 +00:00
|
|
|
template = ENV["LOCATION"]
|
|
|
|
template = File.expand_path(template) if template !~ %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://}
|
2009-07-16 09:17:19 +00:00
|
|
|
|
2010-01-16 19:35:39 +00:00
|
|
|
require 'rails/generators'
|
2010-03-23 13:20:43 +00:00
|
|
|
require 'rails/generators/rails/app/app_generator'
|
2010-01-16 19:35:39 +00:00
|
|
|
generator = Rails::Generators::AppGenerator.new [ Rails.root ], {}, :destination_root => Rails.root
|
2009-07-16 09:17:19 +00:00
|
|
|
generator.apply template, :verbose => false
|
2008-12-07 02:40:23 +00:00
|
|
|
end
|
|
|
|
|
2010-05-14 21:54:13 +00:00
|
|
|
namespace :templates do
|
|
|
|
desc "Copy all the templates from rails to the application directory for customization. Already existing local copies will be overwritten"
|
|
|
|
task :copy do
|
|
|
|
generators_lib = File.expand_path("../../generators", __FILE__)
|
|
|
|
project_templates = "#{Rails.root}/lib/templates"
|
|
|
|
|
|
|
|
default_templates = { "erb" => %w{controller mailer scaffold},
|
|
|
|
"rails" => %w{controller helper metal scaffold_controller stylesheets} }
|
|
|
|
|
|
|
|
default_templates.each do |type, names|
|
|
|
|
local_template_type_dir = File.join(project_templates, type)
|
|
|
|
FileUtils.mkdir_p local_template_type_dir
|
|
|
|
|
|
|
|
names.each do |name|
|
|
|
|
dst_name = File.join(local_template_type_dir, name)
|
|
|
|
src_name = File.join(generators_lib, type, name, "templates")
|
|
|
|
FileUtils.cp_r src_name, dst_name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2006-02-27 04:38:39 +00:00
|
|
|
namespace :update do
|
2009-07-16 09:17:19 +00:00
|
|
|
def invoke_from_app_generator(method)
|
2010-02-21 12:44:08 +00:00
|
|
|
app_generator.invoke(method)
|
|
|
|
end
|
2006-02-27 04:38:39 +00:00
|
|
|
|
2010-02-21 12:44:08 +00:00
|
|
|
def app_generator
|
|
|
|
@app_generator ||= begin
|
|
|
|
require 'rails/generators'
|
2010-03-23 13:20:43 +00:00
|
|
|
require 'rails/generators/rails/app/app_generator'
|
2010-02-21 12:44:08 +00:00
|
|
|
gen = Rails::Generators::AppGenerator.new ["rails"], { :with_dispatchers => true },
|
|
|
|
:destination_root => Rails.root
|
2010-03-27 09:45:54 +00:00
|
|
|
File.exists?(Rails.root.join("config", "application.rb")) ?
|
|
|
|
gen.send(:app_const) : gen.send(:valid_app_const?)
|
2010-02-21 12:44:08 +00:00
|
|
|
gen
|
|
|
|
end
|
2005-11-07 18:09:31 +00:00
|
|
|
end
|
2006-04-07 18:21:52 +00:00
|
|
|
|
2009-12-01 21:27:59 +00:00
|
|
|
desc "Update config/boot.rb from your current rails install"
|
|
|
|
task :configs do
|
|
|
|
invoke_from_app_generator :create_boot_file
|
2009-12-01 21:37:12 +00:00
|
|
|
invoke_from_app_generator :create_config_files
|
2009-12-01 21:27:59 +00:00
|
|
|
end
|
|
|
|
|
2009-07-16 09:17:19 +00:00
|
|
|
desc "Update Prototype javascripts from your current rails install"
|
|
|
|
task :javascripts do
|
|
|
|
invoke_from_app_generator :create_prototype_files
|
|
|
|
end
|
|
|
|
|
2010-02-03 07:31:57 +00:00
|
|
|
desc "Adds new scripts to the application script/ directory"
|
2009-07-16 09:17:19 +00:00
|
|
|
task :scripts do
|
|
|
|
invoke_from_app_generator :create_script_files
|
|
|
|
end
|
|
|
|
|
2008-11-23 12:39:30 +00:00
|
|
|
desc "Rename application.rb to application_controller.rb"
|
|
|
|
task :application_controller do
|
2009-10-16 19:49:39 +00:00
|
|
|
old_style = Rails.root + '/app/controllers/application.rb'
|
|
|
|
new_style = Rails.root + '/app/controllers/application_controller.rb'
|
2008-11-23 12:39:30 +00:00
|
|
|
if File.exists?(old_style) && !File.exists?(new_style)
|
|
|
|
FileUtils.mv(old_style, new_style)
|
|
|
|
puts "#{old_style} has been renamed to #{new_style}, update your SCM as necessary"
|
|
|
|
end
|
|
|
|
end
|
2005-11-07 18:09:31 +00:00
|
|
|
end
|
2006-03-13 18:45:40 +00:00
|
|
|
end
|