[rubygems/rubygems] Refactor Gem::Specification#find_all_by_name
So that it can also be delegated to `Gem::SpecificationRecord`. https://github.com/rubygems/rubygems/commit/1407807a99
This commit is contained in:
parent
d076101af9
commit
35c5c7edb9
@ -271,15 +271,7 @@ class Gem::Dependency
|
|||||||
end
|
end
|
||||||
|
|
||||||
def matching_specs(platform_only = false)
|
def matching_specs(platform_only = false)
|
||||||
env_req = Gem.env_requirement(name)
|
matches = Gem::Specification.find_all_by_name(name, requirement)
|
||||||
matches = Gem::Specification.stubs_for(name).find_all do |spec|
|
|
||||||
requirement.satisfied_by?(spec.version) && env_req.satisfied_by?(spec.version)
|
|
||||||
end.map(&:to_spec)
|
|
||||||
|
|
||||||
if prioritizes_bundler?
|
|
||||||
require_relative "bundler_version_finder"
|
|
||||||
Gem::BundlerVersionFinder.prioritize!(matches)
|
|
||||||
end
|
|
||||||
|
|
||||||
if platform_only
|
if platform_only
|
||||||
matches.reject! do |spec|
|
matches.reject! do |spec|
|
||||||
@ -297,10 +289,6 @@ class Gem::Dependency
|
|||||||
@requirement.specific?
|
@requirement.specific?
|
||||||
end
|
end
|
||||||
|
|
||||||
def prioritizes_bundler?
|
|
||||||
name == "bundler" && !specific?
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_specs
|
def to_specs
|
||||||
matches = matching_specs true
|
matches = matching_specs true
|
||||||
|
|
||||||
|
@ -937,9 +937,19 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
# Returns every spec that matches +name+ and optional +requirements+.
|
# Returns every spec that matches +name+ and optional +requirements+.
|
||||||
|
|
||||||
def self.find_all_by_name(name, *requirements)
|
def self.find_all_by_name(name, *requirements)
|
||||||
requirements = Gem::Requirement.default if requirements.empty?
|
req = Gem::Requirement.create(*requirements)
|
||||||
|
env_req = Gem.env_requirement(name)
|
||||||
|
|
||||||
Gem::Dependency.new(name, *requirements).matching_specs
|
matches = stubs_for(name).find_all do |spec|
|
||||||
|
req.satisfied_by?(spec.version) && env_req.satisfied_by?(spec.version)
|
||||||
|
end.map(&:to_spec)
|
||||||
|
|
||||||
|
if name == "bundler" && !req.specific?
|
||||||
|
require_relative "bundler_version_finder"
|
||||||
|
Gem::BundlerVersionFinder.prioritize!(matches)
|
||||||
|
end
|
||||||
|
|
||||||
|
matches
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
Loading…
x
Reference in New Issue
Block a user