cucumber/gherkin — pull request #277 by ramonza (2013-09-30 01:07:51+00:00)
Title: Ensure PrettyFormatter outputs whole lines and flushed in between

I'm running cucumber via Cli in my gradle build and this patch addresses two issues I'm seeing:

1. Output isn't flushed timeously to the console: several screenfuls of output are buffered and output at once. This probably has to do with the way gradle is redirecting output. I have checked that after this patch, each scenario is printed as soon as it's complete (much better for feedback). Also, since when buffered the output goes to the terminal starting and stopping in essentially random locations, sometimes it stops while it's still in ANSI color mode and then that makes things very ugly (think screenfuls of bright green stack traces).
2. Indentation can get messed up if some logging or other output happens in the time between PrettyFormatter printing indentation and printing text.

This patch basically ensures that we only print entire lines at a time to the underlying Appendable and after each line, we attempt a flush.