diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-09 21:38:59 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-09 21:38:59 +0000 |
commit | 31c94ffeb5f09d09ac2c86fc9e6614e38251a43d (patch) | |
tree | 10e44506238c7af3d7c9d822111996731726e38d /lib/rubygems/dependency.rb | |
parent | a6afbaeb3be396c0fdea3b9077d9256c59edcfca (diff) | |
download | ruby-31c94ffeb5f09d09ac2c86fc9e6614e38251a43d.tar.gz |
Update to RubyGems 1.3.4 r2223
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/dependency.rb')
-rw-r--r-- | lib/rubygems/dependency.rb | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb index 7b9904df55..d142265c5d 100644 --- a/lib/rubygems/dependency.rb +++ b/lib/rubygems/dependency.rb @@ -4,8 +4,6 @@ # See LICENSE.txt for permissions. #++ -require 'rubygems' - ## # The Dependency class holds a Gem name and a Gem::Requirement @@ -72,7 +70,7 @@ class Gem::Dependency alias requirements_list requirement_list def normalize - ver = @version_requirement.instance_eval { @version } + ver = @version_requirement.instance_variable_get :@version @version_requirements = Gem::Requirement.new([ver]) @version_requirement = nil end @@ -81,6 +79,21 @@ class Gem::Dependency "#{name} (#{version_requirements}, #{@type || :runtime})" end + def pretty_print(q) # :nodoc: + q.group 1, 'Gem::Dependency.new(', ')' do + q.pp @name + q.text ',' + q.breakable + + q.pp @version_requirements + + q.text ',' + q.breakable + + q.pp @type + end + end + def ==(other) # :nodoc: self.class === other && self.name == other.name && @@ -89,15 +102,22 @@ class Gem::Dependency end ## - # Uses this dependency as a pattern to compare to the dependency +other+. - # This dependency will match if the name matches the other's name, and other - # has only an equal version requirement that satisfies this dependency. + # Uses this dependency as a pattern to compare to +other+. This dependency + # will match if the name matches the other's name, and other has only an + # equal version requirement that satisfies this dependency. def =~(other) - return false unless self.class === other + other = if self.class === other then + other + else + return false unless other.respond_to? :name and + other.respond_to? :version + + Gem::Dependency.new other.name, other.version + end pattern = @name - pattern = /\A#{@name}\Z/ unless Regexp === pattern + pattern = /\A#{Regexp.escape @name}\Z/ unless Regexp === pattern return false unless pattern =~ other.name @@ -111,9 +131,18 @@ class Gem::Dependency version_requirements.satisfied_by? version end - def hash # :nodoc: + ## + # A dependency's hash is the sum of the hash of the #name, #type and + # #version_requirements + + def hash name.hash + type.hash + version_requirements.hash end + def inspect # :nodoc: + "<%s type=%p name=%p requirements=%p>" % [self.class, @type, @name, + version_requirements.to_s] + end + end |