sdr-client 0.63.0 → 0.64.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: 78ea65d3c9a57d94b5c1e0ec9570d8d46de57b6b96a241075bad23fe2d5f6951
4
- data.tar.gz: 19f5e7b0f327b74654f6affd1aa2d1af63c3638574aa8b7c2aecd66d9596e5db
3
+ metadata.gz: b3c30726b9a149f69e8dc920594be85f01bdd574119012ddc42ce3a83c168ca8
4
+ data.tar.gz: 729fed0fdde2452ea5efd1fa5e9dd56ecec4d83afffdea42c64c53cbce1c3602
5
5
  SHA512:
6
- metadata.gz: 57d3cfa7e333339a774fdba3085cbf7323d6d9fca9804f74382198cbaac9d2210de654345baddfccdfc6b412a9ab619c8c800217da30e849b551912cacd25269
7
- data.tar.gz: d04753f61d433a8c5f80317e1a8e7ebda1c70f1b361096d07fdc934950819316918165e5f466b53724a29a062cdb48882f4263d0d42b066cca20a0aa47b8949f
6
+ metadata.gz: a5720ec320e602a76d9a2aa3a5a5e3a61ebf3927943d8af4d7480bc0026e9f6b5092923174f2c9ed0d187be07b66691e8853682d44b5117f4af3eb1cd29fb9e1
7
+ data.tar.gz: 490fdd129716005a4216e319f9920ad2431e660224db51821d7409914807b3672f261d8bde33e18f25f4f68a7dea99cda661da69f43ab11392de5178b68cfc94
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: cimg/ruby:3.0
7
- environment:
8
- CC_TEST_REPORTER_ID: 859fcfe88b00c026d15dce30e838e2299face8088b49fe62bc3a02d1507ce3d5
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,7 +1,11 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
+ require:
4
+ - rubocop-rake
5
+ - rubocop-rspec
6
+
3
7
  AllCops:
4
- TargetRubyVersion: 2.6
8
+ TargetRubyVersion: 3.0
5
9
  Exclude:
6
10
  - 'bin/console'
7
11
  - 'vendor/**/*'
@@ -9,8 +13,8 @@ AllCops:
9
13
  Metrics/BlockLength:
10
14
  Exclude:
11
15
  - 'spec/**/*'
12
- - 'sdr-client.gemspec'
13
- ExcludedMethods:
16
+ - 'sdr-client.gemspec'
17
+ IgnoredMethods:
14
18
  - 'OptionParser.new'
15
19
 
16
20
  Metrics/ClassLength:
@@ -20,3 +24,116 @@ Metrics/ClassLength:
20
24
  Naming/FileName:
21
25
  Exclude:
22
26
  - 'lib/sdr-client.rb'
