cocina-models 0.94.1 → 0.95.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38c6748d5c7659224f4139fc5d96b6b58732183bf133bb8ea32657a81fadc9ff
4
- data.tar.gz: 29615bf905de450af973bd8a7ee00d0cd45810a8d2bd2b55166b2e686e0e048f
3
+ metadata.gz: b9e38c26d285ece89fdd8adb1faf3cc5fd19bb4c905d7cdb7a3a338948bcd43d
4
+ data.tar.gz: 27aec9cce87dff1300ae06216eed4b9b8c7d2f449e6d8e5eebf209c99a201b94
5
5
  SHA512:
6
- metadata.gz: 3d6192a5bc54d0133483649d0bf421a4ce32f85b328d9cda131a6ce8aff7df180b045de1b58d5c78836a7ec53e326b04a141e3a616046febfc31650ec8ef4e80
7
- data.tar.gz: 93069e72c38d812ddd493c0de9abcb80a0733fad353a36721821250cbf8c36482b1711748760a8f9a1cbc8fa4915654cf4236496f4a99eaa4ab8e687fee74cbe
6
+ metadata.gz: f9c71b2c8b8740baf151eb3dfe150e9a614cc9c655c03f8cbf4924f884d7ce94c2909ec9e5d9a229eac56bc694cc8b9d8142072762b120e2edba98e7fe49f137
7
+ data.tar.gz: 8cd9dd1787b286a9816714bf75b5d99a246ac390a914ffc83bbd6c9e79bc0d0cca1644cb4d2c16e1bbbd687a2407b3565645693ab6ac5ef60bf9ab564c4eef59
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocina-models (0.94.1)
4
+ cocina-models (0.95.0)
5
5
  activesupport
6
6
  deprecation
7
7
  dry-struct (~> 1.0)
@@ -121,7 +121,7 @@ GEM
121
121
  rspec-core (>= 2, < 4, != 2.12.0)
122
122
  rss (0.3.0)
123
123
  rexml
124
- rubocop (1.60.1)
124
+ rubocop (1.60.2)
125
125
  json (~> 2.3)
126
126
  language_server-protocol (>= 3.17.0)
127
127
  parallel (~> 1.10)
data/README.md CHANGED
@@ -143,7 +143,7 @@ which pushes the gem to rubygems.org.
143
143
 
144
144
  ### Step 2: Update client gems coupled to the models
145
145
 
