fnando-test_notifier 0.0.10

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 ADDED
@@ -0,0 +1,40 @@
1
+ == 0.0.1 2007-10-11
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
5
+
6
+ == 0.0.2 2007-10-17
7
+
8
+ * Removed ANSI characters for playing nice with RedGreen
9
+
10
+ == 0.0.3 2007-10-18
11
+
12
+ * growlnotify wasn't working as expected
13
+
14
+ == 0.0.4 2007-10-18
15
+
16
+ * title was displayed incorrectly on growlnotify
17
+
18
+ == 0.0.5 2007-10-18
19
+
20
+ * bug fix
21
+
22
+ == 0.0.6 2008-01-14
23
+
24
+ * added support for both Test::Unit and RSpec, with or without Autotest
25
+
26
+ == 0.0.7 2008-01-16
27
+
28
+ * bug fix
29
+
30
+ == 0.0.8 2008-01-18
31
+
32
+ * bug fix
33
+
34
+ == 0.0.9
35
+
36
+ * minor fix: added freebsd pattern
37
+
38
+ == 0.0.10
39
+
40
+ * minor fix: fixed path for custom images
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Nando Vieira
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,95 @@
1
+ test_notifier
2
+ =============
3
+
4
+ * [http://github.com/fnando/test_notifier](http://github.com/fnando/test_notifier)
5
+
6
+ DESCRIPTION:
7
+ ------------
8
+
9
+ Inspired by
10
+ http://railstips.org/2007/7/23/autotest-growl-pass-fail-notifications
11
+
12
+ After using Growl notification, I decided to write my own plugin because I have
13
+ to work on Ubuntu and Mac OS X and I missed the notification on my Linux box.
14
+ This plugin works with Linux, Mac OS X and Windows. All you need to do is
15
+ install the specific notification library for your OS.
16
+
17
+ Instead of displaying lots of notifications for each failure, I prefer to be
18
+ notified about the whole test result (you'll have to check your log
19
+ file anyway in order to clean up the failures/errors).
20
+
21
+ INSTALLATION:
22
+ -------------
23
+
24
+ ###Mac OS X
25
+
26
+ 1) Install Growl (http://growl.info/)
27
+ 2) Install the growlnotify script located on the "Extras" directory
28
+ 3) Open the Growl Preference Page (System > Growl) and activate the
29
+ options "Listen for incoming notifications" and "Allow remote
30
+ application registration" on the Network tab.
31
+
32
+ ###Linux
33
+
34
+ 1) Install libnotify-bin ant its dependencies:
35
+
36
+ aptitude install libnotify-bin
37
+
38
+ ###Windows
39
+
40
+ 1) Install Snarl: download from http://www.fullphat.net/
41
+ 2) Install ruby-snarl:
42
+
43
+ gem install ruby-snarl
44
+
45
+ ###All
46
+
47
+ Then, install the gem:
48
+
49
+ git clone git://github.com/fnando/test_notifier.git
50
+ cd test_notifier
51
+ rake gem:install
52
+
53
+ or
54
+
55
+ sudo gem install fnando-test_notifier --source=http://gems.github.com
56
+
57
+ USAGE:
58
+ ------
59
+
60
+ If you're using Test::Unit you should add `require "test_notifier/test_unit"`
61
+ If you're using RSpec you should add `require "test_notifier/rspec"`
62
+ If you're using Autotest you should add `require "test_notifier/autotest"` to
63
+ the file `~/.autotest`
64
+
65
+ If you want to customize the images, create a directory at `~/.test_notifier`
66
+ and save the images `none.png`, `passed.png`, `failure.png` and `error.png`.
67
+
68
+ MAINTAINER
69
+ ----------
70
+
71
+ * Nando Vieira ([http://simplesideias.com.br](http://simplesideias.com.br))
72
+
73
+ LICENSE:
74
+ --------
75
+
76
+ (The MIT License)
77
+
78
+ Permission is hereby granted, free of charge, to any person obtaining
79
+ a copy of this software and associated documentation files (the
80
+ 'Software'), to deal in the Software without restriction, including
81
+ without limitation the rights to use, copy, modify, merge, publish,
82
+ distribute, sublicense, and/or sell copies of the Software, and to
83
+ permit persons to whom the Software is furnished to do so, subject to
84
+ the following conditions:
85
+
86
+ The above copyright notice and this permission notice shall be
87
+ included in all copies or substantial portions of the Software.
88
+
89
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
90
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
91
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
92
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
93
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
94
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
95
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,73 @@
1
+ require 'rake'
2
+
3
+ PKG_FILES = %w(Rakefile test_notifier.gemspec History.txt License.txt README.markdown TODO.txt) +
4
+ Dir["lib/**/*"]
5
+
6
+ spec = Gem::Specification.new do |s|
7
+ s.name = "test_notifier"
8
+ s.version = "0.0.10"
9
+ s.summary = "Display system notifications (dbus, growl and snarl) after running tests."
10
+ s.authors = ["Nando Vieira"]
11
+ s.email = ["fnando.vieira@gmail.com"]
12
+ s.homepage = "http://github.com/fnando/test_notifier"
13
+ s.description = "Display system notifications (dbus, growl and snarl) after \
14
+ running tests. It works on Mac OS X, Linux and Windows. Powerful when used \
15
+ with Autotest ZenTest gem for Rails apps."
16
+ s.has_rdoc = false
17
+ s.files = PKG_FILES
18
+
19
+ s.add_dependency "rubigen"
20
+ s.requirements << "You'll need Growl (Mac OS X), Libnotify (Linux) or Snarl (Windows)"
21
+ end
22
+
23
+ namespace :gem do
24
+ # Thanks to the Merb project for this code.
25
+ desc "Update Github Gemspec"
26
+ task :update_gemspec do
27
+ skip_fields = %w(new_platform original_platform specification_version loaded required_ruby_version rubygems_version platform )
28
+
29
+ result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
30
+ result << "# RUN : 'rake gem:update_gemspec'\n\n"
31
+ result << "Gem::Specification.new do |s|\n"
32
+
33
+ spec.instance_variables.each do |ivar|
34
+ value = spec.instance_variable_get(ivar)
35
+ name = ivar.split("@").last
36
+ value = Time.now if name == "date"
37
+
38
+ next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
39
+ if name == "dependencies"
40
+ value.each do |d|
41
+ dep, *ver = d.to_s.split(" ")
42
+ result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "").gsub(", runtime", "")}\n"
43
+ end
44
+ else
45
+ case value
46
+ when Array
47
+ value = name != "files" ? value.inspect : value.inspect.split(",").join(",\n")
48
+ when FalseClass
49
+ when TrueClass
50
+ when Fixnum
51
+ when String
52
+ value = value.inspect
53
+ else
54
+ value = value.to_s.inspect
55
+ end
56
+ result << " s.#{name} = #{value}\n"
57
+ end
58
+ end
59
+
60
+ result << "end"
61
+ File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
62
+ end
63
+
64
+ desc "Build gem"
65
+ task :build => [:update_gemspec] do
66
+ system "gem build #{spec.instance_variable_get('@name')}.gemspec"
67
+ end
68
+
69
+ desc "Install gem"
70
+ task :install => [:update_gemspec, :build] do
71
+ system "sudo gem install #{spec.instance_variable_get('@name')}"
72
+ end
73
+ end
data/TODO.txt ADDED
File without changes
@@ -0,0 +1,12 @@
1
+ require 'test_notifier'
2
+
3
+ Autotest.add_hook :ran_command do |at|
4
+ begin
5
+ content = at.results.to_s
6
+
7
+ TestNotifier.rspec?(content) ?
8
+ TestNotifier.notification_for_rspec(content) :
9
+ TestNotifier.notification_for_test_unit(content)
10
+ rescue
11
+ end
12
+ end
Binary file
Binary file
Binary file
@@ -0,0 +1,26 @@
1
+ require 'test_notifier'
2
+ require 'spec/runner/formatter/base_text_formatter'
3
+
4
+ class Spec::Runner::Formatter::BaseTextFormatter
5
+ alias dump_summary_original dump_summary
6
+
7
+ def dump_summary(duration, examples, failed, pending)
8
+ dump_summary_original(duration, examples, failed, pending)
9
+
10
+ begin
11
+ return if examples == 0
12
+
13
+ if failed > 0
14
+ title = TestNotifier::FAILURE_TITLE
15
+ image = TestNotifier::ERROR_IMAGE
16
+ else
17
+ title = TestNotifier::PASSED_TITLE
18
+ image = TestNotifier::PASSED_IMAGE
19
+ end
20
+
21
+ message = "#{examples} examples, #{failed} failed, #{pending} pending"
22
+ TestNotifier::notify(image, title, message)
23
+ rescue
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ require 'test_notifier'
2
+ require 'test/unit/ui/console/testrunner'
3
+
4
+ class Test::Unit::UI::Console::TestRunner
5
+ alias finished_original finished
6
+
7
+ def finished(elapsed_time)
8
+ finished_original(elapsed_time)
9
+
10
+ begin
11
+ content = @result.to_s
12
+ TestNotifier.notification_for_test_unit(content)
13
+ rescue
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,78 @@
1
+ require 'snarl' if RUBY_PLATFORM =~ /mswin/
2
+
3
+ module TestNotifier
4
+ # create a .test_notifier at your home
5
+ # directory and save the images as passed.png,
6
+ # failure.png and error.png for custom images
7
+ PASSED_IMAGE = "passed.png"
8
+ FAILURE_IMAGE = "failure.png"
9
+ ERROR_IMAGE = "error.png"
10
+ FAILURE_TITLE = "FAILED"
11
+ PASSED_TITLE = "Passed"
12
+
13
+ RSPEC_REGEX = /(\d+) examples?, (\d+) failures?(, (\d+) pendings?)?/
14
+ TEST_UNIT_REGEX = /(\d+)\stests,\s(\d+)\sassertions,\s(\d+)\sfailures,\s(\d+)\serrors/
15
+
16
+ def self.notify(image, title, message)
17
+ image ||= "none.png"
18
+
19
+ custom_image = File.join(File.expand_path("~/.test_notifier"), image)
20
+ image = File.exists?(custom_image) ? custom_image : File.join(File.dirname(__FILE__), "test_notifier", "icons", image)
21
+
22
+ if RUBY_PLATFORM =~ /darwin/
23
+ system("growlnotify -n test_notifier --image #{image} -p 2 -m \"#{message}\" -t \"#{title}\"")
24
+ elsif RUBY_PLATFORM =~ /mswin/
25
+ Snarl.show_message(title, message, image)
26
+ elsif RUBY_PLATFORM =~ /(linux|freebsd)/
27
+ system("notify-send -i #{image} #{title} \"#{message}\"")
28
+ end
29
+ end
30
+
31
+ def self.rspec?(content)
32
+ (RSPEC_REGEX =~ content)
33
+ end
34
+
35
+ def self.notification_for_rspec(content)
36
+ matches, *output = *content.to_s.match(RSPEC_REGEX)
37
+ output = output.map {|i| i.to_i }
38
+ e, f, none, p = output
39
+
40
+ if f > 0
41
+ # test has failed
42
+ title = FAILURE_TITLE
43
+ image = FAILURE_IMAGE
44
+ elsif e > 0
45
+ # everything's ok
46
+ title = PASSED_TITLE
47
+ image = PASSED_IMAGE
48
+ else
49
+ # no examples
50
+ return
51
+ end
52
+
53
+ message = "#{e} examples, #{f} failures, #{p} pending"
54
+ notify(image, title, message)
55
+ end
56
+
57
+ def self.notification_for_test_unit(content)
58
+ matches, *output = *content.to_s.match(TEST_UNIT_REGEX)
59
+ output = output.map {|i| i.to_i }
60
+ t, a, f, e = output
61
+
62
+ if f > 0 || e > 0
63
+ # test has failed or raised an error
64
+ title = FAILURE_TITLE
65
+ image = e > 0 ? ERROR_IMAGE : FAILURE_IMAGE
66
+ elsif a > 0
67
+ # everything's ok
68
+ title = PASSED_TITLE
69
+ image = PASSED_IMAGE
70
+ else
71
+ # no assertions
72
+ return
73
+ end
74
+
75
+ message = "#{t} tests, #{a} assertions, #{f} failures, #{e} errors"
76
+ notify(image, title, message)
77
+ end
78
+ end
@@ -0,0 +1,34 @@
1
+ # WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!
2
+ # RUN : 'rake gem:update_gemspec'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.date = "Sat Sep 27 15:24:55 -0300 2008"
6
+ s.authors = ["Nando Vieira"]
7
+ s.require_paths = ["lib"]
8
+ s.required_rubygems_version = ">= 0"
9
+ s.has_rdoc = false
10
+ s.files = ["Rakefile",
11
+ "test_notifier.gemspec",
12
+ "History.txt",
13
+ "License.txt",
14
+ "README.markdown",
15
+ "TODO.txt",
16
+ "lib/test_notifier",
17
+ "lib/test_notifier/autotest.rb",
18
+ "lib/test_notifier/icons",
19
+ "lib/test_notifier/icons/error.png",
20
+ "lib/test_notifier/icons/failure.png",
21
+ "lib/test_notifier/icons/passed.png",
22
+ "lib/test_notifier/rspec.rb",
23
+ "lib/test_notifier/test_unit.rb",
24
+ "lib/test_notifier.rb"]
25
+ s.email = ["fnando.vieira@gmail.com"]
26
+ s.version = "0.0.10"
27
+ s.homepage = "http://github.com/fnando/test_notifier"
28
+ s.requirements = ["You'll need Growl (Mac OS X), Libnotify (Linux) or Snarl (Windows)"]
29
+ s.name = "test_notifier"
30
+ s.summary = "Display system notifications (dbus, growl and snarl) after running tests."
31
+ s.description = "Display system notifications (dbus, growl and snarl) after running tests. It works on Mac OS X, Linux and Windows. Powerful when used with Autotest ZenTest gem for Rails apps."
32
+ s.add_dependency "rubigen", ">= 0"
33
+ s.bindir = "bin"
34
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fnando-test_notifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.10
5
+ platform: ruby
6
+ authors:
7
+ - Nando Vieira
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-09-27 11:24:55 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rubigen
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ description: Display system notifications (dbus, growl and snarl) after running tests. It works on Mac OS X, Linux and Windows. Powerful when used with Autotest ZenTest gem for Rails apps.
25
+ email:
26
+ - fnando.vieira@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - Rakefile
35
+ - test_notifier.gemspec
36
+ - History.txt
37
+ - License.txt
38
+ - README.markdown
39
+ - TODO.txt
40
+ - lib/test_notifier
41
+ - lib/test_notifier/autotest.rb
42
+ - lib/test_notifier/icons
43
+ - lib/test_notifier/icons/error.png
44
+ - lib/test_notifier/icons/failure.png
45
+ - lib/test_notifier/icons/passed.png
46
+ - lib/test_notifier/rspec.rb
47
+ - lib/test_notifier/test_unit.rb
48
+ - lib/test_notifier.rb
49
+ has_rdoc: false
50
+ homepage: http://github.com/fnando/test_notifier
51
+ post_install_message:
52
+ rdoc_options: []
53
+
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ requirements:
69
+ - You'll need Growl (Mac OS X), Libnotify (Linux) or Snarl (Windows)
70
+ rubyforge_project:
71
+ rubygems_version: 1.2.0
72
+ signing_key:
73
+ specification_version: 2
74
+ summary: Display system notifications (dbus, growl and snarl) after running tests.
75
+ test_files: []
76
+