dor-workflow-client 7.2.0 → 7.3.0

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: 29157476de970bf333e7ca643d49b79ef4e03cf0bf9e18aab8277767492aab3f
4
- data.tar.gz: c25c23a411be47575be4c3d91e912c4d5b48b698423d302d8263a7ca0f1170f7
3
+ metadata.gz: f68410646d6db8f4544022b03aa0c1f4ed062c94482663d6076a2e08deefc0aa
4
+ data.tar.gz: 2fceb32ccab79dc19cf8449268965f3450d26fb1ab57d23ebff17b316f95c758
5
5
  SHA512:
6
- metadata.gz: 32b74f669d2ec51717389c34e6ab113f1271ba05b84f3a9ac5a2e5e95da562ada8d2e7cb85ed78a8d4c80e14862e7658b15bf18b9933f0be4223933d80dcc0c2
7
- data.tar.gz: af1f2bbbb802ebd84ccb239ea62e29b8bfdfb3a0947d0729a9e16caea8594b9bc224750085674b28c7448ff47f4fd8525830b8627ad5dab2f31f0c861d8dafcd
6
+ metadata.gz: bec89343f7f847098e221235e4f8f76fe862e57a4af9f05f6da16bc7739e9db28777ae2df11860eba4630c88d5fe179571b6a18bf556477fcae838793e579960
7
+ data.tar.gz: b1a5e69406924bd48383e18cabd9416d95a77b90c8cbbdfaf2e395de50b2e95926f9a2b30958036f94fa77be2a05f9a0556f5de0c080e3b1881ed7c2351e956a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dor-workflow-client (7.2.0)
4
+ dor-workflow-client (7.3.0)
5
5
  activesupport (>= 3.2.1, < 8)
6
6
  deprecation (>= 0.99.0)
7
7
  faraday (~> 2.0)
@@ -47,7 +47,7 @@ GEM
47
47
  hashdiff (1.1.0)
48
48
  i18n (1.14.4)
49
49
  concurrent-ruby (~> 1.0)
50
- json (2.7.1)
50
+ json (2.7.2)
51
51
  language_server-protocol (3.17.0.3)
52
52
  mini_portile2 (2.8.5)
53
53
  minitest (5.22.3)
@@ -61,10 +61,10 @@ GEM
61
61
  parser (3.3.0.5)
62
62
  ast (~> 2.4.1)
63
63
  racc
64
- public_suffix (5.0.4)
64
+ public_suffix (5.0.5)
65
65
  racc (1.7.3)
66
66
  rainbow (3.1.1)
67
- rake (13.1.0)
67
+ rake (13.2.1)
68
68
  regexp_parser (2.9.0)
69
69
  rexml (3.2.6)
70
70
  rspec (3.13.0)
@@ -82,7 +82,7 @@ GEM
82
82
  rspec-support (3.13.1)
83
83
  rspec_junit_formatter (0.6.0)
84
84
  rspec-core (>= 2, < 4, != 2.12.0)
85
- rubocop (1.62.1)
85
+ rubocop (1.63.0)
86
86
  json (~> 2.3)
87
87
  language_server-protocol (>= 3.17.0)
88
88
  parallel (~> 1.10)
@@ -101,7 +101,7 @@ GEM
101
101
  rubocop (~> 1.41)
102
102
  rubocop-rake (0.6.0)
103
103
  rubocop (~> 1.0)
104
- rubocop-rspec (2.28.0)
104
+ rubocop-rspec (2.29.1)
105
105
  rubocop (~> 1.40)
106
106
  rubocop-capybara (~> 2.17)
107
107
  rubocop-factory_bot (~> 2.22)
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Workflow
5
5
  class Client
6
- VERSION = '7.2.0'
6
+ VERSION = '7.3.0'
7
7
  end
8
8
  end
9
9
  end
@@ -28,8 +28,7 @@ module Dor
28
28
  def process_for_recent_version(name:)
29
29
  nodes = process_nodes_for(name: name)
30
30
  node = nodes.max { |a, b| a.attr('version').to_i <=> b.attr('version').to_i }
31
- attributes = node ? node.attributes.to_h { |k, v| [k.to_sym, v.value] } : {}
32
- Process.new(parent: self, **attributes)
31
+ to_process(node)
33
32
  end
34
33
 
35
34
  def empty?
@@ -39,13 +38,24 @@ module Dor
39
38
  # Check if all processes are skipped or complete for the provided version.
40
39
  # @param [Integer] version the version we are checking for.
41
40
  def complete_for?(version:)
42
- ng_xml.xpath("/workflow/process[@version=#{version}]/@status").map(&:value).all? { |p| %w[skipped completed].include?(p) }
41
+ # ng_xml.xpath("/workflow/process[@version=#{version}]/@status").map(&:value).all? { |p| %w[skipped completed].include?(p) }
42
+ incomplete_processes_for(version: version).empty?
43
43
  end
