Sha256: e004ebbcd519bf549b3e392f8ef3e013e9e133794fa3c543704745d5ecb34bf8

Contents?: true

Size: 866 Bytes

Versions: 29

Compression:

Stored size: 866 Bytes

Contents

require 'sprockets/exporters/base'
require 'sprockets/utils/gzip'

module Sprockets
  module Exporters
    # Generates a `.gz` file using the zlib algorithm built into
    # Ruby's standard library.
    class ZlibExporter < Exporters::Base
      def setup
        @gzip_target = "#{ target }.gz"
        @gzip = Sprockets::Utils::Gzip.new(asset, archiver: Utils::Gzip::ZlibArchiver)
      end

      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

      def call
        write(@gzip_target) do |file|
          @gzip.compress(file, target)
        end
      end
    end
  end
end

Version data entries

29 entries across 28 versions & 10 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/sprockets-4.2.1/lib/sprockets/exporters/zlib_exporter.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/exporters/zlib_exporter.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/sprockets-4.2.1/lib/sprockets/exporters/zlib_exporter.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/exporters/zlib_exporter.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/sprockets-4.1.1/lib/sprockets/exporters/zlib_exporter.rb
sprockets-4.2.1 lib/sprockets/exporters/zlib_exporter.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/sprockets-4.1.1/lib/sprockets/exporters/zlib_exporter.rb
sprockets-4.2.0 lib/sprockets/exporters/zlib_exporter.rb
sprockets-4.1.1 lib/sprockets/exporters/zlib_exporter.rb
sprockets-4.1.0 lib/sprockets/exporters/zlib_exporter.rb
sprockets-4.0.3 lib/sprockets/exporters/zlib_exporter.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/exporters/zlib_exporter.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/exporters/zlib_exporter.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/exporters/zlib_exporter.rb
sprockets-4.0.2 lib/sprockets/exporters/zlib_exporter.rb
sprockets-4.0.1 lib/sprockets/exporters/zlib_exporter.rb
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/sprockets-4.0.0/lib/sprockets/exporters/zlib_exporter.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/sprockets-4.0.0/lib/sprockets/exporters/zlib_exporter.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/sprockets-4.0.0/lib/sprockets/exporters/zlib_exporter.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/sprockets-4.0.0/lib/sprockets/exporters/zlib_exporter.rb