sdr-client 0.64.1 → 0.67.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +16 -6
- data/lib/sdr_client/deposit/file_set.rb +5 -3
- data/lib/sdr_client/deposit/file_type_file_set_strategy.rb +14 -0
- data/lib/sdr_client/deposit/image_file_set_strategy.rb +14 -0
- data/lib/sdr_client/deposit/metadata_builder.rb +5 -2
- data/lib/sdr_client/deposit/process.rb +5 -1
- data/lib/sdr_client/deposit.rb +4 -0
- data/lib/sdr_client/version.rb +1 -1
- data/sdr-client.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e08558986780410f688c1c5f19396dd7a55065281ec47e5e1c2f4f5a09d64618
|
4
|
+
data.tar.gz: 0a6f0a072b0543de5ba731552340d52b8bd2dcc9414be96ee69f5709aa496471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e4f1efe21eaf7938d0a6533d5de35f5a31bbd470a14120036c6991ebdaf3d17885e958861191e49c9f4548d7e61be840e2e94fd1957594515ff19af439b5f4c
|
7
|
+
data.tar.gz: 648509578100d2728172a1644ba8dcc3e60e4489cc82860fca33264d9bbb037e2f8b6699a1b351f87eb87697c330899b19190746c16c611dc05ffeb1aac8f7a4
|
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-
|
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:
|
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:
|
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:
|
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:
|
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
|
-
|
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:
|
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
|
-
|
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')
|
data/lib/sdr_client/deposit.rb
CHANGED
@@ -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'
|
data/lib/sdr_client/version.rb
CHANGED
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.
|
31
|
+
spec.add_dependency 'cocina-models', '~> 0.65.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.
|
4
|
+
version: 0.67.1
|
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-
|
11
|
+
date: 2022-02-15 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.
|
33
|
+
version: 0.65.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.
|
40
|
+
version: 0.65.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
|