146
- Release new versions of [sdr-client](https://github.com/sul-dlss/sdr-client), [dor-services-client](https://github.com/sul-dlss/dor-services-client/), and [dor_indexing](https://github.com/sul-dlss/dor_indexing/) pinned to use the new cocina-models version because applications such as [Argo](https://github.com/sul-dlss/argo) depend on both of these gems using the same models.
146
+ Release new versions of [sdr-client](https://github.com/sul-dlss/sdr-client), [dor-services-client](https://github.com/sul-dlss/dor-services-client/), and [dor_indexing](https://github.com/sul-dlss/dor_indexing/) pinned to use the new cocina-models version because applications such as [Argo](https://github.com/sul-dlss/argo) and [Dor-Services-App](https://github.com/sul-dlss/dor-services-app)depend on these gems using the same models.
147
147
 
148
148
  ### Step 3: Update services directly coupled to the models
149
149
 
@@ -164,7 +164,9 @@ This can be accomplished by copying and pasting the cocina-models schemas to the
164
164
 
165
165
  If step 3A was needed, use the same PRs to also bump the versions of cocina-models, sdr-client, and dor-services-client in these applications/services. Why? When [dor-services-app](https://github.com/sul-dlss/dor-services-app), for example, is updated to use the new models (via the auto-update script), these clients should be updated at the same time or there is risk of models produced by dor-services-app not being acceptable to the clients.
166
166
 
167
- With or without step 3A, perform `bundle update` for cocina-models, sdr-client, and dor-services-client gems in the listed services and then make PRs for those repos.
167
+ With or without step 3A, perform `bundle update` for cocina-models, sdr-client, dor-services-client and dor_indexing* gems in the listed services and then make PRs for those repos.
168
+
169
+ * dor_indexing gem is used by dor_indexing_app and dor-services-app only.
168
170
 
169
171
  #### Step 3C: Merge 'em
170
172
 
@@ -201,6 +201,16 @@ module Cocina
201
201
  # @return [String] the title value from combining the pieces of the structured_values by type and order
202
202
  # with desired punctuation per specs
203
203
  #
204
+ # - nonsorting characters value is followed by a space, unless the nonsorting
205
+ # character count note has a numeric value equal to the length of the
206
+ # nonsorting characters value, in which case no space is inserted
207
+ # - subtitle is preceded by space colon space, unless it is at the beginning
208
+ # of the title string
209
+ # - partName and partNumber are always separated from each other by comma space
210
+ # - first partName or partNumber in the string is preceded by period space
211
+ # - partName or partNumber before nonsorting characters or main title is followed
212
+ # by period space
213
+ #
204
214
  # for punctuaion funky town, thank MARC and catalog cards
205
215
  #
206
216
  # rubocop:disable Metrics/AbcSize
@@ -245,7 +255,7 @@ module Cocina
245
255
  end
246
256
  when 'subtitle'
247
257
  result = if !add_punctuation?
248
- [result, value].select(&:presence).join(' ')
258
+ [result, value.sub(/^:/, '').strip].select(&:presence).join(' ')
249
259
  elsif result.present?
250
260
  # subtitle is preceded by space colon space, unless it is at the beginning of the title string
251
261
  "#{result.sub(/[. :]+$/, '')} : #{value.sub(/^:/, '').strip}"
@@ -14,6 +14,7 @@ module Cocina
14
14
  @attributes = attributes
15
15
  @error_paths_multiple = []
16
16
  @error_paths_blank = []
17
+ @error_paths_missing_title_type = []
17
18
  end
18
19
 
19
20
  def validate
@@ -23,11 +24,12 @@ module Cocina
23
24
 
24
25
  raise ValidationError, "Multiple value, groupedValue, structuredValue, and parallelValue in description: #{error_paths_multiple.join(', ')}" unless error_paths_multiple.empty?
25
26
  raise ValidationError, "Blank value in description: #{error_paths_blank.join(', ')}" unless error_paths_blank.empty?
27
+ raise ValidationError, "Missing type for value in description: #{error_paths_missing_title_type.join(', ')}" unless error_paths_missing_title_type.empty?
26
28
  end
27
29
 
28
30
  private
29
31
 
30
- attr_reader :clazz, :attributes, :error_paths_blank, :error_paths_multiple
32
+ attr_reader :clazz, :attributes, :error_paths_blank, :error_paths_multiple, :error_paths_missing_title_type
31
33
 
32
34
  def meets_preconditions?
33
35
  [Cocina::Models::Description, Cocina::Models::RequestDescription].include?(clazz)
@@ -36,6 +38,7 @@ module Cocina
36
38
  def validate_hash(hash, path)
37
39
  validate_values_for_blanks(hash, path)
38
40
  validate_values_for_multiples(hash, path)
41
+ validate_title_type(hash, path)
39
42
  hash.each do |key, obj|
40
43
  validate_obj(obj, path + [key])
41
44
  end
@@ -64,6 +67,19 @@ module Cocina
64
67
  error_paths_multiple << path_to_s(path)
65
68
  end
66
69
 
70
+ def validate_title_type(hash, path)
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)
73
+
74
+ # if there is a "value" key, make sure there is also a "type" key, only for title.structuredValue
75
+ error_paths_missing_title_type << path_to_s(path) unless hash[:type]
76
+ end
77
+
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
81
+ end
82
+
67
83
  def path_to_s(path)
68
84
  # This matches the format used by descriptive spreadsheets
69
85
  path_str = ''
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.94.1'
5
+ VERSION = '0.95.0'
6
6
  end
7
7
  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.94.1
4
+ version: 0.95.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-01-23 00:00:00.000000000 Z
11
+ date: 2024-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -562,7 +562,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
562
562
  - !ruby/object:Gem::Version
563
563
  version: '0'
564
564
  requirements: []
565
- rubygems_version: 3.4.13
565
+ rubygems_version: 3.4.10
566
566
  signing_key:
567
567
  specification_version: 4
568
568
  summary: Data models for the SDR