Module: Ci::Go::Nfo

Defined in:
lib/ci-go-nfo.rb,
lib/ci-go-nfo/version.rb

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.build_nfo(goXML, index) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/ci-go-nfo.rb', line 49

def self.build_nfo(goXML, index)
  {
    'name'        => goXML['names'][index],
    'last_status' => goXML['lastBuildStatus'][index],
    'last_label'  => goXML['lastBuildLabels'][index],
    'last_time'   => goXML['lastBuildTimes'][index],
    'weburl'      => goXML['weburls'][index]
  }
end

.build_of(pipeline) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/ci-go-nfo.rb', line 41

def self.build_of(pipeline)
  go          = Ci::Go::Cctray.data_from_xml
  build_name  = go['names'].select{|gname| gname.split(/::/)[0] === pipeline}
  idx         = go.index build_name

  Ci::Go::Print.build_status build_nfo(go, idx)
end

.builds(status = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ci-go-nfo.rb', line 27

def self.builds(status = nil)
  go = Ci::Go::Cctray.data_from_xml
  go['names'].each_with_index do |name, idx|
    next if name.split('::').size < 3
    build = build_nfo(go, idx)

    if status.nil? or
      build['last_status'].match(/#{status}/i) or
      ( status === 'pass' && build['last_status'] === 'Success' )
      Ci::Go::Print.build_status build
    end
  end
end

.summaryObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ci-go-nfo.rb', line 13

def self.summary
  go_all = Ci::Go::Cctray.data_from_xml
  failed_builds, passed_builds = [], []
  go_all['names'].each_with_index do |name, idx|
    next unless name.split('::').size == 3
    if go_all['lastBuildStatus'][idx] === 'Failure'
      failed_builds << name.split('::')[0]
    elsif go_all['lastBuildStatus'][idx] === 'Success'
      passed_builds << name.split('::')[0]
    end
  end
  Ci::Go::Print.summary passed_builds.uniq, failed_builds.uniq
end