cocina-models 0.105.2 → 0.107.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: 6283801eacea27f02ff0df5db24f2f18555b886995feea5770ce1d3f401186eb
4
- data.tar.gz: 027c89ba0444e1663efb32e03a7e384b60439c3b2f73b8d372402450d117ae42
3
+ metadata.gz: 5274bff6327cebe2e04f7cc145fde055203131ae9885b4f654ff83dbbbe57408
4
+ data.tar.gz: 2cf28892860fdf3eb011a54aaaf4f6a25663f85cf66b8a1b15280b4165fe52f3
5
5
  SHA512:
6
- metadata.gz: 66ec3baf0a6610aec89f663bb208725bc4d5512750405a5a86d216793394a1162b84bdb548c007045395c94b4ba991aa05359b96c939b41eaf30993c1af418db
7
- data.tar.gz: 04ce19bbb766a4c3c699110edcf11326d87c526705eaa231a08d68adc88a97b79fd3a6dcc27b57f5347bb8b6e733786133985dae22efce8244144bb28ade517a
6
+ metadata.gz: 46b42f34df5bf8aba16f2d47110f8d81ae5f1be62b0b5aeda6fba9898b911540788a6f9ff23318cc7e0870a6c57a8dc95a14b50ced333628ef6f703fd842872f
7
+ data.tar.gz: a769621283a3433cebb98fff0e3a872f21016050e38770932af0aafc1634993631d31e50bddc58cc0720c6002fcaa9ae48fac840aa6042f39d55a745c6a7ec0b
data/.rubocop.yml CHANGED
@@ -6,7 +6,7 @@ plugins:
6
6
  - rubocop-rspec
7
7
 
8
8
  AllCops:
9
- TargetRubyVersion: 3.0
9
+ TargetRubyVersion: 3.4
10
10
 
11
11
  # ----- Layout ------
12
12
 
@@ -110,7 +110,7 @@ Metrics/PerceivedComplexity:
110
110
  - 'lib/cocina/models/mapping/to_mods/*'
111
111
  - 'lib/cocina/models/mapping/normalizers/**/*'
112
112
 
113
- Naming/PredicateName:
113
+ Naming/PredicatePrefix:
114
114
  ForbiddenPrefixes:
115
115
  - is_
116
116
 
@@ -521,3 +521,20 @@ Style/ItBlockParameter: # new in 1.75
521
521
  Enabled: true
522
522
  RSpec/IncludeExamples: # new in 3.6
523
523
  Enabled: true
524
+
525
+ Gemspec/AttributeAssignment: # new in 1.77
526
+ Enabled: true
527
+ Layout/EmptyLinesAfterModuleInclusion: # new in 1.79
528
+ Enabled: true
529
+ Lint/UselessDefaultValueArgument: # new in 1.76
530
+ Enabled: true
531
+ Lint/UselessOr: # new in 1.76
532
+ Enabled: true
533
+ Naming/PredicateMethod: # new in 1.76
534
+ Enabled: true
535
+ Style/CollectionQuerying: # new in 1.77
536
+ Enabled: true
537
+ Style/EmptyStringInsideInterpolation: # new in 1.76
538
+ Enabled: true
539
+ Style/RedundantArrayFlatten: # new in 1.76
540
+ Enabled: true
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocina-models (0.105.2)
4
+ cocina-models (0.107.0)
5
5
  activesupport
6
6
  deprecation
7
7
  dry-struct (~> 1.0)
@@ -19,7 +19,7 @@ PATH
19
19
  GEM
20
20
  remote: https://rubygems.org/
21
21
  specs:
22
- activesupport (8.0.2)
22
+ activesupport (8.0.3)
23
23
  base64
24
24
  benchmark (>= 0.3)
25
25
  bigdecimal
@@ -36,14 +36,14 @@ GEM
36
36
  attr_extras (7.1.0)
37
37
  base64 (0.3.0)
38
38
  benchmark (0.4.1)
