dor-workflow-client 3.23.1 → 4.1.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: 2db7637402c0dd629a9d7ced145e20558b24717e56f7bc3fcd3adabbfca4d162
4
- data.tar.gz: 7d4b3a6e7903ebb67a7786d1e10e7210020dee185674028507570e3ca271b796
3
+ metadata.gz: 77fd46c14ada1f0509732073801d7ea699624a79a41ca1cb7c8c47ba6acb7f55
4
+ data.tar.gz: fe4871b54d1df828b1cca4740aeafefdb1d1eee5af55f2040d23a0762a0cc56a
5
5
  SHA512:
6
- metadata.gz: 14374bf91330e5b7280984ffec6a9547731b8a65a9dbe251d2496ed6c94e732efdddfaeab342ae077658e26b4db24af0c3f7fc59ca8c77ddf7fb3143e6c26453
7
- data.tar.gz: ded3fd3fb5f3cbd7a3a3accbfa010e96cfd30df3773c799176a5645aede13fc5cbdf8171445b1bf60805980292014dd83c4255ad62fe83fb9a0440c78c5b5338
6
+ metadata.gz: e9404ff0f029c86849316f780d3e16cc2af0838313adf9034c7e4e78a779848a7c3cf7e3d7a773376907cde6bcbcecc894115de7386035240ec83294112405d7
7
+ data.tar.gz: 88b7444740059ecc1124793b69a1744ae0cf0518e0b5ac06f31690c1b569cc695cc6a322c2916ba1a382586b57a3c0a5ffdd2888893fdd077202bd98f6096f7a
data/.circleci/config.yml CHANGED
@@ -1,35 +1,10 @@
1
1
  version: 2.1
2
-
3
- jobs:
2
+ orbs:
3
+ ruby-rails: sul-dlss/ruby-rails@2.0.0
4
+ workflows:
4
5
  build:
5
- docker:
6
- - image: circleci/ruby:2.7.1
7
- environment:
8
- CC_TEST_REPORTER_ID: 3853bc688a88a4de1a5568eaa8163d20db8637fe988540a935aff028190cff6a
9
- RAILS_ENV: test
10
- steps:
11
- - checkout
12
- - run:
13
- name: Install Bundler
14
- command: gem install bundler
15
- - run:
16
- name: Which bundler?
17
- command: bundle -v
18
- - run:
19
- name: Bundle Install
20
- command: bundle check || bundle install
21
- - run:
22
- name: Lint using rubocop
23
- command: bundle exec rubocop
24
- - run:
25
- name: Setup Code Climate test-reporter
26
- command: |
27
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
28
- chmod +x ./cc-test-reporter
29
- ./cc-test-reporter before-build
30
- - run:
31
- name: rspec
32
- command: bundle exec rspec
33
- - run:
34
- name: upload test coverage report to Code Climate
35
- command: ./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $?
6
+ jobs:
7
+ - ruby-rails/lint:
8
+ name: lint
9
+ - ruby-rails/test-gem:
10
+ name: test
@@ -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
@@ -1,11 +1,114 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.3
4
+ TargetRubyVersion: 3.0
5
5
  # Configuration parameters: AllowURI, URISchemes.
6
- Metrics/LineLength:
6
+ Layout/LineLength:
7
7
  Max: 300
8
8
 
9
9
  Metrics/BlockLength:
10
10
  Exclude:
11
11
  - spec/**/*_spec.rb
