tcocca / active_pdftk

ruby wrapper for the pdftk command line utility for working with editable pdf files
MIT License
46 stars 37 forks source link

Tempdir option #34

Open rylwin opened 12 years ago

rylwin commented 12 years ago

I needed to add a way to set the tmpdir used during bursts to avoid a race condition where the single pages would be overwritten. I implemented this by allowing users to pass a :tmpdir option. If none is provided, it defaults to Dir.tmpdir, which is what the code was previously using. Please merge this if you think this is a good addition.

Also, note that there is also a commit in this pull request that adds a require for 'digest'. I added this because I got errors when running the tests when digest was not required, so please cherry-pick around this commit if necessary.

And thanks for your work on active_pdftk!

tcocca commented 12 years ago

Hi, thanks for your interest in the project. I will definitely check out this PR. This is an interesting option to be able to set the tmpdir.

What OS/Ruby are you on where you are getting the digest errors? I have tested on os x 10.6 ree and 1.9.2 and ubuntu 1.8.7/1.9.2.

I would love to get a travis-ci set up for the project but I'm not sure how I could get the pdftk lib installed to be able to run the tests.

Thanks again, hopefully I'll have some time to spend on this project this weekend.

tcocca commented 12 years ago

The other thing I would love to be able to do is use Dir.chdir to get into the tmpdir, which is supported by popen3 in version 1.9.2 and up http://apidock.com/ruby/Open3/popen3 but I don't know how to make it work for 1.8.7 / ree w/out pre-pending it to the command? Any ideas?

~ Tom

rylwin commented 12 years ago

Upon further examination of the "digest" issue, I realized it was only required for the custom matchers, so I moved the requires to the spec_helper.rb. I'm running ubuntu and I had the issue with ree and 1.9.2. Not sure if this matters but I use rvm to manage my rubies. It's certainly strange that I'm getting those errors and you aren't.

travis-ci allows you to install packages via apt-get. Check out http://about.travis-ci.org/docs/user/build-configuration/. There is a section titled "Installing Packages Using apt" that may be of interest.

With respect to chdir, I played with this a bit and if you do:

Dir.chdir(tmpdir)
Open3.po...

Then this will use the provided tmpdir without prepending cmd. Now you can't pass :chdir like in 1.9.2, but it seems like you could use this code for all versions of ruby.