mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
86bb0af7ea
commit
25a9b62d45
73 changed files with 2408 additions and 719 deletions
|
@ -32,11 +32,6 @@ class Gem::Dependency
|
|||
|
||||
attr_writer :prerelease
|
||||
|
||||
##
|
||||
# Dependency type.
|
||||
|
||||
attr_reader :type
|
||||
|
||||
##
|
||||
# Constructs a dependency with +name+ and +requirements+. The last
|
||||
# argument can optionally be the dependency type, which defaults to
|
||||
|
@ -72,7 +67,7 @@ class Gem::Dependency
|
|||
|
||||
def inspect # :nodoc:
|
||||
"<%s type=%p name=%p requirements=%p>" %
|
||||
[self.class, @type, @name, requirement.to_s]
|
||||
[self.class, self.type, self.name, requirement.to_s]
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -132,7 +127,18 @@ class Gem::Dependency
|
|||
end
|
||||
|
||||
def to_s # :nodoc:
|
||||
"#{name} (#{requirement}, #{type})"
|
||||
if type != :runtime then
|
||||
"#{name} (#{requirement}, #{type})"
|
||||
else
|
||||
"#{name} (#{requirement})"
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Dependency type.
|
||||
|
||||
def type
|
||||
@type ||= :runtime
|
||||
end
|
||||
|
||||
def == other # :nodoc:
|
||||
|
@ -146,7 +152,7 @@ class Gem::Dependency
|
|||
# Dependencies are ordered by name.
|
||||
|
||||
def <=> other
|
||||
@name <=> other.name
|
||||
self.name <=> other.name
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -187,5 +193,24 @@ class Gem::Dependency
|
|||
requirement.satisfied_by?(spec.version)
|
||||
end
|
||||
|
||||
##
|
||||
# Merges the requirements of +other+ into this dependency
|
||||
|
||||
def merge other
|
||||
unless name == other.name then
|
||||
raise ArgumentError,
|
||||
"#{self} and #{other} have different names"
|
||||
end
|
||||
|
||||
default = Gem::Requirement.default
|
||||
self_req = self.requirement
|
||||
other_req = other.requirement
|
||||
|
||||
return self.class.new name, self_req if other_req == default
|
||||
return self.class.new name, other_req if self_req == default
|
||||
|
||||
self.class.new name, self_req.as_list.concat(other_req.as_list)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue