test-unit-notify 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -0
- data/Manifest.txt +1 -0
- data/README.txt +3 -3
- data/lib/test/unit/notify.rb +111 -23
- data/screenshot/notify-on-gnome.png +0 -0
- data/screenshot/notify-on-mac-os-x.png +0 -0
- metadata +9 -24
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -8,11 +8,11 @@ Test::Unit::Notify - A test result notify extention for Test::Unit.
|
|
8
8
|
|
9
9
|
== FEATURES/PROBLEMS:
|
10
10
|
|
11
|
-
* This provides
|
11
|
+
* This provides test result notification support.
|
12
12
|
|
13
13
|
== INSTALL:
|
14
14
|
|
15
|
-
* sudo gem install test-unit-
|
15
|
+
* sudo gem install test-unit-notify
|
16
16
|
|
17
17
|
== USAGE:
|
18
18
|
|
@@ -28,7 +28,7 @@ See screenshot/notify-on-gnome.png for example on GNOME.
|
|
28
28
|
|
29
29
|
LGPLv2.1 or later.
|
30
30
|
|
31
|
-
(Kouhei Sutou has a right to change the license
|
31
|
+
(Kouhei Sutou has a right to change the license including
|
32
32
|
contributed patches.)
|
33
33
|
|
34
34
|
== AUTHORS:
|
data/lib/test/unit/notify.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Author:: Kouhei Sutou
|
4
4
|
# Copyright::
|
5
5
|
# * Copyright (c) 2010 Kouhei Sutou <kou@clear-code.com>
|
6
|
-
# License::
|
6
|
+
# License:: LGPLv2+
|
7
7
|
|
8
8
|
require 'pathname'
|
9
9
|
require 'erb'
|
@@ -17,14 +17,15 @@ module Test
|
|
17
17
|
|
18
18
|
AutoRunner.setup_option do |auto_runner, options|
|
19
19
|
options.on("--[no-]notify",
|
20
|
-
"Notify test result at the last."
|
20
|
+
"Notify test result at the last.",
|
21
|
+
"(default is auto [#{Notify.enable?}])") do |use_notify|
|
21
22
|
Notify.disable(auto_runner)
|
22
23
|
Notify.enable(auto_runner) if use_notify
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
module Notify
|
27
|
-
VERSION = "0.
|
28
|
+
VERSION = "0.2.0"
|
28
29
|
|
29
30
|
class << self
|
30
31
|
def enable(auto_runner)
|
@@ -37,19 +38,113 @@ module Test
|
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
@@enable =
|
41
|
+
@@enable = nil
|
41
42
|
def enable=(enable)
|
42
43
|
@@enable = enable
|
43
44
|
end
|
44
45
|
|
45
46
|
def enable?
|
47
|
+
if @@enable.nil?
|
48
|
+
@@enable = Notifier.available?
|
49
|
+
end
|
46
50
|
@@enable
|
47
51
|
end
|
48
52
|
end
|
49
53
|
|
50
|
-
class
|
54
|
+
class NotifyCommand
|
55
|
+
def available?
|
56
|
+
paths.any? do |path|
|
57
|
+
File.exist?(File.join(path, @command))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
def paths
|
63
|
+
path_env = ENV["PATH"]
|
64
|
+
if path_env.nil?
|
65
|
+
default_paths
|
66
|
+
else
|
67
|
+
path_env.split(File::PATH_SEPARATOR)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def default_paths
|
72
|
+
["/usr/local/bin", "/usr/bin", "/bin"]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
class NotifySend < NotifyCommand
|
51
77
|
include ERB::Util
|
52
78
|
|
79
|
+
def initialize
|
80
|
+
@command = "notify-send"
|
81
|
+
end
|
82
|
+
|
83
|
+
def run(parameters)
|
84
|
+
expire_time = parameters[:expire_time] * 1000
|
85
|
+
urgency = parameters[:urgency]
|
86
|
+
title = parameters[:title]
|
87
|
+
message = h(parameters[:message])
|
88
|
+
icon = parameters[:icon]
|
89
|
+
|
90
|
+
command_line = [@command,
|
91
|
+
"--expire-time", expire_time.to_s,
|
92
|
+
"--urgency", urgency]
|
93
|
+
command_line.concat(["--icon", icon]) if icon
|
94
|
+
command_line << title
|
95
|
+
command_line << message
|
96
|
+
system(*command_line)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
class Growlnotify < NotifyCommand
|
101
|
+
def initialize
|
102
|
+
@command = "growlnotify"
|
103
|
+
end
|
104
|
+
|
105
|
+
def run(parameters)
|
106
|
+
expire_time = parameters[:expire_time]
|
107
|
+
priority = urgency_to_piroity(parameters[:urgency])
|
108
|
+
title = parameters[:title]
|
109
|
+
message = parameters[:message]
|
110
|
+
image = parameters[:icon]
|
111
|
+
|
112
|
+
command_line = [@command,
|
113
|
+
"--priority", priority,
|
114
|
+
"--message", message]
|
115
|
+
command_line.concat(["--image", image]) if image
|
116
|
+
command_line << title
|
117
|
+
system(*command_line)
|
118
|
+
end
|
119
|
+
|
120
|
+
private
|
121
|
+
def urgency_to_piroity(urgency)
|
122
|
+
case urgency
|
123
|
+
when "normal"
|
124
|
+
"Normal"
|
125
|
+
when "critical"
|
126
|
+
"Emergency"
|
127
|
+
else
|
128
|
+
"Normal"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
class Notifier
|
134
|
+
class << self
|
135
|
+
def available?
|
136
|
+
not command.nil?
|
137
|
+
end
|
138
|
+
|
139
|
+
def command
|
140
|
+
@@command ||= commands.find {|command| command.available?}
|
141
|
+
end
|
142
|
+
|
143
|
+
def commands
|
144
|
+
[NotifySend.new, Growlnotify.new]
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
53
148
|
base_dir = Pathname(__FILE__).dirname.parent.parent.parent.expand_path
|
54
149
|
ICON_DIR = base_dir + "data" + "icons"
|
55
150
|
def initialize
|
@@ -68,30 +163,23 @@ module Test
|
|
68
163
|
end
|
69
164
|
|
70
165
|
def finished(elapsed_time)
|
71
|
-
|
72
|
-
|
73
|
-
# how?
|
74
|
-
when /darwin/
|
75
|
-
# growl?
|
76
|
-
else
|
77
|
-
notify_by_notify_send(elapsed_time)
|
78
|
-
end
|
79
|
-
end
|
166
|
+
command = self.class.command
|
167
|
+
return if command.nil?
|
80
168
|
|
81
|
-
def notify_by_notify_send(elapsed_time)
|
82
|
-
icon = guess_suitable_icon
|
83
|
-
args = ["notify-send",
|
84
|
-
"--expire-time", "5000",
|
85
|
-
"--urgency", urgency]
|
86
|
-
args.concat(["--icon", icon.to_s]) if icon
|
87
169
|
title = "%s [%g%%] (%gs)" % [@result.status,
|
88
170
|
@result.pass_percentage,
|
89
171
|
elapsed_time]
|
90
|
-
|
91
|
-
|
92
|
-
|
172
|
+
parameters = {
|
173
|
+
:expire_time => 5,
|
174
|
+
:icon => guess_suitable_icon,
|
175
|
+
:urgency => urgency,
|
176
|
+
:title => title,
|
177
|
+
:message => @result.summary,
|
178
|
+
}
|
179
|
+
command.run(parameters)
|
93
180
|
end
|
94
181
|
|
182
|
+
private
|
95
183
|
def guess_suitable_icon
|
96
184
|
icon_dir = ICON_DIR + @theme
|
97
185
|
status = @result.status
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-unit-notify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kouhei Sutou
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-02-10 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -35,37 +35,21 @@ dependencies:
|
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: hoe
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 31
|
46
46
|
segments:
|
47
47
|
- 2
|
48
|
-
- 0
|
49
48
|
- 4
|
50
|
-
|
49
|
+
- 0
|
50
|
+
version: 2.4.0
|
51
51
|
type: :development
|
52
52
|
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: hoe
|
55
|
-
prerelease: false
|
56
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
hash: 21
|
62
|
-
segments:
|
63
|
-
- 2
|
64
|
-
- 6
|
65
|
-
- 1
|
66
|
-
version: 2.6.1
|
67
|
-
type: :development
|
68
|
-
version_requirements: *id003
|
69
53
|
description: Test::Unit::Notify - A test result notify extention for Test::Unit.
|
70
54
|
email:
|
71
55
|
- kou@clear-code.com
|
@@ -89,6 +73,7 @@ files:
|
|
89
73
|
- data/icons/kinotan/pending.png
|
90
74
|
- lib/test/unit/notify.rb
|
91
75
|
- screenshot/notify-on-gnome.png
|
76
|
+
- screenshot/notify-on-mac-os-x.png
|
92
77
|
has_rdoc: true
|
93
78
|
homepage: http://rubyforge.org/projects/test-unit/
|
94
79
|
licenses: []
|