aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/tasks
diff options
context:
space:
mode:
authorMatt Jones <al2o3cr@gmail.com>2008-10-04 13:51:23 -0400
committerrick <technoweenie@gmail.com>2008-10-05 10:16:17 -0700
commit2bf58aa782d3b493f2d98f153324b93c5b058ba6 (patch)
tree53278af87e3590bb901754b2e2f8ce1d13d49d73 /railties/lib/tasks
parent4f53db0096be4b167628a136044b0d1262215277 (diff)
downloadrails-2bf58aa782d3b493f2d98f153324b93c5b058ba6.tar.gz
rails-2bf58aa782d3b493f2d98f153324b93c5b058ba6.tar.bz2
rails-2bf58aa782d3b493f2d98f153324b93c5b058ba6.zip
Fix a number of errors in the config.gem mechanism.
* Rails::GemDependency was missing definitions for hash and eql?, causing Array#uniq to not work. * If several versions of a gem are unpacked in vendor, now chooses the highest if no version is specified. * streamlined add_load_path. Now sets up Rubygems correctly to allow 'gem' to find frozen gems, with gems frozen to vendor/gems and specifications in vendor/gems/<gem-name>/.specification * Rails::GemDependency#specification would return a spec for the highest installed version, even for frozen gems and/or previously loaded lower versions. See in part ticket #1123. * removed vendor from default_load_paths - it was causing autoloading to append Gems::Gems::<gem-dir> to constant names * added additional tests for loading frozen gems. * incorporates the fix from #1107 for vendor rails * defers to freeze:gems for handling the Rails framework. gems:unpack WILL NOT place a copy of Rails in vendor/gems. Should close #1123 completely. * incorporates, via using the gem loader for frozen gems, fixes corresponding to #227, #324, #362, #527, and #742. * gem plugins now work the same whether frozen or not. Correctness of the behavior is a matter for another ticket... Signed-off-by: rick <technoweenie@gmail.com>
Diffstat (limited to 'railties/lib/tasks')
-rw-r--r--railties/lib/tasks/gems.rake20
1 files changed, 12 insertions, 8 deletions
diff --git a/railties/lib/tasks/gems.rake b/railties/lib/tasks/gems.rake
index 0321e60e0f..9abdfc56b6 100644
--- a/railties/lib/tasks/gems.rake
+++ b/railties/lib/tasks/gems.rake
@@ -1,14 +1,19 @@
desc "List the gems that this rails application depends on"
task :gems => 'gems:base' do
Rails.configuration.gems.each do |gem|
- code = gem.loaded? ? (gem.frozen? ? "F" : "I") : " "
- puts "[#{code}] #{gem.name} #{gem.requirement.to_s}"
+ print_gem_status(gem)
end
puts
puts "I = Installed"
puts "F = Frozen"
end
+def print_gem_status(gem, indent=1)
+ code = gem.loaded? ? (gem.frozen? ? "F" : "I") : " "
+ puts " "*(indent-1)+" - [#{code}] #{gem.name} #{gem.requirement.to_s}"
+ gem.dependencies.each { |g| print_gem_status(g, indent+1)}
+end
+
namespace :gems do
task :base do
$rails_gem_installer = true
@@ -19,7 +24,7 @@ namespace :gems do
task :build do
$rails_gem_installer = true
require 'rails/gem_builder'
- Dir[File.join(RAILS_ROOT, 'vendor', 'gems', '*')].each do |gem_dir|
+ Dir[File.join(Rails::GemDependency.unpacked_path, '*')].each do |gem_dir|
spec_file = File.join(gem_dir, '.specification')
next unless File.exists?(spec_file)
specification = YAML::load_file(spec_file)
@@ -28,7 +33,7 @@ namespace :gems do
puts "Built gem: '#{gem_dir}'"
end
end
-
+
desc "Installs all required gems for this application."
task :install => :base do
require 'rubygems'
@@ -42,10 +47,10 @@ namespace :gems do
require 'rubygems/gem_runner'
Rails.configuration.gems.each do |gem|
next unless !gem.frozen? && (ENV['GEM'].blank? || ENV['GEM'] == gem.name)
- gem.unpack_to(File.join(RAILS_ROOT, 'vendor', 'gems')) if gem.loaded?
+ gem.unpack_to(Rails::GemDependency.unpacked_path) if gem.loaded?
end
end
-
+
namespace :unpack do
desc "Unpacks the specified gems and its dependencies into vendor/gems"
task :dependencies => :unpack do
@@ -54,9 +59,8 @@ namespace :gems do
Rails.configuration.gems.each do |gem|
next unless ENV['GEM'].blank? || ENV['GEM'] == gem.name
gem.dependencies.each do |dependency|
- dependency.add_load_paths # double check that we have not already unpacked
next if dependency.frozen?
- dependency.unpack_to(File.join(RAILS_ROOT, 'vendor', 'gems'))
+ dependency.unpack_to(Rails::GemDependency.unpacked_path)
end
end
end