cocina-models 0.125.0 → 0.127.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b1cbe64214701949f868f9bc059723de7cdd615f32224b083912598f206b7fe
4
- data.tar.gz: 8056d85b1ae995268a535bfb7054539134333d8284cf71005493bc323498efca
3
+ metadata.gz: c9beced1e40bb48b8cb1b833da51b9205b5f454554c0385ad982c3f8bed648f8
4
+ data.tar.gz: b94cfd3960e8bdd7ff896a3749b12c95ed1827bcf05cdf7a62d37c0e9f88d817
5
5
  SHA512:
6
- metadata.gz: 073300d57326edf9cb163199e8d1d2da1a2793840a048e29bd9bc67de64a09e10e192ceb0d290c4281d515b51325c14f882118794759322a42b9ee38fd5a39f4
7
- data.tar.gz: b960c95acbd75ba99f7363b30fed87aadcc3a26a653506fa56c416547f4e285d5b7dd361a7dff012961b3a90255fa7a6b93237e1af2c92b3e7797eae6e1944f6
6
+ metadata.gz: 3accd9261f9215632a273525b0459e004db3cc0410bda7d455018e5042e1de908f87d7a13d1faa75c605c67c26b6437e0cc1c8dc6a8abda67fe5a6927bd71283
7
+ data.tar.gz: 26c9d0be0086a3567d640760432dca23a4355e088b7368bc48db87023c4e6d915880c33b3ab4588be22b2ce84b49eed69eb30cf357f8dab1921ec9eece3cea1e
data/AGENTS.md CHANGED
@@ -167,7 +167,7 @@ Generate a short kebab-case slug summarizing the query (e.g., `invalid-encoding`
167
167
 
168
168
  The comment lines must use `#` so the file remains valid jq syntax. When resuming (Step 2 resume path), parse these comment sections by their labels to reconstruct the inputs.
169
169
 
170
- Find the most recent `.jsonl.xz` file in the project root by listing `*.jsonl.xz` files sorted by name descending and taking the first result.
170
+ Find the most recent `.jsonl.zst` file in the project root by listing `*.jsonl.zst` files sorted by name descending and taking the first result.
171
171
 
172
172
  ### Step 8 — Output
173
173
 
@@ -178,7 +178,7 @@ Present:
178
178
  4. A ready-to-run shell snippet:
179
179
 
180
180
  ```
181
- xzcat <most-recent .jsonl.xz filename> \
181
+ zstdcat <most-recent .jsonl.zst filename> \
182
182
  | pv -l -s 5500000 \
183
183
  | parallel -j$(sysctl -n hw.logicalcpu) --pipe --block 50M --recend '\n' \
184
184
  jq -rcf <slug>.jq.txt \
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocina-models (0.125.0)
4
+ cocina-models (0.127.0)
5
5
  activesupport
6
6
  cocina_display
7
7
  deprecation
@@ -102,11 +102,11 @@ GEM
102
102
  iso8601 (0.13.0)
103
103
  janeway-jsonpath (1.0.0)
104
104
  json (2.20.0)
105
- jsonschema_rs (0.46.6-arm64-darwin)
105
+ jsonschema_rs (0.46.10-arm64-darwin)
106
106
  bigdecimal (>= 3.1, < 5)
107
- jsonschema_rs (0.46.6-x86_64-linux)
107
+ jsonschema_rs (0.46.10-x86_64-linux)
108
108
  bigdecimal (>= 3.1, < 5)
109
- language_server-protocol (3.17.0.5)
109
+ language_server-protocol (3.17.0.6)
110
110
  lint_roller (1.1.0)
111
111
  logger (1.7.0)
112
112
  minitest (6.0.6)
@@ -162,7 +162,7 @@ GEM
162
162
  rspec-support (3.13.7)
163
163
  rspec_junit_formatter (0.6.0)
164
164
  rspec-core (>= 2, < 4, != 2.12.0)
165
- rubocop (1.88.0)
165
+ rubocop (1.88.1)
166
166
  json (~> 2.3)
167
167
  language_server-protocol (~> 3.17.0.2)
168
168
  lint_roller (~> 1.1.0)
@@ -173,7 +173,7 @@ GEM
173
173
  rubocop-ast (>= 1.49.0, < 2.0)
174
174
  ruby-progressbar (~> 1.7)
175
175
  unicode-display_width (>= 2.4.0, < 4.0)
176
- rubocop-ast (1.49.1)
176
+ rubocop-ast (1.50.0)
177
177
  parser (>= 3.3.7.2)
178
178
  prism (~> 1.7)
179
179
  rubocop-rake (0.7.1)
@@ -232,7 +232,7 @@ CHECKSUMS
232
232
  bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd
233
233
  builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f
234
234
  bundler (4.0.15) sha256=a4ceb882fe94a0e0ac63cd0813932bbfd631a14e5ac0b7975189b19a4d28d9e7
235
- cocina-models (0.125.0)
235
+ cocina-models (0.127.0)
236
236
  cocina_display (2.8.0) sha256=89722e8e204c07cfa38f3deacbd66d42f3db9c7b29fdc034973d847cf93c4995
237
237
  concurrent-ruby (1.3.7) sha256=4412caec3a5ea2e5fdc52076724c071a81f2c0593d83b2ac8cbb8ca63b3151b0
238
238
  connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
@@ -260,9 +260,9 @@ CHECKSUMS
260
260
  iso8601 (0.13.0) sha256=298c2b15b7be5fa95a1372813d36a2257656cd8e906dfbc1f5cb409851425aa2
261
261
  janeway-jsonpath (1.0.0) sha256=c8293f009f2aea9487ddee3067ca735a1f758eb1c8834ff4fab3ffd06c56d0a3
262
262
  json (2.20.0) sha256=9362bc6e55a952b056abf9167cf053358181c904cb70cd6eee0808ea830fc32b
263
- jsonschema_rs (0.46.6-arm64-darwin) sha256=05c0acc91fd03c38160491fa10bfd4d608ccf99be3c34a365e7df93c8a10c647
264
- jsonschema_rs (0.46.6-x86_64-linux) sha256=26e889bbd9e2e884ae187952d00809714946e4626ae8a323e80667b9aa7b2844
265
- language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
263
+ jsonschema_rs (0.46.10-arm64-darwin) sha256=1bece46823184a8cbec55d7585f09de68cc2bc03772d8aa9c29deba23b490609
264
+ jsonschema_rs (0.46.10-x86_64-linux) sha256=ef1f8a244e8e5b4a9e35ccd0b7f7aa9912a7e15b00f1170ba3f3cade0bdc627b
265
+ language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0
266
266
  lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
267
267
  logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
268
268
  minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
@@ -290,8 +290,8 @@ CHECKSUMS
290
290
  rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
291
291
  rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
292
292
  rspec_junit_formatter (0.6.0) sha256=40dde674e6ae4e6cc0ff560da25497677e34fefd2338cc467a8972f602b62b15
293
- rubocop (1.88.0) sha256=e420ddf1662d0ef34bc8a2910ac4b396a7ddda0b51a708264405241734b08e0b
294
- rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035
293
+ rubocop (1.88.1) sha256=726af773d6bc169ed3ff852f3ca020b7c58d39c34e7a8d879a8e0147cc994f26
294
+ rubocop-ast (1.50.0) sha256=b9ca88300da0803ee222ad20cdb30494c0a784eed06fdc35d254b06d662788db
295
295
  rubocop-rake (0.7.1) sha256=3797f2b6810c3e9df7376c26d5f44f3475eda59eb1adc38e6f62ecf027cbae4d
296
296
  rubocop-rspec (3.10.2) sha256=0b3e2ecc592cd10ecbf0095bb58d1e357905276e069643523cc19eb7495f65e2
297
297
  ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
data/bin/validate-data CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- # Validate JSONL (XZ compressed) files against the schema
4
+ # Validate JSONL (zstd compressed) files against the schema
5
5
 
6
6
  # Trap Ctrl+C to exit gracefully
7
7
  Signal.trap('INT') do
@@ -65,7 +65,7 @@ end
65
65
  # Count lines in the file
66
66
  def count_lines(filename)
67
67
  count = 0
68
- IO.popen(['xzcat', filename]) do |io|
68
+ IO.popen(['zstdcat', filename]) do |io|
69
69
  io.each_line { count += 1 }
70
70
  end
71
71
  count
@@ -73,7 +73,7 @@ end
73
73
 
74
74
  # Get total line count (either from option or by counting)
75
75
  def get_total_lines(filename, provided_count)
76
- count_filename = filename.sub(/\.xz$/, '.count.txt')
76
+ count_filename = filename.sub(/\.zst$/, '.count.txt')
77
77
  if provided_count
78
78
  puts "Using provided line count: #{provided_count}"
79
79
  provided_count
@@ -183,7 +183,7 @@ def distribute_work(filename, workers, batch_size, total_lines) # rubocop:disabl
183
183
  throttle_rate: 0.1
184
184
  )
185
185
 
186
- IO.popen(['xzcat', filename]) do |io|
186
+ IO.popen(['zstdcat', filename]) do |io|
187
187
  io.each_line do |line|
188
188
  line_number += 1
189
189
  batch << [line_number, line]
@@ -15,7 +15,7 @@ module Cocina
15
15
  attribute :type, Types::Strict::String.enum(*AdminPolicy::TYPES)
16
16
  # example: druid:bc123df4567
17
17
  attribute :externalIdentifier, Druid
18
- attribute :label, Types::Strict::String
18
+ attribute? :label, Types::Strict::String.default('')
19
19
  attribute :version, Types::Strict::Integer
20
20
  # Administrative properties for an AdminPolicy
21
21
  attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
@@ -13,7 +13,7 @@ module Cocina
13
13
  attribute :type, Types::Strict::String.enum(*AdminPolicyLite::TYPES)
14
14
  # example: druid:bc123df4567
15
15
  attribute :externalIdentifier, Druid
16
- attribute :label, Types::Strict::String
16
+ attribute? :label, Types::Strict::String.default('')
17
17
  attribute :version, Types::Strict::Integer
18
18
  # Administrative properties for an AdminPolicy
19
19
  # Validation of this property is relaxed. See the schema.json for full validation.
@@ -16,7 +16,7 @@ module Cocina
16
16
  attribute :type, Types::Strict::String.enum(*AdminPolicyWithMetadata::TYPES)
17
17
  # example: druid:bc123df4567
18
18
  attribute :externalIdentifier, Druid
19
- attribute :label, Types::Strict::String
19
+ attribute? :label, Types::Strict::String.default('')
20
20
  attribute :version, Types::Strict::Integer
21
21
  # Administrative properties for an AdminPolicy
22
22
  attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
@@ -23,7 +23,7 @@ module Cocina
23
23
  # example: druid:bc123df4567
24
24
  attribute :externalIdentifier, Druid
25
25
  # Primary processing label (can be same as title) for a Collection.
26
- attribute :label, Types::Strict::String
26
+ attribute? :label, Types::Strict::String.default('')
27
27
  # Version for the Collection within SDR.
28
28
  attribute :version, Types::Strict::Integer
29
29
  # Access metadata for collections
@@ -21,7 +21,7 @@ module Cocina
21
21
  # example: druid:bc123df4567
22
22
  attribute :externalIdentifier, Druid
23
23
  # Primary processing label (can be same as title) for a Collection.
24
- attribute :label, Types::Strict::String
24
+ attribute? :label, Types::Strict::String.default('')
25
25
  # Version for the Collection within SDR.
26
26
  attribute :version, Types::Strict::Integer
27
27
  # Access metadata for collections
@@ -22,7 +22,7 @@ module Cocina
22
22
  # example: druid:bc123df4567
23
23
  attribute :externalIdentifier, Druid
24
24
  # Primary processing label (can be same as title) for a Collection.
25
- attribute :label, Types::Strict::String
25
+ attribute? :label, Types::Strict::String.default('')
26
26
  # Version for the Collection within SDR.
27
27
  attribute :version, Types::Strict::Integer
28
28
  # Access metadata for collections
@@ -33,7 +33,7 @@ module Cocina
33
33
  # example: druid:bc123df4567
34
34
  attribute :externalIdentifier, Druid
35
35
  # Primary processing label (can be same as title) for a DRO.
36
- attribute :label, Types::Strict::String
36
+ attribute? :label, Types::Strict::String.default('')
37
37
  # Version for the DRO within SDR.
38
38
  attribute :version, Types::Strict::Integer
39
39
  attribute(:access, DROAccess.default { DROAccess.new })
@@ -31,7 +31,7 @@ module Cocina
31
31
  # example: druid:bc123df4567
32
32
  attribute :externalIdentifier, Druid
33
33
  # Primary processing label (can be same as title) for a DRO.
34
- attribute :label, Types::Strict::String
34
+ attribute? :label, Types::Strict::String.default('')
35
35
  # Version for the DRO within SDR.
36
36
  attribute :version, Types::Strict::Integer
37
37
  # Validation of this property is relaxed. See the schema.json for full validation.
@@ -32,7 +32,7 @@ module Cocina
32
32
  # example: druid:bc123df4567
33
33
  attribute :externalIdentifier, Druid
34
34
  # Primary processing label (can be same as title) for a DRO.
35
- attribute :label, Types::Strict::String
35
+ attribute? :label, Types::Strict::String.default('')
36
36
  # Version for the DRO within SDR.
37
37
  attribute :version, Types::Strict::Integer
38
38
  attribute(:access, DROAccess.default { DROAccess.new })
@@ -14,7 +14,7 @@ module Cocina
14
14
  # example: 1.2.3
15
15
  attribute :cocinaVersion, CocinaVersion.default(VERSION)
16
16
  attribute :type, Types::Strict::String.enum(*RequestAdminPolicy::TYPES)
17
- attribute :label, Types::Strict::String
17
+ attribute? :label, Types::Strict::String.default('')
18
18
  attribute :version, Types::Strict::Integer.default(1).enum(1)
19
19
  # Administrative properties for an AdminPolicy
20
20
  attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
@@ -18,7 +18,7 @@ module Cocina
18
18
  # example: 1.2.3
19
19
  attribute :cocinaVersion, CocinaVersion.default(VERSION)
20
20
  attribute :type, Types::Strict::String.enum(*RequestCollection::TYPES)
21
- attribute :label, Types::Strict::String
21
+ attribute? :label, Types::Strict::String.default('')
22
22
  attribute :version, Types::Strict::Integer.default(1).enum(1)
23
23
  # Access metadata for collections
24
24
  attribute(:access, CollectionAccess.default { CollectionAccess.new })
@@ -30,7 +30,7 @@ module Cocina
30
30
  # example: 1.2.3
31
31
  attribute :cocinaVersion, CocinaVersion.default(VERSION)
32
32
  attribute :type, Types::Strict::String.enum(*RequestDRO::TYPES)
33
- attribute :label, Types::Strict::String
33
+ attribute? :label, Types::Strict::String.default('')
34
34
  attribute :version, Types::Strict::Integer.default(1).enum(1)
35
35
  attribute? :access, DROAccess.optional
36
36
  attribute(:administrative, RequestAdministrative.default { RequestAdministrative.new })
@@ -17,10 +17,10 @@ module Cocina
17
17
  DescriptionDateTimeVisitorValidator,
18
18
  DescriptionEventDateVisitorValidator,
19
19
  DescriptionSubjectTemporalEncodingVisitorValidator,
20
- DescriptionLocationSourceCodeVisitorValidator,
21
20
  DescriptionTitleSourceCodeVisitorValidator,
22
21
  DescriptionLanguageUriVisitorValidator,
23
- DescriptionScriptVisitorValidator
22
+ DescriptionScriptVisitorValidator,
23
+ DescriptionLocationVisitorValidator
24
24
  ].freeze
25
25
 
26
26
  def self.validate(clazz, attributes)
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cocina_display'
4
+
5
+ module Cocina
6
+ module Models
7
+ module Validators
8
+ # Validates location.source.code against location_source_codes.yml and
9
+ # validates location.code against marc_country_codes.yml when source.code is marccountry.
10
+ class DescriptionLocationVisitorValidator < BaseDescriptionVisitorValidator
11
+ def validate!
12
+ errors = []
13
+ errors << "Unrecognized location source codes in description: #{error_paths.join(', ')}" if error_paths.any?
14
+ errors << "Invalid MARC country codes in description: #{marc_country_error_paths.join(', ')}" if marc_country_error_paths.any?
15
+ raise ValidationError, errors.join('; ') if errors.any?
16
+ end
17
+
18
+ def visit_hash(hash:, path:)
19
+ return unless location_path?(path)
20
+
21
+ source_code = hash.dig(:source, :code)
22
+ return unless source_code
23
+
24
+ error_paths << "#{path_to_s(path)}.source.code (#{source_code})" unless valid_codes.include?(source_code.downcase)
25
+
26
+ return unless source_code.downcase == 'marccountry'
27
+
28
+ code = hash[:code]
29
+ marc_country_error_paths << "#{path_to_s(path)}.code (#{code})" if code && !valid_marc_country_codes.include?(code.downcase)
30
+ end
31
+
32
+ private
33
+
34
+ def error_paths
35
+ @error_paths ||= []
36
+ end
37
+
38
+ def marc_country_error_paths
39
+ @marc_country_error_paths ||= []
40
+ end
41
+
42
+ def location_path?(path)
43
+ # Match entries in a location array (e.g., [:location, 0] or [:relatedResource, 0, :location, 0]).
44
+ path.length >= 2 && path[-1].is_a?(Integer) && path[-2].to_s == 'location'
45
+ end
46
+
47
+ # rubocop:disable Style/ClassVars
48
+ def valid_codes
49
+ @@valid_codes ||= YAML.load_file(::File.expand_path('../../../../location_source_codes.yml', __dir__)).to_set(&:downcase)
50
+ end
51
+
52
+ def valid_marc_country_codes
53
+ @@valid_marc_country_codes ||= YAML.load_file(CocinaDisplay.root.join('config/marc_countries.yml')).keys.to_set(&:to_s)
54
+ end
55
+ # rubocop:enable Style/ClassVars
56
+ end
57
+ end
58
+ end
59
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.125.0'
5
+ VERSION = '0.127.0'
6
6
  end
7
7
  end
data/schema.json CHANGED
@@ -107,7 +107,8 @@
107
107
  "$ref": "#/$defs/Druid"
108
108
  },
109
109
  "label": {
110
- "type": "string"
110
+ "type": "string",
111
+ "default": ""
111
112
  },
112
113
  "version": {
113
114
  "type": "integer"
@@ -123,7 +124,6 @@
123
124
  "cocinaVersion",
124
125
  "administrative",
125
126
  "externalIdentifier",
126
- "label",
127
127
  "type",
128
128
  "version"
129
129
  ]
@@ -361,7 +361,8 @@
361
361
  },
362
362
  "label": {
363
363
  "description": "Primary processing label (can be same as title) for a Collection.",
364
- "type": "string"
364
+ "type": "string",
365
+ "default": ""
365
366
  },
366
367
  "version": {
367
368
  "description": "Version for the Collection within SDR.",
@@ -384,7 +385,6 @@
384
385
  "cocinaVersion",
385
386
  "description",
386
387
  "externalIdentifier",
387
- "label",
388
388
  "type",
389
389
  "version",
390
390
  "access",
@@ -634,7 +634,8 @@
634
634
  "externalIdentifier": { "$ref": "#/$defs/Druid" },
635
635
  "label": {
636
636
  "description": "Primary processing label (can be same as title) for a DRO.",
637
- "type": "string"
637
+ "type": "string",
638
+ "default": ""
638
639
  },
639
640
  "version": {
640
641
  "description": "Version for the DRO within SDR.",
@@ -653,7 +654,6 @@
653
654
  "administrative",
654
655
  "description",
655
656
  "externalIdentifier",
656
- "label",
657
657
  "type",
658
658
  "version",
659
659
  "identification",
@@ -1720,7 +1720,7 @@
1720
1720
  "minItems": 1
1721
1721
  }
1722
1722
  }
1723
- }
1723
+ }
1724
1724
  ]
1725
1725
  },
1726
1726
  "File": {
@@ -2656,7 +2656,8 @@
2656
2656
  ]
2657
2657
  },
2658
2658
  "label": {
2659
- "type": "string"
2659
+ "type": "string",
2660
+ "default": ""
2660
2661
  },
2661
2662
  "version": {
2662
2663
  "type": "integer",
@@ -2675,7 +2676,6 @@
2675
2676
  "required": [
2676
2677
  "cocinaVersion",
2677
2678
  "administrative",
2678
- "label",
2679
2679
  "type",
2680
2680
  "version"
2681
2681
  ],
@@ -2716,7 +2716,8 @@
2716
2716
  ]
2717
2717
  },
2718
2718
  "label": {
2719
- "type": "string"
2719
+ "type": "string",
2720
+ "default": ""
2720
2721
  },
2721
2722
  "version": {
2722
2723
  "type": "integer",
@@ -2742,7 +2743,6 @@
2742
2743
  "cocinaVersion",
2743
2744
  "access",
2744
2745
  "administrative",
2745
- "label",
2746
2746
  "type",
2747
2747
  "version"
2748
2748
  ],
@@ -2776,7 +2776,8 @@
2776
2776
  ]
2777
2777
  },
2778
2778
  "label": {
2779
- "type": "string"
2779
+ "type": "string",
2780
+ "default": ""
2780
2781
  },
2781
2782
  "version": {
2782
2783
  "type": "integer",
@@ -2808,7 +2809,6 @@
2808
2809
  "cocinaVersion",
2809
2810
  "administrative",
2810
2811
  "identification",
2811
- "label",
2812
2812
  "type",
2813
2813
  "version"
2814
2814
  ],
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocina-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.125.0
4
+ version: 0.127.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -488,7 +488,7 @@ files:
488
488
  - lib/cocina/models/validators/description_identifier_source_code_visitor_validator.rb
489
489
  - lib/cocina/models/validators/description_language_code_visitor_validator.rb
490
490
  - lib/cocina/models/validators/description_language_uri_visitor_validator.rb
491
- - lib/cocina/models/validators/description_location_source_code_visitor_validator.rb
491
+ - lib/cocina/models/validators/description_location_visitor_validator.rb
492
492
  - lib/cocina/models/validators/description_name_source_code_visitor_validator.rb
493
493
  - lib/cocina/models/validators/description_role_source_code_visitor_validator.rb
494
494
  - lib/cocina/models/validators/description_script_visitor_validator.rb
@@ -536,7 +536,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
536
536
  - !ruby/object:Gem::Version
537
537
  version: '0'
538
538
  requirements: []
539
- rubygems_version: 4.0.6
539
+ rubygems_version: 3.6.9
540
540
  specification_version: 4
541
541
  summary: Data models for the SDR
542
542
  test_files: []
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cocina
4
- module Models
5
- module Validators
6
- # Validates location.source.code values against location_source_codes.yml.
7
- class DescriptionLocationSourceCodeVisitorValidator < BaseDescriptionVisitorValidator
8
- def validate!
9
- return if error_paths.empty?
10
-
11
- raise ValidationError, "Unrecognized location source codes in description: #{error_paths.join(', ')}"
12
- end
13
-
14
- def visit_hash(hash:, path:)
15
- return unless location_path?(path)
16
-
17
- source_code = hash.dig(:source, :code)
18
- return unless source_code
19
- return if valid_codes.include?(source_code.downcase)
20
-
21
- error_paths << "#{path_to_s(path)}.source.code (#{source_code})"
22
- end
23
-
24
- private
25
-
26
- def error_paths
27
- @error_paths ||= []
28
- end
29
-
30
- def location_path?(path)
31
- # Match entries in a location array (e.g., [:location, 0] or [:relatedResource, 0, :location, 0]).
32
- path.length >= 2 && path[-1].is_a?(Integer) && path[-2].to_s == 'location'
33
- end
34
-
35
- # rubocop:disable Style/ClassVars
36
- def valid_codes
37
- @@valid_codes ||= YAML.load_file(::File.expand_path('../../../../location_source_codes.yml', __dir__)).to_set(&:downcase)
38
- end
39
- # rubocop:enable Style/ClassVars
40
- end
41
- end
42
- end
43
- end