dor-workflow-client 4.0.0 → 4.1.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: ebdb5efb62a6eaede5600c160ced195692290cc059666345c4ea7e21b9ffee33
4
- data.tar.gz: da11701acceca8acc9ed30719e034bfe5eb9350394f90d10b9babdad92600c46
3
+ metadata.gz: 77fd46c14ada1f0509732073801d7ea699624a79a41ca1cb7c8c47ba6acb7f55
4
+ data.tar.gz: fe4871b54d1df828b1cca4740aeafefdb1d1eee5af55f2040d23a0762a0cc56a
5
5
  SHA512:
6
- metadata.gz: 027c3795481fb428df972a4cd420a281e39226acffb2bf067769de10580fa42d7c64f826c168c1a009f0cef825acb34f027202b95d19ba9098f92333232fcb46
7
- data.tar.gz: 82cc4205238d2fbe04c75903dd99ad214579becf8326f6ca46dc459e3a962ca05d38fca587cb42b1c5ea4fe030ff1a61b95f5983828081f24d9fae123123b07d
6
+ metadata.gz: e9404ff0f029c86849316f780d3e16cc2af0838313adf9034c7e4e78a779848a7c3cf7e3d7a773376907cde6bcbcecc894115de7386035240ec83294112405d7
7
+ data.tar.gz: 88b7444740059ecc1124793b69a1744ae0cf0518e0b5ac06f31690c1b569cc695cc6a322c2916ba1a382586b57a3c0a5ffdd2888893fdd077202bd98f6096f7a
@@ -1,12 +1,10 @@
1
- ## Why was this change made?
1
+ ## Why was this change made? 🤔
2
2
 
3
3
 
4
4
 
5
- ## How was this change tested?
5
+ ## How was this change tested? 🤨
6
6
 
7
-
8
-
9
- ## Which documentation and/or configurations were updated?
7
+ ⚡ ⚠ If this change affects the API or other fundamentals of this service, ***run [integration tests](https://github.com/sul-dlss/infrastructure-integration-test)*** that exercise this service and/or test in [stage|qa] environment, in addition to specs. ⚡
10
8
 
11
9
 
12
10
 
data/.gitignore CHANGED
@@ -4,7 +4,6 @@
4
4
  .config
5
5
  .yardoc
6
6
  .rvmrc
7
- Gemfile.lock
8
7
  InstalledFiles
9
8
  _yardoc
10
9
  coverage
@@ -18,4 +17,3 @@ test/version_tmp
18
17
  tmp
19
18
  .ruby-version
20
19
  .ruby-gemset
21
-
data/.rubocop.yml CHANGED
@@ -10,7 +10,7 @@ Metrics/BlockLength:
10
10
  Exclude:
11
11
  - spec/**/*_spec.rb
12
12
 
13
- Gemspec/DateAssignment: # new in 1.10
13
+ Gemspec/DeprecatedAttributeAssignment: # new in 1.10
14
14
  Enabled: true
15
15
  Gemspec/RequireMFA: # new in 1.23
16
16
  Enabled: true
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2022-01-14 04:19:32 UTC using RuboCop version 1.24.1.
3
+ # on 2022-06-28 04:56:14 UTC using RuboCop version 1.31.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -27,23 +27,17 @@ Lint/NoReturnInBeginEndBlocks:
27
27
  # Offense count: 5
28
28
  # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
29
29
  Metrics/AbcSize:
30
- Max: 24
31
-
32
- # Offense count: 1
33
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
34
- # IgnoredMethods: refine
35
- Metrics/BlockLength:
36
- Max: 26
30
+ Max: 23
37
31
 
38
32
  # Offense count: 2
39
33
  # Configuration parameters: IgnoredMethods.
40
34
  Metrics/CyclomaticComplexity:
41
35
  Max: 8
42
36
 
43
- # Offense count: 1
37
+ # Offense count: 2
44
38
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
45
39
  Metrics/MethodLength:
46
- Max: 13
40
+ Max: 19
47
41
 
48
42
  # Offense count: 3
49
43
  # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
@@ -51,13 +45,13 @@ Metrics/ParameterLists:
51
45
  Max: 8
52
46
 
53
47
  # Offense count: 1
54
- # Cop supports --auto-correct.
48
+ # This cop supports safe autocorrection (--autocorrect).
55
49
  Style/KeywordParametersOrder:
56
50
  Exclude:
57
51
  - 'lib/dor/workflow/client/workflow_routes.rb'
58
52
 
59
53
  # Offense count: 1
60
- # Cop supports --auto-correct.
54
+ # This cop supports safe autocorrection (--autocorrect).
61
55
  # Configuration parameters: AllowModifier.
62
56
  Style/SoleNestedConditional:
63
57
  Exclude:
data/Gemfile.lock ADDED
@@ -0,0 +1,118 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dor-workflow-client (4.1.0)
5
+ activesupport (>= 3.2.1, < 8)
6
+ deprecation (>= 0.99.0)
7
+ faraday (~> 2.0)
8
+ faraday-retry (~> 1.0)
9
+ nokogiri (~> 1.6)
10
+ zeitwerk (~> 2.1)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ activesupport (7.0.3)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 1.6, < 2)
18
+ minitest (>= 5.1)
19
+ tzinfo (~> 2.0)
20
+ addressable (2.8.0)
21
+ public_suffix (>= 2.0.2, < 5.0)
22
+ ast (2.4.2)
23
+ byebug (11.1.3)
24
+ concurrent-ruby (1.1.10)
25
+ crack (0.4.5)
26
+ rexml
27
+ deprecation (1.1.0)
28
+ activesupport
29
+ diff-lcs (1.5.0)
30
+ docile (1.4.0)
31
+ faraday (2.3.0)
32
+ faraday-net_http (~> 2.0)
33
+ ruby2_keywords (>= 0.0.4)
34
+ faraday-net_http (2.0.3)
35
+ faraday-retry (1.0.3)
36
+ hashdiff (1.0.1)
37
+ i18n (1.10.0)
38
+ concurrent-ruby (~> 1.0)
39
+ minitest (5.16.1)
40
+ nokogiri (1.13.6-x86_64-darwin)
41
+ racc (~> 1.4)
42
+ parallel (1.22.1)
43
+ parser (3.1.2.0)
44
+ ast (~> 2.4.1)
45
+ public_suffix (4.0.7)
46
+ racc (1.6.0)
47
+ rainbow (3.1.1)
48
+ rake (13.0.6)
49
+ regexp_parser (2.5.0)
50
+ rexml (3.2.5)
51
+ rspec (3.11.0)
52
+ rspec-core (~> 3.11.0)
53
+ rspec-expectations (~> 3.11.0)
54
+ rspec-mocks (~> 3.11.0)
55
+ rspec-core (3.11.0)
56
+ rspec-support (~> 3.11.0)
57
+ rspec-expectations (3.11.0)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.11.0)
60
+ rspec-mocks (3.11.1)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.11.0)
63
+ rspec-support (3.11.0)
64
+ rspec_junit_formatter (0.5.1)
65
+ rspec-core (>= 2, < 4, != 2.12.0)
66
+ rubocop (1.31.0)
67
+ parallel (~> 1.10)
68
+ parser (>= 3.1.0.0)
69
+ rainbow (>= 2.2.2, < 4.0)
70
+ regexp_parser (>= 1.8, < 3.0)
71
+ rexml (>= 3.2.5, < 4.0)
72
+ rubocop-ast (>= 1.18.0, < 2.0)
73
+ ruby-progressbar (~> 1.7)
74
+ unicode-display_width (>= 1.4.0, < 3.0)
75
+ rubocop-ast (1.18.0)
76
+ parser (>= 3.1.1.0)
77
+ rubocop-rake (0.6.0)
78
+ rubocop (~> 1.0)
79
+ rubocop-rspec (2.11.1)
80
+ rubocop (~> 1.19)
81
+ ruby-progressbar (1.11.0)
82
+ ruby2_keywords (0.0.5)
83
+ simplecov (0.21.2)
84
+ docile (~> 1.1)
85
+ simplecov-html (~> 0.11)
86
+ simplecov_json_formatter (~> 0.1)
87
+ simplecov-html (0.12.3)
88
+ simplecov_json_formatter (0.1.4)
89
+ tzinfo (2.0.4)
90
+ concurrent-ruby (~> 1.0)
91
+ unicode-display_width (2.2.0)
92
+ webmock (3.14.0)
93
+ addressable (>= 2.8.0)
94
+ crack (>= 0.3.2)
95
+ hashdiff (>= 0.4.0, < 2.0.0)
96
+ webrick (1.7.0)
97
+ yard (0.9.28)
98
+ webrick (~> 1.7.0)
99
+ zeitwerk (2.6.0)
100
+
101
+ PLATFORMS
102
+ ruby
103
+
104
+ DEPENDENCIES
105
+ byebug
106
+ dor-workflow-client!
107
+ rake
108
+ rspec (~> 3.3)
109
+ rspec_junit_formatter
110
+ rubocop (~> 1.24)
111
+ rubocop-rake
112
+ rubocop-rspec (~> 2.1)
113
+ simplecov
114
+ webmock
115
+ yard
116
+
117
+ BUNDLED WITH
118
+ 2.2.32
@@ -14,14 +14,13 @@ Gem::Specification.new do |gem|
14
14
  gem.homepage = 'https://consul.stanford.edu/display/DOR/DOR+services#DORservices-initializeworkflow'