39
- bigdecimal (3.2.2)
39
+ bigdecimal (3.2.3)
40
40
  byebug (12.0.0)
41
41
  committee (5.0.0)
42
42
  json_schema (~> 0.14, >= 0.14.3)
43
43
  openapi_parser (~> 1.0)
44
44
  rack (>= 1.5)
45
45
  concurrent-ruby (1.3.5)
46
- connection_pool (2.5.3)
46
+ connection_pool (2.5.4)
47
47
  deprecation (1.1.0)
48
48
  activesupport
49
49
  diff-lcs (1.6.2)
@@ -78,7 +78,7 @@ GEM
78
78
  i18n (1.14.7)
79
79
  concurrent-ruby (~> 1.0)
80
80
  ice_nine (0.11.2)
81
- json (2.13.2)
81
+ json (2.15.0)
82
82
  json_schema (0.21.0)
83
83
  jsonpath (1.1.5)
84
84
  multi_json
@@ -88,7 +88,7 @@ GEM
88
88
  mini_portile2 (2.8.9)
89
89
  minitest (5.25.5)
90
90
  multi_json (1.17.0)
91
- nokogiri (1.18.9)
91
+ nokogiri (1.18.10)
92
92
  mini_portile2 (~> 2.8.2)
93
93
  racc (~> 1.4)
94
94
  openapi_parser (1.0.0)
@@ -99,12 +99,12 @@ GEM
99
99
  racc
100
100
  patience_diff (1.2.0)
101
101
  optimist (~> 3.0)
102
- prism (1.4.0)
102
+ prism (1.5.1)
103
103
  racc (1.8.1)
104
- rack (3.2.0)
104
+ rack (3.2.1)
105
105
  rainbow (3.1.1)
106
106
  rake (13.3.0)
107
- regexp_parser (2.11.1)
107
+ regexp_parser (2.11.3)
108
108
  rspec (3.13.1)
109
109
  rspec-core (~> 3.13.0)
110
110
  rspec-expectations (~> 3.13.0)
@@ -117,10 +117,10 @@ GEM
117
117
  rspec-mocks (3.13.5)
118
118
  diff-lcs (>= 1.2.0, < 2.0)
119
119
  rspec-support (~> 3.13.0)
120
- rspec-support (3.13.4)
120
+ rspec-support (3.13.6)
121
121
  rspec_junit_formatter (0.6.0)
122
122
  rspec-core (>= 2, < 4, != 2.12.0)
123
- rubocop (1.79.2)
123
+ rubocop (1.81.1)
124
124
  json (~> 2.3)
125
125
  language_server-protocol (~> 3.17.0.2)
126
126
  lint_roller (~> 1.1.0)
@@ -128,16 +128,16 @@ GEM
128
128
  parser (>= 3.3.0.2)
129
129
  rainbow (>= 2.2.2, < 4.0)
130
130
  regexp_parser (>= 2.9.3, < 3.0)
131
- rubocop-ast (>= 1.46.0, < 2.0)
131
+ rubocop-ast (>= 1.47.1, < 2.0)
132
132
  ruby-progressbar (~> 1.7)
133
133
  unicode-display_width (>= 2.4.0, < 4.0)
134
- rubocop-ast (1.46.0)
134
+ rubocop-ast (1.47.1)
135
135
  parser (>= 3.3.7.2)
136
136
  prism (~> 1.4)
137
137
  rubocop-rake (0.7.1)
138
138
  lint_roller (~> 1.1)
139
139
  rubocop (>= 1.72.1)
140
- rubocop-rspec (3.6.0)
140
+ rubocop-rspec (3.7.0)
141
141
  lint_roller (~> 1.1)
142
142
  rubocop (~> 1.72, >= 1.72.1)
143
143
  ruby-progressbar (1.13.0)
@@ -155,9 +155,9 @@ GEM
155
155
  thor (1.4.0)
156
156
  tzinfo (2.0.6)
