libis-workflow 2.0.14 → 2.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/libis/workflow/status.rb +18 -11
- data/lib/libis/workflow/version.rb +1 -1
- data/lib/libis/workflow/work_item.rb +1 -0
- data/spec/workflow_spec.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00b61310a01954b0c05959bec7446bfcddcbb106
|
4
|
+
data.tar.gz: 9dd4d787573e40fb33a348e5a6936569660988cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00376fe9680c270c1b20fd85a96512480e3111a618213365b6f1c8a72785b69722c461b21ceef896f0f8df513377479e32656fdfb4cc969d63bcafe6edd411c9
|
7
|
+
data.tar.gz: 9e46ad09f53c12bc6385e3dc616f5b0a4f6f632d6ce1786b1969f6d01dc54d8f4647bd21b975868ac81fe470c4d30a4e6476d5ec4fdc8fe57ab7e206037c4766
|
@@ -25,13 +25,18 @@ module Libis
|
|
25
25
|
# @param [String] task namepath of the task
|
26
26
|
# @param [Symbol] status status to set
|
27
27
|
def set_status(task, status)
|
28
|
+
task = task.namepath if task.is_a?(Libis::Workflow::Task)
|
29
|
+
log_entry = self.status_entry(task)
|
28
30
|
case status
|
29
31
|
when :STARTED
|
30
|
-
|
32
|
+
unless status(task) == :ASYNC_WAIT
|
33
|
+
log_entry = self.add_status_log('task' => task, 'status' => status, 'created' => DateTime.now)
|
34
|
+
end
|
31
35
|
else
|
32
|
-
log_entry
|
33
|
-
log_entry[:status] = status
|
36
|
+
log_entry ||= self.add_status_log('task' => task, 'status' => status, 'created' => DateTime.now)
|
34
37
|
end
|
38
|
+
log_entry['status'] = status
|
39
|
+
log_entry['updated'] = DateTime.now
|
35
40
|
self.save!
|
36
41
|
end
|
37
42
|
|
@@ -40,8 +45,8 @@ module Libis
|
|
40
45
|
# @param [String] task task name to check item status for
|
41
46
|
# @return [Symbol] the status code
|
42
47
|
def status(task = nil)
|
43
|
-
entry = status_entry(task)
|
44
|
-
status_symbol(entry[
|
48
|
+
entry = self.status_entry(task)
|
49
|
+
status_symbol(entry['status']) rescue :NOT_STARTED
|
45
50
|
end
|
46
51
|
|
47
52
|
# Get last known status text for a given task
|
@@ -49,8 +54,8 @@ module Libis
|
|
49
54
|
# @param [String] task task name to check item status for
|
50
55
|
# @return [Symbol] the status code
|
51
56
|
def status_text(task = nil)
|
52
|
-
entry = status_entry(task)
|
53
|
-
status_string(entry[
|
57
|
+
entry = self.status_entry(task)
|
58
|
+
status_string(entry['status']) rescue STATUS_TEXT.first
|
54
59
|
end
|
55
60
|
|
56
61
|
# Gets the last known status label of the object.
|
@@ -59,7 +64,7 @@ module Libis
|
|
59
64
|
# @return [String] status label ( = task name + status )
|
60
65
|
def status_label(task = nil)
|
61
66
|
entry = self.status_entry(task)
|
62
|
-
"#{entry[
|
67
|
+
"#{entry['task'] rescue nil}#{entry['status'].capitalize rescue nil}"
|
63
68
|
end
|
64
69
|
|
65
70
|
# Check status of the object.
|
@@ -86,8 +91,9 @@ module Libis
|
|
86
91
|
def status_progress(task, progress = 0, max = nil)
|
87
92
|
log_entry = self.status_entry(task)
|
88
93
|
return nil unless log_entry
|
89
|
-
log_entry[
|
90
|
-
log_entry[
|
94
|
+
log_entry['progress'] = progress
|
95
|
+
log_entry['max'] = max if max
|
96
|
+
log_entry['updated'] = DateTime.now
|
91
97
|
self.save!
|
92
98
|
end
|
93
99
|
|
@@ -98,8 +104,9 @@ module Libis
|
|
98
104
|
# @param [String] task task name to check item status for
|
99
105
|
# @return [Hash] the status entry
|
100
106
|
def status_entry(task = nil)
|
107
|
+
task = task.namepath if task.is_a?(Libis::Workflow::Task)
|
101
108
|
return self.status_log.last if task.blank?
|
102
|
-
self.status_log.select { |entry| entry[
|
109
|
+
self.status_log.select { |entry| entry['task'] == task }.last
|
103
110
|
end
|
104
111
|
|
105
112
|
# Convert String, Symbol or Integer to correct symbol for the status.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Libis
|
2
2
|
module Workflow
|
3
|
-
VERSION = '2.0.
|
3
|
+
VERSION = '2.0.16' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
|
4
4
|
end
|
5
5
|
end
|
data/spec/workflow_spec.rb
CHANGED
@@ -131,7 +131,7 @@ STR
|
|
131
131
|
{task: 'ProcessFiles/ChecksumTester', status: :DONE, progress: 1, max: 1},
|
132
132
|
{task: 'ProcessFiles/CamelizeName', status: :DONE, progress: 1, max: 1},
|
133
133
|
].each_with_index do |h, i|
|
134
|
-
h.keys.each { |key| expect(run.status_log[i][key]).to eq h[key] }
|
134
|
+
h.keys.each { |key| expect(run.status_log[i][key.to_s]).to eq h[key] }
|
135
135
|
end
|
136
136
|
|
137
137
|
[
|
@@ -139,7 +139,7 @@ STR
|
|
139
139
|
{task: 'ProcessFiles/ChecksumTester', status: :DONE, progress: 3, max: 3},
|
140
140
|
{task: 'ProcessFiles/CamelizeName', status: :DONE, progress: 3, max: 3},
|
141
141
|
].each_with_index do |h, i|
|
142
|
-
h.keys.each { |key| expect(run.items.first.status_log[i][key]).to eq h[key] }
|
142
|
+
h.keys.each { |key| expect(run.items.first.status_log[i][key.to_s]).to eq h[key] }
|
143
143
|
end
|
144
144
|
|
145
145
|
[
|
@@ -147,7 +147,7 @@ STR
|
|
147
147
|
{task: 'ProcessFiles/ChecksumTester', status: :DONE, progress: nil, max: nil},
|
148
148
|
{task: 'ProcessFiles/CamelizeName', status: :DONE, progress: nil, max: nil},
|
149
149
|
].each_with_index do |h, i|
|
150
|
-
h.keys.each { |key| expect(run.items.first.first.status_log[i][key]).to eq h[key] }
|
150
|
+
h.keys.each { |key| expect(run.items.first.first.status_log[i][key.to_s]).to eq h[key] }
|
151
151
|
end
|
152
152
|
|
153
153
|
end
|