Sha256: 87de6b7c8a5aaa41263f6ae01ab09b7572212736146d371ccdc08b77b9b6cf26

Contents?: true

Size: 1.26 KB

Versions: 23

Compression:

Stored size: 1.26 KB

Contents

require 'open-uri'
require 'fileutils'

module PopplerTestUtils
  def ensure_dir(dir)
    FileUtils.mkdir_p(dir)
    dir
  end

  def test_dir
    File.expand_path(File.dirname(__FILE__))
  end

  def fixtures_dir
    ensure_dir(File.join(test_dir, "fixtures"))
  end

  def tmp_dir
    ensure_dir(File.join(test_dir, "tmp"))
  end

  def form_pdf
    file = File.join(fixtures_dir, "form.pdf")
    return file if File.exist?(file)
    pdf = open("https://www.irs.gov/pub/irs-pdf/fw9.pdf").read
    File.open(file, "wb") do |output|
      output.print(pdf)
    end
    file
  end

  def image_pdf
    File.join(fixtures_dir, "image.pdf")
  end

  def image_png
    File.join(fixtures_dir, "image.png")
  end

  def outline_pdf
    File.join(fixtures_dir, "outline.pdf")
  end

  def later_version?(major, minor, micro=nil)
    micro ||= 0
    (Poppler::BUILD_VERSION <=> [major, minor, micro]) >= 0
  end

  def only_poppler_version(major, minor, micro=nil)
    micro ||= 0
    unless later_version?(major, minor, micro)
      omit("Require Poppler >= #{major}.#{minor}.#{micro}")
    end
  end

  def only_old_poppler_version(major, minor, micro=nil)
    micro ||= 0
    if later_version?(major, minor, micro)
      omit("Require Poppler < #{major}.#{minor}.#{micro}")
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
poppler-3.1.8-x64-mingw32 test/poppler-test-utils.rb
poppler-3.1.8-x86-mingw32 test/poppler-test-utils.rb
poppler-3.1.8 test/poppler-test-utils.rb
poppler-3.1.7-x64-mingw32 test/poppler-test-utils.rb
poppler-3.1.7-x86-mingw32 test/poppler-test-utils.rb
poppler-3.1.7 test/poppler-test-utils.rb
poppler-3.1.6-x64-mingw32 test/poppler-test-utils.rb
poppler-3.1.6-x86-mingw32 test/poppler-test-utils.rb
poppler-3.1.6 test/poppler-test-utils.rb
poppler-3.1.5-x64-mingw32 test/poppler-test-utils.rb
poppler-3.1.5-x86-mingw32 test/poppler-test-utils.rb
poppler-3.1.4-x64-mingw32 test/poppler-test-utils.rb
poppler-3.1.4-x86-mingw32 test/poppler-test-utils.rb
poppler-3.1.4 test/poppler-test-utils.rb
poppler-3.1.3-x64-mingw32 test/poppler-test-utils.rb
poppler-3.1.3-x86-mingw32 test/poppler-test-utils.rb
poppler-3.1.3 test/poppler-test-utils.rb
poppler-3.1.2-x64-mingw32 test/poppler-test-utils.rb
poppler-3.1.2-x86-mingw32 test/poppler-test-utils.rb
poppler-3.1.2 test/poppler-test-utils.rb