Permalink
Browse files

Display gem dependencies correctly and unpack exactly once [#2097 sta…

…te:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
1 parent 3b169cd commit a3ac1e1621506a6519b265ef6ec6abc70f6c8a27 @al2o3cr al2o3cr committed with lifo Mar 1, 2009
Showing with 11 additions and 9 deletions.
  1. +7 −4 railties/lib/rails/gem_dependency.rb
  2. +3 −4 railties/lib/tasks/gems.rake
  3. +1 −1 railties/test/gem_dependency_test.rb
@@ -72,13 +72,14 @@ def add_load_paths
rescue Gem::LoadError
end
- def dependencies
- return [] if framework_gem?
- return [] if specification.nil?
+ def dependencies(options = {})
+ return [] if framework_gem? || specification.nil?
+
all_dependencies = specification.dependencies.map do |dependency|
GemDependency.new(dependency.name, :requirement => dependency.version_requirements)
end
- all_dependencies += all_dependencies.map(&:dependencies).flatten
+
+ all_dependencies += all_dependencies.map { |d| d.dependencies(options) }.flatten if options[:flatten]
all_dependencies.uniq
end
@@ -149,6 +150,8 @@ def install
end
def unpack_to(directory)
+ return if specification.nil? || File.directory?(gem_dir(directory)) || framework_gem?
+
FileUtils.mkdir_p directory
Dir.chdir directory do
Gem::GemRunner.new.run(unpack_command)
@@ -47,8 +47,8 @@ namespace :gems do
require 'rubygems'
require 'rubygems/gem_runner'
Rails.configuration.gems.each do |gem|
- next unless !gem.frozen? && (ENV['GEM'].blank? || ENV['GEM'] == gem.name)
- gem.unpack_to(Rails::GemDependency.unpacked_path) if gem.loaded?
+ next unless ENV['GEM'].blank? || ENV['GEM'] == gem.name
+ gem.unpack_to(Rails::GemDependency.unpacked_path)
end
end
@@ -59,8 +59,7 @@ namespace :gems do
require 'rubygems/gem_runner'
Rails.configuration.gems.each do |gem|
next unless ENV['GEM'].blank? || ENV['GEM'] == gem.name
- gem.dependencies.each do |dependency|
- next if dependency.frozen?
+ gem.dependencies(:flatten => true).each do |dependency|
dependency.unpack_to(Rails::GemDependency.unpacked_path)
end
end
@@ -133,7 +133,7 @@ def test_gem_handle_missing_dependencies
dummy_gem.add_load_paths
dummy_gem.load
assert dummy_gem.loaded?
- assert_equal 2, dummy_gem.dependencies.size
+ assert_equal 2, dummy_gem.dependencies(:flatten => true).size
assert_nothing_raised do
dummy_gem.dependencies.each do |g|
g.dependencies

0 comments on commit a3ac1e1

Please sign in to comment.