Module: Travis::Client::States

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

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#canceled?Boolean

Returns:

  • (Boolean)


53
54
55
56
# File 'lib/travis/client/states.rb', line 53

def canceled?
  check_state
  state == 'canceled'
end

#colorObject



67
68
69
70
71
72
73
# File 'lib/travis/client/states.rb', line 67

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

#created?Boolean

Returns:

  • (Boolean)


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

def created?
  check_state
  !!state
end

#errored?Boolean

Returns:

  • (Boolean)


43
44
45
46
# File 'lib/travis/client/states.rb', line 43

def errored?
  check_state
  state == 'errored'
end

#failed?Boolean

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/travis/client/states.rb', line 48

def failed?
  check_state
  state == 'failed'
end

#finished?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/travis/client/states.rb', line 34

def finished?
  !pending?
end

#green?Boolean

Returns:

  • (Boolean)


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

def green?
  color == 'green'
end

#passed?Boolean Also known as: successful?

Returns:

  • (Boolean)


38
39
40
41
# File 'lib/travis/client/states.rb', line 38

def passed?
  check_state
  state == 'passed'
end

#pending?Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/travis/client/states.rb', line 14

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

#queued?Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/travis/client/states.rb', line 29

def queued?
  check_state
  state != 'created'
end

#ready?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/travis/client/states.rb', line 10

def ready?
  state == 'ready'
end

#received?Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/travis/client/states.rb', line 24

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

#red?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/travis/client/states.rb', line 83

def red?
  color == 'red'
end

#running?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/travis/client/states.rb', line 87

def running?
  state == 'started'
end

#started?Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/travis/client/states.rb', line 19

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

#unsuccessful?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/travis/client/states.rb', line 58

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

#yellow?Boolean

Returns:

  • (Boolean)


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

def yellow?
  color == 'yellow'
end