15
15
 
16
16
  gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
- gem.test_files = gem.files.grep(%r{^(spec)/})
18
17
  gem.require_paths = ['lib']
19
18
  gem.required_ruby_version = '>= 2.7'
20
19
 
21
20
  gem.add_dependency 'activesupport', '>= 3.2.1', '< 8'
22
21
  gem.add_dependency 'deprecation', '>= 0.99.0'
23
22
  gem.add_dependency 'faraday', '~> 2.0'
24
- gem.add_dependency 'faraday-retry'
23
+ gem.add_dependency 'faraday-retry', '~> 1.0'
25
24
 
26
25
  gem.add_dependency 'nokogiri', '~> 1.6'
27
26
  gem.add_dependency 'zeitwerk', '~> 2.1'
@@ -15,7 +15,6 @@ module Dor
15
15
  @logger = logger
16
16
  end
17
17
 
18
- # rubocop:disable Metrics/MethodLength
19
18
  def build_connection
20
19
  Faraday.new(url: url) do |faraday|
21
20
  faraday.use Faraday::Response::RaiseError # raise exceptions on 40x, 50x responses
@@ -37,7 +36,6 @@ module Dor
37
36
  faraday.adapter Faraday.default_adapter # Last middleware must be the adapter
38
37
  end
39
38
  end
40
- # rubocop:enable Metrics/MethodLength
41
39
 
42
40
  def user_agent
43
41
  "dor-workflow-client #{VERSION}"
@@ -84,7 +84,6 @@ module Dor
84
84
  # rubocop:enable Metrics/MethodLength
85
85
 
86
86
  # @return [Array<Hash>]
87
- # rubocop:disable Metrics/MethodLength
88
87
  def milestones(*args)
89
88
  case args.size
90
89
  when 2
@@ -105,7 +104,6 @@ module Dor
105
104
  { milestone: node.text, at: Time.parse(node['date']), version: node['version'] }
106
105
  end
107
106
  end
108
- # rubocop:enable Metrics/MethodLength
109
107
 
110
108
  private
111
109
 
@@ -139,7 +139,7 @@ module Dor
139
139
  # @example
140
140
  # client.errored_objects_for_workstep('accessionWF','content-metadata')
141
141
  # => {"druid:qd556jq0580"=>"druid:qd556jq0580 - Item error; caused by
142
- # #<Rubydora::FedoraInvalidRequest: Error modifying datastream contentMetadata for druid:qd556jq0580. See logger for details>"}
142
+ # blah blah. See logger for details>"}
143
143
  def errored_objects_for_workstep(workflow, step, repository = nil)
144
144
  Deprecation.warn(self, 'the third argument to `#errored_objects_for_workstep` is unused and will go away in Dor::Workflow::Client 4.0.0. omit argument to silence.') unless repository.nil?
145
145
  resp = requestor.request "workflow_queue?workflow=#{workflow}&error=#{step}"
@@ -42,7 +42,6 @@ module Dor
42
42
  end
43
43
 
44
44
  # @return [Hash{Symbol => Object}] including :status_code and :status_time
45
- # rubocop:disable Metrics/MethodLength
46
45
  def info
47
46
  @info ||= begin
48
47
  # if we have an accessioned milestone, this is the last possible step and should be the status regardless of time stamp
@@ -64,7 +63,6 @@ module Dor
64
63
  { status_code: status_code, status_time: status_time }
