web47command 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e041303b05e1d85a36072634de3396c6722b8b4789b7fcc78d9099f876c208f8
4
- data.tar.gz: 64c78bc05a3a2fcb38c164186558aeab8e4cffad9b880ce0974769eab4fbbc08
3
+ metadata.gz: 3ec04e840dab56171aaa7e29aab015888e461d1f2487f53dc854b86baebe799f
4
+ data.tar.gz: 2cf3644fbd84c46a0caaf5c271ebe293a4a608181bc3ef7ecf189a6090490e63
5
5
  SHA512:
6
- metadata.gz: '08bd97add54ae82aa6b3f9ce6de8a4947275b2065c286eb8d049c6b4e75705d29cd6a713c0b37a6e45d14f4bc3be9ed0ab6ac764c51a5db5270ea28ca5416d10'
7
- data.tar.gz: 4ed492b6ad8442e267a5430acde97a86ef464d05dbc7b3c9fa38736ab154327188bb745c566a3e146f0a8e1a7c6a39ce9185f56309c9b1e292f9f7eb738a9062
6
+ metadata.gz: 1840d4ca423bb53b9b86e091f51ee146a444b7bf44dc2904a073f3e9fb8a3cbca247a93dc4d409177f83098ae4ae1ab8e371918f59671e524e054b0aecdb8180
7
+ data.tar.gz: 4fe65ce773a652b7cd77954fa35a2aff89d58e54dc00b72ef701f10303b6186b86595b6489560e75132610edc48fa935510702f8fe447d85fe31668a9d78d510
@@ -13,7 +13,10 @@ class CommandJob
13
13
  STATE_RETRYING = 'retrying' unless defined? STATE_RETRYING
14
14
  STATE_SUCCESS = 'success' unless defined? STATE_SUCCESS
15
15
  STATE_FAIL = 'failure' unless defined? STATE_FAIL
16
- ALL_STATES = [STATE_NEW, STATE_WIP, STATE_RETRYING, STATE_SUCCESS, STATE_FAIL].freeze unless defined? ALL_STATES
16
+ STATE_CANCELLED = 'cancelled' unless defined? STATE_CANCELLED
17
+ unless defined? ALL_STATES
18
+ ALL_STATES = [STATE_NEW, STATE_WIP, STATE_RETRYING, STATE_CANCELLED, STATE_SUCCESS, STATE_FAIL].freeze
19
+ end
17
20
  #
18
21
  # Fields
19
22
  #
@@ -48,43 +51,68 @@ class CommandJob
48
51
  #
49
52
  # True if in new status
50
53
  #
51
- def new?
54
+ def new_job?
52
55
  STATE_NEW.eql?(state)
53
56
  end
54
57
 
55
58
  #
56
59
  # True if in WIP status
57
60
  #
58
- def wip?
61
+ def work_in_progress?
59
62
  [STATE_RETRYING, STATE_WIP].include?(state)
60
63
  end
61
64
 
62
65
  #
63
66
  # True if in success status
64
67
  #
65
- def success?
68
+ def succeeded?
66
69
  STATE_SUCCESS.eql?(state)
67
70
  end
68
71
 
69
72
  #
70
73
  # True if in fail status
71
74
  #
72
- def fail?
75
+ def failed?
73
76
  STATE_FAIL.eql?(state)
74
77
  end
75
78
 
76
79
  #
77
80
  # If we is finished, failed or success
78
81
  #
79
- def finished?
80
- [STATE_FAIL, STATE_SUCCESS].include?(state)
82
+ def completed?
83
+ [STATE_CANCELLED, STATE_FAIL, STATE_SUCCESS].include?(state)
84
+ end
85
+
86
+ #
87
+ # Job has not finished, failure or success
88
+ #
89
+ def incomplete?
90
+ !completed?
81
91
  end
82
92
 
93
+ alias running? incomplete?
94
+
83
95
  #
84
- # If we are still running
96
+ # If we are cancelled
85
97
  #
86
- def running?
87
- !finished?
98
+ def cancelled?
99
+ STATE_CANCELLED.eql?(state)
100
+ end
101
+
102
+ def job_cancelled?(job = self)
103
+ job.reload
104
+ job.cancelled?
105
+ rescue StandardError => error
106
+ App47Logger.log_warn "Unable to check job cancelled #{job}", error
107
+ true
108
+ end
109
+
110
+ def failure_or_cancelled?(job = self)
111
+ job.reload
112
+ job.failure? || job.cancelled?
113
+ rescue StandardError => error
114
+ App47Logger.log_warn "Unable to check job cancelled #{job}", error
115
+ true
88
116
  end
89
117
 
90
118
  #
@@ -266,4 +294,11 @@ class CommandJob
266
294
  def add_log(message)
267
295
  logs.create!(message: message)
268
296
  end
297
+
298
+ #
299
+ # Which to sort by
300
+ #
301
+ def sort_fields
302
+ %i[created_at]
303
+ end
269
304
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Web47command
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web47command
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schroeder