class MatrixCi::Build

Public Class Methods

new(options) click to toggle source
# File lib/build.rb, line 7
def initialize(options)
  @id = options[:id]
  @branch = options[:branch]
  @committer = options[:committer]
  @started = options[:started]
  @ended = options[:ended]
  @outcome = options[:outcome]
  @subject = options[:subject]
  @ref = options[:ref]
  @projectname = options[:projectname]
end

Public Instance Methods

cancel() click to toggle source
# File lib/build.rb, line 56
def cancel
end
mine() click to toggle source
# File lib/build.rb, line 40
def mine
  @highlight = true
end
retry() click to toggle source
# File lib/build.rb, line 59
def retry
end
running?() click to toggle source
# File lib/build.rb, line 48
def running?
  @ended.nil?
end
runtime() click to toggle source
# File lib/build.rb, line 52
def runtime
  (DateTime.parse(@ended) - DateTime.parse(@started)).to_i/60
end
show() click to toggle source
# File lib/build.rb, line 62
def show
end
successful?() click to toggle source
# File lib/build.rb, line 44
def successful?
  @outcome != "failed"
end
to_json() click to toggle source
# File lib/build.rb, line 19
def to_json
  str = "%s %10s %10s %40s %25s %15s %s" % [@id, @started.nil? ? "?" : @started[11,8], @projectname, @branch, @committer, @ref, @subject]

  {:str => str, :highlight => @highlight, :color => running? ? :yellow : successful? ? :green : :red }.to_json
end
to_s() click to toggle source
# File lib/build.rb, line 25
def to_s
  str = "%s %10s %10s %40s %25s %15s %s" % [@id, @started.nil? ? "?" : @started[11,8], @projectname, @branch, @committer, @ref, @subject]

  color = :white
  if running?
    color = :yellow
  else
    color = :green if successful?
    color = :red unless successful?
  end

  str = str.bright if @highlight
  str.foreground(color)
end