test-unit-notify 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +10 -0
- data/README.txt +36 -0
- data/Rakefile +47 -0
- data/data/icons/kinotan/default.png +0 -0
- data/data/icons/kinotan/failure.png +0 -0
- data/data/icons/kinotan/pass.png +0 -0
- data/data/icons/kinotan/pending.png +0 -0
- data/lib/test/unit/notify.rb +104 -0
- data/screenshot/notify-on-gnome.png +0 -0
- metadata +114 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
= Test::Unit::Notify
|
2
|
+
|
3
|
+
* http://rubyforge.org/projects/test-unit/
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Test::Unit::Notify - A test result notify extention for Test::Unit.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* This provides all Test::Unit extensions just one require line.
|
12
|
+
|
13
|
+
== INSTALL:
|
14
|
+
|
15
|
+
* sudo gem install test-unit-full
|
16
|
+
|
17
|
+
== USAGE:
|
18
|
+
|
19
|
+
require 'test/unit/notify'
|
20
|
+
|
21
|
+
And add '--notify' to command line option.
|
22
|
+
|
23
|
+
% ruby test/test_my_class.rb --notify
|
24
|
+
|
25
|
+
See screenshot/notify-on-gnome.png for example on GNOME.
|
26
|
+
|
27
|
+
== LICENSE:
|
28
|
+
|
29
|
+
(The Ruby License)
|
30
|
+
|
31
|
+
This software is distributed under the same terms as ruby.
|
32
|
+
|
33
|
+
== AUTHORS:
|
34
|
+
|
35
|
+
* Kouhei Sutou: program
|
36
|
+
* Mayu & Co.: kinotan icons: http://cocooooooon.com/kinotan/
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
base_dir = Pathname(__FILE__).dirname.expand_path
|
6
|
+
test_unit_dir = (base_dir.parent + "test-unit").expand_path
|
7
|
+
test_unit_lib_dir = test_unit_dir + "lib"
|
8
|
+
lib_dir = base_dir + "lib"
|
9
|
+
|
10
|
+
$LOAD_PATH.unshift(test_unit_lib_dir.to_s)
|
11
|
+
$LOAD_PATH.unshift(lib_dir.to_s)
|
12
|
+
|
13
|
+
require 'test/unit/notify'
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'hoe'
|
17
|
+
|
18
|
+
Test::Unit.run = true
|
19
|
+
|
20
|
+
version = Test::Unit::Notify::VERSION
|
21
|
+
ENV["VERSION"] = version
|
22
|
+
Hoe.spec('test-unit-notify') do
|
23
|
+
self.version = version
|
24
|
+
self.rubyforge_name = "test-unit"
|
25
|
+
|
26
|
+
developer('Kouhei Sutou', 'kou@clear-code.com')
|
27
|
+
|
28
|
+
extra_deps << ["test-unit"]
|
29
|
+
end
|
30
|
+
|
31
|
+
task :docs do
|
32
|
+
doc_dir = base_dir + "doc"
|
33
|
+
doc_screenshot_dir = doc_dir + "screenshot"
|
34
|
+
mkdir_p(doc_screenshot_dir.to_s)
|
35
|
+
(base_dir + "screenshot").children.each do |file|
|
36
|
+
next if file.directory?
|
37
|
+
cp(file.to_s, doc_screenshot_dir.to_s)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
task :tag do
|
42
|
+
message = "Released Test::Unit::Notify #{version}!"
|
43
|
+
base = "svn+ssh://#{ENV['USER']}@rubyforge.org/var/svn/test-unit/extensions/test-unit-notify/"
|
44
|
+
sh 'svn', 'copy', '-m', message, "#{base}trunk", "#{base}tags/#{version}"
|
45
|
+
end
|
46
|
+
|
47
|
+
# vim: syntax=Ruby
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#--
|
2
|
+
#
|
3
|
+
# Author:: Kouhei Sutou
|
4
|
+
# Copyright::
|
5
|
+
# * Copyright (c) 2010 Kouhei Sutou <kou@clear-code.com>
|
6
|
+
# License:: Ruby license.
|
7
|
+
|
8
|
+
require 'pathname'
|
9
|
+
require 'erb'
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
module Test
|
13
|
+
module Unit
|
14
|
+
AutoRunner.setup_option do |auto_runner, options|
|
15
|
+
options.on("--[no-]notify",
|
16
|
+
"Notify test result at the last.") do |use_notify|
|
17
|
+
auto_runner.listeners.reject! do |listener|
|
18
|
+
listener.is_a?(Notify::Notifier)
|
19
|
+
end
|
20
|
+
auto_runner.listeners << Notify::Notifier.new if use_notify
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module Notify
|
25
|
+
VERSION = "0.0.1"
|
26
|
+
|
27
|
+
class Notifier
|
28
|
+
include ERB::Util
|
29
|
+
|
30
|
+
base_dir = Pathname(__FILE__).dirname.parent.parent.parent.expand_path
|
31
|
+
ICON_DIR = base_dir + "data" + "icons"
|
32
|
+
def initialize
|
33
|
+
@theme = "kinotan"
|
34
|
+
end
|
35
|
+
|
36
|
+
def attach_to_mediator(mediator)
|
37
|
+
mediator.add_listener(UI::TestRunnerMediator::STARTED,
|
38
|
+
&method(:started))
|
39
|
+
mediator.add_listener(UI::TestRunnerMediator::FINISHED,
|
40
|
+
&method(:finished))
|
41
|
+
end
|
42
|
+
|
43
|
+
def started(result)
|
44
|
+
@result = result
|
45
|
+
end
|
46
|
+
|
47
|
+
def finished(elapsed_time)
|
48
|
+
case RUBY_PLATFORM
|
49
|
+
when /mswin|mingw|cygwin/
|
50
|
+
# how?
|
51
|
+
when /darwin/
|
52
|
+
# growl?
|
53
|
+
else
|
54
|
+
notify_by_notify_send(elapsed_time)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def notify_by_notify_send(elapsed_time)
|
59
|
+
icon = guess_suitable_icon
|
60
|
+
args = ["notify-send",
|
61
|
+
"--expire-time", "5000",
|
62
|
+
"--urgency", urgency]
|
63
|
+
args.concat(["--icon", icon.to_s]) if icon
|
64
|
+
title = "%s [%g%%] (%gs)" % [@result.status,
|
65
|
+
@result.pass_percentage,
|
66
|
+
elapsed_time]
|
67
|
+
args << title
|
68
|
+
args << h(@result.summary)
|
69
|
+
system(*args)
|
70
|
+
end
|
71
|
+
|
72
|
+
def guess_suitable_icon
|
73
|
+
icon_dir = ICON_DIR + @theme
|
74
|
+
status = @result.status
|
75
|
+
icon_base_names = [status]
|
76
|
+
if @result.passed?
|
77
|
+
icon_base_names << "pass"
|
78
|
+
else
|
79
|
+
case status
|
80
|
+
when "failure"
|
81
|
+
icon_base_names << "error"
|
82
|
+
when "error"
|
83
|
+
icon_base_names << "failure"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
icon_base_names << "default"
|
87
|
+
icon_base_names.each do |base_name|
|
88
|
+
icon = icon_dir + "#{base_name}.png"
|
89
|
+
return icon if icon.exist?
|
90
|
+
end
|
91
|
+
nil
|
92
|
+
end
|
93
|
+
|
94
|
+
def urgency
|
95
|
+
if @result.passed?
|
96
|
+
"normal"
|
97
|
+
else
|
98
|
+
"critical"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: test-unit-notify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Kouhei Sutou
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-07-17 00:00:00 +09:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: test-unit
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: rubyforge
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 2
|
41
|
+
- 0
|
42
|
+
- 4
|
43
|
+
version: 2.0.4
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: hoe
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 2
|
55
|
+
- 6
|
56
|
+
- 1
|
57
|
+
version: 2.6.1
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id003
|
60
|
+
description: Test::Unit::Notify - A test result notify extention for Test::Unit.
|
61
|
+
email:
|
62
|
+
- kou@clear-code.com
|
63
|
+
executables: []
|
64
|
+
|
65
|
+
extensions: []
|
66
|
+
|
67
|
+
extra_rdoc_files:
|
68
|
+
- History.txt
|
69
|
+
- Manifest.txt
|
70
|
+
- README.txt
|
71
|
+
files:
|
72
|
+
- History.txt
|
73
|
+
- Manifest.txt
|
74
|
+
- README.txt
|
75
|
+
- Rakefile
|
76
|
+
- data/icons/kinotan/default.png
|
77
|
+
- data/icons/kinotan/failure.png
|
78
|
+
- data/icons/kinotan/pass.png
|
79
|
+
- data/icons/kinotan/pending.png
|
80
|
+
- lib/test/unit/notify.rb
|
81
|
+
- screenshot/notify-on-gnome.png
|
82
|
+
has_rdoc: true
|
83
|
+
homepage: http://rubyforge.org/projects/test-unit/
|
84
|
+
licenses: []
|
85
|
+
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options:
|
88
|
+
- --main
|
89
|
+
- README.txt
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
version: "0"
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
version: "0"
|
106
|
+
requirements: []
|
107
|
+
|
108
|
+
rubyforge_project: test-unit
|
109
|
+
rubygems_version: 1.3.6
|
110
|
+
signing_key:
|
111
|
+
specification_version: 3
|
112
|
+
summary: Test::Unit::Notify - A test result notify extention for Test::Unit.
|
113
|
+
test_files: []
|
114
|
+
|