latest_specs (Gem::SourceIndex)

    # File lib/rubygems/source_index.rb, line 130
        def latest_specs
          result, latest = Hash.new { |h,k| h[k] = [] }, {}

          self.each do |_, spec| # SourceIndex is not a hash, so we're stuck with each
            name = spec.name
            curr_ver = spec.version
            prev_ver = latest[name]

            next unless prev_ver.nil? or curr_ver >= prev_ver

            if prev_ver.nil? or curr_ver > prev_ver then
              result[name].clear
              latest[name] = curr_ver
            end

            result[name] << spec
          end

          result.values.flatten
        end