libcruisecontrol 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cruise_control/project_proxy.rb +14 -0
- data/lib/cruise_control/server.rb +32 -0
- data/lib/libcruisecontrol.rb +1 -1
- metadata +5 -5
- data/lib/cruise_control_server.rb +0 -30
- data/lib/project_proxy.rb +0 -12
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'delegate'
|
2
|
+
|
3
|
+
module CruiseControl
|
4
|
+
class ProjectProxy < DelegateClass(Hash)
|
5
|
+
def initialize(hash = {})
|
6
|
+
super(hash)
|
7
|
+
end
|
8
|
+
|
9
|
+
# Returns true if the current build of this project was successfull
|
10
|
+
def pass?
|
11
|
+
self['description'] == 'Build passed'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'cruise_control/project_proxy'
|
3
|
+
|
4
|
+
module CruiseControl
|
5
|
+
class Server
|
6
|
+
attr_reader :projects
|
7
|
+
|
8
|
+
def initialize(host, port = 80)
|
9
|
+
@host, @port = host, port
|
10
|
+
@projects = []
|
11
|
+
refresh
|
12
|
+
end
|
13
|
+
|
14
|
+
# Retrieve the projects' newest status from the server
|
15
|
+
def refresh
|
16
|
+
@projects.replace parse_projects_from_xml(Net::HTTP.get @host, '/dashboard/rss.xml', @port)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns true if all projects from this server passes
|
20
|
+
def pass?
|
21
|
+
projects.all? {|p| p.pass?}
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def parse_projects_from_xml(xml)
|
27
|
+
@projects = Hash.from_xml(xml)['rss']['channel']['item']
|
28
|
+
@projects = [@projects] unless @projects.class == Array
|
29
|
+
@projects.map!{|p| ProjectProxy.new p}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/libcruisecontrol.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require '
|
1
|
+
require 'cruise_control/server'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libcruisecontrol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jonas Alves
|
@@ -29,8 +29,8 @@ extra_rdoc_files: []
|
|
29
29
|
|
30
30
|
files:
|
31
31
|
- lib/libcruisecontrol.rb
|
32
|
-
- lib/
|
33
|
-
- lib/project_proxy.rb
|
32
|
+
- lib/cruise_control/server.rb
|
33
|
+
- lib/cruise_control/project_proxy.rb
|
34
34
|
has_rdoc: true
|
35
35
|
homepage: http://github.com/jonasfa/libcruisecontrol
|
36
36
|
licenses: []
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'active_support'
|
2
|
-
require 'project_proxy'
|
3
|
-
|
4
|
-
class CruiseControlServer
|
5
|
-
attr_reader :projects
|
6
|
-
|
7
|
-
def initialize(host, port = 80)
|
8
|
-
@host, @port = host, port
|
9
|
-
@projects = []
|
10
|
-
refresh
|
11
|
-
end
|
12
|
-
|
13
|
-
# Retrieve the projects' newest status from the server
|
14
|
-
def refresh
|
15
|
-
@projects.replace parse_projects_from_xml(Net::HTTP.get @host, '/dashboard/rss.xml', @port)
|
16
|
-
end
|
17
|
-
|
18
|
-
# Returns true if all projects from this server passes
|
19
|
-
def pass?
|
20
|
-
projects.all? {|p| p.pass?}
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def parse_projects_from_xml(xml)
|
26
|
-
@projects = Hash.from_xml(xml)['rss']['channel']['item']
|
27
|
-
@projects = [@projects] unless @projects.class == Array
|
28
|
-
@projects.map!{|p| ProjectProxy.new p}
|
29
|
-
end
|
30
|
-
end
|
data/lib/project_proxy.rb
DELETED