rcr-notify 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +58 -0
- data/VERSION +1 -0
- data/bin/rcr-notify +25 -0
- data/lib/rcr-notify.rb +63 -0
- data/rcr-notify.gemspec +59 -0
- data/test/runcoderun-notifier_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +86 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Jacob Rothstein
|
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.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= runcoderun-notifier
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but
|
13
|
+
bump version in a commit by itself I can ignore when I pull)
|
14
|
+
* Send me a pull request. Bonus points for topic branches.
|
15
|
+
|
16
|
+
== Copyright
|
17
|
+
|
18
|
+
Copyright (c) 2009 Jacob Rothstein. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "rcr-notify"
|
8
|
+
gem.summary = %Q{Growl notification for runcoderun builds}
|
9
|
+
gem.description = %Q{Simple json poller with ruby-growl notification}
|
10
|
+
gem.email = "github@jacobrothstein.com"
|
11
|
+
gem.homepage = "http://github.com/jbr/rcr-notify"
|
12
|
+
gem.bindir = "bin"
|
13
|
+
gem.authors = ["Jacob Rothstein"]
|
14
|
+
gem.add_dependency 'ruby-growl'
|
15
|
+
gem.add_dependency 'json'
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/*_test.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/*_test.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
task :test => :check_dependencies
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
if File.exist?('VERSION')
|
49
|
+
version = File.read('VERSION')
|
50
|
+
else
|
51
|
+
version = ""
|
52
|
+
end
|
53
|
+
|
54
|
+
rdoc.rdoc_dir = 'rdoc'
|
55
|
+
rdoc.title = "runcoderun-notifier #{version}"
|
56
|
+
rdoc.rdoc_files.include('README*')
|
57
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
58
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/rcr-notify
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require File.instance_eval{expand_path(join(dirname(__FILE__), '..', 'lib', 'rcr-notify'))}
|
3
|
+
|
4
|
+
notifier = RcrNotify::Notifier.new
|
5
|
+
|
6
|
+
OptionParser.new do |opts|
|
7
|
+
opts.banner = "Usage: #{$0} [options]"
|
8
|
+
opts.instance_eval do
|
9
|
+
on("-u", "--user USERNAME", "Runcoderun Username") {|u| notifier.settings[:username] = u }
|
10
|
+
on("-i", "--interval INTERVAL", "Polling interval in seconds (default: 30)") do |i|
|
11
|
+
notifier.settings[:interval] = i.to_i
|
12
|
+
end
|
13
|
+
on_tail("--help", "This message") {puts opts; exit}
|
14
|
+
end
|
15
|
+
end.parse!
|
16
|
+
|
17
|
+
unless notifier.settings[:username]
|
18
|
+
puts "at least username is required. see --help"
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
22
|
+
loop do
|
23
|
+
notifier.poll
|
24
|
+
sleep notifier.settings[:interval]
|
25
|
+
end
|
data/lib/rcr-notify.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'ruby-growl'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'json'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
module RcrNotify
|
8
|
+
class Notifier
|
9
|
+
attr_reader :settings, :last_projects
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@settings = {:interval => 30}
|
13
|
+
@growl = Growl.new "localhost", "run>code>run notifier", %w(success failure)
|
14
|
+
end
|
15
|
+
|
16
|
+
def poll
|
17
|
+
data = JSON::parse open(url).read
|
18
|
+
|
19
|
+
projects = data["user"]["projects"].inject({}) do |hash, project|
|
20
|
+
hash.merge project.delete("name") => project
|
21
|
+
end
|
22
|
+
|
23
|
+
if last_projects
|
24
|
+
projects.each do |name, this_time|
|
25
|
+
notify_for last_projects[name], this_time
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
@last_projects = projects
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def notify_for(last_time, this_time)
|
35
|
+
return if this_time['commit'] == last_time['commit']
|
36
|
+
|
37
|
+
commit_message = "\"#{this_time['commit_message']}\"\n" +
|
38
|
+
"\t\t—#{this_time['author_name']}"
|
39
|
+
|
40
|
+
title = if success?(this_time)
|
41
|
+
success?(last_time) ? 'success' : 'fixed'
|
42
|
+
else
|
43
|
+
success?(last_time) ? 'broken' : 'still broken'
|
44
|
+
end
|
45
|
+
|
46
|
+
notify title, commit_message, success?(this_time)
|
47
|
+
end
|
48
|
+
|
49
|
+
def success?(hash)
|
50
|
+
hash["status"] == "success"
|
51
|
+
end
|
52
|
+
|
53
|
+
def url
|
54
|
+
"http://runcoderun.com/api/v1/json/#{settings[:username]}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def notify(title, body, success)
|
58
|
+
type = success ? 'success' : 'failure'
|
59
|
+
@growl.notify type, title, body
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
data/rcr-notify.gemspec
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rcr-notify}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jacob Rothstein"]
|
12
|
+
s.date = %q{2009-11-22}
|
13
|
+
s.default_executable = %q{rcr-notify}
|
14
|
+
s.description = %q{Simple json poller with ruby-growl notification}
|
15
|
+
s.email = %q{github@jacobrothstein.com}
|
16
|
+
s.executables = ["rcr-notify"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/rcr-notify",
|
29
|
+
"lib/rcr-notify.rb",
|
30
|
+
"rcr-notify.gemspec",
|
31
|
+
"test/runcoderun-notifier_test.rb",
|
32
|
+
"test/test_helper.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/jbr/rcr-notify}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.5}
|
38
|
+
s.summary = %q{Growl notification for runcoderun builds}
|
39
|
+
s.test_files = [
|
40
|
+
"test/runcoderun-notifier_test.rb",
|
41
|
+
"test/test_helper.rb"
|
42
|
+
]
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_runtime_dependency(%q<ruby-growl>, [">= 0"])
|
50
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<ruby-growl>, [">= 0"])
|
53
|
+
s.add_dependency(%q<json>, [">= 0"])
|
54
|
+
end
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<ruby-growl>, [">= 0"])
|
57
|
+
s.add_dependency(%q<json>, [">= 0"])
|
58
|
+
end
|
59
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rcr-notify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jacob Rothstein
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-22 00:00:00 -08:00
|
13
|
+
default_executable: rcr-notify
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: ruby-growl
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: json
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: Simple json poller with ruby-growl notification
|
36
|
+
email: github@jacobrothstein.com
|
37
|
+
executables:
|
38
|
+
- rcr-notify
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- bin/rcr-notify
|
52
|
+
- lib/rcr-notify.rb
|
53
|
+
- rcr-notify.gemspec
|
54
|
+
- test/runcoderun-notifier_test.rb
|
55
|
+
- test/test_helper.rb
|
56
|
+
has_rdoc: true
|
57
|
+
homepage: http://github.com/jbr/rcr-notify
|
58
|
+
licenses: []
|
59
|
+
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options:
|
62
|
+
- --charset=UTF-8
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 1.3.5
|
81
|
+
signing_key:
|
82
|
+
specification_version: 3
|
83
|
+
summary: Growl notification for runcoderun builds
|
84
|
+
test_files:
|
85
|
+
- test/runcoderun-notifier_test.rb
|
86
|
+
- test/test_helper.rb
|