157
157
  concurrent-ruby (~> 1.0)
158
- unicode-display_width (3.1.4)
159
- unicode-emoji (~> 4.0, >= 4.0.4)
160
- unicode-emoji (4.0.4)
158
+ unicode-display_width (3.2.0)
159
+ unicode-emoji (~> 4.1)
160
+ unicode-emoji (4.1.0)
161
161
  uri (1.0.3)
162
162
  zeitwerk (2.7.3)
163
163
 
@@ -178,4 +178,4 @@ DEPENDENCIES
178
178
  simplecov
179
179
 
180
180
  BUNDLED WITH
181
- 2.7.1
181
+ 2.7.2
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.bindir = 'exe'
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ['lib']
25
- spec.required_ruby_version = '>= 3.0'
25
+ spec.required_ruby_version = '>= 3.4'
26
26
 
27
27
  spec.add_dependency 'activesupport'
28
28
  spec.add_dependency 'deprecation'
@@ -68,6 +68,8 @@ contributor.name:
68
68
  description: Name used that differs from legal or primary form of name.
69
69
  - value: surname
70
70
  description: Last or family name or names.
71
+ - value: translation
72
+ description: Latinized or other translated version of the name not following a formal transliteration scheme.
71
73
  - value: transliteration
72
74
  description: Name originally in non-Latin script presented phonetically using Latin characters.
73
75
  contributor.name.structuredValue:
@@ -72,6 +72,8 @@ _Path: contributor.name.type_
72
72
  * Name used that differs from legal or primary form of name.
73
73
  * surname
74
74
  * Last or family name or names.
75
+ * translation
76
+ * Latinized or other translated version of the name not following a formal transliteration scheme.
75
77
  * transliteration
76
78
  * Name originally in non-Latin script presented phonetically using Latin characters.
77
79
  ### Contributor name part types for structured value
@@ -22,7 +22,7 @@ module Cocina
22
22
  end
23
23
 
24
24
  def name
25
- "#{key || schema_doc.name}#{lite ? 'Lite' : ''}"
25
+ "#{key || schema_doc.name}#{'Lite' if lite}"
26
26
  end
27
27
 
28
28
  # Allows nullable values to be set to nil. This is useful when doing an
@@ -8,6 +8,7 @@ module Cocina
8
8
  # TitleBuilder selects the prefered title from the cocina object for solr indexing
9
9
  class TitleBuilder # rubocop:disable Metrics/ClassLength
10
10
  extend Deprecation
11
+
11
12
  # @param [Array<Cocina::Models::Title,Cocina::Models::DescriptiveValue>] titles the titles to consider
12
13
  # @param [Array<Cocina::Models::FolioCatalogLink>] catalog_links the folio catalog links to check for digital serials part labels
13
14
  # @param [Symbol] strategy ":first" is the strategy for selection when primary or display
@@ -5,23 +5,23 @@ module Cocina
5
5
  # A common interface for interrogating a model instance's type
6
6
  module Checkable
7
7
  def admin_policy?
8
- (self.class::TYPES & AdminPolicy::TYPES).any?
8
+ self.class::TYPES.intersect?(AdminPolicy::TYPES)
9
9
  end
10
10
 
11
11
  def collection?
12
- (self.class::TYPES & Collection::TYPES).any?
12
+ self.class::TYPES.intersect?(Collection::TYPES)
13
13
  end
14
14
 
15
15
  def dro?
16
- (self.class::TYPES & DRO::TYPES).any?
16
+ self.class::TYPES.intersect?(DRO::TYPES)
17
17
  end
18
18
 
19
19
  def file?
20
- (self.class::TYPES & File::TYPES).any?
20
+ self.class::TYPES.intersect?(File::TYPES)
21
21
  end
22
22
 
23
23
  def file_set?
24
- (self.class::TYPES & FileSet::TYPES).any?
24
+ self.class::TYPES.intersect?(FileSet::TYPES)
25
25
  end
26
26
  end
27
27
  end
