carlosbrando-autotest-notification 1.8.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/autotest-notification.gemspec +2 -2
- data/config/requirements.rb +1 -1
- data/lib/autotest_notification.rb +26 -11
- data/lib/autotest_notification/buuf.rb +1 -1
- data/lib/autotest_notification/cygwin.rb +1 -1
- data/lib/autotest_notification/doom.rb +1 -1
- data/lib/autotest_notification/linux.rb +11 -8
- data/lib/autotest_notification/version.rb +1 -1
- data/test/autotest_notification/test_linux.rb +6 -6
- data/test/test_autotest_notification.rb +1 -1
- metadata +2 -2
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{autotest-notification}
|
5
|
-
s.version = "1.8.
|
5
|
+
s.version = "1.8.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Carlos Brando", "Rodrigo Urubatan", "Alexandre da Silva", "Carlos J\303\272nior", "Davis Zanetti Cabral", "Marcos Tapaj\303\263s", "Thiago Pradi", "Oz\303\251ias Sant'ana", "Samuel Flores", "Diego Carrion"]
|
9
|
-
s.date = %q{2009-01
|
9
|
+
s.date = %q{2009-02-01}
|
10
10
|
s.description = %q{This gem set the autotest (ZenTest) to send messages to software as Growl, LibNotify, and Snarl, displaying a window with the results.}
|
11
11
|
s.email = ["autotest-notification@carlosbrando.com"]
|
12
12
|
s.executables = ["an-install", "an-uninstall", "playsound"]
|
data/config/requirements.rb
CHANGED
@@ -4,7 +4,7 @@ include FileUtils
|
|
4
4
|
require 'rubygems'
|
5
5
|
%w[rake hoe newgem rubigen ZenTest].each do |req_gem|
|
6
6
|
begin
|
7
|
-
require req_gem
|
7
|
+
require req_gem.downcase
|
8
8
|
rescue LoadError
|
9
9
|
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
10
|
puts "Installation: gem install #{req_gem} -y"
|
@@ -1,13 +1,26 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__))
|
2
|
-
%w{ linux mac windows cygwin doom buuf }.each { |x| require "autotest_notification/#{x}" }
|
3
2
|
|
4
3
|
module AutotestNotification
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
class Config
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_reader :images_directory
|
8
|
+
attr_accessor :success_image, :fail_image, :pending_image, :expiration_in_seconds
|
9
|
+
|
10
|
+
def images_directory=(path)
|
11
|
+
@images_directory = File.expand_path(path)
|
12
|
+
|
13
|
+
@success_image = "#{@images_directory}/pass.png"
|
14
|
+
@fail_image = "#{@images_directory}/fail.png"
|
15
|
+
@pending_image = "#{@images_directory}/pending.png"
|
16
|
+
end
|
17
|
+
end
|
9
18
|
|
10
|
-
|
19
|
+
self.images_directory = "#{File.dirname(__FILE__)}/../../images/"
|
20
|
+
|
21
|
+
self.expiration_in_seconds = 3
|
22
|
+
|
23
|
+
end
|
11
24
|
|
12
25
|
Autotest.add_hook :ran_command do |at|
|
13
26
|
result = at.results.is_a?(Array) ? at.results.last : at.results.split("\n").last
|
@@ -29,11 +42,11 @@ module AutotestNotification
|
|
29
42
|
end
|
30
43
|
|
31
44
|
if @failures > 0 || @errors > 0
|
32
|
-
notify "FAIL", msg,
|
45
|
+
notify "FAIL", msg, Config.fail_image, @tests + @examples, @failures + @errors, 2
|
33
46
|
elsif PENDING && @pendings > 0
|
34
|
-
notify "Pending", msg,
|
47
|
+
notify "Pending", msg, Config.pending_image, @tests + @examples, @failures + @errors, 1
|
35
48
|
else
|
36
|
-
notify "Pass", msg,
|
49
|
+
notify "Pass", msg, Config.success_image, @tests + @examples, 0, -2
|
37
50
|
end
|
38
51
|
|
39
52
|
puts "\e[#{code}m#{'=' * 80}\e[0m\n\n"
|
@@ -41,14 +54,14 @@ module AutotestNotification
|
|
41
54
|
end
|
42
55
|
|
43
56
|
class << self
|
44
|
-
def notify(title, msg, img =
|
57
|
+
def notify(title, msg, img = Config.success_image, total = 1, failures = 0, priority = 0)
|
45
58
|
|
46
59
|
img = Doom.image(total, failures) if DOOM_EDITION
|
47
60
|
img = Buuf.image(title.downcase) if BUUF
|
48
61
|
|
49
62
|
case RUBY_PLATFORM
|
50
63
|
when /linux/
|
51
|
-
Linux.notify(title, msg, img, total, failures)
|
64
|
+
Linux.notify(title, msg, img, total, failures, priority)
|
52
65
|
when /darwin/
|
53
66
|
Mac.notify(title, msg, img, total, failures, priority)
|
54
67
|
when /cygwin/
|
@@ -71,3 +84,5 @@ module AutotestNotification
|
|
71
84
|
end
|
72
85
|
end
|
73
86
|
end
|
87
|
+
|
88
|
+
%w{ linux mac windows cygwin doom buuf }.each { |x| require "autotest_notification/#{x}" }
|
@@ -3,7 +3,7 @@ module AutotestNotification
|
|
3
3
|
class << self
|
4
4
|
def notify(title, msg, img)
|
5
5
|
img = get_image_path(img).strip
|
6
|
-
system "sncmd /m '#{title}' '#{msg}' '#{img}' /t #{
|
6
|
+
system "sncmd /m '#{title}' '#{msg}' '#{img}' /t #{Config.expiration_in_seconds}"
|
7
7
|
end
|
8
8
|
|
9
9
|
def get_image_path(img)
|
@@ -2,9 +2,11 @@ module AutotestNotification
|
|
2
2
|
class Linux
|
3
3
|
class << self
|
4
4
|
|
5
|
-
def notify(title, msg, img, total = 1, failures = 0)
|
5
|
+
def notify(title, msg, img, total = 1, failures = 0, priority = 0)
|
6
|
+
Config.expiration_in_seconds = 0 if failures > 0 && STICKY
|
7
|
+
|
6
8
|
if has_notify?
|
7
|
-
notify_send(title, msg, img)
|
9
|
+
notify_send(title, msg, img, priority)
|
8
10
|
elsif has_zenity?
|
9
11
|
zenity(title, msg, img)
|
10
12
|
elsif has_kdialog?
|
@@ -17,23 +19,24 @@ module AutotestNotification
|
|
17
19
|
protected
|
18
20
|
|
19
21
|
def has_notify?
|
20
|
-
system "which notify-send
|
22
|
+
system "which notify-send > /dev/null 2>&1"
|
21
23
|
end
|
22
24
|
|
23
25
|
def has_kdialog?
|
24
|
-
system "which kdialog
|
26
|
+
system "which kdialog > /dev/null 2>&1"
|
25
27
|
end
|
26
28
|
|
27
29
|
def has_zenity?
|
28
|
-
system "which zenity
|
30
|
+
system "which zenity > /dev/null 2>&1"
|
29
31
|
end
|
30
32
|
|
31
|
-
def notify_send(title, msg, img)
|
32
|
-
|
33
|
+
def notify_send(title, msg, img, priority = 0)
|
34
|
+
urgency = priority > 1 ? 'critical' : priority < 0 ? 'low' : 'normal'
|
35
|
+
system "notify-send -t #{Config.expiration_in_seconds * 1000} -i #{img} -u #{urgency} '#{title}' '#{msg}'"
|
33
36
|
end
|
34
37
|
|
35
38
|
def kdialog(title, msg, img)
|
36
|
-
system "kdialog --title '#{title}' --passivepopup '#{msg}' #{
|
39
|
+
system "kdialog --title '#{title}' --passivepopup '<img src=\"#{img}\" align=\"middle\"> #{msg}' #{Config.expiration_in_seconds}"
|
37
40
|
end
|
38
41
|
|
39
42
|
def zenity(title, msg, img)
|
@@ -53,12 +53,12 @@ class TestLinux < Test::Unit::TestCase
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_notify_send
|
56
|
-
AutotestNotification::Linux.expects(:system).with('notify-send -t 3000 -i image \'title\' \'msg\'')
|
56
|
+
AutotestNotification::Linux.expects(:system).with('notify-send -t 3000 -i image -u normal \'title\' \'msg\'')
|
57
57
|
AutotestNotification::Linux.notify_send("title", "msg", "image")
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_notify_kdialog
|
61
|
-
AutotestNotification::Linux.expects(:system).with('kdialog --title \'title\' --passivepopup \'msg\' 3')
|
61
|
+
AutotestNotification::Linux.expects(:system).with('kdialog --title \'title\' --passivepopup \'<img src="image" align="middle"> msg\' 3')
|
62
62
|
AutotestNotification::Linux.kdialog("title", "msg", "image")
|
63
63
|
end
|
64
64
|
|
@@ -68,17 +68,17 @@ class TestLinux < Test::Unit::TestCase
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def test_has_zenity?
|
71
|
-
AutotestNotification::Linux.expects(:system).with('which zenity
|
71
|
+
AutotestNotification::Linux.expects(:system).with('which zenity > /dev/null 2>&1')
|
72
72
|
AutotestNotification::Linux.has_zenity?
|
73
73
|
end
|
74
74
|
|
75
75
|
def test_has_notify?
|
76
|
-
AutotestNotification::Linux.expects(:system).with('which notify-send
|
76
|
+
AutotestNotification::Linux.expects(:system).with('which notify-send > /dev/null 2>&1')
|
77
77
|
AutotestNotification::Linux.has_notify?
|
78
78
|
end
|
79
79
|
|
80
80
|
def test_has_kdialog?
|
81
|
-
AutotestNotification::Linux.expects(:system).with('which kdialog
|
81
|
+
AutotestNotification::Linux.expects(:system).with('which kdialog > /dev/null 2>&1')
|
82
82
|
AutotestNotification::Linux.has_kdialog?
|
83
83
|
end
|
84
84
|
|
@@ -88,4 +88,4 @@ class TestLinux < Test::Unit::TestCase
|
|
88
88
|
AutotestNotification::Linux.expects(method).returns("title", "msg", "image", 1)
|
89
89
|
AutotestNotification::Linux.notify("title", "msg", "image", 1, 1)
|
90
90
|
end
|
91
|
-
end
|
91
|
+
end
|
@@ -26,7 +26,7 @@ class TestAutotestNotification < Test::Unit::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_notify_when_os_is_linux
|
29
|
-
AutotestNotification::Linux.expects(:notify).with(@title, @msg, @image, @total, @failures)
|
29
|
+
AutotestNotification::Linux.expects(:notify).with(@title, @msg, @image, @total, @failures, @priority)
|
30
30
|
verify_to("linux")
|
31
31
|
end
|
32
32
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carlosbrando-autotest-notification
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Brando
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2009-01
|
21
|
+
date: 2009-02-01 00:00:00 -08:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|