Module: Autotest::Growl
- Defined in:
- lib/autotest/growl.rb
Overview
Autotest::Growl
FEATUERS:
-
Display autotest results as local or remote Growl notifications.
-
Clean the terminal on every test cycle while maintaining scrollback.
SYNOPSIS:
~/.autotest
require 'autotest/growl'
Constant Summary collapse
- GEM_PATH =
File.(File.join(File.dirname(__FILE__), '../..'))
- @@remote_notification =
false- @@hide_label =
false
Class Method Summary collapse
-
.growl(title, message, icon, priority = 0, stick = "") ⇒ Object
Display a message through Growl.
-
.hide_label=(boolean) ⇒ Object
Whether to display the label (default) or not.
-
.remote_notification=(boolean) ⇒ Object
Whether to use remote or local notificaton (default).
Instance Method Summary collapse
-
#ran_command ⇒ Object
Parse the test results and send them to Growl.
-
#run_command ⇒ Object
Set the label and clear the terminal.
Class Method Details
.growl(title, message, icon, priority = 0, stick = "") ⇒ Object
Display a message through Growl.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/autotest/growl.rb', line 35 def self.growl title, , icon, priority=0, stick="" growl = File.join(GEM_PATH, 'growl', 'growlnotify') image = File.join(ENV['HOME'], '.autotest-growl', "#{icon}.png") image = File.join(GEM_PATH, 'img', "#{icon}.png") unless File.exists?(image) if @@remote_notification system "#{growl} -H localhost -n autotest --image '#{image}' -p #{priority} -m #{.inspect} '#{title}' #{stick}" else system "#{growl} -n autotest --image '#{image}' -p #{priority} -m #{.inspect} '#{title}' #{stick}" end end |
.hide_label=(boolean) ⇒ Object
Whether to display the label (default) or not.
29 30 31 |
# File 'lib/autotest/growl.rb', line 29 def self.hide_label=(boolean) @@hide_label = boolean end |
.remote_notification=(boolean) ⇒ Object
Whether to use remote or local notificaton (default).
23 24 25 |
# File 'lib/autotest/growl.rb', line 23 def self.remote_notification=(boolean) @@remote_notification = boolean end |
Instance Method Details
#ran_command ⇒ Object
Parse the test results and send them to Growl.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/autotest/growl.rb', line 58 Autotest.add_hook :ran_command do |autotest| gist = autotest.results.grep(/\d+\s+(example|test)s?/).map {|s| s.gsub(/(\e.*?m|\n)/, '') }.join(" / ") if gist == '' growl @label + 'Cannot run tests.', '', 'error' else if gist =~ /[1-9]\d*\s+(failure|error)/ growl @label + 'Some tests have failed.', gist, 'failed' elsif gist =~ /pending/ growl @label + 'Some tests are pending.', gist, 'pending' @run_scenarios = true else growl @label + 'All tests have passed.', gist, 'passed' @run_scenarios = true end end false end |
#run_command ⇒ Object
Set the label and clear the terminal.
48 49 50 51 52 53 54 |
# File 'lib/autotest/growl.rb', line 48 Autotest.add_hook :run_command do @label = (@@hide_label) ? ('') : (File.basename(Dir.pwd).upcase + ': ') @run_scenarios = false print "\n"*2 + '-'*80 + "\n"*2 print "\e[2J\e[f" # clear the terminal false end |