3 desc "Lock this application to the current gems (by unpacking them into vendor/rails)"
5 deps = %w(actionpack activerecord actionmailer activesupport activeresource)
7 require 'rubygems/gem_runner'
9 rails = (version = ENV['VERSION']) ?
10 Gem.cache.find_name('rails', "= #{version}").first :
11 Gem.cache.find_name('rails').sort_by { |g| g.version }.last
13 version ||= rails.version
16 puts "No rails gem #{version} is installed. Do 'gem list rails' to see what you have available."
20 puts "Freezing to the gems for Rails #{rails.version}"
22 mkdir_p "vendor/rails"
25 chdir("vendor/rails") do
26 rails.dependencies.select { |g| deps.include? g.name }.each do |g|
27 Gem::GemRunner.new.run(["unpack", g.name, "--version", g.version_requirements.to_s])
28 mv(Dir.glob("#{g.name}*").first, g.name)
31 Gem::GemRunner.new.run(["unpack", "rails", "--version", "=#{version}"])
32 FileUtils.mv(Dir.glob("rails*").first, "railties")
40 desc 'Lock to latest Edge Rails, for a specific release use RELEASE=1.2.0'
43 version = ENV["RELEASE"] || "edge"
44 target = "rails_#{version}.zip"
45 commits = "http://github.com/api/v1/yaml/rails/rails/commits/master"
46 url = "http://dev.rubyonrails.org/archives/#{target}"
49 latest_revision = YAML.load(open(commits))["commits"].first["id"]
51 puts "Downloading Rails from #{url}"
52 File.open('rails.zip', 'wb') do |dst|
54 while chunk = src.read(4096)
60 puts 'Unpacking Rails'
63 %w(rails.zip rails/Rakefile rails/cleanlogs.sh rails/pushgems.rb rails/release.rb).each do |goner|
67 touch "rails/REVISION_#{latest_revision}"
70 puts 'Updating current scripts, javascripts, and configuration settings'
71 Rake::Task['rails:update'].invoke
75 desc "Unlock this application from freeze of gems or edge and return to a fluid use of system gems"
80 desc "Update both configs, scripts and public/javascripts from Rails"
81 task :update => [ "update:scripts", "update:javascripts", "update:configs" ]
84 desc "Add new scripts to the application script/ directory"
87 edge_base = "#{File.dirname(__FILE__)}/../../bin"
89 local = Dir["#{local_base}/**/*"].reject { |path| File.directory?(path) }
90 edge = Dir["#{edge_base}/**/*"].reject { |path| File.directory?(path) }
93 base_name = script[(edge_base.length+1)..-1]
94 next if base_name == "rails"
95 next if local.detect { |path| base_name == path[(local_base.length+1)..-1] }
96 if !File.directory?("#{local_base}/#{File.dirname(base_name)}")
97 mkdir_p "#{local_base}/#{File.dirname(base_name)}"
99 install script, "#{local_base}/#{base_name}", :mode => 0755
103 desc "Update your javascripts from your current rails install"
105 require 'railties_path'
106 project_dir = RAILS_ROOT + '/public/javascripts/'
107 scripts = Dir[RAILTIES_PATH + '/html/javascripts/*.js']
108 scripts.reject!{|s| File.basename(s) == 'application.js'} if File.exist?(project_dir + 'application.js')
109 FileUtils.cp(scripts, project_dir)
112 desc "Update config/boot.rb from your current rails install"
114 require 'railties_path'
115 FileUtils.cp(RAILTIES_PATH + '/environments/boot.rb', RAILS_ROOT + '/config/boot.rb')