riot_notifier 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ doc
2
+ pkg
3
+ coverage
4
+ tags
data/.watchr ADDED
@@ -0,0 +1,21 @@
1
+
2
+ def run(*args)
3
+ system "ruby -rubygems -Ilib:test #{args.join(' ')}"
4
+ end
5
+
6
+ def run_tests
7
+ system "rake test"
8
+ end
9
+
10
+ def underscore(file)
11
+ file.gsub('/', '_')
12
+ end
13
+
14
+ watch('test/test_.*\.rb') {|md| run md[0] }
15
+ watch('lib/(.*)\.rb') {|md| run "test/test_#{underscore(md[1])}.rb" }
16
+ watch('test/helper.rb') { run_tests }
17
+
18
+ run_tests
19
+
20
+ Signal.trap("QUIT") { abort("\n") }
21
+ Signal.trap("INT") { run_tests }
data/README.rdoc ADDED
@@ -0,0 +1,39 @@
1
+ = Notifier for testing framework riot.
2
+
3
+ Notifies you about passes, errors, failures via $HOME/bin/notify_redgreen
4
+
5
+ == Usage
6
+
7
+ # in your test/helper.rb
8
+
9
+ require 'riot'
10
+ require 'riot_notifier'
11
+
12
+ Riot.reporter = RiotNotifier::RedgreenNotifier
13
+
14
+ == notify_redgreen
15
+
16
+ Your $HOME/bin/notify_redgreen
17
+
18
+ #!/bin/sh
19
+
20
+ case "$1" in
21
+ red)
22
+ OPTIONS="-t 2500 -u critical -i /usr/share/icons/gnome/scalable/emotes/face-angry.svg :-("
23
+ ;;
24
+ green)
25
+ OPTIONS="-t 2000 -u normal -i /usr/share/icons/gnome/scalable/emblems/emblem-default.svg :-)"
26
+ ;;
27
+ esac
28
+ shift
29
+
30
+ notify-send $OPTIONS "$*"
31
+
32
+ == Install via gemcutter
33
+
34
+ gem install gemcutter
35
+ gem tumble
36
+ gem install riot_notifier
37
+
38
+ == Authors
39
+ * Peter Suschlik
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ require 'jeweler'
9
+ Jeweler::Tasks.new do |gem|
10
+ gem.name = "riot_notifier"
11
+ gem.summary = 'Simple notifier for riot'
12
+ gem.email = "peter-riot_notifier@suschlik.de"
13
+ gem.homepage = "http://github.com/splattael/riot_notifier"
14
+ gem.authors = ["Peter Suschlik"]
15
+
16
+ gem.has_rdoc = true
17
+ gem.extra_rdoc_files = [ "README.rdoc" ]
18
+
19
+ gem.add_development_dependency "riot", "= 0.10.1"
20
+
21
+ gem.test_files = Dir.glob('test/test_*.rb')
22
+ end
23
+
24
+ Jeweler::GemcutterTasks.new
25
+
26
+ # Test
27
+ require 'rake/testtask'
28
+ Rake::TestTask.new(:test) do |test|
29
+ test.test_files = FileList.new('test/test_*.rb')
30
+ test.libs << 'test'
31
+ test.verbose = true
32
+ end
33
+
34
+ # RDoc
35
+ Rake::RDocTask.new do |rd|
36
+ rd.title = "Riot Notifier"
37
+ rd.main = "README.rdoc"
38
+ rd.rdoc_files.include("README.rdoc", "lib/*.rb")
39
+ rd.rdoc_dir = "doc"
40
+ end
41
+
42
+
43
+ # Misc
44
+ desc "Tag files for vim"
45
+ task :ctags do
46
+ dirs = $LOAD_PATH.select {|path| File.directory?(path) }
47
+ system "ctags -R #{dirs.join(" ")}"
48
+ end
49
+
50
+ desc "Find whitespace at line ends"
51
+ task :eol do
52
+ system "grep -nrE ' +$' *"
53
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 0
4
+ :patch: 1
5
+ :build:
@@ -0,0 +1,52 @@
1
+ module RiotNotifier
2
+ class Base < Riot::DotMatrixReporter
3
+ def notify(color, msg)
4
+ # overwrite me
5
+ end
6
+
7
+ def fail(desc, message)
8
+ super
9
+ say "#{desc}: #{message}".yellow
10
+ notify(:red, "FAILURE: #{message}")
11
+ end
12
+
13
+ def error(desc, error)
14
+ super
15
+ say "#{desc}: #{error}".red
16
+ notify(:red, "ERROR: #{error}")
17
+ end
18
+
19
+ def results(time_taken)
20
+ super
21
+ unless bad_results?
22
+ notify(:green, "%d passes, %d failures, %d errors in %s seconds" % [passes, failures, errors, ("%0.6f" % time_taken)])
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def bad_results?
29
+ failures + errors > 0
30
+ end
31
+ end
32
+
33
+ class RedgreenNotifier < Base
34
+ attr_reader :path
35
+ PATH = ENV['HOME'] + "/bin/notify_redgreen"
36
+
37
+ def initialize(path = PATH)
38
+ super()
39
+ @path = path
40
+ end
41
+
42
+ def notify(color, msg)
43
+ msg.gsub!(/</, '&lt;')
44
+ msg.gsub!(/"/, "\\\"")
45
+ exec "#{@path} #{color} \"#{msg}\""
46
+ end
47
+
48
+ def exec(*args)
49
+ Kernel.system(*args)
50
+ end
51
+ end
52
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'riot'
2
+
3
+ require 'riot_notifier'
4
+
5
+ Riot.reporter = RiotNotifier::RedgreenNotifier
@@ -0,0 +1,51 @@
1
+ require 'helper'
2
+ require 'stringio'
3
+
4
+ class MockNotifier < ::RiotNotifier::Base
5
+ def initialize
6
+ super(StringIO.new)
7
+ end
8
+
9
+ def notify(color, msg)
10
+ [ color, msg ]
11
+ end
12
+ end
13
+
14
+ context "RiotNotifier" do
15
+ context "with MockNotifier" do
16
+ setup { MockNotifier.new }
17
+
18
+ asserts("displays failure in red") { topic.fail("desc", "failed") }.equals([:red, "FAILURE: failed"])
19
+ asserts("displays error in red") { topic.error("desc", "errored") }.equals([:red, "ERROR: errored"])
20
+ asserts("doesn't display results with bad results") do
21
+ topic.report("desc", [:fail, "failure"])
22
+ topic.report("desc", [:error, "error"])
23
+ topic.results(23.0)
24
+ end.nil
25
+
26
+ context "displays results without bad results" do
27
+ asserts("in green") do
28
+ topic.results(0.0).first
29
+ end.equals(:green)
30
+ asserts("correctly") do
31
+ topic.results(0.0).last
32
+ end.matches(/0 passes, 0 failures, 0 errors in 0.000000 seconds/)
33
+ end
34
+ end # with MockNotifier
35
+
36
+ context "with RedgreenNotifier" do
37
+ setup do
38
+ klass = RiotNotifier::RedgreenNotifier.dup
39
+ klass.class_eval do
40
+ def exec(string)
41
+ string
42
+ end
43
+ end
44
+ klass.new
45
+ end
46
+
47
+ asserts("notify green hello world") { topic.notify(:red, "hello world") }.matches(/red "hello world"/)
48
+ asserts("escape <") { topic.notify(:red, "<Topic>") }.matches(/&lt;Topic>/)
49
+ asserts("quote double quotes") { topic.notify(:red, %{"errored"}) }.matches(/\\"errored\\"/)
50
+ end
51
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riot_notifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Peter Suschlik
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-27 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: riot
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - "="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.10.1
24
+ version:
25
+ description:
26
+ email: peter-riot_notifier@suschlik.de
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.rdoc
33
+ files:
34
+ - .gitignore
35
+ - .watchr
36
+ - README.rdoc
37
+ - Rakefile
38
+ - VERSION.yml
39
+ - lib/riot_notifier.rb
40
+ - test/helper.rb
41
+ - test/test_riot_notifier.rb
42
+ has_rdoc: true
43
+ homepage: http://github.com/splattael/riot_notifier
44
+ licenses: []
45
+
46
+ post_install_message:
47
+ rdoc_options:
48
+ - --charset=UTF-8
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.3.5
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Simple notifier for riot
70
+ test_files:
71
+ - test/test_riot_notifier.rb