class Bundler::Index
def search_by_dependency(dependency, base = nil)
def search_by_dependency(dependency, base = nil) @cache[base || false] ||= {} @cache[base || false][dependency] ||= begin specs = specs_by_name(dependency.name) + (base || []) found = specs.select do |spec| if base # allow all platforms when searching from a lockfile dependency.matches_spec?(spec) else dependency.matches_spec?(spec) && Gem::Platform.match(spec.platform) end end wants_prerelease = dependency.requirement.prerelease? only_prerelease = specs.all? {|spec| spec.version.prerelease? } unless wants_prerelease || only_prerelease found.reject! { |spec| spec.version.prerelease? } end found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\0" : s.platform.to_s] } end end