libis-workflow 2.0.14 → 2.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c25b53a55ca9a0c6aac68722bcb4968fd707df74
4
- data.tar.gz: 0388ade78242e081673c20df700e3cb1cf6d4b85
3
+ metadata.gz: 00b61310a01954b0c05959bec7446bfcddcbb106
4
+ data.tar.gz: 9dd4d787573e40fb33a348e5a6936569660988cc
5
5
  SHA512:
6
- metadata.gz: f3c7070a73796efccec423fd13558672af8da60e7242a209c787621624219182d3c1712ac03301950b334b6af9021f6e6a6cbadeefcedeef83522c18a46ac1d8
7
- data.tar.gz: 8e163873cb9a8076f90f20476dec1910a72a8655fc14115d39ae18e5025b53462c51b16ee84a272bd921b8db753b55ecaf25f679aee306bbca3cace22861237e
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
- self.add_status_log(task: task, status: status)
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 = status_entry(task) || self.add_status_log(task: task, status: status)
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[:status]) rescue :NOT_STARTED
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[:status]) rescue STATUS_TEXT.first
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[:task] rescue nil}#{entry[:status].capitalize rescue nil}"
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[:progress] = progress
90
- log_entry[:max] = max if max
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[:task] == task }.last
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.14' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
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
@@ -28,6 +28,7 @@ module Libis
28
28
  def add_status_log(info)
29
29
  # noinspection RubyResolve
30
30
  self.status_log << info
31
+ self.status_log.last
31
32
  end
32
33
 
33
34
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libis-workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.14
4
+ version: 2.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser