dor-workflow-client 3.19.0 → 3.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dor/workflow/client/status.rb +34 -18
- data/lib/dor/workflow/client/version.rb +1 -1
- data/spec/workflow/client/status_spec.rb +19 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eef64675c5a37fb89ea5f7a522c85dfa8a6e426418f4af515f73719a6812a28
|
4
|
+
data.tar.gz: 32162d0b34a328cc2d42414bac647db71f5e14425c223cf0c22b9dc37b2a71a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 804ed21db035008f7ce28ec81491fcc3d2f8d72c7c06f4874ffe74431d8b5b59ffc3f860a31847456644b428a57c1b0352681c7046b622ff9e72bfab8d02125e
|
7
|
+
data.tar.gz: d76a0c12b6570130d4adf11980fd1cbd80df8336c9d00b960b03d4ff0c75b46812a8a18e1527cd8df82b55a63ab12bbb6564e5b2156332b50dbc7daa4f1bcb64
|
@@ -42,32 +42,38 @@ module Dor
|
|
42
42
|
end
|
43
43
|
|
44
44
|
# @return [Hash{Symbol => Object}] including :status_code and :status_time
|
45
|
+
# rubocop:disable Metrics/MethodLength
|
45
46
|
def info
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
47
|
+
@info ||= begin
|
48
|
+
# if we have an accessioned milestone, this is the last possible step and should be the status regardless of time stamp
|
49
|
+
accessioned_milestones = current_milestones.select { |m| m[:milestone] == 'accessioned' }
|
50
|
+
return { status_code: STEPS['accessioned'], status_time: accessioned_milestones.last[:at].utc.xmlschema } unless accessioned_milestones.empty?
|
51
|
+
|
52
|
+
status_code = 0
|
53
|
+
status_time = nil
|
54
|
+
# for each milestone in the current version, see if it comes at the same time or after the current 'last' step, if so, make it the last and record the date/time
|
55
|
+
current_milestones.each do |m|
|
56
|
+
m_name = m[:milestone]
|
57
|
+
m_time = m[:at].utc.xmlschema
|
58
|
+
next unless STEPS.key?(m_name) && (!status_time || m_time >= status_time)
|
59
|
+
|
60
|
+
status_code = STEPS[m_name]
|
61
|
+
status_time = m_time
|
62
|
+
end
|
63
|
+
|
64
|
+
{ status_code: status_code, status_time: status_time }
|
60
65
|
end
|
66
|
+
end
|
67
|
+
# rubocop:enable Metrics/MethodLength
|
61
68
|
|
62
|
-
|
69
|
+
def status_code
|
70
|
+
info.fetch(:status_code)
|
63
71
|
end
|
64
72
|
|
65
73
|
# @param [Boolean] include_time
|
66
74
|
# @return [String] single composed status from status_info
|
67
75
|
def display(include_time: false)
|
68
|
-
|
69
|
-
status_code = status_info_hash[:status_code]
|
70
|
-
status_time = status_info_hash[:status_time]
|
76
|
+
status_time = info[:status_time]
|
71
77
|
|
72
78
|
# use the translation table to get the appropriate verbage for the latest step
|
73
79
|
result = "v#{version} #{STATUS_CODE_DISP_TXT[status_code]}"
|
@@ -75,6 +81,10 @@ module Dor
|
|
75
81
|
result
|
76
82
|
end
|
77
83
|
|
84
|
+
def display_simplified
|
85
|
+
simplified_status_code(STATUS_CODE_DISP_TXT[status_code])
|
86
|
+
end
|
87
|
+
|
78
88
|
def milestones
|
79
89
|
@milestones ||= lifecycle_routes.milestones('dor', druid)
|
80
90
|
end
|
@@ -83,6 +93,12 @@ module Dor
|
|
83
93
|
|
84
94
|
attr_reader :druid, :version, :lifecycle_routes
|
85
95
|
|
96
|
+
# @return [String] text translation of the status code, minus any trailing parenthetical explanation
|
97
|
+
# e.g. 'In accessioning (described)' and 'In accessioning (described, published)' both return 'In accessioning'
|
98
|
+
def simplified_status_code(display)
|
99
|
+
display.gsub(/\(.*\)$/, '').strip
|
100
|
+
end
|
101
|
+
|
86
102
|
def current_milestones
|
87
103
|
current = []
|
88
104
|
# only get steps that are part of accessioning and part of the current version. That can mean they were archived with the current version
|
@@ -14,12 +14,6 @@ RSpec.describe Dor::Workflow::Client::Status do
|
|
14
14
|
describe '#display' do
|
15
15
|
subject(:status) { instance.display }
|
16
16
|
|
17
|
-
before do
|
18
|
-
# TODO: this stub is too knowledgable about the inner workings of the LifecycleRoutest
|
19
|
-
# instead it should just stub :milestones which returns an array of hashes
|
20
|
-
# expect(lifecycle_routes).to receive(:query_lifecycle).and_return(xml)
|
21
|
-
end
|
22
|
-
|
23
17
|
context 'for gv054hp4128' do
|
24
18
|
context 'when current version is published, but does not have a version attribute' do
|
25
19
|
let(:xml) do
|
@@ -178,4 +172,23 @@ RSpec.describe Dor::Workflow::Client::Status do
|
|
178
172
|
end
|
179
173
|
end
|
180
174
|
end
|
175
|
+
|
176
|
+
describe '#display_simplified' do
|
177
|
+
subject(:status) { instance.display_simplified }
|
178
|
+
let(:xml) do
|
179
|
+
'<?xml version="1.0" encoding="UTF-8"?>
|
180
|
+
<lifecycle objectId="druid:gv054hp4128">
|
181
|
+
<milestone date="2012-11-06T16:19:15-0800" version="2">described</milestone>
|
182
|
+
<milestone date="2012-11-06T16:21:02-0800">opened</milestone>
|
183
|
+
<milestone date="2012-11-06T16:30:03-0800">submitted</milestone>
|
184
|
+
<milestone date="2012-11-06T16:35:00-0800">described</milestone>
|
185
|
+
<milestone date="2012-11-06T16:59:39-0800" version="3">published</milestone>
|
186
|
+
<milestone date="2012-11-06T16:59:39-0800">published</milestone>
|
187
|
+
</lifecycle>'
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'generates a status string' do
|
191
|
+
expect(status).to eq('In accessioning')
|
192
|
+
end
|
193
|
+
end
|
181
194
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dor-workflow-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willy Mene
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-02-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|