diff options
author | varac <varacanero@zeromail.org> | 2016-07-13 20:07:09 +0200 |
---|---|---|
committer | Varac <varac@leap.se> | 2017-10-16 13:20:14 +0200 |
commit | 11d443664b7a785b42cbbd5b96347bafa5ad273a (patch) | |
tree | 9a27d4c1fe58e3375ae1868cf7a29da1af106265 /lib/ccmenu.rb | |
parent | fa7cf47e28a4ac1636e947c269ed83abe49a1491 (diff) |
initial commit, import from pixelated_dashboard
Diffstat (limited to 'lib/ccmenu.rb')
-rw-r--r-- | lib/ccmenu.rb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/ccmenu.rb b/lib/ccmenu.rb new file mode 100644 index 0000000..90257f5 --- /dev/null +++ b/lib/ccmenu.rb @@ -0,0 +1,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 |