Permalink
Browse files

Mad props to Chris Wanstrath for this convention

  • Loading branch information...
0 parents commit f1c8af8530789ebc0bc494ecf171755fecfc7464 Ryan McGeary committed May 11, 2008
@@ -0,0 +1,45 @@
+#require 'autotest/growl'
+require 'autotest/redgreen'
+require '~/.autotest.d/sound/sound.rb' # needs "sudo port install mpg321"
+Autotest::Sound.sound_path = "~/.autotest.d/sound/sound_fx/"
+
+module Autotest::Growl
+ def self.growl(title, message, pass = nil)
+ priority = pass ? -2 : 2
+ image = pass ? '~/.autotest.d/rails_ok.png' : '~/.autotest.d/rails_fail.png'
+ sticky = false # !pass
+ switches = "-s" if sticky
+ system "growlnotify -n autotest --image #{image} -p #{priority} -m #{message.inspect} #{title.inspect} #{switches}"
+ end
+
+ Autotest.add_hook :ran_command do |at|
+ results = at.results.last.chomp
+ if results.match(/^.* (\d+) failures, (\d+) errors$/)
+ error_count = $1.to_i + $2.to_i
+ if (error_count.zero?)
+ growl "Tests Passed", "#{results}", :pass # if at.tainted
+ else
+ growl "Tests Failed", "#{results}"
+ end
+ end
+ end
+
+ Autotest.add_hook :all_good do |at|
+ growl "Tests Passed", "All tests passed", :pass if at.tainted
+ end
+end
+
+class Autotest
+ def find_files_with_flymake
+ result = find_files_without_flymake
+ result.reject { |key, value| key =~ /_flymake\.rb$/ }
+ end
+ alias_method :find_files_without_flymake, :find_files
+ alias_method :find_files, :find_files_with_flymake
+end
+
+# Autotest.send(:alias_method, :real_make_test_cmd, :make_test_cmd)
+# Autotest.send(:define_method, :make_test_cmd) do |*args|
+# real_make_test_cmd(*args).sub('test/unit', %[rubygems -e "require 'redgreen'"])
+# end
+
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,29 @@
+Sounds effects for autotest
+http://fozworks.com/2007/7/28/autotest-sound-effects
+
+This plugin triggers sound files for autotest events.
+
+It requires that you have a command-line mp3 player installed.
+On OSX and Linux, I suggest mpg321, which is available from most package managers (including macports). For fink users, try madplay.
+
+On Windows, try the mplayer command-line app, which can be downloaded from:
+
+ http://www.mplayerhq.hu/design7/dload.html
+
+In you ~/.autotest file, load the plugin and set the sounds location:
+
+ require '~/autotest/sound/sound.rb'
+ Autotest::Sound.sound_path = "~/autotest/sound/sound_fx/"
+
+If you are on Windows, you will need some additional stuff:
+
+ Autotest::Sound.sound_app = "call c:/mplayer/mplayer.exe -really-quiet"
+ Autotest::Sound.process_devnull = "> c:/Windows/Temp/_mplayer_tmp.txt"
+ Autotest::Sound.process_bg = ""
+
+(thanks to John for the Windows info and jinjing for suggesting madplay)
+
+All sounds in sound_fx were created by me, free for your use. See the README and LICENSE in the sound_fx dir.
+
+- foz
+
@@ -0,0 +1,43 @@
+# Sound effects for autotest
+# http://fozworks.com/2007/7/28/autotest-sound-effects
+
+# This plugin will trigger sounds. You will need a command-line
+# sound player to do this. See the README file for more details.
+#
+# 1.2 - doc patch for bad path 2007-08-01
+# 1.1 - updated for Windows 2007-07-31
+# 1.0 - initial release 2007-07-28
+
+module Autotest::Sound
+ @@sound_path = ''
+ @@sound_app = 'mpg321'
+ @@process_devnull = '> /dev/null 2>&1'
+ @@process_bg = '&'
+
+ def self.sound_path= o
+ @@sound_path = o
+ end
+
+ def self.sound_app= o
+ @@sound_app = o
+ end
+
+ def self.process_devnull= o
+ @@process_devnull = o
+ end
+
+ def self.process_bg= o
+ @@process_bg = o
+ end
+
+ def self.playsound file
+ cmd = "#{@@sound_app} #{@@sound_path + file} #{@@process_devnull} #{@@process_bg}"
+ system cmd
+ end
+
+ [:run, :red, :green, :quit, :run_command, :ran_command].each do |hook|
+ Autotest.add_hook hook do |at|
+ playsound "#{hook.to_s}.mp3" unless $TESTING
+ end
+ end
+end
@@ -0,0 +1,29 @@
+Sounds effects for autotest
+http://fozworks.com/2007/7/28/autotest-sound-effects
+
+This plugin triggers sound files for autotest events.
+
+It requires that you have a command-line mp3 player installed.
+On OSX and Linux, I suggest mpg321, which is available from most package managers (including macports). For fink users, try madplay.
+
+On Windows, try the mplayer command-line app, which can be downloaded from:
+
+ http://www.mplayerhq.hu/design7/dload.html
+
+In you ~/.autotest file, load the plugin and set the sounds location:
+
+ require '~/autotest/sound/sound.rb'
+ Autotest::Sound.sound_path = "~/autotest/sound/sound_fx/"
+
+If you are on Windows, you will need some additional stuff:
+
+ Autotest::Sound.sound_app = "call c:/mplayer/mplayer.exe -really-quiet"
+ Autotest::Sound.process_devnull = "> c:/Windows/Temp/_mplayer_tmp.txt"
+ Autotest::Sound.process_bg = ""
+
+(thanks to John for the Windows info and jinjing for suggesting madplay)
+
+All sounds in sound_fx were created by me, free for your use. See the README and LICENSE in the sound_fx dir.
+
+- foz
+
@@ -0,0 +1,43 @@
+# Sound effects for autotest
+# http://fozworks.com/2007/7/28/autotest-sound-effects
+
+# This plugin will trigger sounds. You will need a command-line
+# sound player to do this. See the README file for more details.
+#
+# 1.2 - doc patch for bad path 2007-08-01
+# 1.1 - updated for Windows 2007-07-31
+# 1.0 - initial release 2007-07-28
+
+module Autotest::Sound
+ @@sound_path = ''
+ @@sound_app = 'mpg321'
+ @@process_devnull = '> /dev/null 2>&1'
+ @@process_bg = '&'
+
+ def self.sound_path= o
+ @@sound_path = o
+ end
+
+ def self.sound_app= o
+ @@sound_app = o
+ end
+
+ def self.process_devnull= o
+ @@process_devnull = o
+ end
+
+ def self.process_bg= o
+ @@process_bg = o
+ end
+
+ def self.playsound file
+ cmd = "#{@@sound_app} #{@@sound_path + file} #{@@process_devnull} #{@@process_bg}"
+ system cmd
+ end
+
+ [:run, :red, :green, :quit, :run_command, :ran_command].each do |hook|
+ Autotest.add_hook hook do |at|
+ playsound "#{hook.to_s}.mp3" unless $TESTING
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit f1c8af8

Please sign in to comment.