Sha256: b4776d033090c1f7a1534954068fe7c08ac7567885470603fe00470250cbd4e9

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require File.dirname(__FILE__)+'/adapters/adapter'
require 'rainbow'

module MatrixCi
  class Build
    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

    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.foreground(color)
    end

    def successful?
      @outcome != "failed"
    end

    def running?
      @ended.nil?
    end

    def runtime
      (DateTime.parse(@ended) - DateTime.parse(@started)).to_i/60
    end

    def cancel
    end

    def retry
    end

    def show
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
matrixci-0.0.4 lib/build.rb
matrixci-0.0.3 lib/build.rb