latest_specs (Gem::SourceIndex)

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

        sort.each do |_, spec|
          name = spec.name
          curr_ver = spec.version
          prev_ver = latest.key?(name) ? latest[name].version : nil

          next if curr_ver.prerelease?
          next unless prev_ver.nil? or curr_ver >= prev_ver or
                      latest[name].platform != Gem::Platform::RUBY

          if prev_ver.nil? or
             (curr_ver > prev_ver and spec.platform == Gem::Platform::RUBY) then
            result[name].clear
            latest[name] = spec
          end

          if spec.platform != Gem::Platform::RUBY then
            result[name].delete_if do |result_spec|
              result_spec.platform == spec.platform
            end
          end

          result[name] << spec
        end

        # TODO: why is this a hash while @gems is an array? Seems like
        # structural similarity would be good.
        result.values.flatten
      end