diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-02-22 02:52:35 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-02-22 02:52:35 +0000 |
commit | b551e8c8b36766651be4e782e09e3b02e7d14a10 (patch) | |
tree | e164a1ef908bd4451568abf05b688f1593915b81 /lib/rubygems/dependency_list.rb | |
parent | 65544f575b25b18dc27f9364f973556ddb48538f (diff) | |
download | ruby-b551e8c8b36766651be4e782e09e3b02e7d14a10.tar.gz |
* lib/rubygems: update to 1.3.6.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/dependency_list.rb')
-rw-r--r-- | lib/rubygems/dependency_list.rb | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/lib/rubygems/dependency_list.rb b/lib/rubygems/dependency_list.rb index a73a32d545..25d469d68c 100644 --- a/lib/rubygems/dependency_list.rb +++ b/lib/rubygems/dependency_list.rb @@ -6,23 +6,41 @@ require 'tsort' +## +# Gem::DependencyList is used for installing and uninstalling gems in the +# correct order to avoid conflicts. + class Gem::DependencyList include Enumerable include TSort - def self.from_source_index(src_index) - deps = new + ## + # Allows enabling/disabling use of development dependencies + + attr_accessor :development - src_index.each do |full_name, spec| - deps.add spec + ## + # Creates a DependencyList from a Gem::SourceIndex +source_index+ + + def self.from_source_index(source_index) + list = new + + source_index.each do |full_name, spec| + list.add spec end - deps + list end - def initialize + ## + # Creates a new DependencyList. If +development+ is true, development + # dependencies will be included. + + def initialize development = false @specs = [] + + @development = development end ## @@ -33,8 +51,9 @@ class Gem::DependencyList end ## - # Return a list of the specifications in the dependency list, sorted in - # order so that no spec in the list depends on a gem earlier in the list. + # 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 + # list. # # This is useful when removing gems from a set of installed gems. By # removing them in the returned order, you don't get into as many dependency @@ -77,6 +96,10 @@ class Gem::DependencyList @specs.find { |spec| spec.full_name == full_name } end + def inspect # :nodoc: + "#<%s:0x%x %p>" % [self.class, object_id, map { |s| s.full_name }] + end + ## # Are all the dependencies in the list satisfied? @@ -89,10 +112,10 @@ class Gem::DependencyList end ## - # Is is ok to remove a gem from the dependency list? + # Is is ok to remove a gemspec from the dependency list? # # If removing the gemspec creates breaks a currently ok dependency, then it - # is NOT ok to remove the gem. + # is NOT ok to remove the gemspec. def ok_to_remove?(full_name) gem_to_remove = find_name full_name @@ -117,13 +140,16 @@ class Gem::DependencyList } end + ## + # Removes the gemspec matching +full_name+ from the dependency list + def remove_by_name(full_name) @specs.delete_if { |spec| spec.full_name == full_name } end ## # Return a hash of predecessors. <tt>result[spec]</tt> is an Array of - # gemspecs that have a dependency satisfied by the named spec. + # gemspecs that have a dependency satisfied by the named gemspec. def spec_predecessors result = Hash.new { |h,k| h[k] = [] } @@ -152,7 +178,10 @@ class Gem::DependencyList def tsort_each_child(node, &block) specs = @specs.sort.reverse - node.dependencies.each do |dep| + dependencies = node.runtime_dependencies + dependencies.push(*node.development_dependencies) if @development + + dependencies.each do |dep| specs.each do |spec| if spec.satisfies_requirement? dep then begin |