Class: Bolt::Notifiers::NotifyOsd

Inherits:
Object
  • Object
show all
Defined in:
lib/bolt/notifiers/notify_osd.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pars = {}) ⇒ NotifyOsd

Returns a new instance of NotifyOsd.



13
14
# File 'lib/bolt/notifiers/notify_osd.rb', line 13

def initialize(pars = {})
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



11
12
13
# File 'lib/bolt/notifiers/notify_osd.rb', line 11

def host
  @host
end

#use_growlnotifyObject

Returns the value of attribute use_growlnotify.



11
12
13
# File 'lib/bolt/notifiers/notify_osd.rb', line 11

def use_growlnotify
  @use_growlnotify
end

Instance Method Details

#error(name, description) ⇒ Object



53
54
55
56
# File 'lib/bolt/notifiers/notify_osd.rb', line 53

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



22
23
24
25
# File 'lib/bolt/notifiers/notify_osd.rb', line 22

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 = 'normal') ⇒ Object

generic notify method



17
18
19
# File 'lib/bolt/notifiers/notify_osd.rb', line 17

def notify(title, msg, img, pri = 'normal')
  system "notify-send -i #{img} -u #{pri} '#{title}' '#{msg}'"
end

#result(filename, results) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/bolt/notifiers/notify_osd.rb', line 34

def result(filename, results)
  message = results
  if results.match('example') #rspec
    if results.match('pending')
      icon = 'pending'
    elsif results.match('0 failures')
      icon = 'success'
    else
      icon = 'failed'
    end
  elsif (results.match('0 failures, 0 errors')) # test::unit
    icon = 'success'
  else
    icon = 'failed'
  end
  image_path = File.dirname(__FILE__) + "/../../../images/#{icon}.png"
  notify  "Test results for: #{filename}", message, image_path
end

#test_file_missing(filename) ⇒ Object

message to be displayed when test file is missing



28
29
30
31
32
# File 'lib/bolt/notifiers/notify_osd.rb', line 28

def test_file_missing(filename)
  image_path = File.dirname(__FILE__) + "/../../../images/failed.png"
  message = "The following test file could not be found: #{filename}"
  notify "Could not find test file", message, image_path
end