Adding sound to your .autotest

Being a person with a keen auditory sense, I wanted my autotest to give me sonic feedback as well as colored growl images.

The sndplay utility I have compiled as a universal binary comes from snd (a handy app I used all the time when I was at CCRMA) sndplay has the nice feature of controlling the volume, which is important for toning down the annoyance factor.

Here are the fun audio files that I use in my .autotest. And here is the code:


require 'autotest/redgreen'

module Autotest::Growl
  def self.growl title, msg, img, pri=0, stick="" 
    system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}" 
  end

  Autotest.add_hook :ran_command do |at|
    output = at.results.to_s.slice(/(\d+).*errors/)
    if output =~ /ns.*[1-9]/
      system "~/bin/sndplay ~/Library/autotest/bonk.wav -volume 0.5" 
      growl "Test Results", "#{output}", '~/Library/autotest/rails_fail.png', 2 #, "-s" 
    else
      system "~/bin/sndplay ~/Library/autotest/om.aiff -volume 0.1"    
      growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png'
    end
  end
end

1/29/08 UPDATE: The autotest API has been updated to have sound playback hooks… examples here.

Just for Fun: echo meow | cat -a

Shane at gnufoo.org cleverly patched the cat utility to bind it with the Mac OS X speech synthesizer. :)

I just compiled a universal binary. It’s probably not a good idea to replace the one in /bin/, so put it in ~/bin and change your path accordingly, or name it something different like cat_talk.

Here is an example of cool stuff you can do with it to amuse your friends:
alias say_uptime “uptime | cut -d’ ’ -f3-7 | cat -a”
(bash users need an equals sign after say_uptime)

(I forget where I got this from originally, but I seem to remember the speech synthesizer behaving differently a few years back… like it said hours and minutes. I also used to be able to type gibberish and it made cool sounds instead of naming the letters)

Download the zip file containing the univeral binary and man page here.

actionmailer ActionView ajax alphadecimal audio autotest BDD blocks capistrano ssh ruby controller css dashboard widget delegate dog puppy naming name DRM email obfuscation exceptions factory pattern filemerge find and replace finder fink fixtures fun gem google maps helper helpers imagemagick Intertrust javascript logo math meetup model openssl OS X patch Pioneer Electronics plugin polymorphism prototype.js rails rake rmagick RSA encryption ruby script shoulda subversion SyncTV TDD testing textmate tricks unique hashes unix shell validation view yaml zebra stripes