cocina-models 0.98.1 → 0.99.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 +11 -11
- data/README.md +1 -1
- data/lib/cocina/models/mapping/from_mods/event.rb +2 -4
- data/lib/cocina/models/validators/reserved_filename_validator.rb +60 -0
- data/lib/cocina/models/validators/validator.rb +2 -1
- data/lib/cocina/models/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 763a8aa5a80317a106b9c038a61886460e88b6e8e160304f9250b0e5a56bdf1b
|
4
|
+
data.tar.gz: 5c73044a3a7859474e45edce5575445d6fcd2f23f362dafac3b2f417dd8ac5ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 584c7fe2ff82aee2afd09ca4873664c8d315410a02fa7f6248bc2e6b59fdf5d8eda869737c2788e910fc294c869e908762afc1467d730f0a938f120f519bc787
|
7
|
+
data.tar.gz: 9efc6b6dfe0141c1de7915e70299ba7ac6586364094dcb5b0c69643486cef911d38725eb89dfa0e38abba10410b15e609449344f19e5c425b1b789faa191e5e3
|
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.99.0)
|
5
5
|
activesupport
|
6
6
|
deprecation
|
7
7
|
dry-struct (~> 1.0)
|
@@ -46,12 +46,12 @@ GEM
|
|
46
46
|
deprecation (1.1.0)
|
47
47
|
activesupport
|
48
48
|
diff-lcs (1.5.1)
|
49
|
-
docile (1.4.
|
49
|
+
docile (1.4.1)
|
50
50
|
drb (2.2.1)
|
51
51
|
dry-core (1.0.1)
|
52
52
|
concurrent-ruby (~> 1.0)
|
53
53
|
zeitwerk (~> 2.6)
|
54
|
-
dry-inflector (1.
|
54
|
+
dry-inflector (1.1.0)
|
55
55
|
dry-logic (1.5.0)
|
56
56
|
concurrent-ruby (~> 1.0)
|
57
57
|
dry-core (~> 1.0, < 2)
|
@@ -81,10 +81,10 @@ GEM
|
|
81
81
|
multi_json
|
82
82
|
language_server-protocol (3.17.0.3)
|
83
83
|
mini_portile2 (2.8.7)
|
84
|
-
minitest (5.24.
|
84
|
+
minitest (5.24.1)
|
85
85
|
multi_json (1.15.0)
|
86
86
|
mutex_m (0.2.0)
|
87
|
-
nokogiri (1.16.
|
87
|
+
nokogiri (1.16.7)
|
88
88
|
mini_portile2 (~> 2.8.2)
|
89
89
|
racc (~> 1.4)
|
90
90
|
openapi3_parser (0.10.0)
|
@@ -92,18 +92,18 @@ GEM
|
|
92
92
|
openapi_parser (1.0.0)
|
93
93
|
optimist (3.1.0)
|
94
94
|
parallel (1.25.1)
|
95
|
-
parser (3.3.
|
95
|
+
parser (3.3.4.0)
|
96
96
|
ast (~> 2.4.1)
|
97
97
|
racc
|
98
98
|
patience_diff (1.2.0)
|
99
99
|
optimist (~> 3.0)
|
100
100
|
racc (1.8.0)
|
101
|
-
rack (3.1.
|
101
|
+
rack (3.1.7)
|
102
102
|
rainbow (3.1.1)
|
103
103
|
rake (13.2.1)
|
104
|
-
rb_sys (0.9.
|
104
|
+
rb_sys (0.9.99)
|
105
105
|
regexp_parser (2.9.2)
|
106
|
-
rexml (3.3.
|
106
|
+
rexml (3.3.2)
|
107
107
|
strscan
|
108
108
|
rspec (3.13.0)
|
109
109
|
rspec-core (~> 3.13.0)
|
@@ -120,13 +120,13 @@ GEM
|
|
120
120
|
rspec-support (3.13.1)
|
121
121
|
rspec_junit_formatter (0.6.0)
|
122
122
|
rspec-core (>= 2, < 4, != 2.12.0)
|
123
|
-
rubocop (1.
|
123
|
+
rubocop (1.65.0)
|
124
124
|
json (~> 2.3)
|
125
125
|
language_server-protocol (>= 3.17.0)
|
126
126
|
parallel (~> 1.10)
|
127
127
|
parser (>= 3.3.0.2)
|
128
128
|
rainbow (>= 2.2.2, < 4.0)
|
129
|
-
regexp_parser (>=
|
129
|
+
regexp_parser (>= 2.4, < 3.0)
|
130
130
|
rexml (>= 3.2.5, < 4.0)
|
131
131
|
rubocop-ast (>= 1.31.1, < 2.0)
|
132
132
|
ruby-progressbar (~> 1.7)
|
data/README.md
CHANGED
@@ -140,7 +140,7 @@ Send a note to `#dlss-infra-chg-mgmt` on Slack to let people know what is changi
|
|
140
140
|
|
141
141
|
### Step 1: Cut the release
|
142
142
|
|
143
|
-
The release process is much like any other gem. First bump the version in `lib/cocina/models/version.rb`,
|
143
|
+
The release process is much like any other gem. First bump the version in `lib/cocina/models/version.rb`, then `bundle install` so that `Gemfile.lock` is updated, then commit and push those changes. Then run:
|
144
144
|
```
|
145
145
|
bundle exec rake release
|
146
146
|
```
|
@@ -421,7 +421,6 @@ module Cocina
|
|
421
421
|
cocina_desc_val
|
422
422
|
end
|
423
423
|
|
424
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
425
424
|
def build_structured_date(date_nodes)
|
426
425
|
return if date_nodes.blank?
|
427
426
|
|
@@ -432,13 +431,12 @@ module Cocina
|
|
432
431
|
next if node.text.blank? && node.attributes.empty?
|
433
432
|
|
434
433
|
new_node = node.deep_dup
|
435
|
-
new_node.remove_attribute('encoding') if common_attribs[:encoding].present? || node[:encoding]&.
|
436
|
-
new_node.remove_attribute('qualifier') if common_attribs[:qualifier].present? || node[:qualifier]&.
|
434
|
+
new_node.remove_attribute('encoding') if common_attribs[:encoding].present? || node[:encoding]&.empty?
|
435
|
+
new_node.remove_attribute('qualifier') if common_attribs[:qualifier].present? || node[:qualifier]&.empty?
|
437
436
|
build_date(new_node)
|
438
437
|
end
|
439
438
|
{ structuredValue: dates }.merge(common_attribs).compact
|
440
439
|
end
|
441
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
442
440
|
|
443
441
|
# Per Arcadia, keyDate should only appear once in an originInfo.
|
444
442
|
# If keyDate is on a date of type point and is on both the start and end points, then
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cocina
|
4
|
+
module Models
|
5
|
+
module Validators
|
6
|
+
# Validates that bare external identifier not used as a root filename or directory.
|
7
|
+
# This is necessary due to the bare druid being used as part of the Stacks file layout.
|
8
|
+
class ReservedFilenameValidator
|
9
|
+
def self.validate(clazz, attributes)
|
10
|
+
new(clazz, attributes).validate
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(clazz, attributes)
|
14
|
+
@clazz = clazz
|
15
|
+
@attributes = attributes
|
16
|
+
end
|
17
|
+
|
18
|
+
def validate
|
19
|
+
return unless dro?
|
20
|
+
|
21
|
+
return if filenames.none? { |filename| reserved?(filename) }
|
22
|
+
|
23
|
+
raise ValidationError, 'Bare druid may not be used as a filename or a base directory'
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :clazz, :attributes
|
29
|
+
|
30
|
+
def dro?
|
31
|
+
(clazz::TYPES & DRO::TYPES).any? && attributes[:externalIdentifier].present?
|
32
|
+
rescue NameError
|
33
|
+
false
|
34
|
+
end
|
35
|
+
|
36
|
+
def reserved?(filename)
|
37
|
+
filename == bare_external_identifier || filename.start_with?("#{bare_external_identifier}/")
|
38
|
+
end
|
39
|
+
|
40
|
+
def bare_external_identifier
|
41
|
+
@bare_external_identifier ||= attributes[:externalIdentifier].delete_prefix('druid:')
|
42
|
+
end
|
43
|
+
|
44
|
+
def filenames
|
45
|
+
[].tap do |filenames|
|
46
|
+
next if attributes.dig(:structural, :contains).nil?
|
47
|
+
|
48
|
+
attributes[:structural][:contains].each do |fileset|
|
49
|
+
next if fileset.dig(:structural, :contains).nil?
|
50
|
+
|
51
|
+
fileset[:structural][:contains].each do |file|
|
52
|
+
filenames << file[:filename] if file[:filename].present?
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
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.99.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-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -521,6 +521,7 @@ files:
|
|
521
521
|
- lib/cocina/models/validators/language_tag_validator.rb
|
522
522
|
- lib/cocina/models/validators/open_api_validator.rb
|
523
523
|
- lib/cocina/models/validators/purl_validator.rb
|
524
|
+
- lib/cocina/models/validators/reserved_filename_validator.rb
|
524
525
|
- lib/cocina/models/validators/validator.rb
|
525
526
|
- lib/cocina/models/validators/w3cdtf_validator.rb
|
526
527
|
- lib/cocina/models/version.rb
|