44
44
 
45
45
  def complete?
46
46
  complete_for?(version: version)
47
47
  end
48
48
 
49
+ def incomplete_processes_for(version:)
50
+ process_nodes = ng_xml.xpath("/workflow/process[@version=#{version}]")
51
+ incomplete_process_nodes = process_nodes.reject { |process_node| %w[skipped completed].include?(process_node.attr('status')) }
52
+ incomplete_process_nodes.map { |process_node| to_process(process_node) }
53
+ end
54
+
55
+ def incomplete_processes
56
+ incomplete_processes_for(version: version)
57
+ end
58
+
49
59
  attr_reader :xml
50
60
 
51
61
  private
@@ -66,6 +76,11 @@ module Dor
66
76
  def ng_xml
67
77
  @ng_xml ||= Nokogiri::XML(@xml)
68
78
  end
79
+
80
+ def to_process(node)
81
+ attributes = node ? node.attributes.to_h { |k, v| [k.to_sym, v.value] } : {}
82
+ Process.new(parent: self, **attributes)
83
+ end
69
84
  end
70
85
  end
71
86
  end
@@ -198,4 +198,62 @@ RSpec.describe Dor::Workflow::Response::Workflow do
198
198
  end
199
199
  end
200
200
  end
201
+
202
+ describe '#incomplete_processes' do
203
+ subject(:processes) { instance.incomplete_processes }
204
+
205
+ context 'when all steps are complete' do
206
+ let(:xml) do
207
+ <<~XML
208
+ <workflow repository="dor" objectId="druid:mw971zk1113" id="assemblyWF">
209
+ <process version="1" laneId="default" elapsed="0.0" attempts="1" datetime="2013-02-18T14:40:25-0800" status="completed" name="start-assembly"/>
210
+ <process version="1" laneId="default" elapsed="0.509" attempts="1" datetime="2013-02-18T14:42:24-0800" status="completed" name="jp2-create"/>
211
+ </workflow>
212
+ XML
213
+ end
214
+
215
+ it { is_expected.to be_empty }
216
+ end
217
+
218
+ context 'when some steps are not complete' do
219
+ let(:xml) do
220
+ <<~XML
221
+ <workflow repository="dor" objectId="druid:mw971zk1113" id="assemblyWF">
222
+ <process version="1" laneId="default" elapsed="0.0" attempts="1" datetime="2013-02-18T14:40:25-0800" status="completed" name="start-assembly"/>
223
+ <process version="1" laneId="default" elapsed="0.509" attempts="1" datetime="2013-02-18T14:42:24-0800" status="waiting" name="jp2-create"/>
224
+ </workflow>
225
+ XML
226
+ end
227
+
228
+ it 'returns the incomplete processes' do
229
+ expect(processes.size).to eq 1
230
+ expect(processes.first.name).to eq 'jp2-create'
231
+ end
232
+ end
233
+ end
234
+
235
+ describe '#incomplete_processes_for' do
236
+ let(:xml) do
237
+ <<~XML
238
+ <workflow repository="dor" objectId="druid:mw971zk1113" id="assemblyWF">
239
+ <process version="1" laneId="default" elapsed="0.0" attempts="1" datetime="2013-02-18T14:40:25-0800" status="completed" name="start-assembly"/>
240
+ <process version="1" laneId="default" elapsed="0.509" attempts="1" datetime="2013-02-18T14:42:24-0800" status="waiting" name="jp2-create"/>
241
+ <process version="2" laneId="default" elapsed="0.0" attempts="1" datetime="2013-02-18T14:40:25-0800" status="completed" name="start-assembly"/>
242
+ <process version="2" laneId="default" elapsed="0.509" attempts="1" datetime="2013-02-18T14:42:24-0800" status="completed" name="jp2-create"/>
243
+ </workflow>
244
+ XML
245
+ end
246
+
247
+ context 'when all steps are complete' do
248
+ it 'returns empty' do
249
+ expect(instance.incomplete_processes_for(version: 2)).to be_empty
250
+ end
251
+ end
252
+
253
+ context 'when some steps are not complete' do
254
+ it 'returns false' do
255
+ expect(instance.incomplete_processes_for(version: 1).size).to eq 1
256
+ end
257
+ end
258
+ end
201
259
  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: 7.2.0
4
+ version: 7.3.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: 2024-04-02 00:00:00.000000000 Z
12
+ date: 2024-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  - !ruby/object:Gem::Version
169
169
  version: '0'
170
170
  requirements: []
171
- rubygems_version: 3.4.10
171
+ rubygems_version: 3.5.7
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: Provides convenience methods to work with the DOR Workflow Service