class Gem::Specification

def self.outdated_and_latest_version

def self.outdated_and_latest_version
  return enum_for __method__ unless block_given?
  # TODO: maybe we should switch to rubygems' version service?
  fetcher = Gem::SpecFetcher.fetcher
  latest_specs(true).each do |local_spec|
    dependency =
      Gem::Dependency.new local_spec.name, ">= #{local_spec.version}"
    remotes, = fetcher.search_for_dependency dependency
    remotes  = remotes.map { |n, _| n.version }
    latest_remote = remotes.sort.last
    yield [local_spec, latest_remote] if
      latest_remote and local_spec.version < latest_remote
  end
  nil
end