dor-workflow-client 3.24.0 → 4.0.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: 6fcd257c721798580d9e953614f3b8b29bb71cff18359984f5f12355e43032e2
4
- data.tar.gz: 000a4e4b96f31fafd144a5a02825b4d6a6fe5bab7e2c925d47874db0873dfaae
3
+ metadata.gz: ebdb5efb62a6eaede5600c160ced195692290cc059666345c4ea7e21b9ffee33
4
+ data.tar.gz: da11701acceca8acc9ed30719e034bfe5eb9350394f90d10b9babdad92600c46
5
5
  SHA512:
6
- metadata.gz: 539d6b2915c4d5a031227f73b00065674d401be19610925e0ba4fc2954348b713ca6a093246bdc73fc321705315a94bf082cde53b10cf1196ec75611027c4da0
7
- data.tar.gz: 2be1999274099fa74ee6ba3c69303421af076866ef1a8aba673ef7a1b5b09c4a19306af0f43aa59af0a458aced85b0a8f567ab499f35fcb0f0b353eab7265dbf
6
+ metadata.gz: 027c3795481fb428df972a4cd420a281e39226acffb2bf067769de10580fa42d7c64f826c168c1a009f0cef825acb34f027202b95d19ba9098f92333232fcb46
7
+ data.tar.gz: 82cc4205238d2fbe04c75903dd99ad214579becf8326f6ca46dc459e3a962ca05d38fca587cb42b1c5ea4fe030ff1a61b95f5983828081f24d9fae123123b07d
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
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/DateAssignment: # 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,64 @@
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-01-14 04:19:32 UTC using RuboCop version 1.24.1.
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
9
+ # Offense count: 1
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemspec
12
+ Gemspec/RequiredRubyVersion:
13
+ Exclude:
14
+ - 'dor-workflow-client.gemspec'
15
+
16
+ # Offense count: 1
17
+ # Configuration parameters: AllowComments, AllowEmptyLambdas.
18
+ Lint/EmptyBlock:
19
+ Exclude:
20
+ - 'spec/workflow/client/workflow_routes_spec.rb'
21
+
22
+ # Offense count: 1
23
+ Lint/NoReturnInBeginEndBlocks:
24
+ Exclude:
25
+ - 'lib/dor/workflow/client/status.rb'
26
+
27
+ # Offense count: 5
28
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
10
29
  Metrics/AbcSize:
11
- Max: 26
30
+ Max: 24
12
31
 
13
32
  # Offense count: 1
33
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
34
+ # IgnoredMethods: refine
35
+ Metrics/BlockLength:
36
+ Max: 26
37
+
38
+ # Offense count: 2
39
+ # Configuration parameters: IgnoredMethods.
14
40
  Metrics/CyclomaticComplexity:
15
- Max: 9
41
+ Max: 8
16
42
 
17
43
  # Offense count: 1
18
- # Configuration parameters: CountComments, ExcludedMethods.
44
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
19
45
  Metrics/MethodLength:
20
46
  Max: 13
21
47
 
22
48
  # Offense count: 3
23
- # Configuration parameters: CountKeywordArgs.
49
+ # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
24
50
  Metrics/ParameterLists:
25
51
  Max: 8
52
+
53
+ # Offense count: 1
54
+ # Cop supports --auto-correct.
55
+ Style/KeywordParametersOrder:
56
+ Exclude:
57
+ - 'lib/dor/workflow/client/workflow_routes.rb'
58
+
59
+ # Offense count: 1
60
+ # Cop supports --auto-correct.
61
+ # Configuration parameters: AllowModifier.
62
+ Style/SoleNestedConditional:
63
+ Exclude:
64
+ - '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/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/')
@@ -16,18 +16,23 @@ Gem::Specification.new do |gem|
16
16
  gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
17
  gem.test_files = gem.files.grep(%r{^(spec)/})
18
18
  gem.require_paths = ['lib']
19
+ gem.required_ruby_version = '>= 2.7'
19
20
 
20
21
  gem.add_dependency 'activesupport', '>= 3.2.1', '< 8'
21
22
  gem.add_dependency 'deprecation', '>= 0.99.0'
