Sha256: fbbc7980c3287f1373c6ca6ad8c2cacc81f93c46fefee25b37f645845eea95d6

Contents?: true

Size: 604 Bytes

Versions: 2

Compression:

Stored size: 604 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
        begin
          gz = Zlib::GzipWriter.new(dst, level, strategy)
          gz.write(@file.read)
        ensure
          gz.close
        end
        @file.rewind
        dst.open

        dst
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
paperclip-deflater-0.1.1 lib/paperclip/processors/gzip.rb
paperclip-deflater-0.1.0 lib/paperclip/processors/gzip.rb