which_to_update (Gem::Commands::UpdateCommand)

    # File lib/rubygems/commands/update_command.rb, line 158
      def which_to_update(highest_installed_gems, gem_names)
        result = []

        highest_installed_gems.each do |l_name, l_spec|
          next if not gem_names.empty? and
                  gem_names.all? { |name| /#{name}/ !~ l_spec.name }

          dependency = Gem::Dependency.new l_spec.name, "> #{l_spec.version}"

          begin
            fetcher = Gem::SpecFetcher.fetcher
            spec_tuples = fetcher.find_matching dependency
          rescue Gem::RemoteFetcher::FetchError => e
            raise unless fetcher.warn_legacy e do
              require 'rubygems/source_info_cache'

              dependency.name = '' if dependency.name == //

              specs = Gem::SourceInfoCache.search_with_source dependency

              spec_tuples = specs.map do |spec, source_uri|
                [[spec.name, spec.version, spec.original_platform], source_uri]
              end
            end
          end

          matching_gems = spec_tuples.select do |(name, version, platform),|
            name == l_name and Gem::Platform.match platform
          end

          highest_remote_gem = matching_gems.sort_by do |(name, version),|
            version
          end.last

          if highest_remote_gem and
             l_spec.version < highest_remote_gem.first[1] then
            result << l_name
          end
        end

        result
      end