westoque/phantomjs.rb — pull request #8 by alwold (2013-09-03 06:51:05+00:00)
Title: Complex parameters

Hello,
I'm using this gem in my app, and I have a use case where I need to be able to pass a blank parameter to my PhantomJS script. When I pass the blank param, it wasn't making it into my script. I was able to get it working by quoting the strings I was passing into the gem like this:

info = JSON.parse(Phantomjs.run(script, term, "'#{course}'", "'#{section}'"))

...which is kind of ugly, and would break if there were any quotes in the params. I reworked the code a bit to use IO::popen with the array version of specifying command, and got rid of the backtick way of calling it, since it's difficult to pass the parameters into the shell cleanly with backticks.

I also added some tests for these use cases.

Hopefully you'll find this to be useful. If you want me to change anything, just let me know.

Thanks!

-Al