blinky_monitor 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 James Ottaway, Mark Ryall
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
File without changes
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'gemesis/rake'
2
+
3
+ task :test do
4
+ system 'rspec spec'
5
+ end
data/bin/blink ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.dirname(__FILE__)+'/../lib'
3
+ require 'blinky_monitor'
4
+ BlinkyMonitor.run *ARGV
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'yaml'
3
+ require 'blinky_monitor/monitor'
4
+ require 'blinky'
5
+ require 'blinky_monitor/jenkins_server'
6
+
7
+ module BlinkyMonitor
8
+ def self.run file
9
+ config = YAML.load_file file
10
+ jenkins = JenkinsServer.new config[:url]
11
+ blinky = Blinky.new
12
+
13
+ Monitor.new(jenkins, blinky).run
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ require 'open-uri'
2
+
3
+ module BlinkyMonitor
4
+ class JenkinsServer
5
+ def initialize url
6
+ @url = url
7
+ end
8
+
9
+ def status
10
+ open("#{@url}/rssLatest").include?('(broken') ? :failure : :success
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module BlinkyMonitor
2
+ class Monitor
3
+ def initialize ci_server, blinky
4
+ @ci_server = ci_server
5
+ @blinky = blinky
6
+ end
7
+
8
+ def run
9
+ @blinky.send "#{@ci_server.status}!"
10
+ end
11
+ end
12
+ end
data/spec/blinky.rb ADDED
@@ -0,0 +1,2 @@
1
+ class Blinky
2
+ end
@@ -0,0 +1,58 @@
1
+ require File.dirname(__FILE__)+'/../rspec_helper'
2
+ require 'blinky_monitor/jenkins_server'
3
+
4
+ describe BlinkyMonitor::JenkinsServer do
5
+ before do
6
+ @jenkins = BlinkyMonitor::JenkinsServer.new 'http://10.7.13.12:8090'
7
+ end
8
+
9
+ it 'should return success if all projects are successful' do
10
+ response = <<EOF
11
+ <?xml version="1.0" encoding="UTF-8"?>
12
+ <feed xmlns="http://www.w3.org/2005/Atom">
13
+ <title>All last builds only</title>
14
+ <link type="text/html" href="http://localhost:8080/" rel="alternate"/>
15
+ <updated>2011-02-23T00:08:34Z</updated>
16
+ <author>
17
+ <name>Jenkins Server</name>
18
+ </author>
19
+ <id>urn:uuid:903deee0-7bfa-11db-9fe1-0800200c9a66</id>
20
+ <entry>
21
+ <title>cas #87 (stable)</title>
22
+ <link type="text/html" href="http://localhost:8080/job/cas/87/" rel="alternate"/>
23
+ <id>tag:hudson.dev.java.net,2008:http://localhost:8080/job/cas/</id>
24
+ <published>2011-02-23T00:08:34Z</published>
25
+ <updated>2011-02-23T00:08:34Z</updated>
26
+ </entry>
27
+ </feed>
28
+ EOF
29
+
30
+ @jenkins.should_receive(:open).with('http://10.7.13.12:8090/rssLatest').and_return(response)
31
+ @jenkins.status.should == :success
32
+ end
33
+
34
+ it "should return failure if one of the projects fails" do
35
+ response = <<EOF
36
+ <?xml version="1.0" encoding="UTF-8"?>
37
+ <feed xmlns="http://www.w3.org/2005/Atom">
38
+ <title>All last builds only</title>
39
+ <link type="text/html" href="http://localhost:8080/" rel="alternate"/>
40
+ <updated>2011-02-23T00:08:34Z</updated>
41
+ <author>
42
+ <name>Jenkins Server</name>
43
+ </author>
44
+ <id>urn:uuid:903deee0-7bfa-11db-9fe1-0800200c9a66</id>
45
+ <entry>
46
+ <title>cas #87 (broken since build #1)</title>
47
+ <link type="text/html" href="http://localhost:8080/job/cas/87/" rel="alternate"/>
48
+ <id>tag:hudson.dev.java.net,2008:http://localhost:8080/job/cas/</id>
49
+ <published>2011-02-23T00:08:34Z</published>
50
+ <updated>2011-02-23T00:08:34Z</updated>
51
+ </entry>
52
+ </feed>
53
+ EOF
54
+
55
+ @jenkins.should_receive(:open).with('http://10.7.13.12:8090/rssLatest').and_return(response)
56
+ @jenkins.status.should == :failure
57
+ end
58
+ end
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__)+'/../rspec_helper'
2
+ require 'blinky_monitor/monitor'
3
+
4
+ describe BlinkyMonitor::Monitor do
5
+ before do
6
+ @ci_server = stub 'ci_server'
7
+ @blinky = stub 'blinky'
8
+
9
+ @monitor = BlinkyMonitor::Monitor.new @ci_server, @blinky
10
+ end
11
+
12
+ it 'should tell blinky that it is all good when all projects are successful' do
13
+ @ci_server.should_receive(:status).and_return(:success)
14
+ @blinky.should_receive :success!
15
+
16
+ @monitor.run
17
+ end
18
+
19
+ it 'should tell blinky that bad things are happening when projects are unsuccessful' do
20
+ @ci_server.should_receive(:status).and_return(:failure)
21
+ @blinky.should_receive :failure!
22
+
23
+ @monitor.run
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__)+'/rspec_helper'
2
+ require 'blinky_monitor'
3
+
4
+ describe BlinkyMonitor do
5
+ JENKINS_URL = 'jenkins url goes here'
6
+
7
+ before do
8
+ @file = stub 'file'
9
+ @monitor = stub 'monitor'
10
+ @jenkins = stub 'jenkins'
11
+ @blinky = stub 'blinky'
12
+ end
13
+
14
+ it 'should load configuration from a YAML file' do
15
+ hash = {:url => JENKINS_URL}
16
+ YAML.should_receive(:load_file).with(@file).and_return(hash)
17
+ BlinkyMonitor::JenkinsServer.should_receive(:new).with(JENKINS_URL).and_return(@jenkins)
18
+ Blinky.should_receive(:new).and_return(@blinky)
19
+ BlinkyMonitor::Monitor.should_receive(:new).with(@jenkins, @blinky).and_return(@monitor)
20
+ @monitor.should_receive :run
21
+ BlinkyMonitor.run @file
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ $: << File.dirname(__FILE__)+'/../lib'
2
+ $: << File.dirname(__FILE__)
3
+ require 'blinky'
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blinky_monitor
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - James Ottaway
13
+ - Mark Ryall
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-02 00:00:00 +10:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: blinky
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rake
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 0
44
+ - 8
45
+ version: "0.8"
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: gemesis
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ type: :development
60
+ version_requirements: *id003
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ prerelease: false
64
+ requirement: &id004 !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 2
71
+ version: "2"
72
+ type: :development
73
+ version_requirements: *id004
74
+ description: |
75
+ watches a CI server and tells blinky about it. dude.
76
+
77
+ email: james@ottaway.mp
78
+ executables:
79
+ - blink
80
+ extensions: []
81
+
82
+ extra_rdoc_files: []
83
+
84
+ files:
85
+ - lib/blinky_monitor/jenkins_server.rb
86
+ - lib/blinky_monitor/monitor.rb
87
+ - lib/blinky_monitor.rb
88
+ - spec/blinky.rb
89
+ - spec/blinky_monitor/jenkins_server_spec.rb
90
+ - spec/blinky_monitor/monitor_spec.rb
91
+ - spec/blinky_monitor_spec.rb
92
+ - spec/rspec_helper.rb
93
+ - bin/blink
94
+ - README.rdoc
95
+ - MIT-LICENSE
96
+ - Rakefile
97
+ has_rdoc: true
98
+ homepage: http://github.com/jamesottaway/blinky_monitor
99
+ licenses: []
100
+
101
+ post_install_message:
102
+ rdoc_options: []
103
+
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ segments:
112
+ - 0
113
+ version: "0"
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ segments:
120
+ - 0
121
+ version: "0"
122
+ requirements: []
123
+
124
+ rubyforge_project:
125
+ rubygems_version: 1.3.7
126
+ signing_key:
127
+ specification_version: 3
128
+ summary: watches a CI server and tells blinky about it
129
+ test_files: []
130
+