Cross Reference: state.rb
xref
: /
ontohub
/
lib
/
state.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
module
State
STATES
= %w
(
not_started_yet
failed
no_result
pending
fetching
processing
done
)
TERMINAL_STATES
= %w
(
failed
no_result
done
)
IDLE_STATES
=
TERMINAL_STATES
+ %w
(
not_started_yet
)
STATE_LABEL
=
{
not_started_yet
:
'label-default'
,
failed
:
'label-danger'
,
no_result
:
'label-warning'
,
pending
:
'label-warning'
,
fetching
:
'label-primary'
,
processing
:
'label-primary'
,
done
:
'label-success'
,
}
def
self.terminal
?
(
state
)
TERMINAL_STATES.include
?
(
state
)
end
def
self.most
_successful
(
states
)
states.sort
_by
{ |s|
State.success
_order
(s)
}.
last
end
def
self.success
_order
(
state
)
STATES.index
(
state
)
end
end