collect_specs (Gem::Indexer)

    # File lib/rubygems/indexer.rb, line 413
      def collect_specs(gems = gem_file_list)
        index = Gem::SourceIndex.new

        progress = ui.progress_reporter gems.size,
                                        "Loading #{gems.size} gems from #{@dest_directory}",
                                        "Loaded all gems"

        Gem.time 'loaded' do
          gems.each do |gemfile|
            if File.size(gemfile.to_s) == 0 then
              alert_warning "Skipping zero-length gem: #{gemfile}"
              next
            end

            begin
              spec = Gem::Format.from_file_by_path(gemfile).spec
              spec.loaded_from = gemfile

              unless gemfile =~ /\/#{Regexp.escape spec.original_name}.*\.gem\z/i then
                expected_name = spec.full_name
                expected_name << " (#{spec.original_name})" if
                  spec.original_name != spec.full_name
                alert_warning "Skipping misnamed gem: #{gemfile} should be named #{expected_name}"
                next
              end

              abbreviate spec
              sanitize spec

              index.add_spec spec, spec.original_name

              progress.updated spec.original_name

            rescue SignalException => e
              alert_error "Received signal, exiting"
              raise
            rescue Exception => e
              alert_error "Unable to process #{gemfile}\n#{e.message} (#{e.class})\n\t#{e.backtrace.join "\n\t"}"
            end
          end

          progress.done
        end

        index
      end