12
+
13
+ Gemspec/DeprecatedAttributeAssignment: # new in 1.10
14
+ Enabled: true
15
+ Gemspec/RequireMFA: # new in 1.23
16
+ Enabled: true
17
+ Layout/LineEndStringConcatenationIndentation: # new in 1.18
18
+ Enabled: true
19
+ Layout/SpaceBeforeBrackets: # new in 1.7
20
+ Enabled: true
21
+ Lint/AmbiguousAssignment: # new in 1.7
22
+ Enabled: true
23
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
24
+ Enabled: true
25
+ Lint/AmbiguousRange: # new in 1.19
26
+ Enabled: true
27
+ Lint/DeprecatedConstants: # new in 1.8
28
+ Enabled: true
29
+ Lint/DuplicateBranch: # new in 1.3
30
+ Enabled: true
31
+ Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
32
+ Enabled: true
33
+ Lint/EmptyBlock: # new in 1.1
34
+ Enabled: true
35
+ Lint/EmptyClass: # new in 1.3
36
+ Enabled: true
37
+ Lint/EmptyInPattern: # new in 1.16
38
+ Enabled: true
39
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
40
+ Enabled: true
41
+ Lint/LambdaWithoutLiteralBlock: # new in 1.8
42
+ Enabled: true
43
+ Lint/NoReturnInBeginEndBlocks: # new in 1.2
44
+ Enabled: true
45
+ Lint/NumberedParameterAssignment: # new in 1.9
46
+ Enabled: true
47
+ Lint/OrAssignmentToConstant: # new in 1.9
48
+ Enabled: true
49
+ Lint/RedundantDirGlobSort: # new in 1.8
50
+ Enabled: true
51
+ Lint/RequireRelativeSelfPath: # new in 1.22
52
+ Enabled: true
53
+ Lint/SymbolConversion: # new in 1.9
54
+ Enabled: true
55
+ Lint/ToEnumArguments: # new in 1.1
56
+ Enabled: true
57
+ Lint/TripleQuotes: # new in 1.9
58
+ Enabled: true
59
+ Lint/UnexpectedBlockArity: # new in 1.5
60
+ Enabled: true
61
+ Lint/UnmodifiedReduceAccumulator: # new in 1.1
62
+ Enabled: true
63
+ Lint/UselessRuby2Keywords: # new in 1.23
64
+ Enabled: true
65
+ Naming/BlockForwarding: # new in 1.24
66
+ Enabled: true
67
+ Security/IoMethods: # new in 1.22
68
+ Enabled: true
69
+ Style/ArgumentsForwarding: # new in 1.1
70
+ Enabled: true
71
+ Style/CollectionCompact: # new in 1.2
72
+ Enabled: true
73
+ Style/DocumentDynamicEvalDefinition: # new in 1.1
74
+ Enabled: true
75
+ Style/EndlessMethod: # new in 1.8
76
+ Enabled: true
77
+ Style/FileRead: # new in 1.24
78
+ Enabled: true
79
+ Style/FileWrite: # new in 1.24
80
+ Enabled: true
81
+ Style/HashConversion: # new in 1.10
82
+ Enabled: true
83
+ Style/HashExcept: # new in 1.7
84
+ Enabled: true
85
+ Style/IfWithBooleanLiteralBranches: # new in 1.9
86
+ Enabled: true
87
+ Style/InPatternThen: # new in 1.16
88
+ Enabled: true
89
+ Style/MapToHash: # new in 1.24
90
+ Enabled: true
91
+ Style/MultilineInPatternThen: # new in 1.16
92
+ Enabled: true
93
+ Style/NegatedIfElseCondition: # new in 1.2
94
+ Enabled: true
95
+ Style/NilLambda: # new in 1.3
96
+ Enabled: true
97
+ Style/NumberedParameters: # new in 1.22
98
+ Enabled: true
99
+ Style/NumberedParametersLimit: # new in 1.22
100
+ Enabled: true
101
+ Style/OpenStructUse: # new in 1.23
102
+ Enabled: true
103
+ Style/QuotedSymbols: # new in 1.16
104
+ Enabled: true
105
+ Style/RedundantArgument: # new in 1.4
106
+ Enabled: true
107
+ Style/RedundantSelfAssignmentBranch: # new in 1.19
108
+ Enabled: true
109
+ Style/SelectByRegexp: # new in 1.22
110
+ Enabled: true
111
+ Style/StringChars: # new in 1.12
112
+ Enabled: true
113
+ Style/SwapValues: # new in 1.1
114
+ Enabled: true
data/.rubocop_todo.yml CHANGED
@@ -1,25 +1,58 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-01-06 12:37:25 -0600 using RuboCop version 0.63.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
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 4
10
- Metrics/AbcSize:
11
- Max: 26
9
+ # Offense count: 1
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemspec
12
+ Gemspec/RequiredRubyVersion:
13
+ Exclude:
14
+ - 'dor-workflow-client.gemspec'
12
15
 
