A couple times a year Paperless Post has a Stampy Day (in honor of Stampy — that’s him right there in the top-right corner), where the entire company works together to hack on silly, useful, inspiring, experimental (or ideally, all of the above) things. For a recent Stampy Day, I attempted to add the missing Rails 2 support to the Spin gem.
If you’re not familiar with Spin, it’s a great example of how UNIX fundamentals (namely, fork(2)
, sockets, and signals) can be applied in Ruby to cleanly and elegantly solve a modern web development problem: making unit testing fast and fun. It does this by starting a Rails process, then forking off each time you wish to run a test. When your test is finished running in the fork and exits, you get to start again with the original and pristine Rails process, ready for your next test.
The gem I developed is named Rails2Preload, and is now available on GitHub and on RubyGems.org. The gem uses Spin’s hook system to patch the Rails 2 initialization method into two phases: preload and postload. We hope you find it useful! Bug reports, fixes, and contributions are welcome.
The author of the Spin gem is Jesse Storimer, who’s also (by no coincidence, I’m sure!) the author of Working With Unix Processes. If you happen to feel like you missed UNIX 101 like me, I’d recommend it.