diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-27 04:38:39 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-27 04:38:39 +0000 |
commit | 985cb441103c79651f12a013326aa15f54fa8182 (patch) | |
tree | 4aa28f1488ba5cdf66e58ed6df0aa448dfdbba0b /railties/lib/tasks/framework.rake | |
parent | 1a06d324df43bfb3287293934f0ef34a7c790a34 (diff) | |
download | rails-985cb441103c79651f12a013326aa15f54fa8182.tar.gz rails-985cb441103c79651f12a013326aa15f54fa8182.tar.bz2 rails-985cb441103c79651f12a013326aa15f54fa8182.zip |
Added namespaces to all tasks, so for example load_fixtures is now db:fixtures:load. All the old task names are still valid, they just point to the new namespaced names. "rake -T" will only show the namespaced ones, though [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3680 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/tasks/framework.rake')
-rw-r--r-- | railties/lib/tasks/framework.rake | 127 |
1 files changed, 71 insertions, 56 deletions
diff --git a/railties/lib/tasks/framework.rake b/railties/lib/tasks/framework.rake index 59f8f51381..346d7a7e51 100644 --- a/railties/lib/tasks/framework.rake +++ b/railties/lib/tasks/framework.rake @@ -1,71 +1,86 @@ -desc "Lock this application to the current gems (by unpacking them into vendor/rails)" -task :freeze_gems do - deps = %w(actionpack activerecord actionmailer activesupport actionwebservice) - require 'rubygems' +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' - rails = if version = ENV['VERSION'] - Gem.cache.search('rails', "= #{version}").first - else - Gem.cache.search('rails').sort_by { |g| g.version }.last - end - version ||= rails.version + rails = if version = ENV['VERSION'] + Gem.cache.search('rails', "= #{version}").first + else + Gem.cache.search('rails').sort_by { |g| g.version }.last + end + version ||= rails.version - unless rails - puts "No rails gem #{version} is installed. Do 'gem list rails' to see what you have available." - exit - end + 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}" - rm_rf "vendor/rails" - mkdir_p "vendor/rails" + puts "Freezing to the gems for Rails #{rails.version}" + rm_rf "vendor/rails" + mkdir_p "vendor/rails" - 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}" - end - system "cd vendor/rails; gem unpack -v '=#{version}' rails" + 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}" + end + system "cd vendor/rails; gem unpack -v '=#{version}' rails" - FileUtils.mv(Dir.glob("vendor/rails/rails*").first, "vendor/rails/railties") -end + FileUtils.mv(Dir.glob("vendor/rails/rails*").first, "vendor/rails/railties") + end -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." -task :freeze_edge do - $verbose = false - `svn --version` rescue nil - unless !$?.nil? && $?.success? - $stderr.puts "ERROR: Must have subversion (svn) available in the PATH to lock this application to Edge Rails" - exit 1 - end + desc "Lock this application to latest Edge Rails. Lock a specific revision with REVISION=X" + task :edge do + $verbose = false + `svn --version` rescue nil + unless !$?.nil? && $?.success? + $stderr.puts "ERROR: Must have subversion (svn) available in the PATH to lock this application to Edge Rails" + exit 1 + end - rm_rf "vendor/rails" - mkdir_p "vendor/rails" + rm_rf "vendor/rails" + mkdir_p "vendor/rails" - revision_switch = ENV['REVISION'] ? " -r #{ENV['REVISION']}" : '' - for framework in %w( railties actionpack activerecord actionmailer activesupport actionwebservice ) - mkdir_p "vendor/rails/#{framework}" - system "svn export http://dev.rubyonrails.org/svn/rails/trunk/#{framework}/lib vendor/rails/#{framework}/lib #{revision_switch}" + revision_switch = ENV['REVISION'] ? " -r #{ENV['REVISION']}" : '' + for framework in %w( railties actionpack activerecord actionmailer activesupport actionwebservice ) + mkdir_p "vendor/rails/#{framework}" + system "svn export http://dev.rubyonrails.org/svn/rails/trunk/#{framework}/lib vendor/rails/#{framework}/lib #{revision_switch}" + end + end 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" -end + 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 + + desc "Update both scripts and public/javascripts from Rails" + task :update => [ "update:scripts", "update:javascripts" ] -desc "Add new scripts to the application script/ directory" -task :add_new_scripts do - local_base = "script" - edge_base = "#{File.dirname(__FILE__)}/../../bin" + namespace :update do + desc "Add new scripts to the application script/ directory" + task :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) } + 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)}" + 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" + task :javascripts do + require 'railties_path' + FileUtils.cp(Dir[RAILTIES_PATH + '/html/javascripts/*.js'], RAILS_ROOT + '/public/javascripts/') end - install script, "#{local_base}/#{base_name}", :mode => 0755 end -end +end
\ No newline at end of file |