cocina-models 0.98.1 → 0.99.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ddc2be2ab60d4baa71e5d36e310afb176a649aa60fea3c566650975d4ffe4a6e
4
- data.tar.gz: 6a63e80f2dc8f18e69a011c071b83ff8a268e011504cd413b3d4f341a853c5b2
3
+ metadata.gz: 86609a02da21c8f42f2244ef7f947b1eff8cc4063feef12118b2f605fe516ddd
4
+ data.tar.gz: 7c5d25fbfdab8c87f414c8ecd000e047c2387a26949c460427071e82167c3ec6
5
5
  SHA512:
6
- metadata.gz: 523922282cfcdbb335484dbb2c429561cc60250aa26dd31dbbb6c2823e95966cb5ce6cb00f4dc1c6943f1fb1d1ae1bce18e36c6ba9b0c1b9a44a87a5fa72fcff
7
- data.tar.gz: 609e78a360608dcaa8234ccb34621822c61ccec96d28e2c53e5fea4fa38add47655f5ca627627af57b9409e5f106bb17c28b3bbe9aee46a73d51ef0a3e7d4c64
6
+ metadata.gz: 54d32dd0dff4963df008172bf36f0c229e903375ad4c14f7a00fb3c892e5cc8322751baaf61ef52f14c78503af64b2ac0a8103fe39d92c849113b6d7a03d32cd
7
+ data.tar.gz: 20328dcaeeed98b9baa20966dda3c73930731627db9fd4eab242ec5894424e3973a75b7826d09c26f0f8a4c9e29536fbd76a47417f6b9bb506b1887c1168e428
data/.circleci/config.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  version: 2.1
2
2
  orbs:
3
- ruby-rails: sul-dlss/ruby-rails@4.2.1
3
+ ruby-rails: sul-dlss/ruby-rails@4.2.3
4
4
  workflows:
5
5
  build:
6
6
  jobs:
data/.rubocop.yml CHANGED
@@ -511,3 +511,24 @@ RSpec/ExpectInLet: # new in 2.30
511
511
  Enabled: true
512
512
  RSpec/UndescriptiveLiteralsDescription: # new in 2.29
513
513
  Enabled: true
514
+
515
+ Gemspec/AddRuntimeDependency: # new in 1.65
516
+ Enabled: true
517
+ Lint/DuplicateSetElement: # new in 1.67
518
+ Enabled: true
519
+ Lint/UnescapedBracketInRegexp: # new in 1.68
520
+ Enabled: true
521
+ Lint/UselessNumericOperation: # new in 1.66
522
+ Enabled: true
523
+ Style/AmbiguousEndlessMethodDefinition: # new in 1.68
524
+ Enabled: true
525
+ Style/BitwisePredicate: # new in 1.68
526
+ Enabled: true
527
+ Style/CombinableDefined: # new in 1.68
528
+ Enabled: true
529
+ Style/KeywordArgumentsMerging: # new in 1.68
530
+ Enabled: false
531
+ Style/RedundantInterpolationUnfreeze: # new in 1.66
532
+ Enabled: true
533
+ Style/SafeNavigationChainLength: # new in 1.68
534
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocina-models (0.98.1)
4
+ cocina-models (0.99.1)
5
5
  activesupport
6
6
  deprecation
7
7
  dry-struct (~> 1.0)
@@ -20,38 +20,42 @@ PATH
20
20
  GEM
21
21
  remote: https://rubygems.org/
22
22
  specs:
23
- activesupport (7.1.3.4)
23
+ activesupport (7.2.2)
24
24
  base64
25
+ benchmark (>= 0.3)
25
26
  bigdecimal
26
- concurrent-ruby (~> 1.0, >= 1.0.2)
27
+ concurrent-ruby (~> 1.0, >= 1.3.1)
27
28
  connection_pool (>= 2.2.5)
28
29
  drb
29
30
  i18n (>= 1.6, < 2)
31
+ logger (>= 1.4.2)
30
32
  minitest (>= 5.1)
31
- mutex_m
32
- tzinfo (~> 2.0)
33
+ securerandom (>= 0.3)
34
+ tzinfo (~> 2.0, >= 2.0.5)
33
35
  ast (2.4.2)
34
36
  attr_extras (7.1.0)
35
37
  base64 (0.2.0)
38
+ benchmark (0.4.0)
36
39
  bigdecimal (3.1.8)
37
40
  byebug (11.1.3)
38
41
  committee (5.0.0)
39
42
  json_schema (~> 0.14, >= 0.14.3)
40
43
  openapi_parser (~> 1.0)
41
44
  rack (>= 1.5)
42
- commonmarker (1.1.4)
45
+ commonmarker (1.1.5)
43
46
  rb_sys (~> 0.9)
44
- concurrent-ruby (1.3.3)
47
+ concurrent-ruby (1.3.4)
45
48
  connection_pool (2.4.1)
46
49
  deprecation (1.1.0)
47
50
  activesupport