27
+
28
+ Gemspec/DateAssignment: # new in 1.10
29
+ Enabled: true
30
+ Gemspec/RequireMFA: # new in 1.23
31
+ Enabled: true
32
+ Layout/LineEndStringConcatenationIndentation: # new in 1.18
33
+ Enabled: true
34
+ Layout/SpaceBeforeBrackets: # new in 1.7
35
+ Enabled: true
36
+ Lint/AmbiguousAssignment: # new in 1.7
37
+ Enabled: true
38
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
39
+ Enabled: true
40
+ Lint/AmbiguousRange: # new in 1.19
41
+ Enabled: true
42
+ Lint/DeprecatedConstants: # new in 1.8
43
+ Enabled: true
44
+ Lint/DuplicateBranch: # new in 1.3
45
+ Enabled: true
46
+ Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
47
+ Enabled: true
48
+ Lint/EmptyBlock: # new in 1.1
49
+ Enabled: true
50
+ Lint/EmptyClass: # new in 1.3
51
+ Enabled: true
52
+ Lint/EmptyInPattern: # new in 1.16
53
+ Enabled: true
54
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
55
+ Enabled: true
56
+ Lint/LambdaWithoutLiteralBlock: # new in 1.8
57
+ Enabled: true
58
+ Lint/NoReturnInBeginEndBlocks: # new in 1.2
59
+ Enabled: true
60
+ Lint/NumberedParameterAssignment: # new in 1.9
61
+ Enabled: true
62
+ Lint/OrAssignmentToConstant: # new in 1.9
63
+ Enabled: true
64
+ Lint/RedundantDirGlobSort: # new in 1.8
65
+ Enabled: true
66
+ Lint/RequireRelativeSelfPath: # new in 1.22
67
+ Enabled: true
68
+ Lint/SymbolConversion: # new in 1.9
69
+ Enabled: true
70
+ Lint/ToEnumArguments: # new in 1.1
71
+ Enabled: true
72
+ Lint/TripleQuotes: # new in 1.9
73
+ Enabled: true
74
+ Lint/UnexpectedBlockArity: # new in 1.5
75
+ Enabled: true
76
+ Lint/UnmodifiedReduceAccumulator: # new in 1.1
77
+ Enabled: true
78
+ Lint/UselessRuby2Keywords: # new in 1.23
79
+ Enabled: true
80
+ Naming/BlockForwarding: # new in 1.24
81
+ Enabled: true
82
+ Security/IoMethods: # new in 1.22
83
+ Enabled: true
84
+ Style/ArgumentsForwarding: # new in 1.1
85
+ Enabled: true
86
+ Style/CollectionCompact: # new in 1.2
87
+ Enabled: true
88
+ Style/DocumentDynamicEvalDefinition: # new in 1.1
89
+ Enabled: true
90
+ Style/EndlessMethod: # new in 1.8
91
+ Enabled: true
92
+ Style/FileRead: # new in 1.24
93
+ Enabled: true
94
+ Style/FileWrite: # new in 1.24
95
+ Enabled: true
96
+ Style/HashConversion: # new in 1.10
97
+ Enabled: true
98
+ Style/HashExcept: # new in 1.7
99
+ Enabled: true
100
+ Style/IfWithBooleanLiteralBranches: # new in 1.9
101
+ Enabled: true
102
+ Style/InPatternThen: # new in 1.16
103
+ Enabled: true
104
+ Style/MapToHash: # new in 1.24
105
+ Enabled: true
106
+ Style/MultilineInPatternThen: # new in 1.16
107
+ Enabled: true
108
+ Style/NegatedIfElseCondition: # new in 1.2
109
+ Enabled: true
110
+ Style/NilLambda: # new in 1.3
111
+ Enabled: true
112
+ Style/NumberedParameters: # new in 1.22
113
+ Enabled: true
114
+ Style/NumberedParametersLimit: # new in 1.22
115
+ Enabled: true
116
+ Style/OpenStructUse: # new in 1.23
117
+ Enabled: true
118
+ Style/QuotedSymbols: # new in 1.16
119
+ Enabled: true
120
+ Style/RedundantArgument: # new in 1.4
121
+ Enabled: true
122
+ Style/RedundantSelfAssignmentBranch: # new in 1.19
123
+ Enabled: true
124
+ Style/SelectByRegexp: # new in 1.22
125
+ Enabled: true
126
+ Style/StringChars: # new in 1.12
127
+ Enabled: true
128
+ Style/SwapValues: # new in 1.1
129
+ Enabled: true
130
+ RSpec/ExcessiveDocstringSpacing: # new in 2.5
131
+ Enabled: true
132
+ RSpec/IdenticalEqualityAssertion: # new in 2.4
133
+ Enabled: true
134
+ RSpec/SubjectDeclaration: # new in 2.5
135
+ Enabled: true
136
+ RSpec/FactoryBot/SyntaxMethods: # new in 2.7
137
+ Enabled: true
138
+ RSpec/Rails/AvoidSetupHook: # new in 2.4
139
+ Enabled: true
data/.rubocop_todo.yml CHANGED
@@ -1,25 +1,25 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config --auto-gen-only-exclude`
3
- # on 2021-04-15 12:18:21 -0700 using RuboCop version 0.79.0.
3
+ # on 2022-01-14 01:45:54 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
9
  # Offense count: 1
10
- # Configuration parameters: Max.
11
- Metrics/AbcSize:
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemspec
12
+ Gemspec/RequiredRubyVersion:
12
13
  Exclude:
13
- - 'lib/sdr_client/deposit/model_process.rb'
14
+ - 'sdr-client.gemspec'
14
15
 
15
16
  # Offense count: 1
16
- # Configuration parameters: Max.
17
- Metrics/CyclomaticComplexity:
17
+ Lint/NoReturnInBeginEndBlocks:
18
18
  Exclude:
19
- - 'lib/sdr_client/cli.rb'
19
+ - 'lib/sdr_client/deposit/model_process.rb'
20
20
 
21
- # Offense count: 9
22
- # Configuration parameters: CountComments, Max, ExcludedMethods.
21
+ # Offense count: 10
22
+ # Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, IgnoredMethods.
23
23
  Metrics/MethodLength:
24
24
  Exclude:
25
25
  - 'lib/sdr_client/cli.rb'
@@ -29,9 +29,87 @@ Metrics/MethodLength:
29
29
  - 'lib/sdr_client/deposit/request.rb'
30
30
  - 'lib/sdr_client/login.rb'
31
31
 
32
- # Offense count: 231
32
+ # Offense count: 6
33
+ # Configuration parameters: Max, CountAsOne.
34
+ RSpec/ExampleLength:
35
+ Exclude:
36
+ - 'spec/sdr_client/deposit_spec.rb'
37
+ - 'spec/sdr_client/model_deposit_spec.rb'
38
+
39
+ # Offense count: 3
40
+ # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
41
+ # Include: **/*_spec*rb*, **/spec/**/*
42
+ RSpec/FilePath:
43
+ Exclude:
44
+ - 'spec/sdr_client/client_spec.rb'
45
+ - 'spec/sdr_client/deposit/find_spec.rb'
46
+ - 'spec/sdr_client/model_deposit_spec.rb'
47
+
48
+ # Offense count: 1
49
+ # Configuration parameters: EnforcedStyle.
50
+ # SupportedStyles: have_received, receive
51
+ RSpec/MessageSpies:
52
+ Exclude:
53
+ - 'spec/sdr_client/deposit_spec.rb'
54
+
55
+ # Offense count: 9
56
+ # Configuration parameters: Max.
57
+ RSpec/MultipleExpectations:
58
+ Exclude:
59
+ - 'spec/sdr_client/connection_spec.rb'
60
+ - 'spec/sdr_client/deposit_spec.rb'
61
+ - 'spec/sdr_client/login_spec.rb'
62
+ - 'spec/sdr_client/model_deposit_spec.rb'
63
+
64
+ # Offense count: 21
65
+ # Configuration parameters: AllowSubject, Max.
66
+ RSpec/MultipleMemoizedHelpers:
67
+ Exclude:
68
+ - 'spec/sdr_client/deposit/metadata_builder_spec.rb'
69
+ - 'spec/sdr_client/deposit/model_process_spec.rb'
70
+ - 'spec/sdr_client/deposit/process_spec.rb'
71
+ - 'spec/sdr_client/deposit/request_spec.rb'
72
+
73
+ # Offense count: 24
74
+ # Configuration parameters: IgnoreSharedExamples.
75
+ RSpec/NamedSubject:
76
+ Exclude:
77
+ - 'spec/sdr_client/background_job_results_spec.rb'
78
+ - 'spec/sdr_client/connection_spec.rb'
79
+ - 'spec/sdr_client/credentials_spec.rb'
80
+ - 'spec/sdr_client/deposit/model_process_spec.rb'
81
+ - 'spec/sdr_client/deposit/process_spec.rb'
82
+ - 'spec/sdr_client/login_spec.rb'
83
+
84
+ # Offense count: 11
85
+ # Configuration parameters: Max.
86
+ RSpec/NestedGroups:
87
+ Exclude:
88
+ - 'spec/sdr_client/deposit/model_process_spec.rb'
89
+ - 'spec/sdr_client/deposit/process_spec.rb'
90
+ - 'spec/sdr_client/login_spec.rb'
91
+
92
+ # Offense count: 19
93
+ # Cop supports --auto-correct.
94
+ Style/KeywordParametersOrder:
95
+ Exclude:
96
+ - 'lib/sdr_client/deposit.rb'
97
+ - 'lib/sdr_client/deposit/request.rb'
98
+
99
+ # Offense count: 2
100
+ # Cop supports --auto-correct.
101
+ # Configuration parameters: Mode.
102
+ Style/StringConcatenation:
103
+ Exclude:
104
+ - 'lib/sdr_client/deposit/create_resource.rb'
105
+ - 'spec/sdr_client/deposit_spec.rb'
106
+
107
+ # Offense count: 19
33
108
  # Cop supports --auto-correct.
34
- # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
109
+ # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
35
110
  # URISchemes: http, https
36
111
  Layout/LineLength:
37
- Max: 132
112
+ Exclude:
113
+ - 'lib/sdr_client/deposit/model_process.rb'
114
+ - 'spec/sdr_client/deposit/model_process_spec.rb'
115
+ - 'spec/sdr_client/deposit/process_spec.rb'
data/Gemfile CHANGED
@@ -6,3 +6,4 @@ source 'https://rubygems.org'
6
6
  gemspec
7
7
 
8
8
  gem 'byebug'
9
+ gem 'rspec_junit_formatter' # For circleCI
data/exe/sdr CHANGED
@@ -30,8 +30,8 @@ deposit_options = OptionParser.new do |opts|
30
30
  end
31
31
 
32
32
  opts.on('--type TYPE', 'The object type to create. ' \
33
- 'One of: "image", "book", "document", "map", "manuscript", "media", ' \
34
- '"three_dimensional", "object", "collection", or "admin_policy"') do |type|
33
+ 'One of: "image", "book", "document", "map", "manuscript", "media", ' \
34
+ '"three_dimensional", "object", "collection", or "admin_policy"') do |type|
35
35
  if %w[image book document map manuscript media three_dimensional object collection admin_policy].include?(type)
36
36
  options[:type] = "http://cocina.sul.stanford.edu/models/#{type}.jsonld"
37
37
  end
@@ -58,12 +58,12 @@ deposit_options = OptionParser.new do |opts|
58
58
  end
59
59
 
60
60
  opts.on('--viewing-direction DIRECTION', 'The viewing direction (if a book). ' \
61
- 'Either "left-to-right" or "right-to-left"') do |viewing_direction|
61
+ 'Either "left-to-right" or "right-to-left"') do |viewing_direction|
62
62
  options[:viewing_direction] = viewing_direction if %w[left-to-right right-to-left].include?(viewing_direction)
63
63
  end
64
64
 
65
65
  opts.on('--access LEVEL', 'The access level for this object. ' \
66
- 'Either "world", "stanford", "location-based", "citation-only" or "dark"') do |level|
66
+ 'Either "world", "stanford", "location-based", "citation-only" or "dark"') do |level|
67
67
  options[:access] = level if %w[world stanford location-based citation-only dark].include?(level)
68
68
  end
69
69
 
@@ -18,7 +18,7 @@ module SdrClient
18
18
  def self.read
19
19
  raise NoCredentialsError unless ::File.exist?(credentials_file)
20
20
 
21
- creds = IO.readlines(credentials_file, chomp: true).first if ::File.exist?(credentials_file)
21
+ creds = File.readlines(credentials_file, chomp: true).first if ::File.exist?(credentials_file)
22
22
  raise NoCredentialsError if creds.nil?
23
23
 
24
24
  creds
@@ -6,7 +6,7 @@ module SdrClient
6
6
  class CreateResource
7
7
  DRO_PATH = '/v1/resources'
8
8
 
9
- def self.run(accession:, assign_doi: false, metadata:, logger:, connection:)
9
+ def self.run(accession:, metadata:, logger:, connection:, assign_doi: false)
10
10
  new(accession: accession,
11
11
  assign_doi: assign_doi,
12
12
  metadata: metadata,
@@ -26,7 +26,7 @@ module SdrClient
26
26
 
27
27
  def as_json
28
28
  {
29
- "type": 'http://cocina.sul.stanford.edu/models/file.jsonld',
29
+ type: 'http://cocina.sul.stanford.edu/models/file.jsonld',
30
30
  label: @label,
31
31
  filename: @filename,
32
32
  externalIdentifier: @external_identifier,
@@ -58,7 +58,7 @@ module SdrClient
58
58
 
59
59
  def create_message_digest(algorithm, digest)
60
60
  {
61
- "type": algorithm,
61
+ type: algorithm,
62
62
  digest: digest
63
63
  }
64
64
  end
@@ -4,25 +4,25 @@ module SdrClient
4
4
  module Deposit
5
5
  # This represents the FileSet metadata that we send to the server for doing a deposit
6
6
  class FileSet
7
+ # @param [String] label
7
8
  # @param [Array] uploads
8
9
  # @param [Hash<String,Hash<String,String>>] uploads_metadata the file level metadata
9
10
  # @param [Array] files
10
- # @param [String] label
11
- def initialize(uploads: [], uploads_metadata: {}, files: [], label:)
11
+ def initialize(label:, uploads: [], uploads_metadata: {}, files: [])
12
12
  @label = label
13
- @files = if !uploads.empty?
13
+ @files = if uploads.empty?
14
+ files
15
+ else
14
16
  uploads.map do |upload|
15
17
  File.new(**file_args(upload, uploads_metadata.fetch(upload.filename, {})))
16
18
  end
17
- else
18
- files
19
19
  end
20
20
  end
21
21
 
22
22
  def as_json
23
23
  {
24
- "type": 'http://cocina.sul.stanford.edu/models/resources/file.jsonld',
25
- "label": label,
24
+ type: 'http://cocina.sul.stanford.edu/models/resources/file.jsonld',
25
+ label: label,
26
26
  structural: {
27
27
  contains: files.map(&:as_json)
28
28
  },
@@ -44,7 +44,7 @@ module SdrClient
44
44
  }
45
45
  args.merge!(upload_metadata)
46
46
  # Symbolize
47
- Hash[args.map { |k, v| [k.to_sym, v] }]
47
+ args.transform_keys(&:to_sym)
48
48
  end
49
49
  end
50
50
  end
@@ -8,15 +8,16 @@ module SdrClient
8
8
  class ModelProcess
9
9
  # @param [Cocina::Model::RequestDRO] request_dro for depositing
10
10
  # @param [Connection] connection the connection to use
11
- # @param [Array<String>] files a list of file names to upload
12
11
  # @param [Boolean] accession should the accessionWF be started
12
+ # @param [Array<String>] files a list of file names to upload
13
13
  # @param [Boolean] assign_doi should a DOI be assigned to this item
14
14
  # @param [Logger] logger the logger to use
15
15
  def initialize(request_dro:, # rubocop:disable Metrics/ParameterLists
16
16
  connection:,
17
- files: [], accession:,
17
+ accession:,
18
+ files: [],
18
19
  assign_doi: false,
19
- logger: Logger.new(STDOUT))
20
+ logger: Logger.new($stdout))
20
21
  @files = files
21
22
  @connection = connection
22
23
  @request_dro = request_dro
@@ -62,7 +63,7 @@ module SdrClient
62
63
 
63
64
  # Request files without files
64
65
  filenames = files.map { |filepath| ::File.basename(filepath) }
65
- request_files.keys.each do |request_filename|
66
+ request_files.each_key do |request_filename|
66
67
  raise "File not provided for request file #{request_filename}" unless filenames.include?(request_filename)
67
68
  end
68
69
  end
@@ -70,11 +71,9 @@ module SdrClient
70
71
  # Map of filenames to mimetypes
71
72
  def mime_types
72
73
  @mime_types ||=
73
- Hash[
74
- request_files.map do |filename, file|
75
- [filename, file.hasMimeType || 'application/octet-stream']
76
- end
77
- ]
74
+ request_files.transform_values do |file|
75
+ file.hasMimeType || 'application/octet-stream'
76
+ end
78
77
  end
79
78
 
80
79
  # Map of filenames to request files
@@ -82,13 +81,11 @@ module SdrClient
82
81
  @request_files ||= begin
83
82
  return {} unless request_dro.structural
84
83
 
85
- Hash[
86
- request_dro.structural.contains.map do |file_set|
87
- file_set.structural.contains.map do |file|
88
- [file.filename, file]
89
- end
90
- end.flatten(1)
91
- ]
84
+ request_dro.structural.contains.map do |file_set|
85
+ file_set.structural.contains.map do |file|
86
+ [file.filename, file]
87
+ end
88
+ end.flatten(1).to_h
92
89
  end
93
90
  end
94
91
  end
@@ -7,17 +7,21 @@ module SdrClient
7
7
  # The process for doing a deposit
8
8
  class Process
9
9
  # @param [Request] metadata information about the object
10
- # @param [Class] grouping_strategy class whose run method groups an array of uploads
11
10
  # @param [String] connection the server connection to use
11
+ # @param [Boolean] accession should the accessionWF be started
12
+ # @param [Class] grouping_strategy class whose run method groups an array of uploads
12
13
  # @param [Array<String>] files a list of file names to upload
13
14
  # @param [Boolean] assign_doi should a DOI be assigned to this item
14
- # @param [Boolean] accession should the accessionWF be started
15
15
  # @param [Logger] logger the logger to use
16
16
  #
17
17
  # rubocop:disable Metrics/ParameterLists
18
- def initialize(metadata:, grouping_strategy: SingleFileGroupingStrategy,
19
- connection:, files: [], accession:, assign_doi: false,
20
- logger: Logger.new(STDOUT))
18
+ def initialize(metadata:,
19
+ connection:,
20
+ accession:,
21
+ grouping_strategy: SingleFileGroupingStrategy,
22
+ files: [],
23
+ assign_doi: false,
24
+ logger: Logger.new($stdout))
21
25
  @files = files
22
26
  @connection = connection
23
27
  @metadata = metadata
@@ -63,12 +67,10 @@ module SdrClient
63
67
 
64
68
  def mime_types
65
69
  @mime_types ||=
66
- Hash[
67
- files.map do |filepath|
68
- filename = ::File.basename(filepath)
69
- [filename, metadata.for(filename)['mime_type']]
70
- end
71
- ]
70
+ files.to_h do |filepath|
71
+ filename = ::File.basename(filepath)
72
+ [filename, metadata.for(filename)['mime_type']]
73
+ end
72
74
  end
73
75
  end
74
76
  end
@@ -12,7 +12,6 @@ module SdrClient
12
12
  # @param [Hash<String, Hash<String, String>>] files_metadata file name, hash of additional file metadata
13
13
  # Additional metadata includes access, preserve, shelve, publish, md5, sha1
14
14
  # rubocop:disable Metrics/ParameterLists
15
- # rubocop:disable Metrics/AbcSize
16
15
  def initialize(label: nil,
17
16
  access: 'dark',
18
17
  download: 'none',
@@ -46,9 +45,8 @@ module SdrClient
46
45
  @files_metadata = files_metadata
47
46
  @viewing_direction = viewing_direction
48
47
  end
49
- # rubocop:enable Metrics/ParameterLists
50
- # rubocop:enable Metrics/AbcSize
51
48
 
49
+ # rubocop:enable Metrics/ParameterLists
52
50
  def as_json
53
51
  {
54
52
  access: access_struct,
@@ -62,7 +60,6 @@ module SdrClient
62
60
  end
63
61
 
64
62
  # @return [Request] a clone of this request with the file_sets added
65
- # rubocop:disable Metrics/AbcSize
66
63
  def with_file_sets(file_sets)
67
64
  Request.new(label: label,
68
65
  access: access,
@@ -81,7 +78,6 @@ module SdrClient
81
78
  file_sets: file_sets,
82
79
  files_metadata: files_metadata)
83
80
  end
84
- # rubocop:enable Metrics/AbcSize
85
81
 
86
82
  # @param [String] filename
87
83
  # @return [Hash] the metadata for the file
@@ -17,7 +17,7 @@ module SdrClient
17
17
  end
18
18
 
19
19
  def self.signed_id_map(upload_responses)
20
- Hash[upload_responses.map { |response| [response.filename, response.signed_id] }]
20
+ upload_responses.to_h { |response| [response.filename, response.signed_id] }
21
21
  end
22
22
  private_class_method :signed_id_map
23
23
 
@@ -35,7 +35,7 @@ module SdrClient
35
35
  attr_reader :logger, :connection, :file_metadata
36
36
 
37
37
  def upload_file_metadata
38
- Hash[file_metadata.map { |filename, metadata| [filename, direct_upload(metadata.to_json)] }]
38
+ file_metadata.transform_values { |metadata| direct_upload(metadata.to_json) }
39
39
  end
40
40
 
41
41
  # This creates a signed token that we can use to upload the file. This token has an expiration set in sdr-api,
@@ -28,7 +28,7 @@ module SdrClient
28
28
  files_metadata: {},
29
29
  accession: false,
30
30
  grouping_strategy: SingleFileGroupingStrategy,
31
- logger: Logger.new(STDOUT))
31
+ logger: Logger.new($stdout))
32
32
  augmented_metadata = FileMetadataBuilder.build(files: files, files_metadata: files_metadata)
33
33
  metadata = Request.new(label: label,
34
34
  type: type,
@@ -59,7 +59,7 @@ module SdrClient
59
59
  files: [],
60
60
  url:,
61
61
  accession:,
62
- logger: Logger.new(STDOUT))
62
+ logger: Logger.new($stdout))
63
63
  connection = Connection.new(url: url)
64
64
  ModelProcess.new(request_dro: request_dro,
65
65
  connection: connection,
@@ -7,7 +7,7 @@ module SdrClient
7
7
  module Find
8
8
  DRO_PATH = '/v1/resources/%<id>s'
9
9
  # @return [String] job id for the background job result
10
- def self.run(druid, url:, logger: Logger.new(STDOUT))
10
+ def self.run(druid, url:, logger: Logger.new($stdout))
11
11
  connection = Connection.new(url: url)
12
12
  path = format(DRO_PATH, id: druid)
13
13
  logger.info("Retrieving metadata from: #{path}")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SdrClient
4
- VERSION = '0.63.0'
4
+ VERSION = '0.64.0'
5
5
  end
data/sdr-client.gemspec CHANGED
@@ -28,15 +28,17 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ['lib']
29
29
 
30
30
  spec.add_dependency 'activesupport'
31
- spec.add_dependency 'cocina-models', '~> 0.62.0'
31
+ spec.add_dependency 'cocina-models', '~> 0.63.0'
32
32
  spec.add_dependency 'dry-monads'
33
33
  spec.add_dependency 'faraday', '>= 0.16'
34
34
 
35
35
  spec.add_development_dependency 'bundler', '~> 2.0'
36
36
  spec.add_development_dependency 'rake', '~> 13.0'
37
37
  spec.add_development_dependency 'rspec', '~> 3.0'
38
- spec.add_development_dependency 'rubocop', '~> 0.79.0'
39
- spec.add_development_dependency 'rubocop-rspec', '~> 1.37.1'
40
- spec.add_development_dependency 'simplecov', '~> 0.17.0' # CodeClimate cannot use SimpleCov >= 0.18.0 for generating test coverage
38
+ spec.add_development_dependency 'rubocop', '~> 1.24'
39
+ spec.add_development_dependency 'rubocop-rake'
40
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.1'
41
+ spec.add_development_dependency 'simplecov'
41
42
  spec.add_development_dependency 'webmock', '~> 3.7'
43
+ spec.metadata['rubygems_mfa_required'] = 'true'
42
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdr-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.63.0
4
+ version: 0.64.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-11 00:00:00.000000000 Z
11
+ date: 2022-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.62.0
33
+ version: 0.63.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.62.0
40
+ version: 0.63.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dry-monads
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -114,42 +114,56 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.79.0
117
+ version: '1.24'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.79.0
124
+ version: '1.24'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rubocop-rspec
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: 1.37.1
145
+ version: '2.1'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: 1.37.1
152
+ version: '2.1'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: simplecov
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
- - - "~>"
157
+ - - ">="
144
158
  - !ruby/object:Gem::Version
145
- version: 0.17.0
159
+ version: '0'
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
- - - "~>"
164
+ - - ">="
151
165
  - !ruby/object:Gem::Version
152
- version: 0.17.0
166
+ version: '0'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: webmock
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -224,6 +238,7 @@ metadata:
224
238
  homepage_uri: https://github.com/sul-dlss/sdr-client
225
239
  source_code_uri: https://github.com/sul-dlss/sdr-client
226
240
  changelog_uri: https://github.com/sul-dlss/sdr-client/releases
241
+ rubygems_mfa_required: 'true'
227
242
  post_install_message:
228
243
  rdoc_options: []
229
244
  require_paths:
@@ -239,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
254
  - !ruby/object:Gem::Version
240
255
  version: '0'
241
256
  requirements: []
242
- rubygems_version: 3.2.32
257
+ rubygems_version: 3.3.4
243
258
  signing_key:
244
259
  specification_version: 4
245
260
  summary: The CLI for https://github.com/sul-dlss/sdr-api