dor-workflow-client 3.24.0 → 5.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: 660ca959342689ef767c9b7d6ce72f90ec5d568227e1acab968c7cf5b2e9bb95
4
+ data.tar.gz: e5c19e4cf9c2f79edc1cefaa0b9dbe4954866c2f29357fd58425d173662422ad
5
5
  SHA512:
6
- metadata.gz: 539d6b2915c4d5a031227f73b00065674d401be19610925e0ba4fc2954348b713ca6a093246bdc73fc321705315a94bf082cde53b10cf1196ec75611027c4da0
7
- data.tar.gz: 2be1999274099fa74ee6ba3c69303421af076866ef1a8aba673ef7a1b5b09c4a19306af0f43aa59af0a458aced85b0a8f567ab499f35fcb0f0b353eab7265dbf
6
+ metadata.gz: d7f985246d0238a872a26f9fcab9a65f7d2795be9b7946dffa4fba5cb2557203184de1ec1e1b4a758405a397c34dc991ef74290e8d5d5d28691b69984c18ddfd
7
+ data.tar.gz: c458009469d0684198722475fbe01a1dce917272298b18494979ed63957e399ea76830f1c22036ae0e21b46fb7ac31481b1e37e5f715916ee217648cb62526cc
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@3.1.2
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,122 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dor-workflow-client (5.0.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.1)
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.4.0)
32
+ faraday-net_http (~> 2.0)
33
+ ruby2_keywords (>= 0.0.4)
34
+ faraday-net_http (2.1.0)
35
+ faraday-retry (1.0.3)
36
+ hashdiff (1.0.1)
37
+ i18n (1.12.0)
38
+ concurrent-ruby (~> 1.0)
39
+ json (2.6.2)
40
+ mini_portile2 (2.8.0)
41
+ minitest (5.16.2)
42
+ nokogiri (1.13.8)
43
+ mini_portile2 (~> 2.8.0)
44
+ racc (~> 1.4)
45
+ parallel (1.22.1)
46
+ parser (3.1.2.0)
47
+ ast (~> 2.4.1)
48
+ public_suffix (4.0.7)
49
+ racc (1.6.0)
50
+ rainbow (3.1.1)
51
+ rake (13.0.6)
52
+ regexp_parser (2.5.0)
53
+ rexml (3.2.5)
54
+ rspec (3.11.0)
55
+ rspec-core (~> 3.11.0)
56
+ rspec-expectations (~> 3.11.0)
57
+ rspec-mocks (~> 3.11.0)
58
+ rspec-core (3.11.0)
59
+ rspec-support (~> 3.11.0)
60
+ rspec-expectations (3.11.0)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.11.0)
63
+ rspec-mocks (3.11.1)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.11.0)
66
+ rspec-support (3.11.0)
67
+ rspec_junit_formatter (0.5.1)
68
+ rspec-core (>= 2, < 4, != 2.12.0)
69
+ rubocop (1.32.0)
70
+ json (~> 2.3)
71
+ parallel (~> 1.10)
72
+ parser (>= 3.1.0.0)
73
+ rainbow (>= 2.2.2, < 4.0)
74
+ regexp_parser (>= 1.8, < 3.0)
75
+ rexml (>= 3.2.5, < 4.0)
76
+ rubocop-ast (>= 1.19.1, < 2.0)
77
+ ruby-progressbar (~> 1.7)
78
+ unicode-display_width (>= 1.4.0, < 3.0)
79
+ rubocop-ast (1.19.1)
80
+ parser (>= 3.1.1.0)
81
+ rubocop-rake (0.6.0)
82
+ rubocop (~> 1.0)
83
+ rubocop-rspec (2.12.1)
84
+ rubocop (~> 1.31)
85
+ ruby-progressbar (1.11.0)
86
+ ruby2_keywords (0.0.5)
87
+ simplecov (0.21.2)
88
+ docile (~> 1.1)
89
+ simplecov-html (~> 0.11)
90
+ simplecov_json_formatter (~> 0.1)
91
+ simplecov-html (0.12.3)
92
+ simplecov_json_formatter (0.1.4)
93
+ tzinfo (2.0.5)
94
+ concurrent-ruby (~> 1.0)
95
+ unicode-display_width (2.2.0)
96
+ webmock (3.14.0)
97
+ addressable (>= 2.8.0)
98
+ crack (>= 0.3.2)
99
+ hashdiff (>= 0.4.0, < 2.0.0)
100
+ webrick (1.7.0)
101
+ yard (0.9.28)
102
+ webrick (~> 1.7.0)
103
+ zeitwerk (2.6.0)
104
+
105
+ PLATFORMS
106
+ ruby
107
+
108
+ DEPENDENCIES
109
+ byebug
110
+ dor-workflow-client!
111
+ rake
112
+ rspec (~> 3.3)
113
+ rspec_junit_formatter
114
+ rubocop (~> 1.24)
115
+ rubocop-rake
116
+ rubocop-rspec (~> 2.1)
117
+ simplecov
118
+ webmock
119
+ yard
120
+
121
+ BUNDLED WITH
122
+ 2.3.17
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
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
 
