Module: Sprockets::Utils::Gzip::ZlibArchiver

Defined in:
lib/sprockets/utils/gzip.rb

Overview

Private: Generates a gzipped file based off of reference asset.

ZlibArchiver.call(file, source, mtime)

Compresses a given source using stdlib Zlib algorithm writes contents to the file passed in. Sets mtime of written file to passed in mtime

Constant Summary collapse

MTIME =
RUBY_VERSION >= "2.7" ? 0 : 1

Class Method Summary collapse

Class Method Details

.call(file, source) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/sprockets/utils/gzip.rb', line 15

def self.call(file, source)
  gz = Zlib::GzipWriter.new(file, Zlib::BEST_COMPRESSION)
  gz.mtime = MTIME
  gz.write(source)
  gz.close

  nil
end