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
|
|
|
|
deps = %w(actionpack activerecord actionmailer activesupport actionwebservice)
|
|
|
|
require 'rubygems'
|
2006-03-18 20:34:14 -05:00
|
|
|
Gem.manage_gems
|
|
|
|
|
2006-04-01 01:29:32 -05:00
|
|
|
rails = (version = ENV['VERSION']) ?
|
2006-03-18 20:34:14 -05:00
|
|
|
Gem.cache.search('rails', "= #{version}").first :
|
|
|
|
Gem.cache.search('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
|
|
|
|
2006-03-18 20:34:14 -05:00
|
|
|
chdir("vendor/rails") do
|
|
|
|
rails.dependencies.select { |g| deps.include? g.name }.each do |g|
|
|
|
|
Gem::GemRunner.new.run(["unpack", "-v", "#{g.version_requirements}", "#{g.name}"])
|
|
|
|
mv(Dir.glob("#{g.name}*").first, g.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
Gem::GemRunner.new.run(["unpack", "-v", "=#{version}", "rails"])
|
|
|
|
FileUtils.mv(Dir.glob("rails*").first, "railties")
|
2006-02-26 23:38:39 -05:00
|
|
|
end
|
|
|
|
end
|
2005-10-15 11:00:15 -04:00
|
|
|
|
2006-04-02 22:38:12 -04:00
|
|
|
desc "Lock to latest Edge Rails or a specific revision with REVISION=X (ex: REVISION=4021) or a tag with TAG=Y (ex: TAG=rel_1-1-0)"
|
2006-02-26 23:38:39 -05:00
|
|
|
task :edge do
|
|
|
|
$verbose = false
|
2006-04-04 13:44:34 -04:00
|
|
|
`svn --version` rescue nil
|
2006-02-26 23:38:39 -05:00
|
|
|
unless !$?.nil? && $?.success?
|
|
|
|
$stderr.puts "ERROR: Must have subversion (svn) available in the PATH to lock this application to Edge Rails"
|
|
|
|
exit 1
|
|
|
|
end
|
2006-04-04 13:44:34 -04:00
|
|
|
|
2006-02-26 23:38:39 -05:00
|
|
|
rm_rf "vendor/rails"
|
|
|
|
mkdir_p "vendor/rails"
|
2006-04-04 13:44:34 -04:00
|
|
|
|
|
|
|
svn_root = "http://dev.rubyonrails.org/svn/rails/"
|
2005-10-30 12:17:05 -05:00
|
|
|
|
2006-04-02 22:38:12 -04:00
|
|
|
if ENV['TAG']
|
2006-04-04 13:44:34 -04:00
|
|
|
rails_svn = "#{svn_root}/tags/#{ENV['TAG']}"
|
2006-04-02 22:38:12 -04:00
|
|
|
touch "vendor/rails/TAG_#{ENV['TAG']}"
|
|
|
|
else
|
2006-04-04 13:44:34 -04:00
|
|
|
rails_svn = "#{svn_root}/trunk"
|
2006-04-02 22:38:12 -04:00
|
|
|
|
|
|
|
if ENV['REVISION'].nil?
|
2006-04-04 13:44:34 -04:00
|
|
|
ENV['REVISION'] = /^r(\d+)/.match(%x{svn -qr HEAD log #{svn_root}})[1]
|
2006-04-02 22:38:12 -04:00
|
|
|
puts "REVISION not set. Using HEAD, which is revision #{ENV['REVISION']}."
|
|
|
|
end
|
|
|
|
|
|
|
|
touch "vendor/rails/REVISION_#{ENV['REVISION']}"
|
|
|
|
end
|
2006-03-01 11:02:50 -05:00
|
|
|
|
2006-03-02 21:54:30 -05:00
|
|
|
for framework in %w( railties actionpack activerecord actionmailer activesupport actionwebservice )
|
2006-04-02 22:38:12 -04:00
|
|
|
system "svn export #{rails_svn}/#{framework} vendor/rails/#{framework}" + (ENV['REVISION'] ? " -r #{ENV['REVISION']}" : "")
|
2006-02-26 23:38:39 -05:00
|
|
|
end
|
|
|
|
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"
|
|
|
|
task :update => [ "update:scripts", "update:javascripts", "update:configs" ]
|
2005-11-07 13:09:31 -05:00
|
|
|
|
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']
|
|
|
|
scripts.reject!{|s| File.basename(s) == 'application.js'} if File.exists?(project_dir + 'application.js')
|
|
|
|
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
|
2005-11-07 13:09:31 -05:00
|
|
|
end
|
2006-03-13 13:45:40 -05:00
|
|
|
end
|