sdr-client 2.13.2 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +17 -30
- data/Gemfile.lock +17 -14
- data/lib/sdr_client/cli.rb +4 -0
- data/lib/sdr_client/deposit/create_resource.rb +7 -4
- data/lib/sdr_client/deposit/file.rb +3 -1
- data/lib/sdr_client/deposit/files/direct_upload_request.rb +1 -1
- data/lib/sdr_client/deposit/request.rb +6 -1
- data/lib/sdr_client/deposit/update_resource.rb +9 -4
- data/lib/sdr_client/deposit.rb +2 -0
- data/lib/sdr_client/redesigned_client/cli.rb +4 -0
- data/lib/sdr_client/redesigned_client/create_resource.rb +5 -2
- data/lib/sdr_client/redesigned_client/direct_upload_request.rb +1 -1
- data/lib/sdr_client/redesigned_client/file.rb +6 -0
- data/lib/sdr_client/redesigned_client/request_builder.rb +7 -1
- data/lib/sdr_client/redesigned_client/update_resource.rb +8 -5
- data/lib/sdr_client/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 92a856bedc983187ec0a1721ca4ec66ee7eaa1986fa1ed795fc079bf1140c956
|
|
4
|
+
data.tar.gz: c53dd7fbff6953c2a333245b631dcc8c24d84e9d10833e2c91b92f6cb534feaa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1000308c12ebab774556315768ccc2100b19fa95d9df91fa63356cb9e2b85b4965d32c59de6b6a2f9ba7217477dad3d59102a7185db17a3da5314a9daaafc0c
|
|
7
|
+
data.tar.gz: f6cc0eb1b8d0beff8e46c54f56743ab576d6318148c4fe0bc1360eca7e995171a49fd448a7c246533ac23c816df8a60f3dfb50da51c12d73f332c62438dd41f4
|
data/.rubocop.yml
CHANGED
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 2024-
|
|
3
|
+
# on 2024-05-01 23:27:58 UTC using RuboCop version 1.63.4.
|
|
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
|
|
@@ -13,6 +13,19 @@ Gemspec/RequiredRubyVersion:
|
|
|
13
13
|
Exclude:
|
|
14
14
|
- 'sdr-client.gemspec'
|
|
15
15
|
|
|
16
|
+
# Offense count: 35
|
|
17
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
18
|
+
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
|
19
|
+
# URISchemes: http, https
|
|
20
|
+
Layout/LineLength:
|
|
21
|
+
Exclude:
|
|
22
|
+
- 'lib/sdr_client/cli.rb'
|
|
23
|
+
- 'lib/sdr_client/deposit/model_process.rb'
|
|
24
|
+
- 'lib/sdr_client/update.rb'
|
|
25
|
+
- 'spec/sdr_client/deposit/model_process_spec.rb'
|
|
26
|
+
- 'spec/sdr_client/deposit/process_spec.rb'
|
|
27
|
+
- 'spec/sdr_client/update_spec.rb'
|
|
28
|
+
|
|
16
29
|
# Offense count: 1
|
|
17
30
|
Lint/NoReturnInBeginEndBlocks:
|
|
18
31
|
Exclude:
|
|
@@ -26,11 +39,12 @@ Lint/UnusedMethodArgument:
|
|
|
26
39
|
- 'lib/sdr_client/deposit/file_type_file_set_strategy.rb'
|
|
27
40
|
- 'lib/sdr_client/deposit/image_file_set_strategy.rb'
|
|
28
41
|
|
|
29
|
-
# Offense count:
|
|
42
|
+
# Offense count: 15
|
|
30
43
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
|
31
44
|
Metrics/AbcSize:
|
|
32
45
|
Exclude:
|
|
33
46
|
- 'lib/sdr_client/cli.rb'
|
|
47
|
+
- 'lib/sdr_client/deposit/request.rb'
|
|
34
48
|
- 'lib/sdr_client/redesigned_client.rb'
|
|
35
49
|
- 'lib/sdr_client/redesigned_client/cli.rb'
|
|
36
50
|
- 'lib/sdr_client/redesigned_client/cli/update.rb'
|
|
@@ -74,20 +88,6 @@ RSpec/MessageSpies:
|
|
|
74
88
|
Exclude:
|
|
75
89
|
- 'spec/sdr_client/deposit_spec.rb'
|
|
76
90
|
|
|
77
|
-
# Offense count: 19
|
|
78
|
-
# Configuration parameters: Max.
|
|
79
|
-
RSpec/MultipleExpectations:
|
|
80
|
-
Exclude:
|
|
81
|
-
- 'spec/sdr_client/connection_spec.rb'
|
|
82
|
-
- 'spec/sdr_client/deposit/metadata_builder_spec.rb'
|
|
83
|
-
- 'spec/sdr_client/deposit_model_spec.rb'
|
|
84
|
-
- 'spec/sdr_client/deposit_spec.rb'
|
|
85
|
-
- 'spec/sdr_client/find_spec.rb'
|
|
86
|
-
- 'spec/sdr_client/login_spec.rb'
|
|
87
|
-
- 'spec/sdr_client/redesigned_client/deposit_spec.rb'
|
|
88
|
-
- 'spec/sdr_client/redesigned_client/job_status_spec.rb'
|
|
89
|
-
- 'spec/sdr_client/redesigned_client/upload_files_spec.rb'
|
|
90
|
-
|
|
91
91
|
# Offense count: 24
|
|
92
92
|
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
|
|
93
93
|
# SupportedStyles: always, named_only
|
|
@@ -117,7 +117,7 @@ RSpec/ReceiveMessages:
|
|
|
117
117
|
Exclude:
|
|
118
118
|
- 'spec/sdr_client/update_spec.rb'
|
|
119
119
|
|
|
120
|
-
# Offense count:
|
|
120
|
+
# Offense count: 23
|
|
121
121
|
# This cop supports safe autocorrection (--autocorrect).
|
|
122
122
|
Style/KeywordParametersOrder:
|
|
123
123
|
Exclude:
|
|
@@ -138,16 +138,3 @@ Style/StringConcatenation:
|
|
|
138
138
|
Exclude:
|
|
139
139
|
- 'lib/sdr_client/deposit/create_resource.rb'
|
|
140
140
|
- 'spec/sdr_client/deposit_spec.rb'
|
|
141
|
-
|
|
142
|
-
# Offense count: 35
|
|
143
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
144
|
-
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
|
145
|
-
# URISchemes: http, https
|
|
146
|
-
Layout/LineLength:
|
|
147
|
-
Exclude:
|
|
148
|
-
- 'lib/sdr_client/cli.rb'
|
|
149
|
-
- 'lib/sdr_client/deposit/model_process.rb'
|
|
150
|
-
- 'lib/sdr_client/update.rb'
|
|
151
|
-
- 'spec/sdr_client/deposit/model_process_spec.rb'
|
|
152
|
-
- 'spec/sdr_client/deposit/process_spec.rb'
|
|
153
|
-
- 'spec/sdr_client/update_spec.rb'
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
sdr-client (2.
|
|
4
|
+
sdr-client (2.14.0)
|
|
5
5
|
activesupport
|
|
6
6
|
cocina-models (~> 0.96.0)
|
|
7
7
|
config
|
|
@@ -28,7 +28,7 @@ GEM
|
|
|
28
28
|
ast (2.4.2)
|
|
29
29
|
attr_extras (7.1.0)
|
|
30
30
|
base64 (0.2.0)
|
|
31
|
-
bigdecimal (3.1.
|
|
31
|
+
bigdecimal (3.1.8)
|
|
32
32
|
byebug (11.1.3)
|
|
33
33
|
childprocess (5.0.0)
|
|
34
34
|
cocina-models (0.96.0)
|
|
@@ -94,14 +94,14 @@ GEM
|
|
|
94
94
|
faraday-net_http (3.1.0)
|
|
95
95
|
net-http
|
|
96
96
|
hashdiff (1.1.0)
|
|
97
|
-
i18n (1.14.
|
|
97
|
+
i18n (1.14.5)
|
|
98
98
|
concurrent-ruby (~> 1.0)
|
|
99
99
|
ice_nine (0.11.2)
|
|
100
100
|
json (2.7.2)
|
|
101
101
|
jsonpath (1.1.5)
|
|
102
102
|
multi_json
|
|
103
103
|
language_server-protocol (3.17.0.3)
|
|
104
|
-
launchy (3.0.
|
|
104
|
+
launchy (3.0.1)
|
|
105
105
|
addressable (~> 2.8)
|
|
106
106
|
childprocess (~> 5.0)
|
|
107
107
|
minitest (5.22.3)
|
|
@@ -109,16 +109,18 @@ GEM
|
|
|
109
109
|
mutex_m (0.2.0)
|
|
110
110
|
net-http (0.4.1)
|
|
111
111
|
uri
|
|
112
|
-
nokogiri (1.16.
|
|
112
|
+
nokogiri (1.16.5-arm64-darwin)
|
|
113
113
|
racc (~> 1.4)
|
|
114
|
-
nokogiri (1.16.
|
|
114
|
+
nokogiri (1.16.5-x86_64-darwin)
|
|
115
|
+
racc (~> 1.4)
|
|
116
|
+
nokogiri (1.16.5-x86_64-linux)
|
|
115
117
|
racc (~> 1.4)
|
|
116
118
|
openapi3_parser (0.9.2)
|
|
117
119
|
commonmarker (~> 0.17)
|
|
118
120
|
openapi_parser (1.0.0)
|
|
119
121
|
optimist (3.1.0)
|
|
120
122
|
parallel (1.24.0)
|
|
121
|
-
parser (3.3.0
|
|
123
|
+
parser (3.3.1.0)
|
|
122
124
|
ast (~> 2.4.1)
|
|
123
125
|
racc
|
|
124
126
|
patience_diff (1.2.0)
|
|
@@ -127,7 +129,7 @@ GEM
|
|
|
127
129
|
racc (1.7.3)
|
|
128
130
|
rainbow (3.1.1)
|
|
129
131
|
rake (13.2.1)
|
|
130
|
-
regexp_parser (2.9.
|
|
132
|
+
regexp_parser (2.9.1)
|
|
131
133
|
rexml (3.2.6)
|
|
132
134
|
rspec (3.13.0)
|
|
133
135
|
rspec-core (~> 3.13.0)
|
|
@@ -138,7 +140,7 @@ GEM
|
|
|
138
140
|
rspec-expectations (3.13.0)
|
|
139
141
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
140
142
|
rspec-support (~> 3.13.0)
|
|
141
|
-
rspec-mocks (3.13.
|
|
143
|
+
rspec-mocks (3.13.1)
|
|
142
144
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
143
145
|
rspec-support (~> 3.13.0)
|
|
144
146
|
rspec-support (3.13.1)
|
|
@@ -146,7 +148,7 @@ GEM
|
|
|
146
148
|
rspec-core (>= 2, < 4, != 2.12.0)
|
|
147
149
|
rss (0.3.0)
|
|
148
150
|
rexml
|
|
149
|
-
rubocop (1.63.
|
|
151
|
+
rubocop (1.63.5)
|
|
150
152
|
json (~> 2.3)
|
|
151
153
|
language_server-protocol (>= 3.17.0)
|
|
152
154
|
parallel (~> 1.10)
|
|
@@ -157,15 +159,15 @@ GEM
|
|
|
157
159
|
rubocop-ast (>= 1.31.1, < 2.0)
|
|
158
160
|
ruby-progressbar (~> 1.7)
|
|
159
161
|
unicode-display_width (>= 2.4.0, < 3.0)
|
|
160
|
-
rubocop-ast (1.31.
|
|
161
|
-
parser (>= 3.3.0
|
|
162
|
+
rubocop-ast (1.31.3)
|
|
163
|
+
parser (>= 3.3.1.0)
|
|
162
164
|
rubocop-capybara (2.20.0)
|
|
163
165
|
rubocop (~> 1.41)
|
|
164
166
|
rubocop-factory_bot (2.25.1)
|
|
165
167
|
rubocop (~> 1.41)
|
|
166
168
|
rubocop-rake (0.6.0)
|
|
167
169
|
rubocop (~> 1.0)
|
|
168
|
-
rubocop-rspec (2.29.
|
|
170
|
+
rubocop-rspec (2.29.2)
|
|
169
171
|
rubocop (~> 1.40)
|
|
170
172
|
rubocop-capybara (~> 2.17)
|
|
171
173
|
rubocop-factory_bot (~> 2.22)
|
|
@@ -179,7 +181,7 @@ GEM
|
|
|
179
181
|
simplecov_json_formatter (~> 0.1)
|
|
180
182
|
simplecov-html (0.12.3)
|
|
181
183
|
simplecov_json_formatter (0.1.4)
|
|
182
|
-
super_diff (0.
|
|
184
|
+
super_diff (0.12.1)
|
|
183
185
|
attr_extras (>= 6.2.4)
|
|
184
186
|
diff-lcs
|
|
185
187
|
patience_diff
|
|
@@ -195,6 +197,7 @@ GEM
|
|
|
195
197
|
zeitwerk (2.6.13)
|
|
196
198
|
|
|
197
199
|
PLATFORMS
|
|
200
|
+
arm64-darwin-23
|
|
198
201
|
x86_64-darwin-19
|
|
199
202
|
x86_64-darwin-20
|
|
200
203
|
x86_64-darwin-21
|
data/lib/sdr_client/cli.rb
CHANGED
|
@@ -83,6 +83,8 @@ module SdrClient
|
|
|
83
83
|
option :use_and_reproduction, desc: 'Use and reproduction statement'
|
|
84
84
|
option :viewing_direction, enum: %w[left-to-right right-to-left], desc: 'Viewing direction (if a book)'
|
|
85
85
|
option :view, enum: %w[world stanford location-based citation-only dark], desc: 'Access view level for the object'
|
|
86
|
+
option :download, enum: %w[world stanford location-based none], desc: 'Access download level for the object'
|
|
87
|
+
option :location, enum: %w[spec music ars art hoover m&m], desc: 'Access location for the object'
|
|
86
88
|
option :files_metadata, desc: 'JSON string representing per-file metadata'
|
|
87
89
|
option :grouping_strategy, enum: %w[default filename], desc: 'Strategy for grouping files into filesets'
|
|
88
90
|
option :basepath, default: Dir.getwd, desc: 'Base path for the files'
|
|
@@ -103,6 +105,8 @@ module SdrClient
|
|
|
103
105
|
option :use_and_reproduction, desc: 'Use and reproduction statement'
|
|
104
106
|
option :viewing_direction, enum: %w[left-to-right right-to-left], desc: 'Viewing direction (if a book)'
|
|
105
107
|
option :view, enum: %w[world stanford location-based citation-only dark], desc: 'Access view level for the object'
|
|
108
|
+
option :download, enum: %w[world stanford location-based none], desc: 'Access download level for the object'
|
|
109
|
+
option :location, enum: %w[spec music ars art hoover m&m], desc: 'Access location for the object'
|
|
106
110
|
option :files_metadata, desc: 'JSON string representing per-file metadata'
|
|
107
111
|
option :grouping_strategy, enum: %w[default filename], desc: 'Strategy for grouping files into filesets'
|
|
108
112
|
option :basepath, default: Dir.getwd, desc: 'Base path for the files'
|
|
@@ -5,8 +5,8 @@ module SdrClient
|
|
|
5
5
|
# Creates a resource (metadata) in SDR
|
|
6
6
|
class CreateResource
|
|
7
7
|
DRO_PATH = '/v1/resources'
|
|
8
|
-
def self.run(
|
|
9
|
-
new(
|
|
8
|
+
def self.run(...)
|
|
9
|
+
new(...).run
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
# @param [Boolean] accession should the accessionWF be started
|
|
@@ -15,14 +15,16 @@ module SdrClient
|
|
|
15
15
|
# @param [Hash<Symbol,String>] the result of the metadata call
|
|
16
16
|
# @param [String] priority what processing priority should be used
|
|
17
17
|
# either 'low' or 'default'
|
|
18
|
+
# @param [String] user_versions action (none, new, update) to take for user version when closing version
|
|
18
19
|
# rubocop:disable Metrics/ParameterLists
|
|
19
|
-
def initialize(accession:, metadata:, logger:, connection:, assign_doi: false, priority: nil)
|
|
20
|
+
def initialize(accession:, metadata:, logger:, connection:, assign_doi: false, priority: nil, user_versions: nil)
|
|
20
21
|
@accession = accession
|
|
21
22
|
@priority = priority
|
|
22
23
|
@assign_doi = assign_doi
|
|
23
24
|
@metadata = metadata
|
|
24
25
|
@logger = logger
|
|
25
26
|
@connection = connection
|
|
27
|
+
@user_versions = user_versions
|
|
26
28
|
end
|
|
27
29
|
# rubocop:enable Metrics/ParameterLists
|
|
28
30
|
|
|
@@ -39,7 +41,7 @@ module SdrClient
|
|
|
39
41
|
|
|
40
42
|
private
|
|
41
43
|
|
|
42
|
-
attr_reader :metadata, :logger, :connection, :priority
|
|
44
|
+
attr_reader :metadata, :logger, :connection, :priority, :user_versions
|
|
43
45
|
|
|
44
46
|
def metadata_request
|
|
45
47
|
json = metadata.to_json
|
|
@@ -62,6 +64,7 @@ module SdrClient
|
|
|
62
64
|
params = { accession: accession? }
|
|
63
65
|
params[:priority] = priority if priority
|
|
64
66
|
params[:assign_doi] = true if assign_doi? # false is default
|
|
67
|
+
params[:user_versions] = user_versions if user_versions.present?
|
|
65
68
|
DRO_PATH + '?' + params.map { |k, v| "#{k}=#{v}" }.join('&')
|
|
66
69
|
end
|
|
67
70
|
end
|
|
@@ -6,7 +6,7 @@ module SdrClient
|
|
|
6
6
|
class File
|
|
7
7
|
# rubocop:disable Metrics/ParameterLists
|
|
8
8
|
def initialize(external_identifier:, label:, filename:,
|
|
9
|
-
view: 'dark', download: 'none', preserve: true, shelve: true,
|
|
9
|
+
view: 'dark', download: 'none', location: nil, preserve: true, shelve: true,
|
|
10
10
|
publish: true, mime_type: nil, md5: nil, sha1: nil,
|
|
11
11
|
use: nil)
|
|
12
12
|
@external_identifier = external_identifier
|
|
@@ -14,6 +14,7 @@ module SdrClient
|
|
|
14
14
|
@filename = filename
|
|
15
15
|
@view = view
|
|
16
16
|
@download = download
|
|
17
|
+
@location = location
|
|
17
18
|
@preserve = preserve
|
|
18
19
|
@shelve = view == 'dark' ? false : shelve
|
|
19
20
|
@publish = publish
|
|
@@ -44,6 +45,7 @@ module SdrClient
|
|
|
44
45
|
}.tap do |json|
|
|
45
46
|
json['hasMimeType'] = @mime_type if @mime_type
|
|
46
47
|
json['use'] = @use if @use
|
|
48
|
+
json[:access][:location] = @location if @location
|
|
47
49
|
end
|
|
48
50
|
end
|
|
49
51
|
|
|
@@ -35,7 +35,7 @@ module SdrClient
|
|
|
35
35
|
return 'application/octet-stream' if content_type.blank?
|
|
36
36
|
|
|
37
37
|
# ActiveStorage is expecting "application/x-stata-dta" not "application/x-stata-dta;version=14"
|
|
38
|
-
content_type = content_type.split(';')
|
|
38
|
+
content_type = content_type.split(';').first
|
|
39
39
|
|
|
40
40
|
content_type == 'application/json' ? 'application/x-stanford-json' : content_type
|
|
41
41
|
end
|
|
@@ -15,6 +15,7 @@ module SdrClient
|
|
|
15
15
|
def initialize(label: nil,
|
|
16
16
|
view: 'dark',
|
|
17
17
|
download: 'none',
|
|
18
|
+
location: nil,
|
|
18
19
|
use_and_reproduction: nil,
|
|
19
20
|
copyright: nil,
|
|
20
21
|
apo:,
|
|
@@ -40,6 +41,7 @@ module SdrClient
|
|
|
40
41
|
@embargo_download = embargo_download
|
|
41
42
|
@view = view
|
|
42
43
|
@download = download
|
|
44
|
+
@location = location
|
|
43
45
|
@use_and_reproduction = use_and_reproduction
|
|
44
46
|
@copyright = copyright
|
|
45
47
|
@apo = apo
|
|
@@ -66,6 +68,7 @@ module SdrClient
|
|
|
66
68
|
Request.new(label: label,
|
|
67
69
|
view: view,
|
|
68
70
|
download: download,
|
|
71
|
+
location: location,
|
|
69
72
|
apo: apo,
|
|
70
73
|
collection: collection,
|
|
71
74
|
copyright: copyright,
|
|
@@ -88,6 +91,7 @@ module SdrClient
|
|
|
88
91
|
metadata = files_metadata.fetch(filename, {}).with_indifferent_access
|
|
89
92
|
metadata[:view] = view unless metadata.key?(:view)
|
|
90
93
|
metadata[:download] = download unless metadata.key?(:download)
|
|
94
|
+
metadata[:location] = location unless metadata.key?(:location)
|
|
91
95
|
metadata
|
|
92
96
|
end
|
|
93
97
|
|
|
@@ -97,7 +101,7 @@ module SdrClient
|
|
|
97
101
|
|
|
98
102
|
attr_reader :view, :label, :file_sets, :source_id, :catkey, :folio_instance_hrid, :apo, :collection,
|
|
99
103
|
:files_metadata, :embargo_release_date, :embargo_access, :embargo_download,
|
|
100
|
-
:viewing_direction, :use_and_reproduction, :copyright, :download
|
|
104
|
+
:viewing_direction, :use_and_reproduction, :copyright, :download, :location
|
|
101
105
|
|
|
102
106
|
def administrative
|
|
103
107
|
{
|
|
@@ -132,6 +136,7 @@ module SdrClient
|
|
|
132
136
|
}.tap do |json|
|
|
133
137
|
json[:useAndReproductionStatement] = use_and_reproduction if use_and_reproduction
|
|
134
138
|
json[:copyright] = copyright if copyright
|
|
139
|
+
json[:location] = location if location
|
|
135
140
|
|
|
136
141
|
if embargo_release_date
|
|
137
142
|
json[:embargo] = {
|
|
@@ -6,18 +6,20 @@ module SdrClient
|
|
|
6
6
|
class UpdateResource
|
|
7
7
|
DRO_PATH = '/v1/resources/%<id>s'
|
|
8
8
|
|
|
9
|
-
def self.run(
|
|
10
|
-
new(
|
|
9
|
+
def self.run(...)
|
|
10
|
+
new(...).run
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
# @param [Cocina::Models::DRO] metadata
|
|
14
14
|
# @param [Hash<Symbol,String>] the result of the metadata call
|
|
15
15
|
# @param [String] version_description
|
|
16
|
-
|
|
16
|
+
# @param [String] user_versions action (none, new, update) to take for user version when closing version
|
|
17
|
+
def initialize(metadata:, logger:, connection:, version_description: nil, user_versions: nil)
|
|
17
18
|
@metadata = metadata
|
|
18
19
|
@logger = logger
|
|
19
20
|
@connection = connection
|
|
20
21
|
@version_description = version_description
|
|
22
|
+
@user_versions = user_versions
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
# @param [Hash<Symbol,String>] the result of the metadata call
|
|
@@ -33,8 +35,9 @@ module SdrClient
|
|
|
33
35
|
|
|
34
36
|
private
|
|
35
37
|
|
|
36
|
-
attr_reader :metadata, :logger, :connection, :version_description
|
|
38
|
+
attr_reader :metadata, :logger, :connection, :version_description, :user_versions
|
|
37
39
|
|
|
40
|
+
# rubocop:disable Metrics/AbcSize
|
|
38
41
|
def metadata_request
|
|
39
42
|
json = metadata.to_json
|
|
40
43
|
logger.debug("Starting update metadata: #{json}")
|
|
@@ -43,8 +46,10 @@ module SdrClient
|
|
|
43
46
|
'Content-Type' => 'application/json',
|
|
44
47
|
'X-Cocina-Models-Version' => Cocina::Models::VERSION) do |req|
|
|
45
48
|
req.params['versionDescription'] = version_description if version_description
|
|
49
|
+
req.params['user_versions'] = user_versions if user_versions.present?
|
|
46
50
|
end
|
|
47
51
|
end
|
|
52
|
+
# rubocop:enable Metrics/AbcSize
|
|
48
53
|
|
|
49
54
|
def path(metadata)
|
|
50
55
|
format(DRO_PATH, id: metadata.externalIdentifier)
|
data/lib/sdr_client/deposit.rb
CHANGED
|
@@ -15,6 +15,7 @@ module SdrClient
|
|
|
15
15
|
viewing_direction: nil,
|
|
16
16
|
view: 'dark',
|
|
17
17
|
download: 'none',
|
|
18
|
+
location: nil,
|
|
18
19
|
use_and_reproduction: nil,
|
|
19
20
|
copyright: nil,
|
|
20
21
|
apo:,
|
|
@@ -40,6 +41,7 @@ module SdrClient
|
|
|
40
41
|
type: type,
|
|
41
42
|
view: view,
|
|
42
43
|
download: download,
|
|
44
|
+
location: location,
|
|
43
45
|
apo: apo,
|
|
44
46
|
use_and_reproduction: use_and_reproduction,
|
|
45
47
|
copyright: copyright,
|
|
@@ -102,6 +102,8 @@ module SdrClient
|
|
|
102
102
|
option :use_and_reproduction, desc: 'Use and reproduction statement'
|
|
103
103
|
option :viewing_direction, enum: %w[left-to-right right-to-left], desc: 'Viewing direction (if a book)'
|
|
104
104
|
option :view, enum: %w[world stanford location-based citation-only dark], desc: 'Access view level for the object'
|
|
105
|
+
option :download, enum: %w[world stanford location-based none], desc: 'Access download level for the object'
|
|
106
|
+
option :location, enum: %w[spec music ars art hoover m&m], desc: 'Access location for the object'
|
|
105
107
|
option :files_metadata, desc: 'JSON string representing per-file metadata'
|
|
106
108
|
option :grouping_strategy, enum: %w[default filename], desc: 'Strategy for grouping files into filesets'
|
|
107
109
|
option :basepath, default: Dir.getwd, desc: 'Base path for the files'
|
|
@@ -124,6 +126,8 @@ module SdrClient
|
|
|
124
126
|
option :use_and_reproduction, desc: 'Use and reproduction statement'
|
|
125
127
|
option :viewing_direction, enum: %w[left-to-right right-to-left], desc: 'Viewing direction (if a book)'
|
|
126
128
|
option :view, enum: %w[world stanford location-based citation-only dark], desc: 'Access view level for the object'
|
|
129
|
+
option :download, enum: %w[world stanford location-based none], desc: 'Access download level for the object'
|
|
130
|
+
option :location, enum: %w[spec music ars art hoover m&m], desc: 'Access location for the object'
|
|
127
131
|
option :files_metadata, desc: 'JSON string representing per-file metadata'
|
|
128
132
|
option :grouping_strategy, enum: %w[default filename], desc: 'Strategy for grouping files into filesets'
|
|
129
133
|
option :basepath, default: Dir.getwd, desc: 'Base path for the files'
|
|
@@ -14,11 +14,13 @@ module SdrClient
|
|
|
14
14
|
# @param [Hash<Symbol,String>] the result of the metadata call
|
|
15
15
|
# @param [String] priority what processing priority should be used
|
|
16
16
|
# either 'low' or 'default'
|
|
17
|
-
|
|
17
|
+
# @param [String] user_versions action (none, new, update) to take for user version when closing version
|
|
18
|
+
def initialize(accession:, metadata:, assign_doi: false, priority: nil, user_versions: nil)
|
|
18
19
|
@accession = accession
|
|
19
20
|
@priority = priority
|
|
20
21
|
@assign_doi = assign_doi
|
|
21
22
|
@metadata = metadata
|
|
23
|
+
@user_versions = user_versions
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
# @param [Hash<Symbol,String>] the result of the metadata call
|
|
@@ -41,7 +43,7 @@ module SdrClient
|
|
|
41
43
|
|
|
42
44
|
private
|
|
43
45
|
|
|
44
|
-
attr_reader :metadata, :priority
|
|
46
|
+
attr_reader :metadata, :priority, :user_versions
|
|
45
47
|
|
|
46
48
|
def logger
|
|
47
49
|
SdrClient::RedesignedClient.config.logger
|
|
@@ -63,6 +65,7 @@ module SdrClient
|
|
|
63
65
|
params = { accession: accession? }
|
|
64
66
|
params[:priority] = priority if priority
|
|
65
67
|
params[:assign_doi] = true if assign_doi? # false is default
|
|
68
|
+
params[:user_versions] = user_versions if user_versions.present?
|
|
66
69
|
query_string = params.map { |k, v| "#{k}=#{v}" }.join('&')
|
|
67
70
|
"/v1/resources?#{query_string}"
|
|
68
71
|
end
|
|
@@ -36,7 +36,7 @@ module SdrClient
|
|
|
36
36
|
return 'application/octet-stream' if content_type.blank?
|
|
37
37
|
|
|
38
38
|
# ActiveStorage is expecting "application/x-stata-dta" not "application/x-stata-dta;version=14"
|
|
39
|
-
content_type = content_type.split(';')
|
|
39
|
+
content_type = content_type.split(';').first
|
|
40
40
|
|
|
41
41
|
content_type == 'application/json' ? 'application/x-stanford-json' : content_type
|
|
42
42
|
end
|
|
@@ -10,6 +10,7 @@ module SdrClient
|
|
|
10
10
|
# @param [Hash] options optional parameters
|
|
11
11
|
# @option options [String] view the access level for viewing the object
|
|
12
12
|
# @option options [String] download the access level for downloading the object
|
|
13
|
+
# @option options [String] location the location for location-based access
|
|
13
14
|
# @option options [Boolean] preserve whether to preserve the file or not
|
|
14
15
|
# @option options [Boolean] shelve whether to shelve the file or not
|
|
15
16
|
# @option options [Boolean] publish whether to publish the file or not
|
|
@@ -44,6 +45,7 @@ module SdrClient
|
|
|
44
45
|
}.tap do |json|
|
|
45
46
|
json['hasMimeType'] = mime_type if mime_type
|
|
46
47
|
json['use'] = use if use
|
|
48
|
+
json[:access]['location'] if location
|
|
47
49
|
end
|
|
48
50
|
end
|
|
49
51
|
|
|
@@ -66,6 +68,10 @@ module SdrClient
|
|
|
66
68
|
options.fetch(:download, 'none')
|
|
67
69
|
end
|
|
68
70
|
|
|
71
|
+
def location
|
|
72
|
+
options[:location]
|
|
73
|
+
end
|
|
74
|
+
|
|
69
75
|
def preserve
|
|
70
76
|
options.fetch(:preserve, true)
|
|
71
77
|
end
|
|
@@ -10,6 +10,7 @@ module SdrClient
|
|
|
10
10
|
# @option options [String] label the required object label
|
|
11
11
|
# @option options [String] view the access level for viewing the object
|
|
12
12
|
# @option options [String] download the access level for downloading the object
|
|
13
|
+
# @option options [String] location the location for location-based access
|
|
13
14
|
# @option options [String] type (https://cocina.sul.stanford.edu/models/object) the required object type.
|
|
14
15
|
# @option options [String] use_and_reproduction the use and reproduction statement
|
|
15
16
|
# @option options [String] copyright the copyright statement
|
|
@@ -93,13 +94,14 @@ module SdrClient
|
|
|
93
94
|
end
|
|
94
95
|
end
|
|
95
96
|
|
|
96
|
-
def access_struct # rubocop:disable Metrics/MethodLength
|
|
97
|
+
def access_struct # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
97
98
|
{
|
|
98
99
|
view: view,
|
|
99
100
|
download: download
|
|
100
101
|
}.tap do |json|
|
|
101
102
|
json[:useAndReproductionStatement] = use_and_reproduction if use_and_reproduction
|
|
102
103
|
json[:copyright] = copyright if copyright
|
|
104
|
+
json[:location] = location if location
|
|
103
105
|
|
|
104
106
|
if embargo_release_date
|
|
105
107
|
json[:embargo] = {
|
|
@@ -119,6 +121,10 @@ module SdrClient
|
|
|
119
121
|
options.fetch(:download, 'none')
|
|
120
122
|
end
|
|
121
123
|
|
|
124
|
+
def location
|
|
125
|
+
options[:location]
|
|
126
|
+
end
|
|
127
|
+
|
|
122
128
|
def label
|
|
123
129
|
options[:label]
|
|
124
130
|
end
|
|
@@ -12,9 +12,11 @@ module SdrClient
|
|
|
12
12
|
|
|
13
13
|
# @param [Cocina::Models::DRO] model
|
|
14
14
|
# @param [String] version_description
|
|
15
|
-
|
|
15
|
+
# @param [String] user_versions action (none, new, update) to take for user version when closing version
|
|
16
|
+
def initialize(model:, version_description: nil, user_versions: nil)
|
|
16
17
|
@model = model
|
|
17
18
|
@version_description = version_description
|
|
19
|
+
@user_versions = user_versions
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
# @return [String] job id for the background job result
|
|
@@ -37,7 +39,7 @@ module SdrClient
|
|
|
37
39
|
|
|
38
40
|
private
|
|
39
41
|
|
|
40
|
-
attr_reader :model, :version_description
|
|
42
|
+
attr_reader :model, :version_description, :user_versions
|
|
41
43
|
|
|
42
44
|
def client
|
|
43
45
|
SdrClient::RedesignedClient.instance
|
|
@@ -52,9 +54,10 @@ module SdrClient
|
|
|
52
54
|
end
|
|
53
55
|
|
|
54
56
|
def request_params
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
{
|
|
58
|
+
versionDescription: version_description,
|
|
59
|
+
user_versions: user_versions
|
|
60
|
+
}.compact
|
|
58
61
|
end
|
|
59
62
|
end
|
|
60
63
|
end
|
data/lib/sdr_client/version.rb
CHANGED
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: 2.
|
|
4
|
+
version: 2.14.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: 2024-
|
|
11
|
+
date: 2024-05-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
224
224
|
- !ruby/object:Gem::Version
|
|
225
225
|
version: '0'
|
|
226
226
|
requirements: []
|
|
227
|
-
rubygems_version: 3.
|
|
227
|
+
rubygems_version: 3.4.19
|
|
228
228
|
signing_key:
|
|
229
229
|
specification_version: 4
|
|
230
230
|
summary: The CLI for https://github.com/sul-dlss/sdr-api
|