diff options
author | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-01 09:41:32 +0000 |
---|---|---|
committer | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-01 09:41:32 +0000 |
commit | 25a9b62d45ddd60a231272567c7dda9337da9b62 (patch) | |
tree | e72ba4c9c01cba5fb510eb1eafaba76d998baf4c /lib/rubygems/dependency_list.rb | |
parent | 86bb0af7ea3b50f72e6845a6f5f64cb1b23fd279 (diff) | |
download | ruby-25a9b62d45ddd60a231272567c7dda9337da9b62.tar.gz |
Import rubygems 1.6.0 (released version @ 58d8a0b9)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/dependency_list.rb')
-rw-r--r-- | lib/rubygems/dependency_list.rb | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/lib/rubygems/dependency_list.rb b/lib/rubygems/dependency_list.rb index 647bb91ae2..91c7c5ade4 100644 --- a/lib/rubygems/dependency_list.rb +++ b/lib/rubygems/dependency_list.rb @@ -17,6 +17,7 @@ require 'tsort' # correct order to avoid conflicts. class Gem::DependencyList + attr_reader :specs include Enumerable include TSort @@ -56,6 +57,10 @@ class Gem::DependencyList @specs.push(*gemspecs) end + def clear + @specs.clear + end + ## # Return a list of the gem specifications in the dependency list, sorted in # order so that no gemspec in the list depends on a gemspec earlier in the @@ -110,11 +115,26 @@ class Gem::DependencyList # Are all the dependencies in the list satisfied? def ok? - @specs.all? do |spec| - spec.runtime_dependencies.all? do |dep| - @specs.find { |s| s.satisfies_requirement? dep } + why_not_ok?(:quick).empty? + end + + def why_not_ok? quick = false + unsatisfied = Hash.new { |h,k| h[k] = [] } + source_index = Gem.source_index + @specs.each do |spec| + spec.runtime_dependencies.each do |dep| + inst = source_index.any? { |_, installed_spec| + dep.name == installed_spec.name and + dep.requirement.satisfied_by? installed_spec.version + } + + unless inst or @specs.find { |s| s.satisfies_requirement? dep } then + unsatisfied[spec.name] << dep + return unsatisfied if quick + end end end + unsatisfied end ## @@ -147,6 +167,18 @@ class Gem::DependencyList end ## + # Remove everything in the DependencyList that matches but doesn't + # satisfy items in +dependencies+ (a hash of gem names to arrays of + # dependencies). + + def remove_specs_unsatisfied_by dependencies + specs.reject! { |spec| + dep = dependencies[spec.name] + dep and not dep.requirement.satisfied_by? spec.version + } + end + + ## # Removes the gemspec matching +full_name+ from the dependency list def remove_by_name(full_name) |