ywen/pivotal_to_pdf — pull request #13 by mogul (2012-01-31 07:40:17+00:00)
Title: Added support for selecting stories by label

I've implemented selecting stories by label. It works fine, but I had to make more changes than I would have liked:
* There's a bug in Pivotal Tracker's API when using ActiveResources with Story.find() that results in no stories being returned. It was incredibly frustrating; see pt-workarounds.rb for a pointer to details and the workaround.
* I had a hell of a time debugging what was wrong as I'm a Ruby newbie and I don't know anything about ActiveResource. I left the ActiveResource debugging output hook in, but commented out in pivotal_to_pdf.rb, for the next hapless soul.
* Searching by label just gets back an array of stories. So the PDF writer no longer has an implicitly-useful ID to use for the name of the PDF file as it does for Story and Iteration. Instead, I passed this parameter in to write_to. Now it's explicitly supplied by the caller, which seems more appropriate anyway. Previously you would get the iteration number in the filename when using current_iteration, but now you get current.pdf. (You may want to document this, or make it use the current iteration so the behavior doesn't change.)
* I'm not happy with the stacked ternary operators in pdf_writer.rb to grab @stories, but I don't know enough Ruby to do it better. It would probably be better if the PDF writer just took an array of stories in the constructor... This would be more in-keeping with SRP.
* I wrote tests for the new code just by copying what exists... They pass, but I don't know much about TDD, much less Ruby's way of doing it, so I'm not sure if there are better tests to be written.

Be kind to me, this was the first code I've ever written in Ruby. :)