13
16
  # Offense count: 1
14
- Metrics/CyclomaticComplexity:
15
- Max: 9
17
+ # Configuration parameters: AllowComments, AllowEmptyLambdas.
18
+ Lint/EmptyBlock:
19
+ Exclude:
20
+ - 'spec/workflow/client/workflow_routes_spec.rb'
16
21
 
17
22
  # Offense count: 1
18
- # Configuration parameters: CountComments, ExcludedMethods.
23
+ Lint/NoReturnInBeginEndBlocks:
24
+ Exclude:
25
+ - 'lib/dor/workflow/client/status.rb'
26
+
27
+ # Offense count: 5
28
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
29
+ Metrics/AbcSize:
30
+ Max: 23
31
+
32
+ # Offense count: 2
33
+ # Configuration parameters: IgnoredMethods.
34
+ Metrics/CyclomaticComplexity:
35
+ Max: 8
36
+
37
+ # Offense count: 2
38
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
19
39
  Metrics/MethodLength:
20
- Max: 13
40
+ Max: 19
21
41
 
22
42
  # Offense count: 3
23
- # Configuration parameters: CountKeywordArgs.
43
+ # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
24
44
  Metrics/ParameterLists:
25
45
  Max: 8
46
+
47
+ # Offense count: 1
48
+ # This cop supports safe autocorrection (--autocorrect).
49
+ Style/KeywordParametersOrder:
50
+ Exclude:
51
+ - 'lib/dor/workflow/client/workflow_routes.rb'
52
+
53
+ # Offense count: 1
54
+ # This cop supports safe autocorrection (--autocorrect).
55
+ # Configuration parameters: AllowModifier.
56
+ Style/SoleNestedConditional:
57
+ Exclude:
58
+ - 'lib/dor/workflow/client/status.rb'
data/Gemfile CHANGED
@@ -9,4 +9,5 @@ gem 'activesupport', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
9
9
 
10
10
  group :development, :test do
11
11
  gem 'byebug'
12
+ gem 'rspec_junit_formatter' # For CircleCI
12
13
  end
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
data/README.md CHANGED
@@ -11,7 +11,7 @@ https://consul.stanford.edu/display/DOR/DOR+services#DORservices-initializeworkf
11
11
 
12
12
  ## Usage
13
13
 
14
- You should initialize a `Dor::Workflow::Client` object in your application configuration, i.e. in a bootup or startup method like:
14
+ Initialize a `Dor::Workflow::Client` object in your application configuration, i.e. in a bootup or startup method like:
15
15
 
