2005-10-15 11:00:15 -04:00
desc " Lock this application to the current gems (by unpacking them into vendor/rails) "
task :freeze_gems do
2005-11-08 05:43:40 -05:00
deps = %w( actionpack activerecord actionmailer activesupport actionwebservice )
require 'rubygems'
rails = if version = ENV [ 'VERSION' ]
Gem . cache . search ( 'rails' , " = #{ version } " ) . first
else
Gem . cache . search ( 'rails' ) . sort_by { | g | g . version } . last
end
2005-11-27 19:53:38 -05:00
version || = rails . version
2005-11-08 05:43:40 -05:00
unless rails
puts " No rails gem #{ version } is installed. Do 'gem list rails' to see what you have available. "
exit
end
puts " Freezing to the gems for Rails #{ rails . version } "
2005-10-15 11:00:15 -04:00
rm_rf " vendor/rails "
mkdir_p " vendor/rails "
2005-11-01 13:26:06 -05:00
2005-11-08 05:43:40 -05:00
rails . dependencies . select { | g | deps . include? g . name } . each do | g |
system " cd vendor/rails; gem unpack -v ' #{ g . version_requirements } ' #{ g . name } ; mv #{ g . name } * #{ g . name } "
2005-10-15 11:00:15 -04:00
end
2005-11-27 19:53:38 -05:00
system " cd vendor/rails; gem unpack -v '= #{ version } ' rails "
2005-10-15 11:44:35 -04:00
FileUtils . mv ( Dir . glob ( " vendor/rails/rails* " ) . first , " vendor/rails/railties " )
2005-10-15 11:00:15 -04:00
end
2005-10-30 12:17:05 -05:00
desc " Lock this application to the Edge Rails (by exporting from Subversion). Defaults to svn HEAD; do 'rake freeze_edge REVISION=1234' to lock to a specific revision. "
2005-10-15 11:00:15 -04:00
task :freeze_edge do
2005-10-30 12:17:05 -05:00
$verbose = false
2005-11-07 04:46:40 -05:00
` svn --version ` rescue nil
unless ! $? . nil? && $? . success?
2005-10-30 12:17:05 -05:00
$stderr . puts " ERROR: Must have subversion (svn) available in the PATH to lock this application to Edge Rails "
exit 1
end
2005-10-15 11:00:15 -04:00
rm_rf " vendor/rails "
mkdir_p " vendor/rails "
2005-10-30 12:17:05 -05:00
revision_switch = ENV [ 'REVISION' ] ? " -r #{ ENV [ 'REVISION' ] } " : ''
2005-10-15 11:00:15 -04:00
for framework in %w( railties actionpack activerecord actionmailer activesupport actionwebservice )
mkdir_p " vendor/rails/ #{ framework } "
2005-10-30 12:17:05 -05:00
system " svn export http://dev.rubyonrails.org/svn/rails/trunk/ #{ framework } /lib vendor/rails/ #{ framework } /lib #{ revision_switch } "
2005-10-15 11:00:15 -04:00
end
end
desc " Unlock this application from freeze of gems or edge and return to a fluid use of system gems "
task :unfreeze_rails do
rm_rf " vendor/rails "
2005-10-30 12:17:05 -05:00
end
2005-11-07 13:09:31 -05:00
desc " Add new scripts to the application script/ directory "
task :add_new_scripts do
local_base = " script "
edge_base = " #{ File . dirname ( __FILE__ ) } /../../bin "
local = Dir [ " #{ local_base } /**/* " ] . reject { | path | File . directory? ( path ) }
edge = Dir [ " #{ edge_base } /**/* " ] . reject { | path | File . directory? ( path ) }
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
2005-11-07 17:05:53 -05:00
install script , " #{ local_base } / #{ base_name } " , :mode = > 0755
2005-11-07 13:09:31 -05:00
end
2005-11-07 17:05:53 -05:00
end