@@ -91,8 +91,8 @@ module Cocina
91
91
 
92
92
  def geographic_and_geographic_code?(subject, subject_values)
93
93
  subject.type == 'place' &&
94
- subject_values.count(&:value) == 1 &&
95
- subject_values.count(&:code) == 1
94
+ subject_values.one?(&:value) &&
95
+ subject_values.one?(&:code)
96
96
  end
97
97
 
98
98
  # rubocop:disable Metrics/CyclomaticComplexity
@@ -7,9 +7,9 @@ module Cocina
7
7
  extend ActiveSupport::Concern
8
8
 
9
9
  class_methods do
10
- def new(attributes = default_attributes, safe = false, validate = true, &block)
10
+ def new(attributes = default_attributes, safe = false, validate = true, &)
11
11
  Validators::Validator.validate(self, attributes) if validate
12
- super(attributes, safe, &block)
12
+ super(attributes, safe, &)
13
13
  end
14
14
  end
15
15
 
@@ -61,13 +61,13 @@ module Cocina
61
61
  end
62
62
 
63
63
  def dro?
64
- (clazz::TYPES & DRO::TYPES).any?
64
+ clazz::TYPES.intersect?(DRO::TYPES)
65
65
  rescue NameError
66
66
  false
67
67
  end
68
68
 
69
69
  def collection?
70
- (clazz::TYPES & Collection::TYPES).any?
70
+ clazz::TYPES.intersect?(Collection::TYPES)
71
71
  rescue NameError
72
72
  false
73
73
  end
@@ -33,7 +33,7 @@ module Cocina
33
33
  end
34
34
 
35
35
  def dro?
36
- (clazz::TYPES & DRO::TYPES).any?
36
+ clazz::TYPES.intersect?(DRO::TYPES)
37
37
  rescue NameError
38
38
  false
39
39
  end
@@ -64,6 +64,8 @@ module Cocina
64
64
  end
65
65
 
66
66
  def valid_edtf?(value)
67
+ return false if value == 'XXXX' # Not permitted by the spec, but allowed in the gem. https://github.com/inukshuk/edtf-ruby/issues/41
68
+
67
69
  Date.edtf!(value)
68
70
  true
69
71
  rescue StandardError
@@ -62,22 +62,30 @@ module Cocina
62
62
  end
63
63
 
64
64
  def validate_values_for_multiples(hash, path)
65
- return unless hash.count { |key, value| %i[value groupedValue structuredValue parallelValue].include?(key) && value.present? } > 1
65
+ return unless hash.count { |key, value| %w[value groupedValue structuredValue parallelValue].include?(key) && value.present? } > 1
66
66
 
67
67
  error_paths_multiple << path_to_s(path)
68
68
  end
69
69
 
70
70
  def validate_title_type(hash, path)
71
71
  # only apply to title.structuredValue, title.parallelValue.structuredValue, or relatedResource.title with a value
72
- return unless hash[:value] && (path.first == :title || related_resource_title?(path)) && path.include?(:structuredValue)
72
+ return unless hash[:value] && (structured_value_title?(path) || related_resource_title?(path))
73
73
 
74
74
  # if there is a "value" key, make sure there is also a "type" key, only for title.structuredValue
75
75
  error_paths_missing_title_type << path_to_s(path) unless hash[:type]
76
76
  end
77
77
 
78
78
  def related_resource_title?(path)
79
- # title is directly within relatedResource, e.g [:relatedResource, 0, :title, 0, :structuredValue, 0])
80
- path.first == :relatedResource && path[2] == :title
79
+ # title is within relatedResource, e.g ["relatedResource", 0, "title", 0, "structuredValue", 0])
80
+ structured_value_path = path[4] == 'structuredValue' || (path[4] == 'parallelValue' && path[6] == 'structuredValue')
81
+ path.first == 'relatedResource' && path[2] == 'title' && structured_value_path
82
+ end
83
+
84
+ def structured_value_title?(path)
85
+ # title path includes a structuredValue directly or within a parallelValue
86
+ # e.g. ["title", 0, "structuredValue", 0] or ["title", 0, "parallelValue", 0, "structuredValue", 0])
87
+ structured_value_path = path[2] == 'structuredValue' || (path[2] == 'parallelValue' && path[4] == 'structuredValue')
88
+ path.first == 'title' && structured_value_path
81
89
  end
