instance method
Gem::SpecFetcher#search_for_dependency
search_for_dependency(dependency, matching_platform = true)
lib/rubygems/spec_fetcher.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/rubygems/spec_fetcher.rb, line 86
def search_for_dependency(dependency, matching_platform = true)
found = {}
rejected_specs = {}
list, errors = available_specs(dependency.identity)
list.each do |source, specs|
if dependency.name.is_a?(String) && specs.respond_to?(:bsearch)
start_index = (0...specs.length).bsearch {|i| specs[i].name >= dependency.name }
end_index = (0...specs.length).bsearch {|i| specs[i].name > dependency.name }
specs = specs[start_index...end_index] if start_index && end_index
end
found[source] = specs.select do |tup|
if dependency.match?(tup)
if matching_platform && !Gem::Platform.match_gem?(tup.platform, tup.name)
pm = (
rejected_specs[dependency] ||= \
Gem::PlatformMismatch.new(tup.name, tup.version))
pm.add_platform tup.platform
false
else
true
end
end
end
end
errors += rejected_specs.values
tuples = []
found.each do |source, specs|
specs.each do |s|
tuples << [s, source]
end
end
tuples = tuples.sort_by {|x| x[0].version }
[tuples, errors]
end
Find and fetch gem name tuples that match dependency.
If matching_platform is false, gems for all platforms are returned.
See also
#detect
#spec_for_dependency
#available_specs
#suggest_gems_from_name
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0