sdr-client 0.66.0 → 0.68.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: 37e3a32139e72d8eb278fb0039c959971faad4d88534acfc941169170cdc8e87
4
- data.tar.gz: d9fc1fa3ffd7355744f4b455a4b7dc5d7b8569e0081b81f94ca3aa66a99c6a61
3
+ metadata.gz: 56d9c570c19831deea82ad5c2591705f30a92a92ed93b2c8183a029613cffb35
4
+ data.tar.gz: 603460d6cd1fa94a3a8acac42ae5da6162bd3e64234b0a1927ee39075552d828
5
5
  SHA512:
6
- metadata.gz: a0a1e0e97ad35ef638116a7e6f209ee4649718b2d0c315989ed9bc1eb1144a9ec7d351f3f895afeeb573085f3c089460b4b2dc833f77fc469b2b09dbb05cadde
7
- data.tar.gz: 212ea2fcdc6fec50ae48a6776f1b827d4790796a73445a0c3c354e843fd6248f90f56df61f79c00fd34e4ea439288b3c0dc26756ba26db28c854cc7def511bc2
6
+ metadata.gz: 4ab960d543b9f21c76233ee0bddfeb0be18a0161a38f2ee87c02b3d52fd525617807767d3e1fa497edcab1400bf370a458fd262b7f2612b02ff45187a7df926a
7
+ data.tar.gz: b71e409b03e83ece3241ff20613d2e1c5f44be0d406248d932ede20bea8c6b4e6d192c49a4e45e6c7d1f6ad890a560bba426964412f52ed022108e1f75b2d42e
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config --auto-gen-only-exclude`
3
- # on 2022-01-14 01:45:54 UTC using RuboCop version 1.24.1.
3
+ # on 2022-02-15 02:08:38 UTC using RuboCop version 1.25.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
@@ -18,6 +18,14 @@ Lint/NoReturnInBeginEndBlocks:
18
18
  Exclude:
19
19
  - 'lib/sdr_client/deposit/model_process.rb'
20
20
 
21
+ # Offense count: 2
22
+ # Cop supports --auto-correct.
23
+ # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
24
+ Lint/UnusedMethodArgument:
25
+ Exclude:
26
+ - 'lib/sdr_client/deposit/file_type_file_set_strategy.rb'
27
+ - 'lib/sdr_client/deposit/image_file_set_strategy.rb'
28
+
21
29
  # Offense count: 10
22
30
  # Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, IgnoredMethods.
23
31
  Metrics/MethodLength:
@@ -52,16 +60,17 @@ RSpec/MessageSpies:
52
60
  Exclude:
53
61
  - 'spec/sdr_client/deposit_spec.rb'
54
62
 
55
- # Offense count: 9
63
+ # Offense count: 10
56
64
  # Configuration parameters: Max.
57
65
  RSpec/MultipleExpectations:
58
66
  Exclude:
59
67
  - 'spec/sdr_client/connection_spec.rb'
68
+ - 'spec/sdr_client/deposit/metadata_builder_spec.rb'
60
69
  - 'spec/sdr_client/deposit_spec.rb'
61
70
  - 'spec/sdr_client/login_spec.rb'
62
71
  - 'spec/sdr_client/model_deposit_spec.rb'
63
72
 
64
- # Offense count: 21
73
+ # Offense count: 22
65
74
  # Configuration parameters: AllowSubject, Max.
66
75
  RSpec/MultipleMemoizedHelpers:
67
76
  Exclude:
@@ -81,10 +90,11 @@ RSpec/NamedSubject:
81
90
  - 'spec/sdr_client/deposit/process_spec.rb'
82
91
  - 'spec/sdr_client/login_spec.rb'
83
92
 
84
- # Offense count: 11
93
+ # Offense count: 12
85
94
  # Configuration parameters: Max.
86
95
  RSpec/NestedGroups:
87
96
  Exclude:
97
+ - 'spec/sdr_client/deposit/metadata_builder_spec.rb'
88
98
  - 'spec/sdr_client/deposit/model_process_spec.rb'
89
99
  - 'spec/sdr_client/deposit/process_spec.rb'
90
100
  - 'spec/sdr_client/login_spec.rb'
@@ -97,14 +107,14 @@ Style/KeywordParametersOrder:
97
107
  - 'lib/sdr_client/deposit/request.rb'
98
108
 
99
109
  # Offense count: 2
100
- # Cop supports --auto-correct.
110
+ # Cop supports --auto-correct-all.
101
111
  # Configuration parameters: Mode.
102
112
  Style/StringConcatenation:
103
113
  Exclude:
104
114
  - 'lib/sdr_client/deposit/create_resource.rb'
105
115
  - 'spec/sdr_client/deposit_spec.rb'
106
116
 
107
- # Offense count: 19
117
+ # Offense count: 16
108
118
  # Cop supports --auto-correct.
109
119
  # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
110
120
  # URISchemes: http, https
@@ -8,8 +8,10 @@ module SdrClient
8
8
  # @param [Array] uploads
9
9
  # @param [Hash<String,Hash<String,String>>] uploads_metadata the file level metadata
10
10
  # @param [Array] files
11
- def initialize(label:, uploads: [], uploads_metadata: {}, files: [])
11
+ # @param [Class] type_strategy (FileTypeFileSetStrategy) a class that helps us determine how to type the fileset
12
+ def initialize(label:, uploads: [], uploads_metadata: {}, files: [], type_strategy: FileTypeFileSetStrategy)
12
13
  @label = label
14
+ @type_strategy = type_strategy
13
15
  @files = if uploads.empty?
14
16
  files
15
17
  else
@@ -21,7 +23,7 @@ module SdrClient
21
23
 
22
24
  def as_json
23
25
  {
24
- type: 'http://cocina.sul.stanford.edu/models/resources/file.jsonld',
26
+ type: type_strategy.run(files: files),
25
27
  label: label,
26
28
  structural: {
27
29
  contains: files.map(&:as_json)
@@ -32,7 +34,7 @@ module SdrClient
32
34
 
33
35
  private
34
36
 
35
- attr_reader :files, :label
37
+ attr_reader :files, :label, :type_strategy
36
38
 
37
39
  # This creates the metadata for each file and symbolizes the keys
38
40
  # @return [Hash<Symbol,String>]
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrClient
4
+ module Deposit
5
+ # This strategy is for building the type of a fileset
6
+ class FileTypeFileSetStrategy
7
+ # @param [Array<SdrClient::Deposit::Files>] files the files that are part of this strategy
8
+ # @return [String] The URI that represents the type of file_set
9
+ def self.run(files: [])
10
+ Cocina::Models::Vocab::Resources.file
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrClient
4
+ module Deposit
5
+ # This strategy is for building the type of a fileset
6
+ class ImageFileSetStrategy
7
+ # @param [Array<SdrClient::Deposit::Files>] files the files that are part of this strategy
8
+ # @return [String] The URI that represents the type of file_set
9
+ def self.run(files: [])
10
+ Cocina::Models::Vocab::Resources.image
11
+ end
12
+ end
13
+ end
14
+ end
@@ -10,10 +10,12 @@ module SdrClient
10
10
  # @param [Class] grouping_strategy class whose run method groups an array of uploads
11
11
  # Additional metadata includes access, preserve, shelve, publish, md5, sha1
12
12
  # @param [Logger] logger the logger to use
13
- def initialize(metadata:, grouping_strategy:, logger:)
13
+ # @param [Class] file_set_type_strategy class whose run method determines file_set type
14
+ def initialize(metadata:, grouping_strategy:, logger:, file_set_type_strategy: FileTypeFileSetStrategy)
14
15
  @metadata = metadata
15
16
  @logger = logger
16
17
  @grouping_strategy = grouping_strategy
18
+ @file_set_type_strategy = file_set_type_strategy
17
19
  end
18
20
 
19
21
  # @param [UploadFiles] upload_responses the uploaded file information
@@ -34,7 +36,8 @@ module SdrClient
34
36
  grouped_uploads.map.with_index(1) do |upload_group, i|
35
37
  FileSet.new(uploads: upload_group,
36
38
  uploads_metadata: metadata_group(upload_group),
37
- label: label(i))
39
+ label: label(i),
40
+ type_strategy: @file_set_type_strategy)
38
41
  end
39
42
  end
40
43
 
@@ -10,6 +10,7 @@ module SdrClient
10
10
  # @param [String] connection the server connection to use
11
11
  # @param [Boolean] accession should the accessionWF be started
12
12
  # @param [Class] grouping_strategy class whose run method groups an array of uploads
13
+ # @param [Class] file_set_type_strategy class whose run method determines file_set type
13
14
  # @param [Array<String>] files a list of file names to upload
14
15
  # @param [Boolean] assign_doi should a DOI be assigned to this item
15
16
  # @param [Logger] logger the logger to use
@@ -19,6 +20,7 @@ module SdrClient
19
20
  connection:,
20
21
  accession:,
21
22
  grouping_strategy: SingleFileGroupingStrategy,
23
+ file_set_type_strategy: FileTypeFileSetStrategy,
22
24
  files: [],
23
25
  assign_doi: false,
24
26
  logger: Logger.new($stdout))
@@ -27,6 +29,7 @@ module SdrClient
27
29
  @metadata = metadata
28
30
  @logger = logger
29
31
  @grouping_strategy = grouping_strategy
32
+ @file_set_type_strategy = file_set_type_strategy
30
33
  @accession = accession
31
34
  @assign_doi = assign_doi
32
35
  end
@@ -43,6 +46,7 @@ module SdrClient
43
46
  connection: connection)
44
47
  metadata_builder = MetadataBuilder.new(metadata: metadata,
45
48
  grouping_strategy: grouping_strategy,
49
+ file_set_type_strategy: file_set_type_strategy,
46
50
  logger: logger)
47
51
  request = metadata_builder.with_uploads(upload_responses)
48
52
  model = Cocina::Models.build_request(request.as_json.with_indifferent_access)
@@ -56,7 +60,7 @@ module SdrClient
56
60
 
57
61
  private
58
62
 
59
- attr_reader :metadata, :files, :connection, :logger, :grouping_strategy
63
+ attr_reader :metadata, :files, :connection, :logger, :grouping_strategy, :file_set_type_strategy
60
64
 
61
65
  def check_files_exist
62
66
  logger.info('checking to see if files exist')
@@ -28,6 +28,7 @@ module SdrClient
28
28
  files_metadata: {},
29
29
  accession: false,
30
30
  grouping_strategy: SingleFileGroupingStrategy,
31
+ file_set_type_strategy: FileTypeFileSetStrategy,
31
32
  logger: Logger.new($stdout))
32
33
  augmented_metadata = FileMetadataBuilder.build(files: files, files_metadata: files_metadata)
33
34
  metadata = Request.new(label: label,
@@ -48,6 +49,7 @@ module SdrClient
48
49
  connection = Connection.new(url: url)
49
50
  Process.new(metadata: metadata, connection: connection, files: files,
50
51
  grouping_strategy: grouping_strategy,
52
+ file_set_type_strategy: file_set_type_strategy,
51
53
  accession: accession,
52
54
  logger: logger).run
53
55
  end
@@ -73,6 +75,8 @@ require 'json'
73
75
  require 'sdr_client/deposit/create_resource'
74
76
  require 'sdr_client/deposit/single_file_grouping_strategy'
75
77
  require 'sdr_client/deposit/matching_file_grouping_strategy'
78
+ require 'sdr_client/deposit/file_type_file_set_strategy'
79
+ require 'sdr_client/deposit/image_file_set_strategy'
76
80
  require 'sdr_client/deposit/files/direct_upload_request'
77
81
  require 'sdr_client/deposit/files/direct_upload_response'
78
82
  require 'sdr_client/deposit/file'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SdrClient
4
- VERSION = '0.66.0'
4
+ VERSION = '0.68.0'
5
5
  end
data/sdr-client.gemspec CHANGED
@@ -28,7 +28,7 @@ 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.65.0'
31
+ spec.add_dependency 'cocina-models', '~> 0.66.0'
32
32
  spec.add_dependency 'dry-monads'
33
33
  spec.add_dependency 'faraday', '>= 0.16'
34
34
 
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.66.0
4
+ version: 0.68.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-02-08 00:00:00.000000000 Z
11
+ date: 2022-02-25 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.65.0
33
+ version: 0.66.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.65.0
40
+ version: 0.66.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dry-monads
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -214,8 +214,10 @@ files:
214
214
  - lib/sdr_client/deposit/file_metadata_builder_operations/mime_type.rb
215
215
  - lib/sdr_client/deposit/file_metadata_builder_operations/sha1.rb
216
216
  - lib/sdr_client/deposit/file_set.rb
217
+ - lib/sdr_client/deposit/file_type_file_set_strategy.rb
217
218
  - lib/sdr_client/deposit/files/direct_upload_request.rb
218
219
  - lib/sdr_client/deposit/files/direct_upload_response.rb
220
+ - lib/sdr_client/deposit/image_file_set_strategy.rb
219
221
  - lib/sdr_client/deposit/matching_file_grouping_strategy.rb
220
222
  - lib/sdr_client/deposit/metadata_builder.rb
221
223
  - lib/sdr_client/deposit/model_process.rb