2006-02-26 23:38:39 -05:00
|
|
|
namespace :rails do
|
|
|
|
namespace :freeze do
|
|
|
|
desc "Lock this application to the current gems (by unpacking them into vendor/rails)"
|
|
|
|
task :gems do
|
2007-10-08 03:10:58 -04:00
|
|
|
deps = %w(actionpack activerecord actionmailer activesupport activeresource)
|
2006-02-26 23:38:39 -05:00
|
|
|
require 'rubygems'
|
2007-12-08 20:20:24 -05:00
|
|
|
require 'rubygems/gem_runner'
|
2006-03-18 20:34:14 -05:00
|
|
|
|
2006-04-01 01:29:32 -05:00
|
|
|
rails = (version = ENV['VERSION']) ?
|
2007-07-24 17:06:45 -04:00
|
|
|
Gem.cache.find_name('rails', "= #{version}").first :
|
|
|
|
Gem.cache.find_name('rails').sort_by { |g| g.version }.last
|
2005-11-08 05:43:40 -05:00
|
|
|
|
2006-02-26 23:38:39 -05:00
|
|
|
version ||= rails.version
|
2005-11-08 05:43:40 -05:00
|
|
|
|
2006-02-26 23:38:39 -05:00
|
|
|
unless rails
|
|
|
|
puts "No rails gem #{version} is installed. Do 'gem list rails' to see what you have available."
|
|
|
|
exit
|
|
|
|
end
|
2005-11-08 05:43:40 -05:00
|
|
|
|
2006-02-26 23:38:39 -05:00
|
|
|
puts "Freezing to the gems for Rails #{rails.version}"
|
|
|
|
rm_rf "vendor/rails"
|
|
|
|
mkdir_p "vendor/rails"
|
2005-11-01 13:26:06 -05:00
|
|
|
|
2007-12-08 20:20:24 -05:00
|
|
|
begin
|
|
|
|
chdir("vendor/rails") do
|
|
|
|
rails.dependencies.select { |g| deps.include? g.name }.each do |g|
|
|
|
|
Gem::GemRunner.new.run(["unpack", g.name, "--version", g.version_requirements.to_s])
|
|
|
|
mv(Dir.glob("#{g.name}*").first, g.name)
|
|
|
|
end
|
2006-03-18 20:34:14 -05:00
|
|
|
|
2007-12-08 20:20:24 -05:00
|
|
|
Gem::GemRunner.new.run(["unpack", "rails", "--version", "=#{version}"])
|
|
|
|
FileUtils.mv(Dir.glob("rails*").first, "railties")
|
|
|
|
end
|
|
|
|
rescue Exception
|
|
|
|
rm_rf "vendor/rails"
|
|
|
|
raise
|
2006-02-26 23:38:39 -05:00
|
|
|
end
|
|
|
|
end
|
2005-10-15 11:00:15 -04:00
|
|
|
|
2008-04-11 20:08:26 -04:00
|
|
|
desc 'Lock to latest Edge Rails, for a specific release use RELEASE=1.2.0'
|
2006-02-26 23:38:39 -05:00
|
|
|
task :edge do
|
2008-04-11 01:15:50 -04:00
|
|
|
require 'open-uri'
|
2008-04-11 20:08:26 -04:00
|
|
|
version = ENV["RELEASE"] || "edge"
|
|
|
|
target = "rails_#{version}.zip"
|
2008-08-19 18:14:17 -04:00
|
|
|
commits = "http://github.com/api/v1/yaml/rails/rails/commits/master"
|
2008-04-11 20:08:26 -04:00
|
|
|
url = "http://dev.rubyonrails.org/archives/#{target}"
|
2006-04-02 22:38:12 -04:00
|
|
|
|
2008-04-11 01:15:50 -04:00
|
|
|
chdir 'vendor' do
|
2008-08-19 18:14:17 -04:00
|
|
|
latest_revision = YAML.load(open(commits))["commits"].first["id"]
|
|
|
|
|
2008-04-11 20:08:26 -04:00
|
|
|
puts "Downloading Rails from #{url}"
|
|
|
|
File.open('rails.zip', 'wb') do |dst|
|
|
|
|
open url do |src|
|
2008-04-11 01:15:50 -04:00
|
|
|
while chunk = src.read(4096)
|
|
|
|
dst << chunk
|
|
|
|
end
|
|
|
|
end
|
2006-04-02 22:38:12 -04:00
|
|
|
end
|
|
|
|
|
2008-04-11 01:15:50 -04:00
|
|
|
puts 'Unpacking Rails'
|
|
|
|
rm_rf 'rails'
|
2008-04-11 20:08:26 -04:00
|
|
|
`unzip rails.zip`
|
|
|
|
%w(rails.zip rails/Rakefile rails/cleanlogs.sh rails/pushgems.rb rails/release.rb).each do |goner|
|
2008-04-11 01:15:50 -04:00
|
|
|
rm_f goner
|
|
|
|
end
|
2008-08-19 18:14:17 -04:00
|
|
|
|
|
|
|
touch "rails/REVISION_#{latest_revision}"
|
2006-04-02 22:38:12 -04:00
|
|
|
end
|
2007-05-27 18:21:20 -04:00
|
|
|
|
2008-04-11 01:15:50 -04:00
|
|
|
puts 'Updating current scripts, javascripts, and configuration settings'
|
|
|
|
Rake::Task['rails:update'].invoke
|
2006-02-26 23:38:39 -05:00
|
|
|
end
|
2005-10-15 11:00:15 -04:00
|
|
|
end
|
|
|
|
|
2006-02-26 23:38:39 -05:00
|
|
|
desc "Unlock this application from freeze of gems or edge and return to a fluid use of system gems"
|
|
|
|
task :unfreeze do
|
|
|
|
rm_rf "vendor/rails"
|
|
|
|
end
|
|
|
|
|
2006-04-07 14:21:52 -04:00
|
|
|
desc "Update both configs, scripts and public/javascripts from Rails"
|
2008-11-23 07:39:30 -05:00
|
|
|
task :update => [ "update:scripts", "update:javascripts", "update:configs", "update:application_controller" ]
|
2005-11-07 13:09:31 -05:00
|
|
|
|
2008-12-06 21:40:23 -05:00
|
|
|
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
|
|
|
|
|
2006-02-26 23:38:39 -05:00
|
|
|
namespace :update do
|
|
|
|
desc "Add new scripts to the application script/ directory"
|
|
|
|
task :scripts do
|
|
|
|
local_base = "script"
|
|
|
|
edge_base = "#{File.dirname(__FILE__)}/../../bin"
|
2005-11-07 13:09:31 -05:00
|
|
|
|
2006-02-26 23:38:39 -05:00
|
|
|
local = Dir["#{local_base}/**/*"].reject { |path| File.directory?(path) }
|
|
|
|
edge = Dir["#{edge_base}/**/*"].reject { |path| File.directory?(path) }
|
2005-11-07 13:09:31 -05:00
|
|
|
|
2006-02-26 23:38:39 -05:00
|
|
|
edge.each do |script|
|
|
|
|
base_name = script[(edge_base.length+1)..-1]
|
|
|
|
next if base_name == "rails"
|
|
|
|
next if local.detect { |path| base_name == path[(local_base.length+1)..-1] }
|
|
|
|
if !File.directory?("#{local_base}/#{File.dirname(base_name)}")
|
|
|
|
mkdir_p "#{local_base}/#{File.dirname(base_name)}"
|
|
|
|
end
|
|
|
|
install script, "#{local_base}/#{base_name}", :mode => 0755
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Update your javascripts from your current rails install"
|
2006-03-13 13:45:40 -05:00
|
|
|
task :javascripts do
|
2006-02-26 23:38:39 -05:00
|
|
|
require 'railties_path'
|
2006-03-13 13:45:40 -05:00
|
|
|
project_dir = RAILS_ROOT + '/public/javascripts/'
|
|
|
|
scripts = Dir[RAILTIES_PATH + '/html/javascripts/*.js']
|
2007-12-17 13:54:55 -05:00
|
|
|
scripts.reject!{|s| File.basename(s) == 'application.js'} if File.exist?(project_dir + 'application.js')
|
2006-03-13 13:45:40 -05:00
|
|
|
FileUtils.cp(scripts, project_dir)
|
2005-11-07 13:09:31 -05:00
|
|
|
end
|
2006-04-07 14:21:52 -04:00
|
|
|
|
2006-06-20 22:11:59 -04:00
|
|
|
desc "Update config/boot.rb from your current rails install"
|
2006-04-07 14:21:52 -04:00
|
|
|
task :configs do
|
|
|
|
require 'railties_path'
|
2006-04-07 14:29:43 -04:00
|
|
|
FileUtils.cp(RAILTIES_PATH + '/environments/boot.rb', RAILS_ROOT + '/config/boot.rb')
|
2006-04-07 14:21:52 -04:00
|
|
|
end
|
2008-11-23 07:39:30 -05:00
|
|
|
|
|
|
|
desc "Rename application.rb to application_controller.rb"
|
|
|
|
task :application_controller do
|
|
|
|
old_style = RAILS_ROOT + '/app/controllers/application.rb'
|
|
|
|
new_style = RAILS_ROOT + '/app/controllers/application_controller.rb'
|
|
|
|
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
|
2008-11-24 13:50:09 -05:00
|
|
|
|
|
|
|
desc "Generate dispatcher files in RAILS_ROOT/public"
|
|
|
|
task :generate_dispatchers do
|
|
|
|
require 'railties_path'
|
2008-12-01 13:21:18 -05:00
|
|
|
FileUtils.cp(RAILTIES_PATH + '/dispatches/config.ru', RAILS_ROOT + '/config.ru')
|
2008-11-24 13:50:09 -05:00
|
|
|
FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.fcgi', RAILS_ROOT + '/public/dispatch.fcgi')
|
|
|
|
FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.rb')
|
|
|
|
FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.cgi')
|
|
|
|
end
|
2005-11-07 13:09:31 -05:00
|
|
|
end
|
2006-03-13 13:45:40 -05:00
|
|
|
end
|