svoop-autotest-growl 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,10 @@
1
+ == 0.1.1 2009-06-02
2
+
3
+ * 1 major improvement
4
+ * Suppress Cucumber notification if not used
5
+
6
+ == 0.1.0 2009-05-28
7
+
8
+ * Initial release
9
+ * Growl notifications for Test::Unit, RSpec and Cucumber (workaround)
10
+ * Formerly part of autotest-mac which is now deprecated
data/Manifest.txt ADDED
@@ -0,0 +1,20 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ autotest-growl.gemspec
7
+ growl/growlnotify
8
+ img/error.png
9
+ img/failed.png
10
+ img/passed.png
11
+ img/pending.png
12
+ lib/autotest-growl.rb
13
+ lib/autotest/growl.rb
14
+ script/console
15
+ script/destroy
16
+ script/generate
17
+ spec/autotest-growl_spec.rb
18
+ spec/spec.opts
19
+ spec/spec_helper.rb
20
+ tasks/rspec.rake
data/PostInstall.txt ADDED
@@ -0,0 +1,15 @@
1
+ In order to use autotest-growl, the following line has to be added to your
2
+ ~/.autotest file:
3
+
4
+ require 'autotest/growl'
5
+
6
+ Make sure Growl is installed on your computer. Download it from:
7
+
8
+ http://growl.info
9
+
10
+ If Growl notifications are not always displayed, take a look at the README
11
+ for assistance.
12
+
13
+ For more information, feedback and bug submissions, please visit:
14
+
15
+ See http://www.bitcetera.com/products/autotest-growl
data/README.rdoc ADDED
@@ -0,0 +1,124 @@
1
+ = Autotest Growl
2
+
3
+ * Homepage: http://www.bitcetera.com/products/autotest-growl
4
+ * Issues and forum: https://forge.bitcetera.com/projects/show/autotest-growl
5
+
6
+ == DESCRIPTION:
7
+
8
+ This gem aims to improve support for Growl notification by ZenTest's autotest.
9
+ It comes with a nice colored Ruby icon set and - for now - supports Cucumber
10
+ notifications by means of a workaround.
11
+
12
+ Furthermore the terminal running autotest is cleared on every cycle. Don't
13
+ worry though, it's still possible to scroll up to see the output of previous
14
+ cycles.
15
+
16
+ === Ruby 1.9.1 Note
17
+
18
+ For the moment, autotest-growl doesn't seem to work on Ruby 1.9.1. Fixing this
19
+ might take a while though as autotest itself is currently misbehaving on Ruby
20
+ 1.9 - at least on my setup.
21
+
22
+ == REQUIREMENTS:
23
+
24
+ * Growl >= 1.1.4
25
+ * ZenTest >= 4.0.1
26
+
27
+ == INSTALL:
28
+
29
+ First install the gem:
30
+
31
+ sudo gem install autotest-growl
32
+
33
+ Then add the following line to your ~/.autotest file:
34
+
35
+ require 'autotest/growl'
36
+
37
+ Make sure Growl is installed on your computer. You can download it from:
38
+
39
+ http://growl.info
40
+
41
+ == CONFIGURATION:
42
+
43
+ === Custom Icons
44
+
45
+ Using your own set of icons is pretty simple. Just create a directory
46
+ ~/.autotest-growl, copy your icons there and name them passed.png,
47
+ pending.png, failed.png and error.png.
48
+
49
+ === Hide the Label
50
+
51
+ If you prefer the Growl notifications not to show labels such as "LABEL:
52
+ All tests have passed", add the following to your ~/.autotest:
53
+
54
+ Autotest::Growl::hide_label = true
55
+
56
+ == TROUBLESHOOTING:
57
+
58
+ === Missing Cucumber Notifications
59
+
60
+ If you are using autotest-fsevent as well, the require statements are not
61
+ ordered correctly. The require for autotest-fsevent must come after all
62
+ other requires in your ~/.autotest.
63
+
64
+ === Unreliable Growl Notifications
65
+
66
+ Under some circumstances, Growl notifications seem to be swallowed randomly.
67
+ If this happens to you, try the following.
68
+
69
+ Add this to your ~/.autotest:
70
+
71
+ Autotest::Growl::remote_notification = true
72
+
73
+ Now open "System Preferences -> Growl -> Network" and set the checkboxes
74
+ "Listen for incoming notifications" and "Allow remote application
75
+ registration”. Try whether remote notifications work with the following
76
+ test:
77
+
78
+ find /Library/Ruby /usr -name growlnotify -exec {} -H localhost -n autotest -m ok \;
79
+
80
+ If you get a NSPortTimeoutException, you should restart Growl and check
81
+ whether a firewall is blocking the connection. Once the notification is
82
+ displayed, go back to the System Preferences and disable the checkbox
83
+ "Allow remote application registration" again.
84
+
85
+ == DEVELOPMENT:
86
+
87
+ You can install the bleeding-edge version as follows:
88
+
89
+ sudo gem uninstall autotest-growl
90
+ sudo gem install svoop-autotest-growl --source http://gems.github.com
91
+
92
+ Please submit issues on:
93
+
94
+ https://forge.bitcetera.com/projects/show/autotest-growl
95
+
96
+ To contribute code, fork the project on Github, add your code and submit a
97
+ pull request:
98
+
99
+ http://github.com/guides/fork-a-project-and-submit-your-modifications
100
+
101
+ == LICENSE:
102
+
103
+ (The MIT License)
104
+
105
+ Copyright (c) 2009 Sven Schwyn
106
+
107
+ Permission is hereby granted, free of charge, to any person obtaining
108
+ a copy of this software and associated documentation files (the
109
+ 'Software'), to deal in the Software without restriction, including
110
+ without limitation the rights to use, copy, modify, merge, publish,
111
+ distribute, sublicense, and/or sell copies of the Software, and to
112
+ permit persons to whom the Software is furnished to do so, subject to
113
+ the following conditions:
114
+
115
+ The above copyright notice and this permission notice shall be
116
+ included in all copies or substantial portions of the Software.
117
+
118
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
119
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
120
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
121
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
122
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
123
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
124
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
2
+ %w[rake rake/clean fileutils newgem rubigen].each { |f| require f }
3
+ require File.dirname(__FILE__) + '/lib/autotest-growl'
4
+
5
+ $hoe = Hoe.new('autotest-growl', AutotestGrowl::VERSION) do |p|
6
+ p.developer('Sven Schwyn', 'ruby@bitcetera.com')
7
+ p.summary = %q{Next generation Growl notification support for ZenTest's autotest.}
8
+ p.description = %q{This gem aims to improve support for Growl notification by ZenTest's autotest. It comes with a nice colored Ruby icon set and - for now - supports Cucumber by means of a workaround.}
9
+ p.url = %q{http://www.bitcetera.com/products/autotest-growl}
10
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
11
+ p.post_install_message = "\n\e[1;32m" + File.read('PostInstall.txt') + "\e[0;30m\n"
12
+ p.rubyforge_name = p.name
13
+ p.extra_deps = [
14
+ ['ZenTest','>= 4.0.0'],
15
+ ]
16
+ p.extra_dev_deps = [
17
+ ['newgem', ">= #{::Newgem::VERSION}"]
18
+ ]
19
+
20
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
21
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
22
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
23
+ p.rsync_args = '-av --delete --ignore-errors'
24
+ end
25
+
26
+ require 'newgem/tasks'
27
+ Dir['tasks/**/*.rake'].each { |t| load t }
data/growl/growlnotify ADDED
Binary file
data/img/error.png ADDED
Binary file
data/img/failed.png ADDED
Binary file
data/img/passed.png ADDED
Binary file
data/img/pending.png ADDED
Binary file
@@ -0,0 +1,95 @@
1
+ require 'rubygems'
2
+ require 'autotest'
3
+
4
+ ##
5
+ # Autotest::Growl
6
+ #
7
+ # == FEATUERS:
8
+ # * Display autotest results as local or remote Growl notifications.
9
+ # * Clean the terminal on every test cycle while maintaining scrollback.
10
+ #
11
+ # == SYNOPSIS:
12
+ # ~/.autotest
13
+ # require 'autotest/growl'
14
+ module Autotest::Growl
15
+
16
+ GEM_PATH = File.expand_path(File.join(File.dirname(__FILE__), '../..'))
17
+
18
+ @@remote_notification = false
19
+ @@hide_label = false
20
+
21
+ ##
22
+ # Whether to use remote or local notificaton (default).
23
+ def self.remote_notification=(boolean)
24
+ @@remote_notification = boolean
25
+ end
26
+
27
+ ##
28
+ # Whether to display the label (default) or not.
29
+ def self.hide_label=(boolean)
30
+ @@hide_label = boolean
31
+ end
32
+
33
+ ##
34
+ # Display a message through Growl.
35
+ def self.growl title, message, icon, priority=0, stick=""
36
+ growl = File.join(GEM_PATH, 'growl', 'growlnotify')
37
+ image = File.join(ENV['HOME'], '.autotest-growl', "#{icon}.png")
38
+ image = File.join(GEM_PATH, 'img', "#{icon}.png") unless File.exists?(image)
39
+ if @@remote_notification
40
+ system "#{growl} -H localhost -n autotest --image '#{image}' -p #{priority} -m #{message.inspect} '#{title}' #{stick}"
41
+ else
42
+ system "#{growl} -n autotest --image '#{image}' -p #{priority} -m #{message.inspect} '#{title}' #{stick}"
43
+ end
44
+ end
45
+
46
+ ##
47
+ # Set the label and clear the terminal.
48
+ Autotest.add_hook :run_command do
49
+ @label = (@@hide_label) ? ('') : (File.basename(Dir.pwd).upcase + ': ')
50
+ @run_scenarios = false
51
+ print "\n"*2 + '-'*80 + "\n"*2
52
+ print "\e[2J\e[f" # clear the terminal
53
+ false
54
+ end
55
+
56
+ ##
57
+ # Parse the test results and send them to Growl.
58
+ Autotest.add_hook :ran_command do |autotest|
59
+ gist = autotest.results.grep(/\d+\s+(example|test)s?/).map {|s| s.gsub(/(\e.*?m|\n)/, '') }.join(" / ")
60
+ if gist == ''
61
+ growl @label + 'Cannot run tests.', '', 'error'
62
+ else
63
+ if gist =~ /[1-9]\d*\s+(failure|error)/
64
+ growl @label + 'Some tests have failed.', gist, 'failed'
65
+ elsif gist =~ /pending/
66
+ growl @label + 'Some tests are pending.', gist, 'pending'
67
+ @run_scenarios = true
68
+ else
69
+ growl @label + 'All tests have passed.', gist, 'passed'
70
+ @run_scenarios = true
71
+ end
72
+ end
73
+ false
74
+ end
75
+
76
+ # FIXME: This is a temporary workaround until Cucumber is properly integrated!
77
+ Autotest.add_hook :waiting do |autotest|
78
+ if @run_scenarios && !autotest.results.grep(/^\d+ scenario/).empty?
79
+ gist = autotest.results.grep(/\d+\s+(scenario|step)s?/).map {|s| s.gsub(/(\e.*?m|\n)/, '') }.join(" / ")
80
+ if gist == ''
81
+ growl @label + 'Cannot run scenarios.', '', 'error'
82
+ else
83
+ if gist =~ /failed/
84
+ growl @label + 'Some scenarios have failed.', gist, 'failed'
85
+ elsif gist =~ /undefined/
86
+ growl @label + 'Some scenarios are undefined.', gist, 'pending'
87
+ else
88
+ growl @label + 'All scenarios have passed.', gist, 'passed'
89
+ end
90
+ end
91
+ end
92
+ false
93
+ end
94
+
95
+ end
@@ -0,0 +1,8 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ module AutotestGrowl
5
+
6
+ VERSION = '0.1.0'
7
+
8
+ 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-growl.rb'}"
9
+ puts "Loading autotest-growl 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)
data/script/generate 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/generate'
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::Generate.new.run(ARGV)
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'autotest-growl'
data/tasks/rspec.rake ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: svoop-autotest-growl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sven Schwyn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-06-03 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: ZenTest
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 4.0.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: newgem
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.4.1
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: hoe
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.8.0
44
+ version:
45
+ description: This gem aims to improve support for Growl notification by ZenTest's autotest. It comes with a nice colored Ruby icon set and - for now - supports Cucumber by means of a workaround.
46
+ email:
47
+ - ruby@bitcetera.com
48
+ executables: []
49
+
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - History.txt
54
+ - Manifest.txt
55
+ - PostInstall.txt
56
+ - README.rdoc
57
+ files:
58
+ - History.txt
59
+ - Manifest.txt
60
+ - PostInstall.txt
61
+ - README.rdoc
62
+ - Rakefile
63
+ - growl/growlnotify
64
+ - img/error.png
65
+ - img/failed.png
66
+ - img/passed.png
67
+ - img/pending.png
68
+ - lib/autotest-growl.rb
69
+ - lib/autotest/growl.rb
70
+ - script/console
71
+ - script/destroy
72
+ - script/generate
73
+ - spec/autotest-growl_spec.rb
74
+ - spec/spec.opts
75
+ - spec/spec_helper.rb
76
+ - tasks/rspec.rake
77
+ has_rdoc: false
78
+ homepage: http://www.bitcetera.com/products/autotest-growl
79
+ post_install_message: "\n\
80
+ \e[1;32mIn order to use autotest-growl, the following line has to be added to your\n\
81
+ ~/.autotest file:\n\n\
82
+ require 'autotest/growl'\n\n\
83
+ Make sure Growl is installed on your computer. Download it from:\n\n\
84
+ http://growl.info\n\n\
85
+ If Growl notifications are not always displayed, take a look at the README\n\
86
+ for assistance.\n\n\
87
+ For more information, feedback and bug submissions, please visit:\n\n\
88
+ See http://www.bitcetera.com/products/autotest-growl\n\
89
+ \e[0;30m\n"
90
+ rdoc_options:
91
+ - --main
92
+ - README.rdoc
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: "0"
100
+ version:
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: "0"
106
+ version:
107
+ requirements: []
108
+
109
+ rubyforge_project: autotest-growl
110
+ rubygems_version: 1.2.0
111
+ signing_key:
112
+ specification_version: 3
113
+ summary: Next generation Growl notification support for ZenTest's autotest.
114
+ test_files: []
115
+