65
64
  end
66
65
  end
67
- # rubocop:enable Metrics/MethodLength
68
66
 
69
67
  def status_code
70
68
  info.fetch(:status_code)
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Workflow
5
5
  class Client
6
- VERSION = '4.0.0'
6
+ VERSION = '4.1.0'
7
7
  end
8
8
  end
9
9
  end
@@ -28,7 +28,7 @@ module Dor
28
28
  deprecation_deprecate create_workflow: 'use create_workflow_by_name instead'
29
29
 
30
30
  # Creates a workflow for a given object in the repository. If this particular workflow for this objects exists,
31
- # it will replace the old workflow. You have the option of creating a datastream or not.
31
+ # it will replace the old workflow.
32
32
  # Returns true on success. Caller must handle any exceptions.
33
33
  #
34
34
  # @param [String] druid The id of the object
@@ -124,7 +124,6 @@ module Dor
124
124
  # @param [String] workflow The name of the workflow
125
125
  # @param [String] process The name of the process step
126
126
  # @return [String] status for repo-workflow-process-druid
127
- # rubocop:disable Metrics/MethodLength
128
127
  # rubocop:disable Metrics/AbcSize
129
128
  def workflow_status(*args)
130
129
  case args.length
@@ -147,16 +146,14 @@ module Dor
147
146
  process = processes.max { |a, b| a.attr('version').to_i <=> b.attr('version').to_i }
148
147
  process&.attr('status')
149
148
  end
150
- # rubocop:enable Metrics/AbcSize
151
- # rubocop:enable Metrics/MethodLength
152
149
 
150
+ # rubocop:enable Metrics/AbcSize
153
151
  #
154
152
  # Retrieves the raw XML for the given workflow
155
153
  # @param [String] repo The repository the object resides in. Currently recoginzes "dor" and "sdr".
156
154
  # @param [String] druid The id of the object
157
155
  # @param [String] workflow The name of the workflow
158
156
  # @return [String] XML of the workflow
159
- # rubocop:disable Metrics/MethodLength
160
157
  def workflow_xml(*args)
161
158
  case args.length
162
159
  when 3
@@ -177,8 +174,6 @@ module Dor
177
174
  end
178
175
  deprecation_deprecate workflow_xml: 'workflow_xml will not be replaced'
179
176
 
180
- # rubocop:enable Metrics/MethodLength
181
-
182
177
  # Updates the status of one step in a workflow to error.
183
178
  # Returns true on success. Caller must handle any exceptions
184
179
  #
@@ -275,19 +270,29 @@ module Dor
275
270
  end
276
271
 
277
272
  # Deletes a workflow from a particular repository and druid. This is only used by Hydrus.
278
- # @param [String] repo The repository the object resides in. The service recoginzes "dor" and "sdr" at the moment
279
273
  # @param [String] druid The id of the object to delete the workflow from
280
274
  # @param [String] workflow The name of the workflow to be deleted
281
275
  # @param [Integer] version The version of the workflow to delete
282
276
  # @return [Boolean] always true
283
- def delete_workflow(repo, druid, workflow, version: nil)
277
+ def delete_workflow(*args)
278
+ case args.length
279
+ when 3..4
280
+ Deprecation.warn(self, 'Calling delete_workflow with positional args is deprecated, use kwargs instead')
281
+ (_repo, druid, workflow, version_hash) = *args
282
+ version = version_hash && version_hash[:version]
283
+ when 1
284
+ opts = args.first
285
+ druid = opts[:druid]
286
+ workflow = opts[:workflow]
287
+ version = opts[:version]
288
+ end
284
289
  qs_args = if version
285
290
  "?version=#{version}"
286
291
  else
287
292
  Deprecation.warn(self, 'Calling delete_workflow without passing version is deprecated and will result in an error in dor-workflow-client 4.0')
288
293
  ''
289
294
  end
290
- requestor.request "#{repo}/objects/#{druid}/workflows/#{workflow}#{qs_args}", 'delete'
295
+ requestor.request "/objects/#{druid}/workflows/#{workflow}#{qs_args}", 'delete'
291
296
  true
292
297
  end
293
298
 
@@ -147,6 +147,19 @@ RSpec.describe Dor::Workflow::Client::WorkflowRoutes do
147
147
  end
148
148
  end
149
149
 