@@ -14,39 +14,12 @@ module Dor
14
14
  # @param [String] repo The repository the object resides in. This parameter is deprecated
15
15
  # @param [String] druid object id
16
16
  # @param [String] milestone_name the name of the milestone being queried for
17
- # @param [Number] version the version to query for
17
+ # @param [Number] version (nil) the version to query for
18
18
  # @param [Boolean] active_only (false) if true, return only lifecycle steps for versions that have all processes complete
19
19
  # @return [Time] when the milestone was achieved. Returns nil if the milestone does not exist
20
- #
21
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
22
- def lifecycle(*args)
23
- case args.size
24
- when 4
25
- Deprecation.warn(self, 'you provided 4 args, but lifecycle now takes kwargs')
26
- (repo, druid, milestone_name) = args[0..2]
27
- version = args[3][:version]
28
- active_only = args[3][:active_only] || false
29
- when 3
30
- Deprecation.warn(self, 'you provided 3 args, but lifecycle now takes kwargs')
31
- (repo, druid, milestone_name) = args
32
- version = nil
33
- active_only = false
34
- when 1
35
- opts = args.first
36
- repo = opts[:repo]
37
- druid = opts[:druid]
38
- milestone_name = opts[:milestone_name]
39
- version = opts[:version]
40
- active_only = opts[:active_only] || false
41
- else
42
- raise ArgumentError, 'wrong number of arguments, must be 1, or 3-5'
43
- end
44
-
45
- Deprecation.warn(self, 'passing the repo parameter to lifecycle is no longer necessary. This will raise an error in dor-workflow-client version 4') if repo
46
-
20
+ def lifecycle(druid:, milestone_name:, version: nil, active_only: false)
47
21
  filter_milestone(query_lifecycle(druid, version: version, active_only: active_only), milestone_name)
48
22
  end
49
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
50
23
 
51
24
  # Returns the Date for a requested milestone ONLY for the current version.
52
25
  # This is slow as the workflow server will query dor-services-app for the version.
@@ -55,57 +28,17 @@ module Dor
55
28
  # @param [String] milestone_name the name of the milestone being queried for
56
29
  # @param [Number] version the version to query for
57
30
  # @return [Time] when the milestone was achieved. Returns nil if the milestone does not exis
58
- #
59
- # rubocop:disable Metrics/MethodLength
60
- def active_lifecycle(*args)
61
- case args.size
62
- when 4
63
- Deprecation.warn(self, 'you provided 4 args, but active_lifecycle now takes kwargs')
64
- (repo, druid, milestone_name) = args[0..2]
65
- version = args[3][:version]
66
- when 3
67
- Deprecation.warn(self, 'you provided 3 args, but active_lifecycle now takes kwargs')
68
- (repo, druid, milestone_name) = args
69
- version = nil
70
- when 1
71
- opts = args.first
72
- repo = opts[:repo]
73
- druid = opts[:druid]
74
- milestone_name = opts[:milestone_name]
75
- version = opts[:version]
76
- else
77
- raise ArgumentError, 'wrong number of arguments, must be 1, 3, or 4'
78
- end
79
-
80
- Deprecation.warn(self, 'passing the repo parameter to active_lifecycle is no longer necessary. This will raise an error in dor-workflow-client version 4') if repo
81
-
31
+ def active_lifecycle(druid:, milestone_name:, version:)
82
32
  lifecycle(druid: druid, milestone_name: milestone_name, version: version, active_only: true)
83
33
  end
84
- # rubocop:enable Metrics/MethodLength
85
34
 
86
35
  # @return [Array<Hash>]
87
- # rubocop:disable Metrics/MethodLength
88
- def milestones(*args)
89
- case args.size
90
- when 2
91
- Deprecation.warn(self, 'you provided 2 args, but active_lifecycle now takes kwargs')
92
- (repo, druid) = args
93
- when 1
94
- opts = args.first
95
- repo = opts[:repo]
96
- druid = opts.fetch(:druid)
97
- else
98
- raise ArgumentError, 'wrong number of arguments, must be 1-2'
99
- end
100
-
101
- Deprecation.warn(self, 'passing the repo parameter to active_lifecycle is no longer necessary. This will raise an error in dor-workflow-client version 4') if repo
102
-
36
+ def milestones(druid:)
103
37
  doc = query_lifecycle(druid, active_only: false)
104
38
  doc.xpath('//lifecycle/milestone').collect do |node|
105
39
  { milestone: node.text, at: Time.parse(node['date']), version: node['version'] }
106
40
  end
107
41
  end
108
- # rubocop:enable Metrics/MethodLength
109
42
 
110
43
  private
111
44