Sha256: 9d5c8938d063826f9a823e2065df745f9c872d8109c87a5420add7c92c3ad703

Contents?: true

Size: 646 Bytes

Versions: 1

Compression:

Stored size: 646 Bytes

Contents

module Gjman
  module PDF
    class Matcher < Base
      class << self

        def test(pdf_x, pdf_y)
          begin
            tmp_x, tmp_y = uncompress(pdf_x, pdf_y)
            ! [:same_fonts?, :same_images?, :same_contents?].
              any?{|test| !send(test, tmp_x, tmp_y) }
          ensure
            FileSystem.trash_tmp_files
          end
        end

        private

          def uncompress(*pdfs)
            [pdfs].flatten.map do |pdf|
              tmp = FileSystem.tmp_file([Digest::MD5.hexdigest(pdf),'.pdf']).path
              PDF.uncompress(pdf, :to => tmp)
            end
          end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gjman-0.1.0 lib/gjman/pdf/matcher.rb