Sha256: 71b6c380480a1374c97172545a7834b1cdd4c440c48f591b0558dfa7bec12602

Contents?: true

Size: 770 Bytes

Versions: 7

Compression:

Stored size: 770 Bytes

Contents

require_relative 'deflater_base'

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

      def make
        level       = @deflate_options[:level]
        window_bits = @deflate_options[:window_bits]
        memlevel    = @deflate_options[:memlevel]
        strategy    = @deflate_options[:strategy]

        dst = create_tempfile
        begin
          zd = Zlib::Deflate.new(level, window_bits, memlevel, strategy)
          dst.write zd.deflate(@file.read)
        ensure
          zd.close
        end
        @file.rewind
        dst.flush
        dst.rewind

        dst
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
paperclip-deflater-0.1.6 lib/paperclip/processors/deflater.rb
paperclip-deflater-0.1.5 lib/paperclip/processors/deflater.rb
paperclip-deflater-0.1.4 lib/paperclip/processors/deflater.rb
paperclip-deflater-0.1.3 lib/paperclip/processors/deflater.rb
paperclip-deflater-0.1.2 lib/paperclip/processors/deflater.rb
paperclip-deflater-0.1.1 lib/paperclip/processors/deflater.rb
paperclip-deflater-0.1.0 lib/paperclip/processors/deflater.rb