Class: Sprockets::Exporters::ZlibExporter
- Inherits:
-
Exporters::Base
- Object
- Exporters::Base
- Sprockets::Exporters::ZlibExporter
- Defined in:
- lib/sprockets/exporters/zlib_exporter.rb
Overview
Generates a .gz file using the zlib algorithm built into
Ruby's standard library.
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
26 27 28 29 30 |
# File 'lib/sprockets/exporters/zlib_exporter.rb', line 26 def call write(@gzip_target) do |file| @gzip.compress(file, target) end end |
#setup ⇒ Object
9 10 11 12 |
# File 'lib/sprockets/exporters/zlib_exporter.rb', line 9 def setup @gzip_target = "#{ target }.gz" @gzip = Sprockets::Utils::Gzip.new(asset, archiver: Utils::Gzip::ZlibArchiver) end |
#skip?(logger) ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sprockets/exporters/zlib_exporter.rb', line 14 def skip?(logger) return true if environment.skip_gzip? return true if @gzip.cannot_compress? if ::File.exist?(@gzip_target) logger.debug "Skipping #{ @gzip_target }, already exists" true else logger.info "Writing #{ @gzip_target }" false end end |