diff --git a/.travis.yml b/.travis.yml index 227f158..f8f9d5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,8 @@ language: crystal script: - crystal spec - crystal tool format --check + +addons: + apt: + packages: + - pdftk \ No newline at end of file diff --git a/spec/pdftk_spec.cr b/spec/pdftk_spec.cr index 1b7903a..1fe6664 100644 --- a/spec/pdftk_spec.cr +++ b/spec/pdftk_spec.cr @@ -3,8 +3,6 @@ require "./spec_helper" describe Muse::Dl::Pdftk do it "should find pdftk binary" do pdftk = Muse::Dl::Pdftk.new - if pdftk.binary - pdftk.binary.should eq "/usr/sbin/pdftk" - end + pdftk.ready?.should eq true end end diff --git a/src/pdftk.cr b/src/pdftk.cr index 5ab02a4..8403edc 100644 --- a/src/pdftk.cr +++ b/src/pdftk.cr @@ -7,14 +7,15 @@ require "dir" module Muse::Dl class Pdftk PDFTK_BINARY_NAME = "pdftk" - @binary = "/usr/sbin/pdftk" + @binary : String | Nil @tmp_file_path : String - getter :binary + def ready? + @binary != nil + end def initialize(tmp_file_path : String = Dir.tempdir) @tmp_file_path = tmp_file_path - possible_binary = Process.find_executable(Pdftk::PDFTK_BINARY_NAME) if possible_binary @binary = possible_binary