generate_gzipped()
public
Compress the search_index.js file using gzip
Show source
def generate_gzipped
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
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.to_s
gz.write search_index
gz.close
end
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.to_s
gz.write data
gz.close
end
end
end
end