class RDoc::Generator::JsonIndex

def generate_gzipped

def generate_gzipped
  return if @options.dry_run or not defined?(Zlib)
  debug_msg "Compressing generated JSON index"
  out_dir = @base_dir + @options.op_dir
  search_index_file = out_dir + SEARCH_INDEX_FILE
  outfile           = out_dir + "#{search_index_file}.gz"
  debug_msg "Reading the JSON index file from %s" % search_index_file
  search_index = search_index_file.read(mode: 'r:utf-8')
  debug_msg "Writing gzipped search index to %s" % outfile
  Zlib::GzipWriter.open(outfile) do |gz|
    gz.mtime = File.mtime(search_index_file)
    gz.orig_name = search_index_file.basename.to_s
    gz.write search_index
    gz.close
  end
  # GZip the rest of the js files
  Dir.chdir @template_dir do
    Dir['**/*.js'].each do |source|
      dest = out_dir + source
      outfile = out_dir + "#{dest}.gz"
      debug_msg "Reading the original js file from %s" % dest
      data = dest.read
      debug_msg "Writing gzipped file to %s" % outfile
      Zlib::GzipWriter.open(outfile) do |gz|
        gz.mtime = File.mtime(dest)
        gz.orig_name = dest.basename.to_s
        gz.write data
        gz.close
      end
    end
  end
end