blackwinter-autotest-notification 1.8.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 +58 -0
- data/License.txt +20 -0
- data/Manifest.txt +59 -0
- data/PostInstall.txt +9 -0
- data/README.txt +138 -0
- data/Rakefile +4 -0
- data/autotest-notification.gemspec +49 -0
- data/bin/an-install +106 -0
- data/bin/an-uninstall +50 -0
- data/bin/playsound +0 -0
- data/config/hoe.rb +75 -0
- data/config/requirements.rb +15 -0
- data/images/buuf/fail.png +0 -0
- data/images/buuf/pass.png +0 -0
- data/images/buuf/pending.png +0 -0
- data/images/doom/doom_0.png +0 -0
- data/images/doom/doom_1.png +0 -0
- data/images/doom/doom_2.png +0 -0
- data/images/doom/doom_3.png +0 -0
- data/images/doom/doom_4.png +0 -0
- data/images/doom/doom_5.png +0 -0
- data/images/doom/doom_6.png +0 -0
- data/images/fail.png +0 -0
- data/images/pass.png +0 -0
- data/images/pending.png +0 -0
- data/lib/autotest_notification.rb +73 -0
- data/lib/autotest_notification/buuf.rb +9 -0
- data/lib/autotest_notification/cygwin.rb +14 -0
- data/lib/autotest_notification/doom.rb +25 -0
- data/lib/autotest_notification/linux.rb +58 -0
- data/lib/autotest_notification/mac.rb +30 -0
- data/lib/autotest_notification/version.rb +9 -0
- data/lib/autotest_notification/windows.rb +11 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/sounds/doom/0.wav +0 -0
- data/sounds/doom/1.wav +0 -0
- data/sounds/doom/2.wav +0 -0
- data/sounds/doom/3.wav +0 -0
- data/sounds/doom/4.wav +0 -0
- data/sounds/doom/5.wav +0 -0
- data/sounds/doom/6.wav +0 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/autotest_notification/test_cygwin.rb +10 -0
- data/test/autotest_notification/test_linux.rb +91 -0
- data/test/autotest_notification/test_mac.rb +78 -0
- data/test/autotest_notification/test_windows.rb +12 -0
- data/test/test_autotest_notification.rb +44 -0
- data/test/test_helper.rb +25 -0
- data/website/index.html +86 -0
- data/website/index.txt +83 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +151 -0
data/bin/an-uninstall
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Created on 2008-5-11.
|
4
|
+
# Copyright (c) 2008. All rights reserved.
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'rubygems'
|
8
|
+
rescue LoadError
|
9
|
+
# no rubygems to load, so we fail silently
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'optparse'
|
13
|
+
require 'ftools'
|
14
|
+
|
15
|
+
# NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application.
|
16
|
+
|
17
|
+
OPTIONS = {
|
18
|
+
:path => '~'
|
19
|
+
}
|
20
|
+
MANDATORY_OPTIONS = %w( )
|
21
|
+
|
22
|
+
parser = OptionParser.new do |opts|
|
23
|
+
opts.banner = <<BANNER
|
24
|
+
This application is wonderful because...
|
25
|
+
|
26
|
+
Usage: #{File.basename($0)} [options]
|
27
|
+
|
28
|
+
Options are:
|
29
|
+
BANNER
|
30
|
+
opts.separator ""
|
31
|
+
opts.on("-p", "--path=PATH", String,
|
32
|
+
"The root path for selecting files",
|
33
|
+
"Default: ~") { |OPTIONS[:path]| }
|
34
|
+
opts.on("-h", "--help",
|
35
|
+
"Show this help message.") { puts opts; exit }
|
36
|
+
opts.parse!(ARGV)
|
37
|
+
|
38
|
+
if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
|
39
|
+
puts opts; exit
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
path = OPTIONS[:path]
|
44
|
+
|
45
|
+
autotest_file = File.expand_path(path) + "/.autotest"
|
46
|
+
if File.exist?(autotest_file)
|
47
|
+
File.delete(autotest_file)
|
48
|
+
puts "\nYou no longer receive notifications of your tests."
|
49
|
+
puts "" # a blank line
|
50
|
+
end
|
data/bin/playsound
ADDED
Binary file
|
data/config/hoe.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'autotest_notification/version'
|
2
|
+
|
3
|
+
AUTHOR = "Carlos Brando, Rodrigo Urubatan, Alexandre da Silva, Carlos Júnior, Davis Zanetti Cabral, Marcos Tapajós, Thiago Pradi, Ozéias Sant'ana, Samuel Flores, Diego Carrion"
|
4
|
+
EMAIL = "autotest-notification@carlosbrando.com"
|
5
|
+
DESCRIPTION = "This gem set the autotest (ZenTest) to send messages to software as Growl, LibNotify, and Snarl, displaying a window with the results."
|
6
|
+
GEM_NAME = 'autotest-notification' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = nil # 'autotestnotific' # The unix name for your project
|
8
|
+
HOMEPATH = "http://github.com/carlosbrando/autotest-notification/"
|
9
|
+
DOWNLOAD_PATH = "http://github.com/carlosbrando/autotest-notification/tarball/master"
|
10
|
+
|
11
|
+
EXTRA_DEPENDENCIES = [
|
12
|
+
['ZenTest', '>= 3.9.2']
|
13
|
+
# ['activesupport', '>= 1.3.1']
|
14
|
+
] # An array of rubygem dependencies [name, version]
|
15
|
+
|
16
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
17
|
+
@config = nil
|
18
|
+
RUBYFORGE_USERNAME = "carlosbrando"
|
19
|
+
def rubyforge_username
|
20
|
+
unless @config
|
21
|
+
begin
|
22
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
23
|
+
rescue
|
24
|
+
puts <<-EOS
|
25
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
26
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
27
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
28
|
+
EOS
|
29
|
+
exit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
REV = nil
|
37
|
+
# UNCOMMENT IF REQUIRED:
|
38
|
+
# REV = YAML.load(`svn info`)['Revision']
|
39
|
+
VERS = AutotestNotification::VERSION::STRING + (REV ? ".#{REV}" : "")
|
40
|
+
RDOC_OPTS = ['--quiet', '--title', 'autotest_notification documentation',
|
41
|
+
"--opname", "index.html",
|
42
|
+
"--line-numbers",
|
43
|
+
"--main", "README",
|
44
|
+
"--inline-source"]
|
45
|
+
|
46
|
+
class Hoe
|
47
|
+
def extra_deps
|
48
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
49
|
+
@extra_deps
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Generate all the Rake tasks
|
54
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
55
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
56
|
+
p.developer(AUTHOR, EMAIL)
|
57
|
+
p.description = DESCRIPTION
|
58
|
+
p.summary = DESCRIPTION
|
59
|
+
p.url = HOMEPATH
|
60
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
61
|
+
p.test_globs = ["test/**/test_*.rb"]
|
62
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
63
|
+
|
64
|
+
# == Optional
|
65
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
66
|
+
p.extra_deps = EXTRA_DEPENDENCIES
|
67
|
+
|
68
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
69
|
+
end
|
70
|
+
|
71
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
72
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
73
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
74
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
75
|
+
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen ZenTest].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/images/fail.png
ADDED
Binary file
|
data/images/pass.png
ADDED
Binary file
|
data/images/pending.png
ADDED
Binary file
|
@@ -0,0 +1,73 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__))
|
2
|
+
%w{ linux mac windows cygwin doom buuf }.each { |x| require "autotest_notification/#{x}" }
|
3
|
+
|
4
|
+
module AutotestNotification
|
5
|
+
IMAGES_DIRECTORY = File.expand_path(File.dirname(__FILE__) + "/../images/")
|
6
|
+
SUCCESS_IMAGE = "#{IMAGES_DIRECTORY}/pass.png";
|
7
|
+
FAIL_IMAGE = "#{IMAGES_DIRECTORY}/fail.png";
|
8
|
+
PENDING_IMAGE = "#{IMAGES_DIRECTORY}/pending.png"
|
9
|
+
|
10
|
+
EXPIRATION_IN_SECONDS = 3
|
11
|
+
|
12
|
+
Autotest.add_hook :ran_command do |at|
|
13
|
+
result = at.results.is_a?(Array) ? at.results.last : at.results.split("\n").last
|
14
|
+
|
15
|
+
if result
|
16
|
+
%w{ test assertion error example pending failure }.each { |x| instance_variable_set "@#{x}s", result[/(\d+) #{x}/, 1].to_i }
|
17
|
+
|
18
|
+
case result
|
19
|
+
when /test/
|
20
|
+
code = 31 if @failures > 0 || @errors > 0
|
21
|
+
msg = unit_test_message(@tests, @assertions, @failures, @errors)
|
22
|
+
when /example/
|
23
|
+
code = (@failures > 0) ? 31 : (@pendings > 0) ? 33 : 32
|
24
|
+
msg = rspec_message(@examples, @failures, @pendings)
|
25
|
+
else
|
26
|
+
code = 31
|
27
|
+
msg = "1 exception occurred"
|
28
|
+
@failures = 1
|
29
|
+
end
|
30
|
+
|
31
|
+
if @failures > 0 || @errors > 0
|
32
|
+
notify "FAIL", msg, FAIL_IMAGE, @tests + @examples, @failures + @errors, 2
|
33
|
+
elsif PENDING && @pendings > 0
|
34
|
+
notify "Pending", msg, PENDING_IMAGE, @tests + @examples, @failures + @errors, 1
|
35
|
+
else
|
36
|
+
notify "Pass", msg, SUCCESS_IMAGE, @tests + @examples, 0, -2
|
37
|
+
end
|
38
|
+
|
39
|
+
puts "\e[#{code}m#{'=' * 80}\e[0m\n\n"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class << self
|
44
|
+
def notify(title, msg, img = SUCCESS_IMAGE, total = 1, failures = 0, priority = 0)
|
45
|
+
|
46
|
+
img = Doom.image(total, failures) if DOOM_EDITION
|
47
|
+
img = Buuf.image(title.downcase) if BUUF
|
48
|
+
|
49
|
+
case RUBY_PLATFORM
|
50
|
+
when /linux/
|
51
|
+
Linux.notify(title, msg, img, total, failures, priority)
|
52
|
+
when /darwin/
|
53
|
+
Mac.notify(title, msg, img, total, failures, priority)
|
54
|
+
when /cygwin/
|
55
|
+
Cygwin.notify(title, msg, img)
|
56
|
+
when /mswin/
|
57
|
+
Windows.notify(title, msg, img)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def pluralize(text, number)
|
62
|
+
"#{number} #{text}#{'s' if number != 1}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def unit_test_message(tests, assertions, failures, errors)
|
66
|
+
"#{pluralize('test', tests)}, #{pluralize('assertion', assertions)}, #{pluralize('failure', failures)}, #{pluralize('error', errors)}"
|
67
|
+
end
|
68
|
+
|
69
|
+
def rspec_message(examples, failures, pendings)
|
70
|
+
"#{pluralize('example', examples)}, #{pluralize('failure', failures)}, #{pendings} pending"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module AutotestNotification
|
2
|
+
class Cygwin
|
3
|
+
class << self
|
4
|
+
def notify(title, msg, img)
|
5
|
+
img = get_image_path(img).strip
|
6
|
+
system "sncmd /m '#{title}' '#{msg}' '#{img}' /t #{EXPIRATION_IN_SECONDS}"
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_image_path(img)
|
10
|
+
`cygpath -m #{img}`
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module AutotestNotification
|
2
|
+
class Doom
|
3
|
+
class << self
|
4
|
+
def image(total, failures)
|
5
|
+
"#{IMAGES_DIRECTORY}/doom/doom_#{percent(total, failures)}.png"
|
6
|
+
end
|
7
|
+
|
8
|
+
def play_sound(total, failures)
|
9
|
+
sound_file = "#{File.expand_path(File.dirname(__FILE__) + "/../../sounds/doom/")}/#{percent(total, failures)}.wav"
|
10
|
+
|
11
|
+
case RUBY_PLATFORM
|
12
|
+
when /darwin/
|
13
|
+
`#{File.expand_path(File.dirname(__FILE__) + "/../../bin/")}/playsound #{sound_file}`
|
14
|
+
when /linux/
|
15
|
+
system("/usr/bin/mplayer #{sound_file} > /dev/null 2> /dev/null")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def percent(total, failures)
|
21
|
+
percent = failures.zero? ? 0 : ((5 * failures) / total) + 1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module AutotestNotification
|
2
|
+
class Linux
|
3
|
+
class << self
|
4
|
+
|
5
|
+
def notify(title, msg, img, total = 1, failures = 0, priority = 0)
|
6
|
+
@expiration_in_seconds = failures > 0 && STICKY ? 0 : EXPIRATION_IN_SECONDS
|
7
|
+
|
8
|
+
if has_notify?
|
9
|
+
notify_send(title, msg, img, priority)
|
10
|
+
elsif has_zenity?
|
11
|
+
zenity(title, msg, img)
|
12
|
+
elsif has_kdialog?
|
13
|
+
kdialog(title, msg, img)
|
14
|
+
end
|
15
|
+
|
16
|
+
say(total, failures) if SPEAKING
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def has_notify?
|
22
|
+
system "which notify-send > /dev/null 2>&1"
|
23
|
+
end
|
24
|
+
|
25
|
+
def has_kdialog?
|
26
|
+
system "which kdialog > /dev/null 2>&1"
|
27
|
+
end
|
28
|
+
|
29
|
+
def has_zenity?
|
30
|
+
system "which zenity > /dev/null 2>&1"
|
31
|
+
end
|
32
|
+
|
33
|
+
def notify_send(title, msg, img, priority)
|
34
|
+
urgency = priority > 1 ? 'critical' : priority < 0 ? 'low' : 'normal'
|
35
|
+
system "notify-send -t #{@expiration_in_seconds * 1000} -i #{img} -u #{urgency} '#{title}' '#{msg}'"
|
36
|
+
end
|
37
|
+
|
38
|
+
def kdialog(title, msg, img)
|
39
|
+
system "kdialog --title '#{title}' --passivepopup '<img src=\"#{img}\" align=\"middle\"> #{msg}' #{@expiration_in_seconds}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def zenity(title, msg, img)
|
43
|
+
system "zenity --info --text='#{msg}' --title='#{title}'"
|
44
|
+
end
|
45
|
+
|
46
|
+
def say(total, failures)
|
47
|
+
if failures > 0
|
48
|
+
DOOM_EDITION ? Doom.play_sound(total, failures) : system("/usr/bin/espeak '#{failures} test#{'s' unless failures == 1} failed'")
|
49
|
+
else
|
50
|
+
DOOM_EDITION ? Doom.play_sound(total, failures) : system("/usr/bin/espeak 'All tests passed successfully'")
|
51
|
+
end
|
52
|
+
rescue
|
53
|
+
puts "You need the #{DOOM_EDITION ? 'mplayer' : 'espeak'} installed to hear the sounds."
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module AutotestNotification
|
2
|
+
class Mac
|
3
|
+
@last_test_failed = false
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def notify(title, msg, img, total = 1, failures = 0, priority = 0)
|
8
|
+
system "growlnotify -n autotest --image #{img} #{'-s ' if ((failures > 0) and STICKY)}-p #{priority} -m '#{msg}' -t #{title}"
|
9
|
+
play(SUCCESS_SOUND) unless SUCCESS_SOUND.empty? or failures > 0
|
10
|
+
play(FAILURE_SOUND) unless FAILURE_SOUND.empty? or failures == 0
|
11
|
+
say(total, failures) if SPEAKING
|
12
|
+
end
|
13
|
+
|
14
|
+
def say(total, failures)
|
15
|
+
if failures > 0
|
16
|
+
DOOM_EDITION ? Doom.play_sound(total, failures) : system("say #{failures} test#{'s' unless failures == 1} failed.")
|
17
|
+
@last_test_failed = true
|
18
|
+
elsif @last_test_failed
|
19
|
+
DOOM_EDITION ? Doom.play_sound(total, failures) : system("say All tests passed successfully.")
|
20
|
+
@last_test_failed = false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def play(sound_file)
|
25
|
+
`#{File.expand_path(File.dirname(__FILE__) + "/../../bin/")}/playsound #{sound_file}`
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/autotest_notification.rb'}"
|
9
|
+
puts "Loading autotest_notification gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|