82
90
 
83
91
  def path_to_s(path)
@@ -32,7 +32,7 @@ module Cocina
32
32
  end
33
33
 
34
34
  def dro?
35
- (clazz::TYPES & DRO::TYPES).any?
35
+ clazz::TYPES.intersect?(DRO::TYPES)
36
36
  rescue NameError
37
37
  false
38
38
  end
@@ -28,7 +28,7 @@ module Cocina
28
28
  attr_reader :clazz, :attributes
29
29
 
30
30
  def dro?
31
- (clazz::TYPES & DRO::TYPES).any? && attributes[:externalIdentifier].present?
31
+ clazz::TYPES.intersect?(DRO::TYPES) && attributes[:externalIdentifier].present?
32
32
  rescue NameError
33
33
  false
34
34
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.105.2'
5
+ VERSION = '0.107.0'
6
6
  end
7
7
  end
@@ -80,8 +80,8 @@ module Cocina
80
80
 
81
81
  REQUEST_ADMIN_POLICY_DEFAULTS = ADMIN_POLICY_DEFAULTS.except(:id)
82
82
 
83
- def self.build_dro_properties(id:, **kwargs)
84
- build_request_dro_properties(**kwargs)
83
+ def self.build_dro_properties(id:, **)
84
+ build_request_dro_properties(**)
85
85
  .merge(externalIdentifier: id)
86
86
  .tap do |props|
87
87
  props[:description][:purl] = "https://purl.stanford.edu/#{id.delete_prefix('druid:')}"
@@ -134,8 +134,8 @@ module Cocina
134
134
  Cocina::Models.build_request(build_request_dro_properties(**REQUEST_DRO_DEFAULTS.merge(attributes)))
135
135
  end
136
136
 
137
- def self.build_collection_properties(id:, **kwargs)
138
- build_request_collection_properties(**kwargs)
137
+ def self.build_collection_properties(id:, **)
138
+ build_request_collection_properties(**)
139
139
  .merge(externalIdentifier: id)
140
140
  .tap do |props|
141
141
  props[:description][:purl] = "https://purl.stanford.edu/#{id.delete_prefix('druid:')}"
@@ -194,8 +194,8 @@ module Cocina
194
194
  Cocina::Models.build_request(build_request_admin_policy_properties(**REQUEST_ADMIN_POLICY_DEFAULTS.merge(attributes)))
195
195
  end
196
196
 
197
- def self.build_admin_policy_properties(id:, **kwargs)
198
- build_request_admin_policy_properties(**kwargs)
197
+ def self.build_admin_policy_properties(id:, **)
198
+ build_request_admin_policy_properties(**)
199
199
  .merge(externalIdentifier: id)
200
200
  .tap do |props|
201
201
  props[:description][:purl] = "https://purl.stanford.edu/#{id.delete_prefix('druid:')}"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocina-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.105.2
4
+ version: 0.107.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-08-14 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport
@@ -528,14 +528,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
528
528
  requirements:
529
529
  - - ">="
530
530
  - !ruby/object:Gem::Version
531
- version: '3.0'
531
+ version: '3.4'
532
532
  required_rubygems_version: !ruby/object:Gem::Requirement
533
533
  requirements:
534
534
  - - ">="
535
535
  - !ruby/object:Gem::Version
536
536
  version: '0'
537
537
  requirements: []
538
- rubygems_version: 3.6.2
538
+ rubygems_version: 3.7.0
539
539
  specification_version: 4
540
540
  summary: Data models for the SDR
541
541
  test_files: []