datacite 0.8.4 → 0.8.5
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/Gemfile +1 -1
- data/Gemfile.lock +41 -21
- data/README.md +10 -0
- data/bin/validate-cocina +35 -0
- data/lib/datacite/mapping/from_cocina/types.rb +23 -16
- data/lib/datacite/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 00f41bdc53e8f7aaa02f9f09e1dfe88edf480c12227f76fd8119b1ec261db326
|
|
4
|
+
data.tar.gz: f99aa687067a3b5ed223916e1a10b52e14c2ccce291f79369db3308646034865
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 59c3b1b903a6b0288816db41213e6c0201863b8f94acf411e8851edd9717f14c1f4f3e54dd7ddfceeec762f113ff77d203b74971bee596ad22a916162dc0c49c
|
|
7
|
+
data.tar.gz: ffa85b5ecf4d3042f98b3565ae4105ce08ef1c065fc622e5f38392cccd7e7548773344fa46d9ae4202f399ff848289420b04c79b4810ea949aa870de71d249ce
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
datacite (0.8.
|
|
4
|
+
datacite (0.8.5)
|
|
5
5
|
activesupport
|
|
6
6
|
dry-monads (~> 1.3)
|
|
7
7
|
faraday (~> 2.0)
|
|
@@ -11,7 +11,7 @@ PATH
|
|
|
11
11
|
GEM
|
|
12
12
|
remote: https://rubygems.org/
|
|
13
13
|
specs:
|
|
14
|
-
activesupport (8.1.3)
|
|
14
|
+
activesupport (8.1.3.1)
|
|
15
15
|
base64
|
|
16
16
|
bigdecimal
|
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
@@ -30,9 +30,7 @@ GEM
|
|
|
30
30
|
attr_extras (7.1.0)
|
|
31
31
|
base64 (0.3.0)
|
|
32
32
|
bigdecimal (4.1.2)
|
|
33
|
-
|
|
34
|
-
reline (>= 0.6.0)
|
|
35
|
-
cocina-models (0.132.0)
|
|
33
|
+
cocina-models (0.133.0)
|
|
36
34
|
activesupport
|
|
37
35
|
cocina_display
|
|
38
36
|
deprecation
|
|
@@ -46,7 +44,7 @@ GEM
|
|
|
46
44
|
super_diff
|
|
47
45
|
thor
|
|
48
46
|
zeitwerk (~> 2.1)
|
|
49
|
-
cocina_display (2.
|
|
47
|
+
cocina_display (2.10.0)
|
|
50
48
|
activesupport (>= 7)
|
|
51
49
|
edtf (~> 3.2)
|
|
52
50
|
geo_coord (~> 0.2)
|
|
@@ -59,6 +57,9 @@ GEM
|
|
|
59
57
|
crack (1.0.1)
|
|
60
58
|
bigdecimal
|
|
61
59
|
rexml
|
|
60
|
+
debug (1.11.1)
|
|
61
|
+
irb (~> 1.10)
|
|
62
|
+
reline (>= 0.3.8)
|
|
62
63
|
deprecation (1.1.0)
|
|
63
64
|
activesupport
|
|
64
65
|
diff-lcs (1.6.2)
|
|
@@ -93,6 +94,7 @@ GEM
|
|
|
93
94
|
activesupport (>= 3.0, < 9.0)
|
|
94
95
|
equivalent-xml (0.6.0)
|
|
95
96
|
nokogiri (>= 1.4.3)
|
|
97
|
+
erb (6.0.7)
|
|
96
98
|
faraday (2.14.3)
|
|
97
99
|
faraday-net_http (>= 2.0, < 3.5)
|
|
98
100
|
json
|
|
@@ -105,29 +107,34 @@ GEM
|
|
|
105
107
|
i18n (1.15.2)
|
|
106
108
|
concurrent-ruby (~> 1.0)
|
|
107
109
|
ice_nine (0.11.2)
|
|
108
|
-
io-console (0.
|
|
110
|
+
io-console (0.9.2)
|
|
111
|
+
irb (1.18.0)
|
|
112
|
+
pp (>= 0.6.0)
|
|
113
|
+
prism (>= 1.3.0)
|
|
114
|
+
rdoc (>= 4.0.0)
|
|
115
|
+
reline (>= 0.4.2)
|
|
109
116
|
iso8601 (0.13.0)
|
|
110
|
-
janeway-jsonpath (1.
|
|
111
|
-
json (2.21.
|
|
117
|
+
janeway-jsonpath (1.1.0)
|
|
118
|
+
json (2.21.2)
|
|
112
119
|
json_schemer (2.5.0)
|
|
113
120
|
bigdecimal
|
|
114
121
|
hana (~> 1.3)
|
|
115
122
|
regexp_parser (~> 2.0)
|
|
116
123
|
simpleidn (~> 0.2)
|
|
117
|
-
jsonschema_rs (0.49.
|
|
124
|
+
jsonschema_rs (0.49.9)
|
|
118
125
|
bigdecimal (>= 3.1, < 5)
|
|
119
126
|
rb_sys (~> 0.9.124)
|
|
120
|
-
jsonschema_rs (0.49.
|
|
127
|
+
jsonschema_rs (0.49.9-aarch64-linux)
|
|
121
128
|
bigdecimal (>= 3.1, < 5)
|
|
122
|
-
jsonschema_rs (0.49.
|
|
129
|
+
jsonschema_rs (0.49.9-aarch64-linux-musl)
|
|
123
130
|
bigdecimal (>= 3.1, < 5)
|
|
124
|
-
jsonschema_rs (0.49.
|
|
131
|
+
jsonschema_rs (0.49.9-arm64-darwin)
|
|
125
132
|
bigdecimal (>= 3.1, < 5)
|
|
126
|
-
jsonschema_rs (0.49.
|
|
133
|
+
jsonschema_rs (0.49.9-x86_64-darwin)
|
|
127
134
|
bigdecimal (>= 3.1, < 5)
|
|
128
|
-
jsonschema_rs (0.49.
|
|
135
|
+
jsonschema_rs (0.49.9-x86_64-linux)
|
|
129
136
|
bigdecimal (>= 3.1, < 5)
|
|
130
|
-
jsonschema_rs (0.49.
|
|
137
|
+
jsonschema_rs (0.49.9-x86_64-linux-musl)
|
|
131
138
|
bigdecimal (>= 3.1, < 5)
|
|
132
139
|
language_server-protocol (3.17.0.6)
|
|
133
140
|
lint_roller (1.1.0)
|
|
@@ -160,6 +167,9 @@ GEM
|
|
|
160
167
|
racc
|
|
161
168
|
patience_diff (1.2.0)
|
|
162
169
|
optimist (~> 3.0)
|
|
170
|
+
pp (0.6.4)
|
|
171
|
+
prettyprint
|
|
172
|
+
prettyprint (0.2.0)
|
|
163
173
|
prism (1.9.0)
|
|
164
174
|
public_suffix (7.0.5)
|
|
165
175
|
racc (1.8.1)
|
|
@@ -168,8 +178,17 @@ GEM
|
|
|
168
178
|
rake-compiler-dock (1.12.0)
|
|
169
179
|
rb_sys (0.9.128)
|
|
170
180
|
rake-compiler-dock (= 1.12.0)
|
|
181
|
+
rbs (4.1.3)
|
|
182
|
+
logger
|
|
183
|
+
prism (>= 1.6.0)
|
|
184
|
+
tsort
|
|
185
|
+
rdoc (8.0.0)
|
|
186
|
+
erb
|
|
187
|
+
prism (>= 1.6.0)
|
|
188
|
+
rbs (>= 4.0.0)
|
|
189
|
+
tsort
|
|
171
190
|
regexp_parser (2.12.0)
|
|
172
|
-
reline (0.
|
|
191
|
+
reline (0.7.0)
|
|
173
192
|
io-console (~> 0.5)
|
|
174
193
|
rexml (3.4.4)
|
|
175
194
|
rspec (3.13.2)
|
|
@@ -185,7 +204,7 @@ GEM
|
|
|
185
204
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
186
205
|
rspec-support (~> 3.13.0)
|
|
187
206
|
rspec-support (3.13.7)
|
|
188
|
-
rubocop (1.
|
|
207
|
+
rubocop (1.89.0)
|
|
189
208
|
json (~> 2.3)
|
|
190
209
|
language_server-protocol (~> 3.17.0.2)
|
|
191
210
|
lint_roller (~> 1.1.0)
|
|
@@ -215,6 +234,7 @@ GEM
|
|
|
215
234
|
diff-lcs (~> 1.5)
|
|
216
235
|
patience_diff (~> 1.2)
|
|
217
236
|
thor (1.5.0)
|
|
237
|
+
tsort (0.2.0)
|
|
218
238
|
tzinfo (2.0.6)
|
|
219
239
|
concurrent-ruby (~> 1.0)
|
|
220
240
|
unicode-display_width (3.2.0)
|
|
@@ -225,7 +245,7 @@ GEM
|
|
|
225
245
|
addressable (>= 2.8.0)
|
|
226
246
|
crack (>= 0.3.2)
|
|
227
247
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
228
|
-
zeitwerk (2.8.
|
|
248
|
+
zeitwerk (2.8.3)
|
|
229
249
|
|
|
230
250
|
PLATFORMS
|
|
231
251
|
aarch64-linux-gnu
|
|
@@ -239,9 +259,9 @@ PLATFORMS
|
|
|
239
259
|
|
|
240
260
|
DEPENDENCIES
|
|
241
261
|
base64
|
|
242
|
-
byebug
|
|
243
262
|
cocina-models
|
|
244
263
|
datacite!
|
|
264
|
+
debug
|
|
245
265
|
rake (~> 13.0)
|
|
246
266
|
rspec (~> 3.0)
|
|
247
267
|
rubocop (~> 1.7)
|
|
@@ -251,4 +271,4 @@ DEPENDENCIES
|
|
|
251
271
|
webmock (~> 3.13)
|
|
252
272
|
|
|
253
273
|
BUNDLED WITH
|
|
254
|
-
4.0.
|
|
274
|
+
4.0.18
|
data/README.md
CHANGED
|
@@ -117,6 +117,16 @@ validator = Datacite::Validators::AttributesValidator.new(attributes: datacite_a
|
|
|
117
117
|
puts validator.errors.join(', ') unless validator.valid?
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
+
## Validating cocina locally
|
|
121
|
+
|
|
122
|
+
With cocina json saved from arge (append `.json` to an argo view URL and save the content locally) then run:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
bin/validate-cocina path/to/file.json
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
This will result in either a `Valid!` message or an `Invalid!` message with a list of validation errors.
|
|
129
|
+
|
|
120
130
|
## Development
|
|
121
131
|
|
|
122
132
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/bin/validate-cocina
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# This is used to validate if a cocina object will produce
|
|
5
|
+
# a valid datacite payload
|
|
6
|
+
# usage: bin/validate-cocina tmp/druid.json
|
|
7
|
+
|
|
8
|
+
require 'bundler/setup'
|
|
9
|
+
require 'datacite'
|
|
10
|
+
require 'cocina/models'
|
|
11
|
+
require 'json'
|
|
12
|
+
|
|
13
|
+
if ARGV.empty?
|
|
14
|
+
warn "Usage: #{$PROGRAM_NAME} <path-to-cocina-json>"
|
|
15
|
+
exit 1
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
json_path = ARGV[0]
|
|
19
|
+
|
|
20
|
+
unless File.exist?(json_path)
|
|
21
|
+
warn "File not found: #{json_path}"
|
|
22
|
+
exit 1
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
json = JSON.parse(File.read(json_path))
|
|
26
|
+
cocina_object = Cocina::Models::DROWithMetadata.new(json)
|
|
27
|
+
validator = Datacite::Validators::CocinaValidator.new(cocina_object: cocina_object)
|
|
28
|
+
|
|
29
|
+
if validator.valid?
|
|
30
|
+
puts 'Valid!'
|
|
31
|
+
else
|
|
32
|
+
puts 'Invalid:'
|
|
33
|
+
validator.errors.each { |error| puts " - #{error}" }
|
|
34
|
+
exit 1
|
|
35
|
+
end
|
|
@@ -39,26 +39,33 @@ module Datacite
|
|
|
39
39
|
end&.value
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
# @return [String] DataCite resourceType value
|
|
42
|
+
# @return [String, nil] DataCite resourceType value
|
|
43
43
|
def resource_type
|
|
44
|
-
@resource_type ||=
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
@resource_type ||= resource_type_from_subtypes || resource_type_from_type
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def resource_type_from_subtypes
|
|
48
|
+
subtypes = self_deposit_subtypes(self_deposit_form)
|
|
49
|
+
return if subtypes.blank?
|
|
50
|
+
|
|
51
|
+
subtypes.reject { |subtype| subtype == resource_type_general }.join('; ')
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def resource_type_from_type
|
|
55
|
+
self_deposit_type(self_deposit_form) || self_deposit_form&.value
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self_deposit_form
|
|
59
|
+
@self_deposit_form ||= Array(description.form).find { |cocina_form| self_deposit_form?(cocina_form) }
|
|
54
60
|
end
|
|
55
61
|
|
|
56
|
-
#
|
|
57
|
-
#
|
|
62
|
+
# @param cocina_self_deposit_form [Cocina::Models::DescriptiveValue, nil] cocina form element for
|
|
63
|
+
# Stanford self deposit resource types
|
|
64
|
+
# @return [String, nil] the value from the structuredValue when the type is 'type'
|
|
58
65
|
def self_deposit_type(cocina_self_deposit_form)
|
|
59
|
-
cocina_self_deposit_form&.structuredValue&.
|
|
60
|
-
|
|
61
|
-
end
|
|
66
|
+
cocina_self_deposit_form&.structuredValue&.find do |struct_val|
|
|
67
|
+
struct_val.type == 'type'
|
|
68
|
+
end&.value
|
|
62
69
|
end
|
|
63
70
|
|
|
64
71
|
def self_deposit_subtypes(cocina_self_deposit_form)
|
data/lib/datacite/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: datacite
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Coyne
|
|
@@ -98,6 +98,7 @@ files:
|
|
|
98
98
|
- Rakefile
|
|
99
99
|
- bin/console
|
|
100
100
|
- bin/setup
|
|
101
|
+
- bin/validate-cocina
|
|
101
102
|
- datacite.gemspec
|
|
102
103
|
- lib/datacite.rb
|
|
103
104
|
- lib/datacite/autogenerate_doi_request_body.rb
|