summaryrefslogtreecommitdiff
path: root/lib/rubygems/dependency.rb
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems/dependency.rb57
1 files changed, 39 insertions, 18 deletions
@@ -74,7 +74,7 @@ class Gem::Dependency
end
def inspect # :nodoc:
- if @prerelease
"<%s type=%p name=%p requirements=%p prerelease=ok>" %
[self.class, self.type, self.name, requirement.to_s]
else
@@ -145,7 +145,6 @@ class Gem::Dependency
@requirement = @version_requirements if defined?(@version_requirements)
end
- # DOC: this method needs documentation or :nodoc''d
def requirements_list
requirement.as_list
end
@@ -205,9 +204,19 @@ class Gem::Dependency
alias === =~
- # DOC: this method needs either documented or :nodoc'd
- def match? obj, version=nil
if !version
name = obj.name
version = obj.version
@@ -216,12 +225,23 @@ class Gem::Dependency
end
return false unless self.name === name
- return true if requirement.none?
- requirement.satisfied_by? Gem::Version.new(version)
end
- # DOC: this method needs either documented or :nodoc'd
def matches_spec? spec
return false unless name === spec.name
@@ -249,8 +269,6 @@ class Gem::Dependency
self.class.new name, self_req.as_list.concat(other_req.as_list)
end
- # DOC: this method needs either documented or :nodoc'd
-
def matching_specs platform_only = false
matches = Gem::Specification.stubs.find_all { |spec|
self.name === spec.name and # TODO: == instead of ===
@@ -273,8 +291,6 @@ class Gem::Dependency
@requirement.specific?
end
- # DOC: this method needs either documented or :nodoc'd
-
def to_specs
matches = matching_specs true
@@ -287,12 +303,13 @@ class Gem::Dependency
if specs.empty?
total = Gem::Specification.to_a.size
- error = Gem::LoadError.new \
- "Could not find '#{name}' (#{requirement}) among #{total} total gem(s)"
else
- error = Gem::LoadError.new \
- "Could not find '#{name}' (#{requirement}) - did find: [#{specs.join ','}]"
end
error.name = self.name
error.requirement = self.requirement
raise error
@@ -303,11 +320,15 @@ class Gem::Dependency
matches
end
- # DOC: this method needs either documented or :nodoc'd
-
def to_spec
matches = self.to_specs
- matches.find { |spec| spec.activated? } or matches.last
end
end