Class: 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 Attribute Summary
Attributes inherited from Base
#asset, #directory, #environment, #target
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Sprockets::Exporters::Base
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 |