def tar(root, slip)
      io = StringIO.new('', 'r+b')
      Gem::Package::TarWriter.new(io) do |tar|
        slip.each do |original_file, tarball_file|
          mode = File.stat(original_file).mode

          if File.directory?(original_file)
            tar.mkdir(tarball_file, mode)
          else
            tar.add_file(tarball_file, mode) do |tf|
              File.open(original_file, 'rb') { |f| tf.write(f.read) }
            end
          end
        end
      end

      io.rewind
      io
    end
def tar(root, slip)
      io = StringIO.new('', 'r+b')
      Gem::Package::TarWriter.new(io) do |tar|
        slip.each do |original_file, tarball_file|
          mode = File.stat(original_file).mode

          if File.directory?(original_file)
            tar.mkdir(tarball_file, mode)
          else
            tar.add_file(tarball_file, mode) do |tf|
              File.open(original_file, 'rb') { |f| tf.write(f.read) }
            end
          end
        end
      end

      io.rewind
      io
    end
Create a tar file from the given root and packaging slip

 @param [String] root
   the root where the tar files are being created
 @param [Hash<String, String>] slip
   the map from physical file path to tarball file path

 @return [StringIO]
   the io object that contains the tarball contents