def suggest_gems_from_name gem_name
    gem_name        = gem_name.downcase
    max             = gem_name.size / 2
    specs           = list.values.flatten 1

    matches = specs.map { |name, version, platform|
      next unless Gem::Platform.match platform

      distance = levenshtein_distance gem_name, name.downcase

      next if distance >= max

      return [name] if distance == 0

      [name, distance]
    }.compact

    matches = matches.uniq.sort_by { |name, dist| dist }

    matches.first(5).map { |name, dist| name }
  end
#
Suggests a gem based on the supplied +gem_name+. Returns a string
of the gem name if an approximate match can be found or nil
otherwise. NOTE: for performance reasons only gems which exactly
match the first character of +gem_name+ are considered.