22
- gem.add_dependency 'faraday', '>= 0.9.2', '< 2.0'
23
- gem.add_dependency 'faraday_middleware'
23
+ gem.add_dependency 'faraday', '~> 2.0'
24
+ gem.add_dependency 'faraday-retry'
25
+
24
26
  gem.add_dependency 'nokogiri', '~> 1.6'
25
27
  gem.add_dependency 'zeitwerk', '~> 2.1'
26
28
 
27
29
  gem.add_development_dependency 'rake'
28
30
  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
31
+ gem.add_development_dependency 'rubocop', '~> 1.24'
32
+ gem.add_development_dependency 'rubocop-rake'
33
+ gem.add_development_dependency 'rubocop-rspec', '~> 2.1'
34
+ gem.add_development_dependency 'simplecov'
31
35
  gem.add_development_dependency 'webmock'
32
36
  gem.add_development_dependency 'yard'
37
+ gem.metadata['rubygems_mfa_required'] = 'true'
33
38
  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
@@ -21,7 +19,6 @@ module Dor
21
19
  def build_connection
22
20
  Faraday.new(url: url) do |faraday|
23
21
  faraday.use Faraday::Response::RaiseError # raise exceptions on 40x, 50x responses
24
- faraday.use FaradayMiddleware::FollowRedirects, limit: 3
25
22
  faraday.options.params_encoder = Faraday::FlatParamsEncoder
26
23
  if timeout
27
24
  faraday.options.timeout = timeout
@@ -51,17 +48,17 @@ module Dor
51
48
  attr_reader :logger, :timeout, :url
52
49
 
53
50
  def retriable_methods
54
- Faraday::Request::Retry::IDEMPOTENT_METHODS + [:post]
51
+ Faraday::Retry::Middleware::IDEMPOTENT_METHODS + [:post]
55
52
  end
56
53
 
57
54
  def retriable_exceptions
58
- Faraday::Request::Retry::DEFAULT_EXCEPTIONS + [Faraday::ConnectionFailed]
55
+ Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [Faraday::ConnectionFailed]
59
56
  end
60
57
 
61
58
  def retry_block
62
59
  lambda do |env, _opts, retries, exception|
63
60
  logger.warn "retrying connection (#{retries} remaining) to #{env.url}: (#{exception.class}) " \
64
- "#{exception.message} #{env.status}"
61
+ "#{exception.message} #{env.status}"
65
62
  end
66
63
  end
67
64
 
@@ -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
@@ -143,9 +143,9 @@ module Dor
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
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Workflow
5
5
  class Client
6
- VERSION = '3.24.0'
6
+ VERSION = '4.0.0'
7
7
  end
8
8
  end
9
9
  end
@@ -23,7 +23,7 @@ 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
 
@@ -313,8 +313,8 @@ module Dor
313
313
  # @return [String]
314
314
  def create_process_xml(params)
315
315
  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
316
+ attrs = params.compact
317
+ attrs = attrs.transform_keys { |k| k.to_s.camelize(:lower) } # camelize all the keys in the attrs hash
318
318
  xml.process(attrs)
319
319
  end
320
320
  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
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.24.0
4
+ version: 4.0.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-12-16 00:00:00.000000000 Z
12
+ date: 2022-03-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -49,24 +49,18 @@ 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
  - - ">="
@@ -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
@@ -240,8 +262,9 @@ files:
240
262
  - spec/workflow/client_spec.rb
241
263
  homepage: https://consul.stanford.edu/display/DOR/DOR+services#DORservices-initializeworkflow
242
264
  licenses: []
243
- metadata: {}
244
- post_install_message:
265
+ metadata:
266
+ rubygems_mfa_required: 'true'
267
+ post_install_message:
245
268
  rdoc_options: []
246
269
  require_paths:
247
270
  - lib
@@ -249,15 +272,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
249
272
  requirements:
250
273
  - - ">="
251
274
  - !ruby/object:Gem::Version
252
- version: '0'
275
+ version: '2.7'
253
276
  required_rubygems_version: !ruby/object:Gem::Requirement
254
277
  requirements:
255
278
  - - ">="
256
279
  - !ruby/object:Gem::Version
257
280
  version: '0'
258
281
  requirements: []
259
- rubygems_version: 3.1.4
260
- signing_key:
282
+ rubygems_version: 3.2.32
283
+ signing_key:
261
284
  specification_version: 4
262
285
  summary: Provides convenience methods to work with the DOR Workflow Service
263
286
  test_files: