cocina-models 0.83.0 → 0.84.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/Gemfile.lock +15 -19
- data/README.md +3 -3
- data/lib/cocina/models/doi_exceptions.rb +9 -0
- data/lib/cocina/models/{doi.rb → doi_pattern.rb} +1 -1
- data/lib/cocina/models/identification.rb +1 -2
- data/lib/cocina/models/mapping/from_mods/subject.rb +2 -1
- data/lib/cocina/models/mapping/to_mods/subject.rb +12 -2
- data/lib/cocina/models/validators/date_time_validator.rb +10 -2
- data/lib/cocina/models/validators/validator.rb +2 -1
- data/lib/cocina/models/version.rb +1 -1
- data/lib/cocina/models.rb +8 -1
- data/openapi.yml +11 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 326a7390c3ec14bfbc4ec9e4e79f26528b9dfa214f38aefd0646baddfbad96d5
|
4
|
+
data.tar.gz: cce43d9334fd16e47e790a082bbc999cf969b18ab78dc3d5e7015f757f6f4ea0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1a83488b4c5a07ae64073693c0a77424ce10fbfdada5e769fca6794d75cddc5c789d04ab92e35fa80a30eae82a0f8c284753df16ddab044bcd1ad11030b22f5
|
7
|
+
data.tar.gz: 6604a503733106b82f2e0155a2632a1eb8d00881dc762b52779179a96d962fd5e5143be6ebbe2738cb5d35eac88ee95d039c7f358d2664f10f6a82f71626b058
|
data/.circleci/config.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cocina-models (0.
|
4
|
+
cocina-models (0.84.0)
|
5
5
|
activesupport
|
6
6
|
deprecation
|
7
7
|
dry-struct (~> 1.0)
|
@@ -20,7 +20,7 @@ PATH
|
|
20
20
|
GEM
|
21
21
|
remote: https://rubygems.org/
|
22
22
|
specs:
|
23
|
-
activesupport (7.0.3)
|
23
|
+
activesupport (7.0.3.1)
|
24
24
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
25
25
|
i18n (>= 1.6, < 2)
|
26
26
|
minitest (>= 5.1)
|
@@ -38,15 +38,11 @@ GEM
|
|
38
38
|
activesupport
|
39
39
|
diff-lcs (1.5.0)
|
40
40
|
docile (1.4.0)
|
41
|
-
dry-
|
41
|
+
dry-container (0.10.1)
|
42
42
|
concurrent-ruby (~> 1.0)
|
43
|
-
|
44
|
-
dry-container (0.9.0)
|
43
|
+
dry-core (0.8.1)
|
45
44
|
concurrent-ruby (~> 1.0)
|
46
|
-
|
47
|
-
dry-core (0.7.1)
|
48
|
-
concurrent-ruby (~> 1.0)
|
49
|
-
dry-inflector (0.2.1)
|
45
|
+
dry-inflector (0.3.0)
|
50
46
|
dry-logic (1.2.0)
|
51
47
|
concurrent-ruby (~> 1.0)
|
52
48
|
dry-core (~> 0.5, >= 0.5)
|
@@ -60,11 +56,11 @@ GEM
|
|
60
56
|
dry-core (~> 0.5, >= 0.5)
|
61
57
|
dry-inflector (~> 0.1, >= 0.1.2)
|
62
58
|
dry-logic (~> 1.0, >= 1.0.2)
|
63
|
-
edtf (3.0
|
59
|
+
edtf (3.1.0)
|
64
60
|
activesupport (>= 3.0, < 8.0)
|
65
61
|
equivalent-xml (0.6.0)
|
66
62
|
nokogiri (>= 1.4.3)
|
67
|
-
i18n (1.
|
63
|
+
i18n (1.12.0)
|
68
64
|
concurrent-ruby (~> 1.0)
|
69
65
|
ice_nine (0.11.2)
|
70
66
|
json (2.6.2)
|
@@ -72,9 +68,9 @@ GEM
|
|
72
68
|
jsonpath (1.1.2)
|
73
69
|
multi_json
|
74
70
|
mini_portile2 (2.8.0)
|
75
|
-
minitest (5.16.
|
71
|
+
minitest (5.16.3)
|
76
72
|
multi_json (1.15.0)
|
77
|
-
nokogiri (1.13.
|
73
|
+
nokogiri (1.13.8)
|
78
74
|
mini_portile2 (~> 2.8.0)
|
79
75
|
racc (~> 1.4)
|
80
76
|
openapi3_parser (0.9.2)
|
@@ -82,7 +78,7 @@ GEM
|
|
82
78
|
openapi_parser (0.15.0)
|
83
79
|
optimist (3.0.1)
|
84
80
|
parallel (1.22.1)
|
85
|
-
parser (3.1.2.
|
81
|
+
parser (3.1.2.1)
|
86
82
|
ast (~> 2.4.1)
|
87
83
|
patience_diff (1.2.0)
|
88
84
|
optimist (~> 3.0)
|
@@ -109,17 +105,17 @@ GEM
|
|
109
105
|
rspec-core (>= 2, < 4, != 2.12.0)
|
110
106
|
rss (0.2.9)
|
111
107
|
rexml
|
112
|
-
rubocop (1.
|
108
|
+
rubocop (1.35.1)
|
113
109
|
json (~> 2.3)
|
114
110
|
parallel (~> 1.10)
|
115
|
-
parser (>= 3.1.
|
111
|
+
parser (>= 3.1.2.1)
|
116
112
|
rainbow (>= 2.2.2, < 4.0)
|
117
113
|
regexp_parser (>= 1.8, < 3.0)
|
118
114
|
rexml (>= 3.2.5, < 4.0)
|
119
|
-
rubocop-ast (>= 1.
|
115
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
120
116
|
ruby-progressbar (~> 1.7)
|
121
117
|
unicode-display_width (>= 1.4.0, < 3.0)
|
122
|
-
rubocop-ast (1.
|
118
|
+
rubocop-ast (1.21.0)
|
123
119
|
parser (>= 3.1.1.0)
|
124
120
|
rubocop-rake (0.6.0)
|
125
121
|
rubocop (~> 1.0)
|
@@ -137,7 +133,7 @@ GEM
|
|
137
133
|
diff-lcs
|
138
134
|
patience_diff
|
139
135
|
thor (1.2.1)
|
140
|
-
tzinfo (2.0.
|
136
|
+
tzinfo (2.0.5)
|
141
137
|
concurrent-ruby (~> 1.0)
|
142
138
|
unicode-display_width (2.2.0)
|
143
139
|
zeitwerk (2.6.0)
|
data/README.md
CHANGED
@@ -51,10 +51,10 @@ Beyond what is necessary to test the generator, the Cocina model classes are not
|
|
51
51
|
|
52
52
|
## Testing validation changes
|
53
53
|
|
54
|
-
If there is a possibility that a model or validation change will conflict with some existing objects then [validate-cocina](https://github.com/sul-dlss/dor-services-app/blob/main/bin/validate-cocina) should be used for testing. This must be run on sdr-
|
54
|
+
If there is a possibility that a model or validation change will conflict with some existing objects then [validate-cocina](https://github.com/sul-dlss/dor-services-app/blob/main/bin/validate-cocina) should be used for testing. This must be run on sdr-infra since it requires deploying a branch of cocina-models.
|
55
55
|
|
56
|
-
1. Create a cocina-models branch containing the proposed change and push to
|
57
|
-
2. On sdr-
|
56
|
+
1. Create a cocina-models branch containing the proposed change and push to GitHub.
|
57
|
+
2. On sdr-infra, check out `main`, update the `Gemfile` so that cocina-models references the branch, and `bundle install`.
|
58
58
|
3. Select the appropriate database.
|
59
59
|
For QA:
|
60
60
|
```
|
@@ -7,8 +7,7 @@ module Cocina
|
|
7
7
|
attribute? :barcode, Types::Nominal::Any
|
8
8
|
attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).default([].freeze)
|
9
9
|
# Digital Object Identifier (https://www.doi.org)
|
10
|
-
|
11
|
-
attribute? :doi, Types::Strict::String
|
10
|
+
attribute? :doi, Types::Nominal::Any
|
12
11
|
# Unique identifier in some other system. This is because a large proportion of what is deposited in SDR, historically and currently, are representations of objects that are also represented in other systems. For example, digitized paper and A/V collections have physical manifestations, and those physical objects are managed in systems that have their own identifiers. Similarly, books have barcodes, archival materials have collection numbers and physical locations, etc. The sourceId allows determining if an item has been deposited before and where to look for the original item if you're looking at its SDR representation. The format is: "namespace:identifier"
|
13
12
|
|
14
13
|
# example: sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026
|
@@ -339,7 +339,8 @@ module Cocina
|
|
339
339
|
end
|
340
340
|
notes = name_notes_for(full_name[:role], node)
|
341
341
|
name_attrs[:note] = notes unless notes.empty?
|
342
|
-
name_attrs
|
342
|
+
name_attrs[:identifier] = full_name[:identifier]
|
343
|
+
name_attrs.compact.merge(attrs)
|
343
344
|
end
|
344
345
|
|
345
346
|
def name_notes_for(roles, name_node)
|
@@ -230,8 +230,11 @@ module Cocina
|
|
230
230
|
# Write nodes within MODS subject
|
231
231
|
def write_topic(subject, subject_value, is_parallel: false, type: nil, subject_values_have_same_authority: true)
|
232
232
|
type ||= subject_value.type
|
233
|
-
topic_attributes = topic_attributes_for(subject,
|
234
|
-
|
233
|
+
topic_attributes = topic_attributes_for(subject,
|
234
|
+
subject_value,
|
235
|
+
type,
|
236
|
+
is_parallel: is_parallel,
|
237
|
+
subject_values_have_same_authority: subject_values_have_same_authority)
|
235
238
|
case type
|
236
239
|
when 'person'
|
237
240
|
xml.name topic_attributes.merge(type: 'personal') do
|
@@ -395,6 +398,7 @@ module Cocina
|
|
395
398
|
write_name_part(subject_value)
|
396
399
|
write_display_form(display_values)
|
397
400
|
write_roles(subject_value.note)
|
401
|
+
write_identifier(subject.identifier)
|
398
402
|
write_other_notes(subject.note, 'description')
|
399
403
|
write_other_notes(subject.note, 'affiliation')
|
400
404
|
end
|
@@ -427,6 +431,12 @@ module Cocina
|
|
427
431
|
end.each { |role| RoleWriter.write(xml: xml, role: role) }
|
428
432
|
end
|
429
433
|
|
434
|
+
def write_identifier(identifiers)
|
435
|
+
identifiers.each do |identifier|
|
436
|
+
xml.nameIdentifier identifier.value, type: identifier.source.code
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
430
440
|
def write_other_notes(notes, type)
|
431
441
|
Array(notes).filter { |note| note.type == type }.each { |note| xml.public_send(type, note.value) }
|
432
442
|
end
|
@@ -68,7 +68,15 @@ module Cocina
|
|
68
68
|
Date.edtf!(value)
|
69
69
|
true
|
70
70
|
rescue StandardError
|
71
|
-
|
71
|
+
# NOTE: the upstream EDTF implementation in the `edtf` gem does not
|
72
|
+
# allow a valid pattern that we use (possibly because only level
|
73
|
+
# 0 of the spec was implemented?):
|
74
|
+
#
|
75
|
+
# * Y-20555
|
76
|
+
#
|
77
|
+
# So we catch the false positives from the upstream gem and allow
|
78
|
+
# this pattern to validate
|
79
|
+
/\AY-?\d{5,}\Z/.match?(value)
|
72
80
|
end
|
73
81
|
|
74
82
|
def valid_iso8601?(value)
|
@@ -90,7 +98,7 @@ module Cocina
|
|
90
98
|
#
|
91
99
|
# So we catch the false positives from the upstream gem and allow
|
92
100
|
# these two patterns to validate
|
93
|
-
/\A\d{4}(-0[1-9]
|
101
|
+
/\A\d{4}(-0[1-9]|-1[0-2])?\Z/.match?(value)
|
94
102
|
end
|
95
103
|
|
96
104
|
def druid
|
data/lib/cocina/models.rb
CHANGED
@@ -40,7 +40,7 @@ loader = Zeitwerk::Loader.new
|
|
40
40
|
loader.inflector = CocinaModelsInflector.new
|
41
41
|
loader.push_dir(File.absolute_path("#{__FILE__}/../.."))
|
42
42
|
loader.ignore("#{__dir__}/rspec.rb")
|
43
|
-
loader.ignore("#{__dir__}/rspec
|
43
|
+
loader.ignore("#{__dir__}/rspec")
|
44
44
|
loader.setup
|
45
45
|
|
46
46
|
module Cocina
|
@@ -153,5 +153,12 @@ module Cocina
|
|
153
153
|
raise ValidationError, 'Type field not found'
|
154
154
|
end
|
155
155
|
private_class_method :type_for
|
156
|
+
|
157
|
+
def self.druid_regex
|
158
|
+
@druid_regex ||= begin
|
159
|
+
str = Openapi3Parser.load_file('openapi.yml').components.schemas['Druid'].pattern
|
160
|
+
Regexp.new(str)
|
161
|
+
end
|
162
|
+
end
|
156
163
|
end
|
157
164
|
end
|
data/openapi.yml
CHANGED
@@ -896,8 +896,18 @@ components:
|
|
896
896
|
# description: An alphabet or other notation used to represent a
|
897
897
|
# language or other symbolic system of the descriptive element value.
|
898
898
|
DOI:
|
899
|
-
type: string
|
900
899
|
description: Digital Object Identifier (https://www.doi.org)
|
900
|
+
oneOf:
|
901
|
+
- $ref: '#/components/schemas/DoiPattern'
|
902
|
+
- $ref: '#/components/schemas/DoiExceptions'
|
903
|
+
DoiExceptions:
|
904
|
+
type: string
|
905
|
+
description: pre-existing Digital Object Identifiers (https://www.doi.org) not matching the pattern (case insensitive)
|
906
|
+
pattern: '^10\.(25740\/([vV][aA]90-[cC][tT]15|[sS][yY][xX][aA]-[mM]256|12[qQ][fF]-5243|65[jJ]8-6114)|25936\/629[tT]-[bB][xX]79)$'
|
907
|
+
example: '10.25740/12qF-5243'
|
908
|
+
DoiPattern:
|
909
|
+
type: string
|
910
|
+
description: Digital Object Identifier (https://www.doi.org) regex pattern
|
901
911
|
# The prod and test prefixes are permitted
|
902
912
|
pattern: '^10\.(25740|80343)\/[b-df-hjkmnp-tv-z]{2}[0-9]{3}[b-df-hjkmnp-tv-z]{2}[0-9]{4}$'
|
903
913
|
example: '10.25740/bc123df4567'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocina-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.84.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-
|
11
|
+
date: 2022-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -398,7 +398,8 @@ files:
|
|
398
398
|
- lib/cocina/models/descriptive_structured_value.rb
|
399
399
|
- lib/cocina/models/descriptive_value.rb
|
400
400
|
- lib/cocina/models/descriptive_value_language.rb
|
401
|
-
- lib/cocina/models/
|
401
|
+
- lib/cocina/models/doi_exceptions.rb
|
402
|
+
- lib/cocina/models/doi_pattern.rb
|
402
403
|
- lib/cocina/models/dro.rb
|
403
404
|
- lib/cocina/models/dro_access.rb
|
404
405
|
- lib/cocina/models/dro_structural.rb
|
@@ -537,7 +538,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
537
538
|
- !ruby/object:Gem::Version
|
538
539
|
version: '0'
|
539
540
|
requirements: []
|
540
|
-
rubygems_version: 3.
|
541
|
+
rubygems_version: 3.2.32
|
541
542
|
signing_key:
|
542
543
|
specification_version: 4
|
543
544
|
summary: Data models for the SDR
|