Module: Autotest::NotifyOSD

Defined in:
lib/autotest/notify-osd.rb

Overview

Autotest::NotifyOSD

FEATUERS:

  • Display autotest results as NotifyOSD notifications.

  • Clean the terminal on every test cycle while maintaining scrollback.

SYNOPSIS:

~/.autotest

require 'autotest/notify-osd'

Constant Summary collapse

GEM_PATH =
File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
@@remote_notification =
false
@@one_notification_per_run =
false
@@clear_terminal =
true
@@hide_label =
false
@@show_modified_files =
false

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.clear_terminal=(boolean) ⇒ Object

Whether to clear the terminal before running tests (default) or not.



44
45
46
# File 'lib/autotest/notify-osd.rb', line 44

def self.clear_terminal=(boolean)
  @@clear_terminal = boolean
end

.hide_label=(boolean) ⇒ Object

Whether to display the label (default) or not.



50
51
52
# File 'lib/autotest/notify-osd.rb', line 50

def self.hide_label=(boolean)
  @@hide_label = boolean
end

.notify_osd(title, message, icon, priority = 0, stick = "") ⇒ Object

Display a message through Growl.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/autotest/notify-osd.rb', line 62

def self.notify_osd(title, message, icon, priority=0, stick="")
  image = File.join(ENV['HOME'], '.autotest-notify-osd', "#{icon}.png")
  image = File.join(GEM_PATH, 'img', "#{icon}.png") unless File.exists?(image)

  # Translate the priority
  case priority
  when 0,1
    pri = 'normal'
  when 2
    pri = 'critical'
  else
    pri = 'low'
  end

  system %(notify-send -i '#{image}' -u #{pri} '#{title}' '#{message}')
end

.one_notification_per_run=(boolean) ⇒ Object

Whether to limit the number of notifications per run to one or not (default).



38
39
40
# File 'lib/autotest/notify-osd.rb', line 38

def self.one_notification_per_run=(boolean)
  @@one_notification_per_run = boolean
end

.remote_notification=(boolean) ⇒ Object

Whether to use remote or local notificaton (default).



32
33
34
# File 'lib/autotest/notify-osd.rb', line 32

def self.remote_notification=(boolean)
  @@remote_notification = boolean
end

.show_modified_files=(boolean) ⇒ Object

Whether to display the modified files or not (default).



56
57
58
# File 'lib/autotest/notify-osd.rb', line 56

def self.show_modified_files=(boolean)
  @@show_modified_files = boolean
end

Instance Method Details

#ran_commandObject

Parse the RSpec and Test::Unit results and send them to Growl.



95
96
97
98
# File 'lib/autotest/notify-osd.rb', line 95

Autotest.add_hook :ran_command do |autotest|
  print "\nThis gem has been deprecated and replaced by autotest-growl\n"
  false
end

#ran_featuresObject

Parse the Cucumber results and sent them to Growl.



102
103
104
105
# File 'lib/autotest/notify-osd.rb', line 102

Autotest.add_hook :ran_features do |autotest|
  print "\nThis gem has been deprecated and replaced by autotest-growl\n"
  false
end

#run_commandObject

Set the label and clear the terminal.



88
89
90
91
# File 'lib/autotest/notify-osd.rb', line 88

Autotest.add_hook :run_command do
  print "\nThis gem has been deprecated and replaced by autotest-growl\n"
  false
end

#updatedObject

Display the modified files.



81
82
83
84
# File 'lib/autotest/notify-osd.rb', line 81

Autotest.add_hook :updated do |autotest, modified|
  print "\nThis gem has been deprecated and replaced by autotest-growl\n"
  false
end