Class: MatrixCi::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/build.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Build

Returns a new instance of Build.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/build.rb', line 6

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

Instance Method Details

#cancelObject



44
45
# File 'lib/build.rb', line 44

def cancel
end

#retryObject



47
48
# File 'lib/build.rb', line 47

def retry
end

#running?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/build.rb', line 36

def running?
  @ended.nil?
end

#runtimeObject



40
41
42
# File 'lib/build.rb', line 40

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

#showObject



50
51
# File 'lib/build.rb', line 50

def show
end

#successful?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/build.rb', line 32

def successful?
  @outcome != "failed"
end

#to_sObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/build.rb', line 18

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