blob: 90257f5c9c36d981b96b392a647e0f49eb8bb704 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
require 'crack'
require 'open-uri'
require 'json'
class CCMenu
def initialize(url)
@data = Crack::XML.parse(open(url))['Projects']['Project']
@data=@data.select{ |i| i['name'][/^[^\:\:]*\:\:[^\:\:]*$/]}
puts @data
end
def json
@data.to_json
end
def status
overall = 'Success'
@data.each do |step|
if step['lastBuildStatus'] != 'Success'
overall = step['lastBuildStatus']
end
end
return overall
end
def failed
list = Array.new
@data.each do |step|
puts step
list << step['name'] if step['lastBuildStatus'] == 'Failure'
end
return list
end
def num_total
@data.length
end
def num_failed
self.failed.length
end
def color
case status
when 'Failure' then 'red'
when 'Exception' then 'orange'
when 'Unknown' then 'orange'
else 'green'
end
end
def data
@data
end
end
|