48
51
  diff-lcs (1.5.1)
49
- docile (1.4.0)
52
+ docile (1.4.1)
50
53
  drb (2.2.1)
51
- dry-core (1.0.1)
54
+ dry-core (1.0.2)
52
55
  concurrent-ruby (~> 1.0)
56
+ logger
53
57
  zeitwerk (~> 2.6)
54
- dry-inflector (1.0.0)
58
+ dry-inflector (1.1.0)
55
59
  dry-logic (1.5.0)
56
60
  concurrent-ruby (~> 1.0)
57
61
  dry-core (~> 1.0, < 2)
@@ -72,66 +76,63 @@ GEM
72
76
  activesupport (>= 3.0, < 8.0)
73
77
  equivalent-xml (0.6.0)
74
78
  nokogiri (>= 1.4.3)
75
- i18n (1.14.5)
79
+ i18n (1.14.6)
76
80
  concurrent-ruby (~> 1.0)
77
81
  ice_nine (0.11.2)
78
- json (2.7.2)
82
+ json (2.8.2)
79
83
  json_schema (0.21.0)
80
84
  jsonpath (1.1.5)
81
85
  multi_json
82
86
  language_server-protocol (3.17.0.3)
83
- mini_portile2 (2.8.7)
84
- minitest (5.24.0)
87
+ logger (1.6.1)
88
+ mini_portile2 (2.8.8)
89
+ minitest (5.25.2)
85
90
  multi_json (1.15.0)
86
- mutex_m (0.2.0)
87
- nokogiri (1.16.6)
91
+ nokogiri (1.16.7)
88
92
  mini_portile2 (~> 2.8.2)
89
93
  racc (~> 1.4)
90
94
  openapi3_parser (0.10.0)
91
95
  commonmarker (>= 1.0)
92
96
  openapi_parser (1.0.0)
93
- optimist (3.1.0)
94
- parallel (1.25.1)
95
- parser (3.3.3.0)
97
+ optimist (3.2.0)
98
+ parallel (1.26.3)
99
+ parser (3.3.6.0)
96
100
  ast (~> 2.4.1)
97
101
  racc
98
102
  patience_diff (1.2.0)
99
103
  optimist (~> 3.0)
100
- racc (1.8.0)
101
- rack (3.1.4)
104
+ racc (1.8.1)
105
+ rack (3.1.8)
102
106
  rainbow (3.1.1)
103
107
  rake (13.2.1)
104
- rb_sys (0.9.97)
108
+ rb_sys (0.9.103)
105
109
  regexp_parser (2.9.2)
106
- rexml (3.3.0)
107
- strscan
108
110
  rspec (3.13.0)
109
111
  rspec-core (~> 3.13.0)
110
112
  rspec-expectations (~> 3.13.0)
111
113
  rspec-mocks (~> 3.13.0)
112
- rspec-core (3.13.0)
114
+ rspec-core (3.13.2)
113
115
  rspec-support (~> 3.13.0)
114
- rspec-expectations (3.13.1)
116
+ rspec-expectations (3.13.3)
115
117
  diff-lcs (>= 1.2.0, < 2.0)
116
118
  rspec-support (~> 3.13.0)
117
- rspec-mocks (3.13.1)
119
+ rspec-mocks (3.13.2)
118
120
  diff-lcs (>= 1.2.0, < 2.0)
119
121
  rspec-support (~> 3.13.0)
120
122
  rspec-support (3.13.1)
121
123
  rspec_junit_formatter (0.6.0)
122
124
  rspec-core (>= 2, < 4, != 2.12.0)
123
- rubocop (1.64.1)
125
+ rubocop (1.68.0)
124
126
  json (~> 2.3)
125
127
  language_server-protocol (>= 3.17.0)
126
128
  parallel (~> 1.10)
127
129
  parser (>= 3.3.0.2)
128
130
  rainbow (>= 2.2.2, < 4.0)
129
- regexp_parser (>= 1.8, < 3.0)
130
- rexml (>= 3.2.5, < 4.0)
131
- rubocop-ast (>= 1.31.1, < 2.0)
131
+ regexp_parser (>= 2.4, < 3.0)
132
+ rubocop-ast (>= 1.32.2, < 2.0)
132
133
  ruby-progressbar (~> 1.7)
133
134
  unicode-display_width (>= 2.4.0, < 3.0)
134
- rubocop-ast (1.31.3)
135
+ rubocop-ast (1.36.1)
135
136
  parser (>= 3.3.1.0)
136
137
  rubocop-capybara (2.21.0)
137
138
  rubocop (~> 1.41)
@@ -147,22 +148,22 @@ GEM
147
148
  rubocop-rspec_rails (2.29.1)
148
149
  rubocop (~> 1.61)
149
150
  ruby-progressbar (1.13.0)
151
+ securerandom (0.3.2)
150
152
  simplecov (0.22.0)
151
153
  docile (~> 1.1)