16
16
  ```ruby
17
17
  client = Dor::Workflow::Client.new(url: 'https://test-server.edu/workflow/')
@@ -14,20 +14,24 @@ 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']
18
+ gem.required_ruby_version = '>= 2.7'
19
19
 
20
- gem.add_dependency 'activesupport', '>= 3.2.1', '< 7'
20
+ gem.add_dependency 'activesupport', '>= 3.2.1', '< 8'
21
21
  gem.add_dependency 'deprecation', '>= 0.99.0'
22
- gem.add_dependency 'faraday', '>= 0.9.2', '< 2.0'
23
- gem.add_dependency 'faraday_middleware'
22
+ gem.add_dependency 'faraday', '~> 2.0'
23
+ gem.add_dependency 'faraday-retry', '~> 1.0'
24
+
24
25
  gem.add_dependency 'nokogiri', '~> 1.6'
25
26
  gem.add_dependency 'zeitwerk', '~> 2.1'
26
27
 
27
28
  gem.add_development_dependency 'rake'
28
29
  gem.add_development_dependency 'rspec', '~> 3.3'
29
- gem.add_development_dependency 'rubocop', '~> 0.63.1'
30
- gem.add_development_dependency 'simplecov', '~> 0.17.0' # CodeClimate cannot use SimpleCov >= 0.18.0 for generating test coverage
30
+ gem.add_development_dependency 'rubocop', '~> 1.24'
31
+ gem.add_development_dependency 'rubocop-rake'
32
+ gem.add_development_dependency 'rubocop-rspec', '~> 2.1'
33
+ gem.add_development_dependency 'simplecov'
31
34
  gem.add_development_dependency 'webmock'
32
35
  gem.add_development_dependency 'yard'
36
+ gem.metadata['rubygems_mfa_required'] = 'true'
33
37
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'faraday_middleware'
4
-
5
3
  module Dor
6
4
  module Workflow
7
5
  class Client
@@ -17,11 +15,9 @@ module Dor
17
15
  @logger = logger
18
16
  end
19
17
 
20
- # rubocop:disable Metrics/MethodLength
21
18
  def build_connection
22
19
  Faraday.new(url: url) do |faraday|
23
20
  faraday.use Faraday::Response::RaiseError # raise exceptions on 40x, 50x responses
24
- faraday.use FaradayMiddleware::FollowRedirects, limit: 3
25
21
  faraday.options.params_encoder = Faraday::FlatParamsEncoder
26
22
  if timeout
27
23
  faraday.options.timeout = timeout
@@ -40,7 +36,6 @@ module Dor
40
36
  faraday.adapter Faraday.default_adapter # Last middleware must be the adapter
41
37
  end
42
38
  end
43
- # rubocop:enable Metrics/MethodLength
44
39
 
45
40
  def user_agent
46
41
  "dor-workflow-client #{VERSION}"
@@ -51,17 +46,17 @@ module Dor
51
46
  attr_reader :logger, :timeout, :url
52
47
 
53
48
  def retriable_methods
54
- Faraday::Request::Retry::IDEMPOTENT_METHODS + [:post]
49
+ Faraday::Retry::Middleware::IDEMPOTENT_METHODS + [:post]
55
50
  end
56
51
 
57
52
  def retriable_exceptions
58
- Faraday::Request::Retry::DEFAULT_EXCEPTIONS + [Faraday::ConnectionFailed]
53
+ Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [Faraday::ConnectionFailed]
59
54
  end
60
55
 
61
56
  def retry_block
62
57
  lambda do |env, _opts, retries, exception|
63
58
  logger.warn "retrying connection (#{retries} remaining) to #{env.url}: (#{exception.class}) " \
64
- "#{exception.message} #{env.status}"
59
+ "#{exception.message} #{env.status}"
65
60
  end
66
61
  end
67
62
 
@@ -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
 
@@ -63,7 +63,7 @@ module Dor
63
63
  )
64
64
  args.shift # ditch the `repo` argument
65
65
  end
66
- uri_string = build_queued_uri(args.first) + '&count-only=true'
66
+ uri_string = "#{build_queued_uri(args.first)}&count-only=true"
67
67
  doc = Nokogiri::XML(requestor.request(uri_string))
68
68
  doc.at_xpath('/objects/@count').value.to_i
69
69
  end
@@ -139,13 +139,13 @@ 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}"
146
- Nokogiri::XML(resp).xpath('//object').map do |node|
146
+ Nokogiri::XML(resp).xpath('//object').to_h do |node|
147
147
  [node['id'], node['errorMessage']]
148
- end.to_h
148
+ end
149
149
  end
150
150
 
151
151
  # Used by preservation robots stats reporter
@@ -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 = '3.23.1'
6
+ VERSION = '4.1.0'
7
7
  end
8
8
  end
9
9
  end
@@ -23,12 +23,12 @@ module Dor
23
23
  # @return [Boolean] always true
24
24
  #
25
25
  def create_workflow(_repo, druid, workflow_name, _wf_xml, opts = {})
26
- create_workflow_by_name(druid, workflow_name, opts)
26
+ create_workflow_by_name(druid, workflow_name, **opts)
27
27
  end
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
 
@@ -313,8 +318,8 @@ module Dor
313
318
  # @return [String]
314
319
  def create_process_xml(params)
315
320
  builder = Nokogiri::XML::Builder.new do |xml|
316
- attrs = params.reject { |_k, v| v.nil? }
317
- attrs = Hash[attrs.map { |k, v| [k.to_s.camelize(:lower), v] }] # camelize all the keys in the attrs hash
321
+ attrs = params.compact
322
+ attrs = attrs.transform_keys { |k| k.to_s.camelize(:lower) } # camelize all the keys in the attrs hash
318
323
  xml.process(attrs)
319
324
  end
320
325
  builder.to_xml
@@ -5,6 +5,7 @@ require 'active_support/core_ext'
5
5
  require 'nokogiri'
6
6
  require 'zeitwerk'
7
7
  require 'faraday'
8
+ require 'faraday/retry'
8
9
  require 'deprecation'
9
10
 
10
11
  loader = Zeitwerk::Loader.new
@@ -35,7 +35,7 @@ module Dor
35
35
  def process_for_recent_version(name:)
36
36
  nodes = process_nodes_for(name: name)
37
37
  node = nodes.max { |a, b| a.attr('version').to_i <=> b.attr('version').to_i }
38
- attributes = node ? Hash[node.attributes.collect { |k, v| [k.to_sym, v.value] }] : {}
38
+ attributes = node ? node.attributes.to_h { |k, v| [k.to_sym, v.value] } : {}
39
39
  Process.new(parent: self, **attributes)
40
40
  end
41
41
 
@@ -72,7 +72,7 @@ RSpec.describe Dor::Workflow::Response::Workflow do
72
72
  end
73
73
  end
74
74
 
75
- describe '#active?' do
75
+ describe '#active_for?' do
76
76
  subject { instance.active_for?(version: 2) }
77
77
 
78
78
  context 'when the workflow has not been instantiated for the given version' do
@@ -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
@@ -804,7 +816,7 @@ RSpec.describe Dor::Workflow::Client do
804
816
 
805
817
  let(:stubs) do
806
818
  Faraday::Adapter::Test::Stubs.new do |stub|
807
- stub.get('workflow_queue/lane_ids?lane_ids?step=dor:accessionWF:shelve') do |_env|
819
+ stub.get('workflow_queue/lane_ids?step=accessionWF:shelve') do |_env|
808
820
  [200, {}, <<-XML]
809
821
  <lanes>
810
822
  <lane id="lane1"/>
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-workflow-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.23.1
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willy Mene
8
8
  - Darren Hardy
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-08 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
@@ -20,7 +20,7 @@ dependencies:
20
20
  version: 3.2.1
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: '7'
23
+ version: '8'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,7 +30,7 @@ dependencies:
30
30
  version: 3.2.1
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '7'
33
+ version: '8'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: deprecation
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -49,36 +49,30 @@ dependencies:
49
49
  name: faraday
50
50
  requirement: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 0.9.2
55
- - - "<"
52
+ - - "~>"
56
53
  - !ruby/object:Gem::Version
57
54
  version: '2.0'
58
55
  type: :runtime
59
56
  prerelease: false
60
57
  version_requirements: !ruby/object:Gem::Requirement
61
58
  requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: 0.9.2
65
- - - "<"
59
+ - - "~>"
66
60
  - !ruby/object:Gem::Version
67
61
  version: '2.0'
68
62
  - !ruby/object:Gem::Dependency
69
- name: faraday_middleware
63
+ name: faraday-retry
70
64
  requirement: !ruby/object:Gem::Requirement
71
65
  requirements:
72
- - - ">="
66
+ - - "~>"
73
67
  - !ruby/object:Gem::Version
74
- version: '0'
68
+ version: '1.0'
75
69
  type: :runtime
76
70
  prerelease: false
77
71
  version_requirements: !ruby/object:Gem::Requirement
78
72
  requirements:
79
- - - ">="
73
+ - - "~>"
80
74
  - !ruby/object:Gem::Version
81
- version: '0'
75
+ version: '1.0'
82
76
  - !ruby/object:Gem::Dependency
83
77
  name: nokogiri
84
78
  requirement: !ruby/object:Gem::Requirement
@@ -141,28 +135,56 @@ dependencies:
141
135
  requirements:
142
136
  - - "~>"
143
137
  - !ruby/object:Gem::Version
144
- version: 0.63.1
138
+ version: '1.24'
145
139
  type: :development
146
140
  prerelease: false
147
141
  version_requirements: !ruby/object:Gem::Requirement
148
142
  requirements:
149
143
  - - "~>"
150
144
  - !ruby/object:Gem::Version
151
- version: 0.63.1
145
+ version: '1.24'
152
146
  - !ruby/object:Gem::Dependency
153
- name: simplecov
147
+ name: rubocop-rake
148
+ requirement: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ type: :development
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ - !ruby/object:Gem::Dependency
161
+ name: rubocop-rspec
154
162
  requirement: !ruby/object:Gem::Requirement
155
163
  requirements:
156
164
  - - "~>"
157
165
  - !ruby/object:Gem::Version
158
- version: 0.17.0
166
+ version: '2.1'
159
167
  type: :development
160
168
  prerelease: false
161
169
  version_requirements: !ruby/object:Gem::Requirement
162
170
  requirements:
163
171
  - - "~>"
164
172
  - !ruby/object:Gem::Version
165
- version: 0.17.0
173
+ version: '2.1'
174
+ - !ruby/object:Gem::Dependency
175
+ name: simplecov
176
+ requirement: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ type: :development
182
+ prerelease: false
183
+ version_requirements: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
166
188
  - !ruby/object:Gem::Dependency
167
189
  name: webmock
168
190
  requirement: !ruby/object:Gem::Requirement
@@ -206,6 +228,7 @@ files:
206
228
  - ".rubocop_todo.yml"
207
229
  - ".yardopts"
208
230
  - Gemfile
231
+ - Gemfile.lock
209
232
  - LICENSE.txt
210
233
  - README.md
211
234
  - Rakefile
@@ -240,8 +263,9 @@ files:
240
263
  - spec/workflow/client_spec.rb
241
264
  homepage: https://consul.stanford.edu/display/DOR/DOR+services#DORservices-initializeworkflow
242
265
  licenses: []
243
- metadata: {}
244
- post_install_message:
266
+ metadata:
267
+ rubygems_mfa_required: 'true'
268
+ post_install_message:
245
269
  rdoc_options: []
246
270
  require_paths:
247
271
  - lib
@@ -249,27 +273,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
249
273
  requirements:
250
274
  - - ">="
251
275
  - !ruby/object:Gem::Version
252
- version: '0'
276
+ version: '2.7'
253
277
  required_rubygems_version: !ruby/object:Gem::Requirement
254
278
  requirements:
255
279
  - - ">="
256
280
  - !ruby/object:Gem::Version
257
281
  version: '0'
258
282
  requirements: []
259
- rubygems_version: 3.0.3
260
- signing_key:
283
+ rubygems_version: 3.2.32
284
+ signing_key:
261
285
  specification_version: 4
262
286
  summary: Provides convenience methods to work with the DOR Workflow Service
263
- test_files:
264
- - spec/models/response/process_spec.rb
265
- - spec/models/response/workflow_spec.rb
266
- - spec/models/response/workflows_spec.rb
267
- - spec/spec_helper.rb
268
- - spec/workflow/client/connection_factory_spec.rb
269
- - spec/workflow/client/lifecycle_routes_spec.rb
270
- - spec/workflow/client/requestor_spec.rb
271
- - spec/workflow/client/status_spec.rb
272
- - spec/workflow/client/version_routes_spec.rb
273
- - spec/workflow/client/workflow_routes_spec.rb
274
- - spec/workflow/client/workflow_template_spec.rb
275
- - spec/workflow/client_spec.rb
287
+ test_files: []