rcov_notifier 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/PostInstall.txt +9 -0
- data/README.markdown +34 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/growl/growlnotify +0 -0
- data/growl/growlnotify.com +0 -0
- data/images/100_green.png +0 -0
- data/images/100_red.png +0 -0
- data/images/20_green.png +0 -0
- data/images/20_red.png +0 -0
- data/images/40_green.png +0 -0
- data/images/40_red.png +0 -0
- data/images/60_green.png +0 -0
- data/images/60_red.png +0 -0
- data/images/80_green.png +0 -0
- data/images/80_red.png +0 -0
- data/images/application.png +0 -0
- data/lib/rcov_notifier/rcov_notifier.rb +92 -0
- data/lib/rcov_notifier.rb +8 -0
- data/rcov_notifier.gemspec +84 -0
- data/spec/rcov_notifier_spec.rb +4 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- metadata +129 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Chinmay Garde
|
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/PostInstall.txt
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
----------------------------------------------------
|
2
|
+
----------------------------------------------------
|
3
|
+
|
4
|
+
Add the following to your ~/.autotext file
|
5
|
+
|
6
|
+
require 'rcov_notifier'
|
7
|
+
|
8
|
+
----------------------------------------------------
|
9
|
+
----------------------------------------------------
|
data/README.markdown
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
rcov_notifier
|
2
|
+
-------------
|
3
|
+
|
4
|
+
Get RCov report notifications via Growl
|
5
|
+
|
6
|
+
Usage
|
7
|
+
-----
|
8
|
+
1. Get the gem
|
9
|
+
[sudo] gem install rcov_notifier
|
10
|
+
|
11
|
+
2. Add the following to the `~/.autotest` file
|
12
|
+
require 'rcov_notifier'
|
13
|
+
|
14
|
+
Customization
|
15
|
+
-------------
|
16
|
+
1. Modify the coverage reports directory. Add the following to the `~/.autotest` file
|
17
|
+
RCovNotifier.coverage_dir = "foo"
|
18
|
+
RCovNotifier.threshold_percent = 95
|
19
|
+
|
20
|
+
Note on Patches/Pull Requests
|
21
|
+
-----------------------------
|
22
|
+
|
23
|
+
* Fork the project.
|
24
|
+
* Make your feature addition or bug fix.
|
25
|
+
* Add tests for it. This is important so I don't break it in a
|
26
|
+
future version unintentionally.
|
27
|
+
* Commit, do not mess with rakefile, version, or history.
|
28
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
29
|
+
* Send me a pull request. Bonus points for topic branches.
|
30
|
+
|
31
|
+
Copyright
|
32
|
+
---------
|
33
|
+
|
34
|
+
Copyright (c) 2010 Chinmay Garde. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "rcov_notifier"
|
8
|
+
gem.summary = %Q{Get RCov notifications via Growl}
|
9
|
+
gem.description = %Q{Get RCov notifications via Growl. More on GitHub}
|
10
|
+
gem.email = "chinmaygarde@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/chinmaygarde/rcov_notifier"
|
12
|
+
gem.post_install_message = "\n\e[1;32m" + File.read('PostInstall.txt') + "\e[0m\n"
|
13
|
+
gem.authors = ["Chinmay Garde"]
|
14
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
15
|
+
gem.add_dependency "nokogiri"
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.libs << 'lib' << 'spec'
|
25
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
end
|
27
|
+
|
28
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
+
spec.libs << 'lib' << 'spec'
|
30
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
spec.rcov = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task :spec => :check_dependencies
|
35
|
+
|
36
|
+
task :default => :spec
|
37
|
+
|
38
|
+
require 'rake/rdoctask'
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
40
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
+
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = "rcov_notifier #{version}"
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/growl/growlnotify
ADDED
Binary file
|
Binary file
|
Binary file
|
data/images/100_red.png
ADDED
Binary file
|
data/images/20_green.png
ADDED
Binary file
|
data/images/20_red.png
ADDED
Binary file
|
data/images/40_green.png
ADDED
Binary file
|
data/images/40_red.png
ADDED
Binary file
|
data/images/60_green.png
ADDED
Binary file
|
data/images/60_red.png
ADDED
Binary file
|
data/images/80_green.png
ADDED
Binary file
|
data/images/80_red.png
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,92 @@
|
|
1
|
+
class RCovNotifier
|
2
|
+
@@coverage_dir = "coverage"
|
3
|
+
@@threshold_percent = 100
|
4
|
+
|
5
|
+
GEM_PATH = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
|
6
|
+
|
7
|
+
def self.coverage_dir=(name)
|
8
|
+
@@coverage_dir = name
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.threshold_percent=(percent)
|
12
|
+
@@threshold_percent = percent
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(project_path)
|
16
|
+
@project_path = project_path
|
17
|
+
end
|
18
|
+
|
19
|
+
def image_path(image_name)
|
20
|
+
File.join(GEM_PATH, "images", image_name)
|
21
|
+
end
|
22
|
+
|
23
|
+
def coverage_report_index_path
|
24
|
+
File.join(File.expand_path(@project_path), @@coverage_dir, "index.html")
|
25
|
+
end
|
26
|
+
|
27
|
+
def report
|
28
|
+
if !File.exists?(coverage_report_index_path)
|
29
|
+
growl("Not Found", "Could not file coverage report files at #{coverage_report_index_path}")
|
30
|
+
else
|
31
|
+
coverage_percentage = get_coverage_percentage(coverage_report_index_path)
|
32
|
+
message = get_message_for_coverage(coverage_percentage)
|
33
|
+
growl("Test Coverage", "#{coverage_percentage}% #{message}", select_image(coverage_percentage))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def growl(title, message, icon="application.png", priority=0, sticky=false)
|
38
|
+
growl = File.join(GEM_PATH, 'growl', 'growlnotify')
|
39
|
+
image = image_path(icon)
|
40
|
+
case Config::CONFIG['host_os']
|
41
|
+
when /mac os|darwin/i
|
42
|
+
options = "-w -n Autotest --image '#{image}' -p #{priority} -m '#{message}' '#{title}' #{'-s' if sticky}"
|
43
|
+
system %(#{growl} #{options} &)
|
44
|
+
when /linux|bsd/i
|
45
|
+
system %(notify-send "#{title}" "#{message}" -i #{image} -t 5000)
|
46
|
+
when /windows|mswin|mingw|cygwin/i
|
47
|
+
growl += '.com'
|
48
|
+
system %(#{growl} #{message.inspect} /a:"Autotest" /r:"Autotest" /n:"Autotest" /i:"#{image}" /p:#{priority} /t:"#{title}" /s:#{sticky})
|
49
|
+
else
|
50
|
+
raise "#{Config::CONFIG['host_os']} is not supported by autotest-growl (feel free to submit a patch)"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_message_for_coverage(coverage_percentage)
|
55
|
+
message = "coverage."
|
56
|
+
case coverage_percentage
|
57
|
+
when 100
|
58
|
+
message = "coverage. Pure awesomeness"
|
59
|
+
when (@@threshold_percent .. 100)
|
60
|
+
message = "coverage. You're on target :)"
|
61
|
+
when (0 .. @@threshold_percent)
|
62
|
+
message = "coverage. Not enough. Try harder!"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_coverage_percentage(file_path)
|
67
|
+
doc = Nokogiri::HTML(File.open(file_path, "r").read)
|
68
|
+
doc.at_css('tfoot .percent_graph_legend tt').text.match(/[0-9.]+/).to_s.to_f
|
69
|
+
end
|
70
|
+
|
71
|
+
def select_image(percentage)
|
72
|
+
|
73
|
+
display_num = 100
|
74
|
+
case percentage
|
75
|
+
when (80 .. 100)
|
76
|
+
display_num = 100
|
77
|
+
when (60 .. 80)
|
78
|
+
display_num = 80
|
79
|
+
when (40 .. 60)
|
80
|
+
display_num = 60
|
81
|
+
when (20 .. 40)
|
82
|
+
display_num = 40
|
83
|
+
when (0 .. 20)
|
84
|
+
display_num = 20
|
85
|
+
end
|
86
|
+
below_threshold?(percentage) ? "#{display_num}_red.png" : "#{display_num}_green.png"
|
87
|
+
end
|
88
|
+
|
89
|
+
def below_threshold?(percentage)
|
90
|
+
percentage < @@threshold_percent
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rcov_notifier}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Chinmay Garde"]
|
12
|
+
s.date = %q{2010-10-02}
|
13
|
+
s.description = %q{Get RCov notifications via Growl. More on GitHub}
|
14
|
+
s.email = %q{chinmaygarde@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"PostInstall.txt",
|
24
|
+
"README.markdown",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"growl/growlnotify",
|
28
|
+
"growl/growlnotify.com",
|
29
|
+
"images/100_green.png",
|
30
|
+
"images/100_red.png",
|
31
|
+
"images/20_green.png",
|
32
|
+
"images/20_red.png",
|
33
|
+
"images/40_green.png",
|
34
|
+
"images/40_red.png",
|
35
|
+
"images/60_green.png",
|
36
|
+
"images/60_red.png",
|
37
|
+
"images/80_green.png",
|
38
|
+
"images/80_red.png",
|
39
|
+
"images/application.png",
|
40
|
+
"lib/rcov_notifier.rb",
|
41
|
+
"lib/rcov_notifier/rcov_notifier.rb",
|
42
|
+
"rcov_notifier.gemspec",
|
43
|
+
"spec/rcov_notifier_spec.rb",
|
44
|
+
"spec/spec.opts",
|
45
|
+
"spec/spec_helper.rb"
|
46
|
+
]
|
47
|
+
s.homepage = %q{http://github.com/chinmaygarde/rcov_notifier}
|
48
|
+
s.post_install_message = %q{
|
49
|
+
[1;32m----------------------------------------------------
|
50
|
+
----------------------------------------------------
|
51
|
+
|
52
|
+
Add the following to your ~/.autotext file
|
53
|
+
|
54
|
+
require 'rcov_notifier'
|
55
|
+
|
56
|
+
----------------------------------------------------
|
57
|
+
----------------------------------------------------[0m
|
58
|
+
}
|
59
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
60
|
+
s.require_paths = ["lib"]
|
61
|
+
s.rubygems_version = %q{1.3.7}
|
62
|
+
s.summary = %q{Get RCov notifications via Growl}
|
63
|
+
s.test_files = [
|
64
|
+
"spec/rcov_notifier_spec.rb",
|
65
|
+
"spec/spec_helper.rb"
|
66
|
+
]
|
67
|
+
|
68
|
+
if s.respond_to? :specification_version then
|
69
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
70
|
+
s.specification_version = 3
|
71
|
+
|
72
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
73
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
74
|
+
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
75
|
+
else
|
76
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
77
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
78
|
+
end
|
79
|
+
else
|
80
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
81
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rcov_notifier
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Chinmay Garde
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-02 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 2
|
33
|
+
- 9
|
34
|
+
version: 1.2.9
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: nokogiri
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: *id002
|
51
|
+
description: Get RCov notifications via Growl. More on GitHub
|
52
|
+
email: chinmaygarde@gmail.com
|
53
|
+
executables: []
|
54
|
+
|
55
|
+
extensions: []
|
56
|
+
|
57
|
+
extra_rdoc_files:
|
58
|
+
- LICENSE
|
59
|
+
- README.markdown
|
60
|
+
files:
|
61
|
+
- .document
|
62
|
+
- .gitignore
|
63
|
+
- LICENSE
|
64
|
+
- PostInstall.txt
|
65
|
+
- README.markdown
|
66
|
+
- Rakefile
|
67
|
+
- VERSION
|
68
|
+
- growl/growlnotify
|
69
|
+
- growl/growlnotify.com
|
70
|
+
- images/100_green.png
|
71
|
+
- images/100_red.png
|
72
|
+
- images/20_green.png
|
73
|
+
- images/20_red.png
|
74
|
+
- images/40_green.png
|
75
|
+
- images/40_red.png
|
76
|
+
- images/60_green.png
|
77
|
+
- images/60_red.png
|
78
|
+
- images/80_green.png
|
79
|
+
- images/80_red.png
|
80
|
+
- images/application.png
|
81
|
+
- lib/rcov_notifier.rb
|
82
|
+
- lib/rcov_notifier/rcov_notifier.rb
|
83
|
+
- rcov_notifier.gemspec
|
84
|
+
- spec/rcov_notifier_spec.rb
|
85
|
+
- spec/spec.opts
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
has_rdoc: true
|
88
|
+
homepage: http://github.com/chinmaygarde/rcov_notifier
|
89
|
+
licenses: []
|
90
|
+
|
91
|
+
post_install_message: "\n\
|
92
|
+
\e[1;32m----------------------------------------------------\n\
|
93
|
+
----------------------------------------------------\n\n\
|
94
|
+
Add the following to your ~/.autotext file\n\n\
|
95
|
+
\trequire 'rcov_notifier'\n\n\
|
96
|
+
----------------------------------------------------\n\
|
97
|
+
----------------------------------------------------\e[0m\n"
|
98
|
+
rdoc_options:
|
99
|
+
- --charset=UTF-8
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
hash: 3
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
version: "0"
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
hash: 3
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
version: "0"
|
120
|
+
requirements: []
|
121
|
+
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 1.3.7
|
124
|
+
signing_key:
|
125
|
+
specification_version: 3
|
126
|
+
summary: Get RCov notifications via Growl
|
127
|
+
test_files:
|
128
|
+
- spec/rcov_notifier_spec.rb
|
129
|
+
- spec/spec_helper.rb
|