gather_dependencies (Gem::DependencyInstaller)

    # File lib/rubygems/dependency_installer.rb, line 182
      def gather_dependencies
        specs = @specs_and_sources.map { |spec,_| spec }

        dependency_list = Gem::DependencyList.new
        dependency_list.add(*specs)

        unless @ignore_dependencies then
          to_do = specs.dup
          seen = {}

          until to_do.empty? do
            spec = to_do.shift
            next if spec.nil? or seen[spec.name]
            seen[spec.name] = true

            spec.dependencies.each do |dep|
              results = find_gems_with_sources(dep).reverse # local gems first

              results.each do |dep_spec, source_uri|
                next if seen[dep_spec.name]
                @specs_and_sources << [dep_spec, source_uri]
                dependency_list.add dep_spec
                to_do.push dep_spec
              end
            end
          end
        end

        @gems_to_install = dependency_list.dependency_order.reverse
      end