If you’ve ever been working on a Rails application and found yourself [stupidly] slipping in your testing, I have just the tool for you.
Using rake and rubyosa, you can now automatically post your Code to Test Ratio as your iChat status message—meaning you can now use shame and self-humiliation to keep you motivated.
After you’ve installed rubyosa, add shame.rake to your lib/tasks directory. The file contains:
require 'rbosa'
require 'code_statistics'
task :shame do
stats = CodeStatistics.new(*STATS_DIRECTORIES)
code = stats.send :calculate_code
tests = stats.send :calculate_tests
ichat = OSA.app('ichat')
msg = "Code To Test Ratio: 1:#{sprintf("%.1f", tests.to_f/code)}"
ichat.status_message = msg
$stderr.puts %|iChat status set to: #{msg.inspect}|
end