startask 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/startask.rb +109 -24
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98f7117e10b305b80d9ca459f61f9b6612eac3119d1e512bcc16211db5abcb7d
|
4
|
+
data.tar.gz: 0abf88ac656c4dd87c0dc0280f426a724866f8a18b2f60ed0805eaad8cfd8cb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6536b528bc0587c8d225bae4a8da20762eafef9a3ee5e7854e79e0410fe8ef4fa9a1d08c6fea4d12ca10e0b8fa82301077b6a4ca1dea9b22506552dbad04e77
|
7
|
+
data.tar.gz: 89da5ddcbed700bd31887d9aab6a9d62b242b68059ee891acfd2e688d8e058fd483f90585b7bc3c16523c3fad7b6dd20740817ec3ad2c2713615eb3d36a10110
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/startask.rb
CHANGED
@@ -6,17 +6,35 @@
|
|
6
6
|
require 'kvx'
|
7
7
|
require 'rxfhelper'
|
8
8
|
|
9
|
+
module RecordHelper
|
10
|
+
|
11
|
+
def generate_id()
|
12
|
+
Time.now.to_f.to_s.sub('.','-')
|
13
|
+
end
|
14
|
+
|
15
|
+
def logit(label)
|
16
|
+
@log << [label, Time.now.strftime("%H:%M%P")]
|
17
|
+
@log.last
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
9
22
|
class ActionItem
|
23
|
+
include RecordHelper
|
10
24
|
|
11
|
-
attr_reader :log
|
25
|
+
attr_reader :log, :id
|
12
26
|
|
13
|
-
def initialize(s)
|
27
|
+
def initialize(s, callback=nil)
|
28
|
+
|
29
|
+
@id = generate_id()
|
14
30
|
@title = s
|
15
31
|
@log = []
|
32
|
+
@callback = callback
|
33
|
+
|
16
34
|
end
|
17
35
|
|
18
36
|
def done()
|
19
|
-
|
37
|
+
logaction :completed
|
20
38
|
end
|
21
39
|
|
22
40
|
alias completed done
|
@@ -26,15 +44,15 @@ class ActionItem
|
|
26
44
|
end
|
27
45
|
|
28
46
|
def started()
|
29
|
-
|
47
|
+
logaction :started
|
30
48
|
end
|
31
49
|
|
32
50
|
def status()
|
33
|
-
@log.last
|
51
|
+
@log.last ? @log.last : []
|
34
52
|
end
|
35
53
|
|
36
54
|
def stopped()
|
37
|
-
|
55
|
+
logaction :stopped
|
38
56
|
end
|
39
57
|
|
40
58
|
def status=(status)
|
@@ -48,20 +66,34 @@ class ActionItem
|
|
48
66
|
|
49
67
|
end
|
50
68
|
|
69
|
+
def to_xml()
|
70
|
+
|
71
|
+
h = {id: @id, status: status().join(' ')}
|
72
|
+
Rexle::Element.new(:action, attributes: h, value: @title)
|
73
|
+
|
74
|
+
end
|
75
|
+
|
51
76
|
private
|
52
77
|
|
53
|
-
def
|
54
|
-
|
78
|
+
def logaction(label)
|
79
|
+
r = logit label
|
80
|
+
@callback.status = r.clone.insert(1, @title) if @callback
|
55
81
|
end
|
56
82
|
|
57
83
|
end
|
58
84
|
|
59
85
|
class Actions
|
60
86
|
|
87
|
+
attr_accessor :status
|
88
|
+
|
89
|
+
def initialize(callback=nil)
|
90
|
+
@callback = callback
|
91
|
+
end
|
92
|
+
|
61
93
|
def import(a)
|
62
94
|
|
63
95
|
@a = a.map do |x|
|
64
|
-
x.is_a?(String) ? ActionItem.new(x) : Actions.new.import(x)
|
96
|
+
x.is_a?(String) ? ActionItem.new(x, @callback) : Actions.new(@callback).import(x)
|
65
97
|
end
|
66
98
|
|
67
99
|
return self
|
@@ -75,25 +107,43 @@ class Actions
|
|
75
107
|
def to_s()
|
76
108
|
@a.each(&:to_s)
|
77
109
|
end
|
110
|
+
|
111
|
+
def to_xml()
|
112
|
+
|
113
|
+
Rexle::Element.new( :actions, value: @a.map(&:to_xml).join)
|
114
|
+
#@a.map(&:to_xml)
|
115
|
+
end
|
78
116
|
|
79
117
|
end
|
80
118
|
|
81
119
|
class ResultItem
|
120
|
+
include RecordHelper
|
121
|
+
|
122
|
+
attr_reader :id
|
82
123
|
|
83
|
-
def initialize(s)
|
124
|
+
def initialize(s, callback=nil)
|
125
|
+
@id = generate_id()
|
84
126
|
@evidence = s
|
127
|
+
@callback = callback
|
85
128
|
end
|
86
129
|
|
87
130
|
def to_s()
|
88
131
|
@evidence
|
89
132
|
end
|
90
133
|
|
134
|
+
def to_xml()
|
135
|
+
|
136
|
+
h = {id: @id}
|
137
|
+
Rexle::Element.new(:result, attributes: h, value: @evidence)
|
138
|
+
|
139
|
+
end
|
140
|
+
|
91
141
|
end
|
92
142
|
|
93
143
|
class Results
|
94
144
|
|
95
|
-
def initialize()
|
96
|
-
|
145
|
+
def initialize(callback=nil)
|
146
|
+
@callback = callback
|
97
147
|
end
|
98
148
|
|
99
149
|
def import(a)
|
@@ -121,6 +171,17 @@ class Results
|
|
121
171
|
end.join("\n")
|
122
172
|
end
|
123
173
|
|
174
|
+
def to_xml()
|
175
|
+
|
176
|
+
if @a.length < 2 then
|
177
|
+
@a[0].to_xml
|
178
|
+
else
|
179
|
+
Rexle::Element.new( :results, value: @a.map(&:to_xml).join)
|
180
|
+
end
|
181
|
+
|
182
|
+
#@a.map(&:to_xml)
|
183
|
+
end
|
184
|
+
|
124
185
|
def print_row(id, indent: 0)
|
125
186
|
|
126
187
|
@a.map.with_index do |x, i|
|
@@ -150,17 +211,21 @@ end
|
|
150
211
|
# started (method) adds a status message to the log
|
151
212
|
|
152
213
|
class StarTask
|
214
|
+
include RecordHelper
|
153
215
|
|
154
|
-
attr_reader :situation, :task, :actions, :log, :results
|
216
|
+
attr_reader :situation, :task, :actions, :log, :results, :id
|
155
217
|
|
156
218
|
def initialize(src=nil, debug: false)
|
219
|
+
|
157
220
|
@debug = debug
|
221
|
+
@id = generate_id()
|
158
222
|
@log = []
|
223
|
+
@status = ''
|
159
224
|
import src if src
|
160
225
|
end
|
161
226
|
|
162
227
|
def done()
|
163
|
-
|
228
|
+
logtask :completed
|
164
229
|
end
|
165
230
|
|
166
231
|
alias completed done
|
@@ -179,7 +244,7 @@ class StarTask
|
|
179
244
|
|
180
245
|
rawlabel, body = x.split(/\n/,2)
|
181
246
|
|
182
|
-
[rawlabel.downcase.gsub(/\s+/, '_').to_sym,
|
247
|
+
[rawlabel.rstrip.downcase.gsub(/\s+/, '_').to_sym,
|
183
248
|
body.strip.gsub(/^(\s*)[\*\+] /,'\1')]
|
184
249
|
|
185
250
|
end.to_h
|
@@ -200,30 +265,50 @@ class StarTask
|
|
200
265
|
kvx = Kvx.new obj
|
201
266
|
@situation = kvx.situation
|
202
267
|
@task = kvx.task
|
203
|
-
@actions = Actions.new.import(kvx.action[:items])
|
204
|
-
@results = Results.new.import(kvx.result[:items])
|
268
|
+
@actions = Actions.new(self).import(kvx.action[:items])
|
269
|
+
@results = Results.new(self).import(kvx.result[:items])
|
205
270
|
|
206
271
|
end
|
207
272
|
|
208
273
|
# adds a status message to the log
|
209
274
|
#
|
210
275
|
def started()
|
211
|
-
|
276
|
+
logtask :started
|
212
277
|
end
|
213
278
|
|
214
279
|
def status()
|
215
|
-
@
|
280
|
+
@status
|
216
281
|
end
|
217
282
|
|
218
|
-
def
|
219
|
-
|
283
|
+
def status=(s)
|
284
|
+
@status = s
|
220
285
|
end
|
221
286
|
|
287
|
+
def stopped()
|
288
|
+
logtask :stopped
|
289
|
+
end
|
290
|
+
|
291
|
+
def to_xml()
|
292
|
+
|
293
|
+
situation = Rexle::Element.new( :situation, value: @situation)
|
294
|
+
task = Rexle::Element.new( :task, value: @task)
|
295
|
+
|
296
|
+
doc = Rexle.new('<star/>')
|
297
|
+
doc.root.add situation
|
298
|
+
doc.root.add task
|
299
|
+
doc.root.add @actions.to_xml
|
300
|
+
doc.root.add @results.to_xml
|
301
|
+
doc.root.xml pretty: true
|
302
|
+
|
303
|
+
end
|
304
|
+
|
222
305
|
private
|
223
306
|
|
224
|
-
def
|
225
|
-
|
226
|
-
|
307
|
+
def logtask(label)
|
308
|
+
|
309
|
+
r = logit label
|
310
|
+
@status = r
|
311
|
+
|
227
312
|
end
|
228
313
|
|
229
314
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: startask
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
BWN+6F7HF8UfTUHWCQqk9FoCAYtbfQWLUqZwWN+dLzn1CPK0yoPjuSR59/HShliV
|
37
37
|
IUEz9QfhClpwEVu+leXBe7RwfxADwAWYEfI=
|
38
38
|
-----END CERTIFICATE-----
|
39
|
-
date: 2022-09-
|
39
|
+
date: 2022-09-30 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rxfhelper
|
metadata.gz.sig
CHANGED
Binary file
|