Class: Bolt::Notifiers::Growl
- Inherits:
-
Object
- Object
- Bolt::Notifiers::Growl
- Defined in:
- lib/bolt/notifiers/growl.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#use_growlnotify ⇒ Object
Returns the value of attribute use_growlnotify.
Instance Method Summary collapse
- #error(name, description) ⇒ Object
-
#info(name, description) ⇒ Object
info message.
-
#initialize(pars = {}) ⇒ Growl
constructor
A new instance of Growl.
-
#notify(title, msg, img, pri = 0) ⇒ Object
generic notify method.
- #result(filename, results) ⇒ Object
-
#test_file_missing(filename) ⇒ Object
message to be displayed when test file is missing.
Constructor Details
#initialize(pars = {}) ⇒ Growl
Returns a new instance of Growl.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bolt/notifiers/growl.rb', line 15 def initialize(pars = {}) if Bolt['notifier_host'] @host = Bolt['notifier_host'] # load the gem only if required begin gem 'ruby-growl' require 'ruby-growl' rescue ::Gem::LoadError puts "** ERROR: Could not start growl network support. Install 'ruby-growl' gem to enable." @host = nil end end @use_growlnotify = false @use_growlnotify = true if pars[:use_growlnotify] or !@host end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
13 14 15 |
# File 'lib/bolt/notifiers/growl.rb', line 13 def host @host end |
#use_growlnotify ⇒ Object
Returns the value of attribute use_growlnotify.
13 14 15 |
# File 'lib/bolt/notifiers/growl.rb', line 13 def use_growlnotify @use_growlnotify end |
Instance Method Details
#error(name, description) ⇒ Object
75 76 77 78 |
# File 'lib/bolt/notifiers/growl.rb', line 75 def error(name, description) image_path = File.dirname(__FILE__) + "/../../../images/failed.png" notify name, description.to_s, image_path end |
#info(name, description) ⇒ Object
info message
42 43 44 45 |
# File 'lib/bolt/notifiers/growl.rb', line 42 def info(name, description) image_path = File.dirname(__FILE__) + "/../../../images/pending.png" notify name, description.to_s, image_path end |
#notify(title, msg, img, pri = 0) ⇒ Object
generic notify method
32 33 34 35 36 37 38 39 |
# File 'lib/bolt/notifiers/growl.rb', line 32 def notify(title, msg, img, pri = 0) if @use_growlnotify system("growlnotify -w -n bolt --image #{img} -p #{pri} -m #{msg.inspect} #{title} &") else g = ::Growl.new(@host, "bolt", ["notification"]) g.notify("notification", title, msg, pri) end end |
#result(filename, results) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/bolt/notifiers/growl.rb', line 54 def result(filename, results) = results if results and results.match('example') #rspec if results.match('pending') icon = 'pending' elsif results.match('0 failures') icon = 'success' else icon = 'failed' end elsif results and results.match('0 failures, 0 errors') # test::unit icon = 'success' elsif results and results.match(/([0-9]*) scenario(s*) \([0-9]+ passed\) ([0-9]*) step(s*) \([0-9]+ passed\)/) # cucumber icon = 'success' else icon = 'failed' end image_path = File.dirname(__FILE__) + "/../../../images/#{icon}.png" notify "Test results for: #{filename}", , image_path end |
#test_file_missing(filename) ⇒ Object
message to be displayed when test file is missing
48 49 50 51 52 |
# File 'lib/bolt/notifiers/growl.rb', line 48 def test_file_missing(filename) image_path = File.dirname(__FILE__) + "/../../../images/failed.png" = "The following test file could not be found: #{filename}" notify "Could not find test file", , image_path end |