Sha256: 27ade1be64d0a2555dd603d91fc95654ea95a18f16c2b4517638fbeeb53b5f5b

Contents?: true

Size: 617 Bytes

Versions: 3

Compression:

Stored size: 617 Bytes

Contents

require_relative 'deflater_base'

module Paperclip
  module Processors
    class Gzip < DeflaterBase
      def initialize(file, options = {}, attachment = nil)
        super
        @gzip_options = @options[:gzip_options] || {}
      end

      def make
        level       = @gzip_options[:level]
        strategy    = @gzip_options[:strategy]

        dst = create_tempfile
        Zlib::GzipWriter.open(dst, level, strategy) do |gz|
          while chunk = @file.read(16 * 1024) do
            gz.write chunk
          end
        end
        @file.rewind
        dst.open

        dst
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
paperclip-deflater-0.1.6 lib/paperclip/processors/gzip.rb
paperclip-deflater-0.1.5 lib/paperclip/processors/gzip.rb
paperclip-deflater-0.1.4 lib/paperclip/processors/gzip.rb