150
+ describe '#delete_all_workflows' do
151
+ subject(:delete_all_workflows) do
152
+ routes.delete_all_workflows(pid: 'druid:mw971zk1113')
153
+ end
154
+ let(:mock_requestor) { instance_double(Dor::Workflow::Client::Requestor, request: nil) }
155
+
156
+ it 'sends a delete request' do
157
+ delete_all_workflows
158
+ expect(mock_requestor).to have_received(:request)
159
+ .with('objects/druid:mw971zk1113/workflows', 'delete')
160
+ end
161
+ end
162
+
150
163
  describe '#all_workflows' do
151
164
  let(:xml) do
152
165
  <<~XML
@@ -729,22 +729,34 @@ RSpec.describe Dor::Workflow::Client do
729
729
  end
730
730
  end
731
731
 
732
- context 'without a version' do
733
- let(:url) { "/objects/#{@druid}/workflows/accessionWF" }
732
+ context 'with positional args' do
733
+ context 'without a version' do
734
+ let(:url) { "/objects/#{@druid}/workflows/accessionWF" }
734
735
 
735
- it 'sends a delete request to the workflow service' do
736
- expect(Deprecation).to receive(:warn)
737
- expect(mock_http_connection).to receive(:delete).with(url).and_call_original
738
- client.delete_workflow(nil, @druid, 'accessionWF')
736
+ it 'sends a delete request to the workflow service' do
737
+ expect(Deprecation).to receive(:warn).twice
738
+ expect(mock_http_connection).to receive(:delete).with(url).and_call_original
739
+ client.delete_workflow(nil, @druid, 'accessionWF')
740
+ end
741
+ end
742
+
743
+ context 'with a version' do
744
+ let(:url) { "/objects/#{@druid}/workflows/accessionWF?version=5" }
745
+
746
+ it 'sends a delete request to the workflow service' do
747
+ expect(Deprecation).to receive(:warn)
748
+ expect(mock_http_connection).to receive(:delete).with(url).and_call_original
749
+ client.delete_workflow(nil, @druid, 'accessionWF', version: 5)
750
+ end
739
751
  end
740
752
  end
741
753
 
742
- context 'with a version' do
754
+ context 'with kwargs' do
743
755
  let(:url) { "/objects/#{@druid}/workflows/accessionWF?version=5" }
744
756
 
745
757
  it 'sends a delete request to the workflow service' do
746
758
  expect(mock_http_connection).to receive(:delete).with(url).and_call_original
747
- client.delete_workflow(nil, @druid, 'accessionWF', version: 5)
759
+ client.delete_workflow(druid: @druid, workflow: 'accessionWF', version: 5)
748
760
  end
749
761
  end
750
762
  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: 4.0.0
4
+ version: 4.1.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: 2022-03-01 00:00:00.000000000 Z
12
+ date: 2022-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -63,16 +63,16 @@ dependencies:
63
63
  name: faraday-retry
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '1.0'
69
69
  type: :runtime
70
70
  prerelease: false
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '1.0'
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: nokogiri
78
78
  requirement: !ruby/object:Gem::Requirement
@@ -228,6 +228,7 @@ files:
228
228
  - ".rubocop_todo.yml"
229
229
  - ".yardopts"
230
230
  - Gemfile
231
+ - Gemfile.lock
231
232
  - LICENSE.txt
232
233
  - README.md
233
234
  - Rakefile
@@ -283,16 +284,4 @@ rubygems_version: 3.2.32
283
284
  signing_key:
284
285
  specification_version: 4
285
286
  summary: Provides convenience methods to work with the DOR Workflow Service
286
- test_files:
287
- - spec/models/response/process_spec.rb
288
- - spec/models/response/workflow_spec.rb
289
- - spec/models/response/workflows_spec.rb
290
- - spec/spec_helper.rb
291
- - spec/workflow/client/connection_factory_spec.rb
292
- - spec/workflow/client/lifecycle_routes_spec.rb
293
- - spec/workflow/client/requestor_spec.rb
294
- - spec/workflow/client/status_spec.rb
295
- - spec/workflow/client/version_routes_spec.rb
296
- - spec/workflow/client/workflow_routes_spec.rb
297
- - spec/workflow/client/workflow_template_spec.rb
298
- - spec/workflow/client_spec.rb
287
+ test_files: []