Been longer than I intended between updates. Been busy at work, but I’ve managed to keep the writing streak up. Today was day 57 (i.e., ~57 hours of work). I’m amazed at what I’ve got done with so little time spent consciously working on it. Really amazing what can be accomplished when you’re focused. Now, if I could figure out how to write for 30 - 40 hours a week, I’d actually be able to turn out books pretty quickly. :-)
The last few days haven’t been writing explicitly, they’ve been coding. Kind of cool bit of code, so I thought I’d share.
There’s @code@ blocks in Prag’s PML that contain the code. Writing unit tests for straight code is simple enough, but I needed a way to test code that’s supposed to be run in the REPL. Since I’m working with Node and the 0.3.x branch, there’s no guarantees that what I write today will be exactly by the time we’re ready to go to print.
To fix that, I wrote a script that parses the blocks of code that are flagged as runnable in Node and figures out what code is supposed to be run and what is output. Once it has that, it fires up a new window in tmux running Node then executes all of the code. After it’s finished, it saves the window’s output and compares it to what’s in the book. There’s some extra niceties like fuzzy matching (for example, dates – I match that the output was the same length, but that’s it) and the ability to continue between examples.
No, it wasn’t written in Node. :-)