152
154
  simplecov-html (~> 0.11)
153
155
  simplecov_json_formatter (~> 0.1)
154
- simplecov-html (0.12.3)
156
+ simplecov-html (0.13.1)
155
157
  simplecov_json_formatter (0.1.4)
156
- strscan (3.1.0)
157
- super_diff (0.12.1)
158
+ super_diff (0.14.0)
158
159
  attr_extras (>= 6.2.4)
159
160
  diff-lcs
160
161
  patience_diff
161
- thor (1.3.1)
162
+ thor (1.3.2)
162
163
  tzinfo (2.0.6)
163
164
  concurrent-ruby (~> 1.0)
164
- unicode-display_width (2.5.0)
165
- zeitwerk (2.6.16)
165
+ unicode-display_width (2.6.0)
166
+ zeitwerk (2.7.1)
166
167
 
167
168
  PLATFORMS
168
169
  ruby
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`, and commit the result. Then run:
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]&.size&.zero?
436
- new_node.remove_attribute('qualifier') if common_attribs[:qualifier].present? || node[:qualifier]&.size&.zero?
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
@@ -290,10 +290,8 @@ module Cocina
290
290
  end
291
291
 
292
292
  def build_affiliation_notes(name_node)
293
- [].tap do |parts|
294
- name_node.xpath('mods:affiliation', mods: Description::DESC_METADATA_NS).each do |affiliation_node|
295
- parts << { value: affiliation_node.text, type: 'affiliation' }
296
- end
293
+ name_node.xpath('mods:affiliation', mods: Description::DESC_METADATA_NS).map do |affiliation_node|
294
+ { value: affiliation_node.text, type: 'affiliation' }
297
295
  end
298
296
  end
299
297
 
@@ -32,7 +32,7 @@ module Cocina
32
32
  note_present?(node)
33
33
  end
34
34
  altrepgroup_abstract_nodes, other_abstract_nodes = AltRepGroup.split(nodes: all_abstract_nodes)
35
- other_abstract_nodes.map { |node| common_note_for(node).merge(abstract_type(node)) } + \
35
+ other_abstract_nodes.map { |node| common_note_for(node).merge(abstract_type(node)) } +
36
36
  altrepgroup_abstract_nodes.map { |parallel_nodes| parallel_abstract_for(parallel_nodes) }
37
37
  end
38
38
 
@@ -92,7 +92,7 @@ module Cocina
92
92
  note_present?(node) && node[:type] != 'contact'
93
93
  end
94
94
  altrepgroup_note_nodes, other_note_nodes = AltRepGroup.split(nodes: all_note_nodes)
95
- other_note_nodes.map { |node| common_note_for(node) } + \
95
+ other_note_nodes.map { |node| common_note_for(node) } +
96
96
  altrepgroup_note_nodes.map { |parallel_nodes| parallel_note_for(parallel_nodes) }
97
97
  end
98
98
 
@@ -123,7 +123,7 @@ module Cocina
123
123
  note_present?(node)
124
124
  end
125
125
  altrepgroup_toc_nodes, other_toc_nodes = AltRepGroup.split(nodes: all_toc_nodes)
126
- other_toc_nodes.map { |node| toc_for(node).merge({ type: 'table of contents' }) } + \
126
+ other_toc_nodes.map { |node| toc_for(node).merge({ type: 'table of contents' }) } +
127
127
  altrepgroup_toc_nodes.map { |parallel_nodes| parallel_toc_for(parallel_nodes) }
128
128
  end
129
129
 
@@ -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
@@ -14,7 +14,8 @@ module Cocina
14
14
  DescriptionTypesValidator,
15
15
  DescriptionValuesValidator,
16
16
  DateTimeValidator,
17
- LanguageTagValidator
17
+ LanguageTagValidator,
18
+ ReservedFilenameValidator
18
19
  ].freeze
19
20
 
20
21
  def self.validate(clazz, attributes)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.98.1'
5
+ VERSION = '0.99.1'
6
6
  end
7
7
  end
@@ -62,7 +62,8 @@ module Cocina
62
62
  version: 1,
63
63
  label: 'factory collection label',
64
64
  title: 'factory collection title',
65
- admin_policy_id: 'druid:hv992ry2431'
65
+ admin_policy_id: 'druid:hv992ry2431',
66
+ source_id: 'sulcollection:1234'
66
67
  }.freeze
67
68
 
68
69
  REQUEST_COLLECTION_DEFAULTS = COLLECTION_DEFAULTS.except(:id)
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.98.1
4
+ version: 0.99.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: 2024-06-24 00:00:00.000000000 Z
11
+ date: 2024-11-27 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
@@ -549,7 +550,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
549
550
  - !ruby/object:Gem::Version
550
551
  version: '0'
551
552
  requirements: []
552
- rubygems_version: 3.4.19
553
+ rubygems_version: 3.5.16
553
554
  signing_key:
554
555
  specification_version: 4
555
556
  summary: Data models for the SDR