    # File lib/rubygems/package/tar_output.rb, line 63
      def add_gem_contents
        @tar_writer.add_file "data.tar.gz", 0644 do |inner|
          sio = @signer ? StringIO.new : nil
          Zlib::GzipWriter.wrap(sio || inner) do |os|

            Gem::Package::TarWriter.new os do |data_tar_writer|
              def data_tar_writer.metadata() @metadata end
              def data_tar_writer.metadata=(metadata) @metadata = metadata end

              yield data_tar_writer

              @metadata = data_tar_writer.metadata
            end
          end

          # if we have a signing key, then sign the data
          # digest and return the signature
          if @signer then
            digest = Gem::Security::OPT[:dgst_algo].digest sio.string
            @data_signature = @signer.sign digest
            inner.write sio.string
          end
        end

        self
      end