shift (owner)

Revisions

gist: 214221 Download_button fork
public
Public Clone URL: git://gist.github.com/214221.git
Embed All Files: show embed
autotest-dbus.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'rbus'
 
module Autotest::DBus
  def self.notify title, msg, pri = 'Information', img = nil
    title += " in #{Dir.pwd.split(/\//).last(3).join("/")}"
    msg += " at #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}"
 
    bus = RBus.session_bus
    object = bus.get_object('org.freedesktop.Notifications','/org/freedesktop/Notifications')
    object.interface!('org.freedesktop.Notifications')
    object.Notify("AT: #{title}",
                  0,
                  "#{pri}",
                  "AT: #{title}",
                  "#{msg}",
                  [],
                  {},
                  -1)
    nil
  end
 
  Autotest.add_hook :initialize do |at|
    notify "autotest running", "Started"
  end
 
  Autotest.add_hook :red do |at|
    notify "Tests Failed", "#{at.files_to_test.size} tests failed", "Error"
  end
 
  Autotest.add_hook :green do |at|
    notify "Tests Passed", "Tests passed", "Information" if at.tainted
  end
 
  Autotest.add_hook :all_good do |at|
    notify "Tests Passed", "All tests passed", "Information" if at.tainted
  end
end