Author: Nat Ritmeyer (www.natontesting.com)
I remember one colleague who used to often type ‘ptus’ into his ruby code instead of ‘puts’. Every time he made the mistake, he would explode in a rage with himself when the code ran and failed: “Just because of a stupid [expletive] typo!!!”. He could never break the habit, so we wrote a monkey patch that would allow his code to run, but the line of code containing the offending typo would be flagged. “Everyone’s a winner”: his code would run, his typo would be flagged, and since the monkey patch lived on his machine and never got checked in (svn ignore!), ‘ptus’ didn’t creep into the codebase.
A few years on, I now find myself typing ‘ptus’ enough for it to begin to irritate me. Age related, maybe. So I’ve rewritten the code and bundled it up properly into this gem.
Not difficult:
gem install ptus
Simply require the gem, and make as many ‘ptus’ typos as you want!
require 'rubygems' require 'ptus' puts "This is right" ptus "This is wrong" #=> Used to cause your app to die... puts "This is also right"
Writing code like the above will no longer kill your app at runtime; instead it will run just fine, but you’ll get the following warning:
This is right Change 'ptus' to 'puts' here: my_file.rb:5:in `<main>' This is wrong This is also right
Though this gem is partly in in jest, it would sadly be useful to a lot of people ;)