dor-services-client 15.16.0 → 15.17.0

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
  SHA256:
3
- metadata.gz: ab50c5a851df383096d632a859cbac9a0afcdbbb54f95910ab31a266b044e6f4
4
- data.tar.gz: 233523b1995ef21dadb3aba64708bc1b8512650c18b33a1500602340a73a0638
3
+ metadata.gz: '08d442e83ffd620ca6ce507912bfad7ece5ce2e303c05dbfa09753828b348f17'
4
+ data.tar.gz: 7da84b625648e7dfaef778ece349cea18d5e25b5ebd49163e33aa223920d81ba
5
5
  SHA512:
6
- metadata.gz: 81ebf90e472f4a6548df3a8282a9a95de3c4177508cab234b31cbf8c66eed9c9af9d2ccc889e6e12a743f8bb92a14d3f4ddf68d43cee24645b65e08fb46b7494
7
- data.tar.gz: e5e4a931b65ecd85a4421f9df55b96a2511ba620088642462c455dcae872d9ba427d4e03f9016ad10d52936aad1efce7c32ac73187b4ed8594c02c0d064bb079
6
+ metadata.gz: 957c36d544c0708e407885b10f5eb2d5c82dff88a4635800d90ad1d3371563d6b63147f2674c9678d2d6049d3289046632c631d337eab04e3b6e427e4b381f53
7
+ data.tar.gz: ba46d21dda5de8a2a614c014fc26ad7287e6de283c5285ffbec4661090c529c3df9cb4333ba22e7ae5188b9360b2d68f5255f1d50524ce9e62019bab5a6800b1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dor-services-client (15.16.0)
4
+ dor-services-client (15.17.0)
5
5
  activesupport (>= 7.0.0)
6
6
  cocina-models (~> 0.104.1)
7
7
  deprecation
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '15.16.0'
6
+ VERSION = '15.17.0'
7
7
  end
8
8
  end
9
9
  end
@@ -24,7 +24,12 @@ module Dor
24
24
  result ? true : false
25
25
  end
26
26
 
27
- # Returns the process, for the most recent version that matches the given name:
27
+ def error_count
28
+ process_names.map { |process_name| process_for_recent_version(name: process_name) }
29
+ .count { |process| process.status == 'error' }
30
+ end
31
+
32
+ # Returns the process for the most recent version that matches the given name:
28
33
  def process_for_recent_version(name:)
29
34
  nodes = process_nodes_for(name: name)
30
35
  node = nodes.max { |a, b| a.attr('version').to_i <=> b.attr('version').to_i }
@@ -38,12 +43,11 @@ module Dor
38
43
  # Check if all processes are skipped or complete for the provided version.
39
44
  # @param [Integer] version the version we are checking for.
40
45
  def complete_for?(version:)
41
- # ng_xml.xpath("/workflow/process[@version=#{version}]/@status").map(&:value).all? { |p| %w[skipped completed].include?(p) }
42
46
  incomplete_processes_for(version: version).empty?
43
47
  end
44
48
 
45
49
  def complete?
46
- complete_for?(version: version)
50
+ complete_for?(version: latest_version)
47
51
  end
48
52
 
49
53
  def incomplete_processes_for(version:)
@@ -53,15 +57,15 @@ module Dor
53
57
  end
54
58
 
55
59
  def incomplete_processes
56
- incomplete_processes_for(version: version)
60
+ incomplete_processes_for(version: latest_version)
57
61
  end
58
62
 
59
63
  attr_reader :xml
60
64
 
61
65
  private
62
66
 
63
- # Return the max version in this workflow document
64
- def version
67
+ # Return the latest version in this workflow document
68
+ def latest_version
65
69
  ng_xml.xpath('/workflow/process/@version').map { |attr| attr.value.to_i }.max
66
70
  end
67
71
 
@@ -81,6 +85,10 @@ module Dor
81
85
  attributes = node ? node.attributes.to_h { |k, v| [k.to_sym, v.value] } : {}
82
86
  Process.new(parent: self, **attributes)
83
87
  end
88
+
89
+ def process_names(version: latest_version)
90
+ ng_xml.xpath("/workflow/process[@version=#{version}]").map { |process| process['name'] }
91
+ end
84
92
  end
85
93
  end
86
94
  end
@@ -5,32 +5,26 @@ module Dor
5
5
  module Response
6
6
  # The response from asking the server about all workflows for an item
7
7
  class Workflows
8
+ attr_reader :xml
9
+
10
+ # @param [Nokogiri::XML] xml Nokogiri XML document showing all workflows
8
11
  def initialize(xml:)
9
12
  @xml = xml
10
13
  end
11
14
 
12
15
  def pid
13
- ng_xml.at_xpath('/workflows/@objectId').text
16
+ xml.at_xpath('/workflows/@objectId').text
14
17
  end
15
18
 
16
19
  def workflows
17
- @workflows ||= ng_xml.xpath('/workflows/workflow').map do |node|
20
+ @workflows ||= xml.xpath('/workflows/workflow').map do |node|
18
21
  Workflow.new(xml: node.to_xml)
19
22
  end
20
23
  end
21
24
 
22
- # @return [Array<String>] returns a list of errors for any process for the current version
25
+ # @return [Array<String>] returns a list of errors for any process for the specified version
23
26
  def errors_for(version:)
24
- ng_xml.xpath("//workflow/process[@version='#{version}' and @status='error']/@errorMessage")
25
- .map(&:text)
26
- end
27
-
28
- attr_reader :xml
29
-
30
- private
31
-
32
- def ng_xml
33
- @ng_xml ||= Nokogiri::XML(@xml)
27
+ xml.xpath("//workflow/process[@version='#{version}' and @status='error']/@errorMessage").map(&:text)
34
28
  end
35
29
  end
36
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-services-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.16.0
4
+ version: 15.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne