Module: Travis::Client::States

Included in:
Build, Job, Repository, Worker
Defined in:
lib/travis/client/states.rb

Constant Summary collapse

STATES =
%w[created queued started passed failed errored canceled ready]

Instance Method Summary collapse

Instance Method Details

#canceled?Boolean



46
47
48
49
# File 'lib/travis/client/states.rb', line 46

def canceled?
  check_state
  state == 'canceled'
end

#colorObject



60
61
62
63
64
65
66
# File 'lib/travis/client/states.rb', line 60

def color
  case state
  when 'created', 'queued', 'started'   then 'yellow'
  when 'passed', 'ready'                then 'green'
  when 'errored', 'canceled', 'failed'  then 'red'
  end
end

#created?Boolean



55
56
57
58
# File 'lib/travis/client/states.rb', line 55

def created?
  check_state
  !!state
end

#errored?Boolean



36
37
38
39
# File 'lib/travis/client/states.rb', line 36

def errored?
  check_state
  state == 'errored'
end

#failed?Boolean



41
42
43
44
# File 'lib/travis/client/states.rb', line 41

def failed?
  check_state
  state == 'failed'
end

#finished?Boolean



27
28
29
# File 'lib/travis/client/states.rb', line 27

def finished?
  not pending?
end

#green?Boolean



72
73
74
# File 'lib/travis/client/states.rb', line 72

def green?
  color == 'green'
end

#passed?Boolean Also known as: successful?



31
32
33
34
# File 'lib/travis/client/states.rb', line 31

def passed?
  check_state
  state == 'passed'
end

#pending?Boolean



12
13
14
15
# File 'lib/travis/client/states.rb', line 12

def pending?
  check_state
  %w[created started queued].include? state
end

#queued?Boolean



22
23
24
25
# File 'lib/travis/client/states.rb', line 22

def queued?
  check_state
  state != 'created'
end

#ready?Boolean



8
9
10
# File 'lib/travis/client/states.rb', line 8

def ready?
  state == 'ready'
end

#red?Boolean



76
77
78
# File 'lib/travis/client/states.rb', line 76

def red?
  color == 'red'
end

#running?Boolean



80
81
82
# File 'lib/travis/client/states.rb', line 80

def running?
  state == 'started'
end

#started?Boolean



17
18
19
20
# File 'lib/travis/client/states.rb', line 17

def started?
  check_state
  state != 'created' and state != 'queued'
end

#unsuccessful?Boolean



51
52
53
# File 'lib/travis/client/states.rb', line 51

def unsuccessful?
  errored? or failed? or canceled?
end

#yellow?Boolean



68
69
70
# File 'lib/travis/client/states.rb', line 68

def yellow?
  color == 'yellow'
end