cocina-models 0.96.0 → 0.98.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: da05dda48140bb467d82b84614b44beea26884fcd4cd0891a507a53e6f967e5b
4
- data.tar.gz: 322900e86d817d5d65820389fb7a6a13c92d98e4b9d6f2150e49de4ddd34785a
3
+ metadata.gz: 760c4c58f3a365278d5a1b96607435cf99a3ac73cd070fce630ed99e40ebeb51
4
+ data.tar.gz: 9b66dd57dc5ed2b5a2eb3638ceb3ab5f10e1efe9bb8c5df5395c480c1c9b3bbd
5
5
  SHA512:
6
- metadata.gz: ce287a4da425257a40eb13e68f7eb7c2819fcd4658cef4d1fa81dae961d4e47df7a33ed2fe385e69a122c5542f73e42a441064e8d4f36fdafa8fdf6cc1bdaa84
7
- data.tar.gz: cf060d2984d736229e2fbd68ba28e7b3b68efae7e4f393ca0c6bdf7d09fa6ccaa8cfc6c2c0924b37c498b2d762b5817c36a74f31953a72550cd68b748ecdd355
6
+ metadata.gz: baaa5f6697353b9a261d0976d5ed6d60a79c87d2f2a83912c40c63e3dab3b3e30506f2fa86a93b7d35b681d5eb1a1222f2c31ee030259730155b99926fe2565b
7
+ data.tar.gz: 4cd05c60b8263e1cc39cbef3bca5b469a55c6f2c206cb260d56d5d6acc492ad29cab978e71ce8d8b3544a5151f5e9c1e606539e952fed68fe51b0dbf165cb987
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.1.0
3
+ ruby-rails: sul-dlss/ruby-rails@4.2.1
4
4
  workflows:
5
5
  build:
6
6
  jobs:
data/.rubocop.yml CHANGED
@@ -303,7 +303,7 @@ RSpec/SubjectDeclaration: # new in 2.5
303
303
  Enabled: true
304
304
  FactoryBot/SyntaxMethods: # new in 2.7
305
305
  Enabled: true
306
- RSpec/Rails/AvoidSetupHook: # new in 2.4
306
+ RSpecRails/AvoidSetupHook: # new in 2.4
307
307
  Enabled: true
308
308
  Style/NestedFileDirname: # new in 1.26
309
309
  Enabled: true
@@ -343,7 +343,7 @@ RSpec/ChangeByZero: # new in 2.11.0
343
343
  Enabled: true
344
344
  Capybara/SpecificMatcher: # new in 2.12
345
345
  Enabled: false
346
- RSpec/Rails/HaveHttpStatus: # new in 2.12
346
+ RSpecRails/HaveHttpStatus: # new in 2.12
347
347
  Enabled: false
348
348
 
349
349
  RSpec/ClassCheck: # new in 2.13
@@ -394,9 +394,9 @@ FactoryBot/ConsistentParenthesesStyle: # new in 2.14
394
394
  Enabled: true
395
395
  FactoryBot/FactoryNameStyle: # new in 2.16
396
396
  Enabled: true
397
- RSpec/Rails/InferredSpecType: # new in 2.14
397
+ RSpecRails/InferredSpecType: # new in 2.14
398
398
  Enabled: true
399
- RSpec/Rails/MinitestAssertions: # new in 2.17
399
+ RSpecRails/MinitestAssertions: # new in 2.17
400
400
  Enabled: true
401
401
  Style/RedundantHeredocDelimiterQuotes: # new in 1.45
402
402
  Enabled: true
@@ -411,7 +411,7 @@ RSpec/RedundantAround: # new in 2.19
411
411
  Enabled: true
412
412
  RSpec/SkipBlockInsideExample: # new in 2.19
413
413
  Enabled: true
414
- RSpec/Rails/TravelAround: # new in 2.19
414
+ RSpecRails/TravelAround: # new in 2.19
415
415
  Enabled: true
416
416
 
417
417
  Lint/DuplicateMatchPattern: # new in 1.50
@@ -457,7 +457,7 @@ Style/YAMLFileRead: # new in 1.53
457
457
  Enabled: true
458
458
  RSpec/ReceiveMessages: # new in 2.23
459
459
  Enabled: true
460
- RSpec/Rails/NegationBeValid: # new in 2.23
460
+ RSpecRails/NegationBeValid: # new in 2.23
461
461
  Enabled: true
462
462
 
463
463
  Lint/ItWithoutArgumentsInBlock: # new in 1.59
@@ -498,3 +498,16 @@ RSpec/IsExpectedSpecify: # new in 2.27
498
498
  Enabled: true
499
499
  RSpec/RepeatedSubjectCall: # new in 2.27
500
500
  Enabled: true
501
+
502
+ Style/MapIntoArray: # new in 1.63
503
+ Enabled: true
504
+ Style/SendWithLiteralMethodName: # new in 1.64
505
+ Enabled: true
506
+ Style/SuperArguments: # new in 1.64
507
+ Enabled: true
508
+ RSpec/EmptyOutput: # new in 2.29
509
+ Enabled: true
510
+ RSpec/ExpectInLet: # new in 2.30
511
+ Enabled: true
512
+ RSpec/UndescriptiveLiteralsDescription: # new in 2.29
513
+ Enabled: true
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocina-models (0.96.0)
4
+ cocina-models (0.98.0)
5
5
  activesupport
6
6
  deprecation
7
7
  dry-struct (~> 1.0)
@@ -13,7 +13,6 @@ PATH
13
13
  nokogiri
14
14
  openapi3_parser
15
15
  openapi_parser (~> 1.0)
16
- rss
17
16
  super_diff
18
17
  thor
19
18
  zeitwerk (~> 2.1)
@@ -21,7 +20,7 @@ PATH
21
20
  GEM
22
21
  remote: https://rubygems.org/
23
22
  specs:
24
- activesupport (7.1.3.2)
23
+ activesupport (7.1.3.4)
25
24
  base64
26
25
  bigdecimal
27
26
  concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -34,14 +33,15 @@ GEM
34
33
  ast (2.4.2)
35
34
  attr_extras (7.1.0)
36
35
  base64 (0.2.0)
37
- bigdecimal (3.1.7)
36
+ bigdecimal (3.1.8)
38
37
  byebug (11.1.3)
39
38
  committee (5.0.0)
40
39
  json_schema (~> 0.14, >= 0.14.3)
41
40
  openapi_parser (~> 1.0)
42
41
  rack (>= 1.5)
43
- commonmarker (0.23.10)
44
- concurrent-ruby (1.2.3)
42
+ commonmarker (1.1.4)
43
+ rb_sys (~> 0.9)
44
+ concurrent-ruby (1.3.3)
45
45
  connection_pool (2.4.1)
46
46
  deprecation (1.1.0)
47
47
  activesupport
@@ -72,37 +72,39 @@ GEM
72
72
  activesupport (>= 3.0, < 8.0)
73
73
  equivalent-xml (0.6.0)
74
74
  nokogiri (>= 1.4.3)
75
- i18n (1.14.4)
75
+ i18n (1.14.5)
76
76
  concurrent-ruby (~> 1.0)
77
77
  ice_nine (0.11.2)
78
- json (2.7.1)
78
+ json (2.7.2)
79
79
  json_schema (0.21.0)
80
80
  jsonpath (1.1.5)
81
81
  multi_json
82
82
  language_server-protocol (3.17.0.3)
83
- mini_portile2 (2.8.5)
84
- minitest (5.22.3)
83
+ mini_portile2 (2.8.7)
84
+ minitest (5.23.1)
85
85
  multi_json (1.15.0)
86
86
  mutex_m (0.2.0)
87
- nokogiri (1.16.3)
87
+ nokogiri (1.16.5)
88
88
  mini_portile2 (~> 2.8.2)
89
89
  racc (~> 1.4)
90
- openapi3_parser (0.9.2)
91
- commonmarker (~> 0.17)
90
+ openapi3_parser (0.10.0)
91
+ commonmarker (>= 1.0)
92
92
  openapi_parser (1.0.0)
93
93
  optimist (3.1.0)
94
- parallel (1.24.0)
95
- parser (3.3.0.5)
94
+ parallel (1.25.1)
95
+ parser (3.3.2.0)
96
96
  ast (~> 2.4.1)
97
97
  racc
98
98
  patience_diff (1.2.0)
99
99
  optimist (~> 3.0)
100
- racc (1.7.3)
101
- rack (3.0.10)
100
+ racc (1.8.0)
101
+ rack (3.0.11)
102
102
  rainbow (3.1.1)
103
- rake (13.1.0)
104
- regexp_parser (2.9.0)
105
- rexml (3.2.6)
103
+ rake (13.2.1)
104
+ rb_sys (0.9.97)
105
+ regexp_parser (2.9.2)
106
+ rexml (3.2.9)
107
+ strscan
106
108
  rspec (3.13.0)
107
109
  rspec-core (~> 3.13.0)
108
110
  rspec-expectations (~> 3.13.0)
@@ -112,15 +114,13 @@ GEM
112
114
  rspec-expectations (3.13.0)
113
115
  diff-lcs (>= 1.2.0, < 2.0)
114
116
  rspec-support (~> 3.13.0)
115
- rspec-mocks (3.13.0)
117
+ rspec-mocks (3.13.1)
116
118
  diff-lcs (>= 1.2.0, < 2.0)
117
119
  rspec-support (~> 3.13.0)
118
120
  rspec-support (3.13.1)
119
121
  rspec_junit_formatter (0.6.0)
120
122
  rspec-core (>= 2, < 4, != 2.12.0)
121
- rss (0.3.0)
122
- rexml
123
- rubocop (1.62.1)
123
+ rubocop (1.64.1)
124
124
  json (~> 2.3)
125
125
  language_server-protocol (>= 3.17.0)
126
126
  parallel (~> 1.10)
@@ -131,18 +131,21 @@ GEM
131
131
  rubocop-ast (>= 1.31.1, < 2.0)
132
132
  ruby-progressbar (~> 1.7)
133
133
  unicode-display_width (>= 2.4.0, < 3.0)
134
- rubocop-ast (1.31.2)
135
- parser (>= 3.3.0.4)
136
- rubocop-capybara (2.20.0)
134
+ rubocop-ast (1.31.3)
135
+ parser (>= 3.3.1.0)
136
+ rubocop-capybara (2.21.0)
137
137
  rubocop (~> 1.41)
138
- rubocop-factory_bot (2.25.1)
138
+ rubocop-factory_bot (2.26.0)
139
139
  rubocop (~> 1.41)
140
140
  rubocop-rake (0.6.0)
141
141
  rubocop (~> 1.0)
142
- rubocop-rspec (2.27.1)
142
+ rubocop-rspec (2.31.0)
143
143
  rubocop (~> 1.40)
144
144
  rubocop-capybara (~> 2.17)
145
145
  rubocop-factory_bot (~> 2.22)
146
+ rubocop-rspec_rails (~> 2.28)
147
+ rubocop-rspec_rails (2.29.0)
148
+ rubocop (~> 1.40)
146
149
  ruby-progressbar (1.13.0)
147
150
  simplecov (0.22.0)
148
151
  docile (~> 1.1)
@@ -150,7 +153,8 @@ GEM
150
153
  simplecov_json_formatter (~> 0.1)
151
154
  simplecov-html (0.12.3)
152
155
  simplecov_json_formatter (0.1.4)
153
- super_diff (0.11.0)
156
+ strscan (3.1.0)
157
+ super_diff (0.12.1)
154
158
  attr_extras (>= 6.2.4)
155
159
  diff-lcs
156
160
  patience_diff
@@ -158,7 +162,7 @@ GEM
158
162
  tzinfo (2.0.6)
159
163
  concurrent-ruby (~> 1.0)
160
164
  unicode-display_width (2.5.0)
161
- zeitwerk (2.6.13)
165
+ zeitwerk (2.6.15)
162
166
 
163
167
  PLATFORMS
164
168
  ruby
data/README.md CHANGED
@@ -53,10 +53,10 @@ Beyond what is necessary to test the generator, the Cocina model classes are not
53
53
 
54
54
  ## Testing validation changes
55
55
 
56
- If there is a possibility that a model, mapping, or validation change will conflict with some existing objects then [validate-cocina](https://github.com/sul-dlss/dor-services-app/blob/main/bin/validate-cocina) should be used for testing. This must be run on sdr-infra since it requires deploying a branch of cocina-models.
56
+ If there is a possibility that a model, mapping, or validation change will conflict with some existing objects then [validate-cocina](https://github.com/sul-dlss/dor-services-app/blob/main/bin/validate-cocina) should be used for testing. This must be run on the `sdr-infra` VM since it requires deploying a branch of cocina-models.
57
57
 
58
58
  1. Create a cocina-models branch containing the proposed change and push to GitHub.
59
- 2. On sdr-infra, check out `main`, update the `Gemfile` so that cocina-models references the branch, and `bundle install`.
59
+ 2. On the `sdr-infra` VM, while logged in as the `deploy` user, check out `main`, update the `Gemfile` so that cocina-models references the branch, and `bundle install`.
60
60
  3. Select the appropriate environment vars below - they are set to values in puppet. (first 2 lines are the same; last two lines use different variables)
61
61
 
62
62
  For QA:
@@ -94,33 +94,30 @@ RAILS_ENV=production bin/validate-cocina -p 8
94
94
 
95
95
  Custom reports stored in dor-services-app can be run similarly to validation testing described above.
96
96
 
97
- 1. Go the sdr-infra box:
98
-
99
- ```
100
- ssh deploy@sdr-infra
101
- ```
102
-
103
- 2. Go to the dor-services-app directory and reset to main if needed (verify nobody else is using this first though):
104
-
105
- ```
106
- cd dor-services-app
107
- git status # see if there are any unsaved changes, if so, you may need to git stash them
108
- git pull # OR git reset --hard main to just ditch any local unsaved changes
109
- ```
110
-
111
- 3. Connect to the desired database by setting the environment variables as described in the section above. This must be done each time you SSH back into the box to run a new report.
112
-
113
- 4. Run the report (good idea to do it in a screen or via background process in case you get disconnected):
114
-
115
- ```
116
- bundle exec bin/rails r -e production "BadIso8601Dates.report" > BadIso8601Dates.csv
117
- ```
118
-
119
- 5. When done, you can pull the report to your laptop as needed:
120
-
121
- ```
122
- scp deploy@sdr-infra:/opt/app/deploy/dor-services-app/BadIso8601Dates.csv BadIso8601Dates.csv
123
- ```
97
+ 1. Connect to the `sdr-infra` box:
98
+ ```shell
99
+ ssh sdr-infra
100
+ ```
101
+ 1. Start a shell as the `deploy` user:
102
+ ```shell
103
+ # you may or may not need to supply the `-n SUNETID` argument
104
+ ksu deploy
105
+ ```
106
+ 1. Go to the `~/dor-services-app` directory and reset to main if needed (verify nobody else is using this first though):
107
+ ```shell
108
+ cd ~/dor-services-app
109
+ git status # see if there are any unsaved changes, if so, you may need to git stash them
110
+ git pull # OR git reset --hard main to just ditch any local unsaved changes
111
+ ```
112
+ 1. Connect to the desired database by setting the environment variables as described in the section above. This must be done each time you SSH back into the box to run a new report.
113
+ 1. Run the report (good idea to do it in a screen or via background process in case you get disconnected):
114
+ ```shell
115
+ bundle exec bin/rails r -e production "BadIso8601Dates.report" > BadIso8601Dates.csv
116
+ ```
117
+ 1. When done, you can pull the report to your laptop as needed:
118
+ ```shell
119
+ scp sdr-infra:/opt/app/deploy/dor-services-app/BadIso8601Dates.csv .
120
+ ```
124
121
 
125
122
  ## Releasing a patch change
126
123
  A patch change is a change that (1) does not affect the data model; (2) does not alter the openapi.yml; and more broadly (3) does not matter if some applications have the change and others do not.
@@ -129,6 +126,14 @@ A patch change can be released as part of regular dependency updates or selectiv
129
126
 
130
127
  ## Releasing major or minor change
131
128
 
129
+ NOTE: If dependency updates are about to be released, you have the option of shortening the process and stopping after Step 3. This is because Steps 4 onwards will be taken care of by the regular dependency updates process (basically the updating of cocina-models, dor-services-client and sdr-client as needed in the rest of the associated apps). You still do need to manually bump some gems and the pinned version of cocina-models in a couple apps and get those PRs approved and merged, as described in Steps 1-3 below.
130
+
131
+ IMPORTANT: If you do opt to skip steps 4 onward, you should NOT merge the cocina-models bump dor-services-app and sdr-api PRs you created in step 3 until you are ready to finish the dependency updates process. You can have them reviewed and approved, but if you merge, you will greatly increase the risk of issues if the main branch of DSA or sdr-api are deployed after steps 1-3 are complete but before the rest of the apps are updated to use the new cocina-models via regular dependency updates. The fix for this is to either roll-back DSA and sdr-api to the previous release tag, or proceed forwards with step 4-5.
132
+
133
+ Before you release a major or minor change, think about if this release will include new validations. Even if your change didn't make any changes that would affect validation, there may be other unreleased changes since the previous version of the gem was cut and released. Best practice is to scan back through the commit history until you get to the last version bump and see if there any significant changes that may affect validation.
134
+
135
+ If unsure, ask the team or ask for help to just run the validation report anyway (as described above).
136
+
132
137
  ### Step 0: Share intent to change the models
133
138
 
134
139
  Send a note to `#dlss-infra-chg-mgmt` on Slack to let people know what is changing and when.
@@ -143,7 +148,7 @@ which pushes the gem to rubygems.org.
143
148
 
144
149
  ### Step 2: Update client gems coupled to the models
145
150
 
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.
151
+ Release new versions of [sdr-client](https://github.com/sul-dlss/sdr-client) and [dor-services-client](https://github.com/sul-dlss/dor-services-client/) 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
152
 
148
153
  ### Step 3: Update services directly coupled to the models
149
154
 
@@ -164,9 +169,7 @@ This can be accomplished by copying and pasting the cocina-models schemas to the
164
169
 
165
170
  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
171
 
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. You may need to update how these gems are pinned in the `Gemfile` in order to bump them.
168
-
169
- NOTE: dor_indexing gem is used by dor-services-app and dor_indexing_app only. dor_indexing_app does NOT need to be updated in this step.
172
+ 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. You may first need to update how these gems are pinned in the `Gemfile` in order to bump them. Note that dor-services-app only needs a bump to cocina-models gem and sdr-api only needs a bump to cocina-models and dor-services-client gems.
170
173
 
171
174
  #### Step 3C: Merge 'em
172
175
 
@@ -186,7 +189,7 @@ If for some reason the above method does not work, the sul-dlss/access-update-sc
186
189
 
187
190
  #### Step 4B: Merge the Cocina Level 2 PRs
188
191
 
189
- [sul-dlss/access-update-scripts](https://github.com/sul-dlss/access-update-scripts) has a switch in the `merge-all.rb` script for this, as noted in the comments at the top of that script.
192
+ [sul-dlss/access-update-scripts](https://github.com/sul-dlss/access-update-scripts) has a switch in the `merge-all.rb` script for this, as noted in the comments at the top of that script.
190
193
  ```
191
194
  REPOS_PATH=infrastructure GH_ACCESS_TOKEN=abc123 COCINA_LEVEL2= ./merge-all.rb
192
195
  ```
@@ -37,7 +37,6 @@ Gem::Specification.new do |spec|
37
37
  # Match these version requirements to what committee wants,
38
38
  # so that our client (non-committee) users have the same dependencies.
39
39
  spec.add_dependency 'openapi_parser', '~> 1.0'
40
- spec.add_dependency 'rss' # used for date/time validation
41
40
  spec.add_dependency 'super_diff'
42
41
  spec.add_dependency 'thor'
43
42
  spec.add_dependency 'zeitwerk', '~> 2.1'
@@ -127,11 +127,12 @@ module Cocina
127
127
  run("rubocop -a #{filepaths.join(' ')} > /dev/null")
128
128
  end
129
129
 
130
- NO_CLEAN = [
131
- 'checkable.rb',
132
- 'validatable.rb',
133
- 'version.rb',
134
- 'vocabulary.rb'
130
+ NO_CLEAN = %w[
131
+ checkable.rb
132
+ utils.rb
133
+ validatable.rb
134
+ version.rb
135
+ vocabulary.rb
135
136
  ].freeze
136
137
 
137
138
  def clean_output
@@ -5,7 +5,6 @@ module Cocina
5
5
  class Administrative < Struct
6
6
  # example: druid:bc123df4567
7
7
  attribute :hasAdminPolicy, Druid
8
- attribute :releaseTags, Types::Strict::Array.of(ReleaseTag).default([].freeze)
9
8
  end
10
9
  end
11
10
  end
@@ -71,11 +71,7 @@ module Cocina
71
71
  def self.contributor_name_value_slices(contributor)
72
72
  return if contributor&.name.blank?
73
73
 
74
- slices = []
75
- Array(contributor.name).each do |contrib_name|
76
- slices << value_slices(contrib_name)
77
- end
78
- slices.flatten
74
+ Array(contributor.name).map { |contrib_name| value_slices(contrib_name) }.flatten
79
75
  end
80
76
 
81
77
  # @params [Cocina::Models::DescriptiveValue] desc_value
@@ -24,8 +24,12 @@ module Cocina
24
24
  attribute? :hasMimeType, Types::Strict::String
25
25
  # BCP 47 language tag: https://www.rfc-editor.org/rfc/rfc4646.txt -- other applications (like media players) expect language codes of this format, see e.g. https://videojs.com/guides/text-tracks/#srclang
26
26
  attribute? :languageTag, LanguageTag.optional
27
- # Use for the File.
27
+ # Use for the File (e.g. "transcription" for OCR).
28
28
  attribute? :use, FileUse.optional
29
+ # Indicates if the text (OCR/captioning) was generated by SDR.
30
+ attribute? :sdrGeneratedText, Types::Strict::Bool.default(false)
31
+ # Indicates if text that has been verified for accessibility/correctness.
32
+ attribute? :correctedForAccessibility, Types::Strict::Bool.default(false)
29
33
  attribute :hasMessageDigests, Types::Strict::Array.of(MessageDigest).default([].freeze)
30
34
  attribute(:access, FileAccess.default { FileAccess.new })
31
35
  attribute(:administrative, FileAdministrative.default { FileAdministrative.new })
@@ -73,9 +73,8 @@ module Cocina
73
73
  end
74
74
 
75
75
  def build_note
76
- notes = []
77
- record_origins.each do |record_origin|
78
- notes << {
76
+ notes = record_origins.map do |record_origin|
77
+ {
79
78
  type: 'record origin',
80
79
  value: record_origin.text
81
80
  }
@@ -196,9 +196,8 @@ module Cocina
196
196
  end
197
197
 
198
198
  def build_date_values(origin_info_node)
199
- date_values = []
200
- DATE_ELEMENTS_2_TYPE.each do |mods_el_name, cocina_type|
201
- date_values << build_date_desc_values(mods_el_name, origin_info_node, cocina_type)
199
+ date_values = DATE_ELEMENTS_2_TYPE.map do |mods_el_name, cocina_type|
200
+ build_date_desc_values(mods_el_name, origin_info_node, cocina_type)
202
201
  end
203
202
  date_values.flatten.compact
204
203
  end
@@ -5,7 +5,6 @@ module Cocina
5
5
  class RequestAdministrative < Struct
6
6
  # example: druid:bc123df4567
7
7
  attribute :hasAdminPolicy, Druid
8
- attribute :releaseTags, Types::Strict::Array.of(ReleaseTag).default([].freeze)
9
8
  # Internal project this resource is a part of. This governs routing of messages about this object.
10
9
  # example: Google Books
11
10
  attribute? :partOfProject, Types::Strict::String
@@ -16,8 +16,12 @@ module Cocina
16
16
  # BCP 47 language tag: https://www.rfc-editor.org/rfc/rfc4646.txt -- other applications (like media players) expect language codes of this format, see e.g. https://videojs.com/guides/text-tracks/#srclang
17
17
  attribute? :languageTag, LanguageTag.optional
18
18
  attribute? :externalIdentifier, Types::Strict::String
19
- # Use for the File.
19
+ # Use for the File (e.g. "transcription" for OCR).
20
20
  attribute? :use, FileUse.optional
21
+ # Indicates if the text (OCR/captioning) was generated by SDR.
22
+ attribute? :sdrGeneratedText, Types::Strict::Bool.default(false)
23
+ # Indicates if text that has been verified for accessibility/correctness.
24
+ attribute? :correctedForAccessibility, Types::Strict::Bool.default(false)
21
25
  attribute :hasMessageDigests, Types::Strict::Array.of(MessageDigest).default([].freeze)
22
26
  attribute(:access, FileAccess.default { FileAccess.new })
23
27
  attribute(:administrative, FileAdministrative.default { FileAdministrative.new })
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ module Utils
6
+ # @param [Cocina::Models::Dro] dro
7
+ # @param [Array<Cocina::Models::File>]
8
+ def self.files(dro)
9
+ dro.structural.contains.flat_map do |fileset|
10
+ fileset.structural.contains
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -15,7 +15,7 @@ module Cocina
15
15
 
16
16
  def new(*args)
17
17
  validate = args.first.delete(:validate) if args.present?
18
- new_model = super(*args)
18
+ new_model = super
19
19
  Validators::Validator.validate(new_model.class, new_model) if validate || validate.nil?
20
20
  new_model
21
21
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'edtf'
4
4
  require 'jsonpath'
5
- require 'rss'
6
5
 
7
6
  module Cocina
8
7
  module Models
@@ -87,18 +86,7 @@ module Cocina
87
86
  end
88
87
 
89
88
  def valid_w3cdtf?(value)
90
- Time.w3cdtf(value)
91
- true
92
- rescue StandardError
93
- # NOTE: the upstream W3CDTF implementation in the `rss` gem does not
94
- # allow two patterns that should be valid per the specification:
95
- #
96
- # * YYYY
97
- # * YYYY-MM
98
- #
99
- # This catches the false positives from the upstream gem and allow
100
- # these two patterns to validate
101
- /\A\d{4}(-0[1-9]|-1[0-2])?\Z/.match?(value)
89
+ W3cdtfValidator.validate(value)
102
90
  end
103
91
 
104
92
  def druid
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ module Validators
6
+ # Validates w3cdtf date
7
+ class W3cdtfValidator
8
+ REGEX = /\A(?<year>\d{4})(?:-(?<month>\d\d)(?:-(?<day>\d\d)(?<time>T\d\d:\d\d(?::\d\d(?:.\d+)?)?(?:Z|[+-]\d\d:\d\d))?)?)?\z/ix
9
+
10
+ def self.validate(date)
11
+ new(date).validate
12
+ end
13
+
14
+ def initialize(date)
15
+ @date = date
16
+ end
17
+
18
+ # The W3CDTF format is defined here: http://www.w3.org/TR/NOTE-datetime
19
+ #
20
+ # Year:
21
+ # YYYY (eg 1997)
22
+ # Year and month:
23
+ # YYYY-MM (eg 1997-07)
24
+ # Complete date:
25
+ # YYYY-MM-DD (eg 1997-07-16)
26
+ # Complete date plus hours and minutes:
27
+ # YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
28
+ # Complete date plus hours, minutes and seconds:
29
+ # YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
30
+ # Complete date plus hours, minutes, seconds and a decimal fraction of a second
31
+ # YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
32
+ def validate
33
+ return false unless (matches = @date.match(REGEX))
34
+ return true unless matches[:month]
35
+ return (1..12).include? matches[:month].to_i unless matches[:day]
36
+
37
+ Date.parse(@date)
38
+
39
+ true
40
+ rescue Date::Error
41
+ false
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.96.0'
5
+ VERSION = '0.98.0'
6
6
  end
7
7
  end
data/openapi.yml CHANGED
@@ -229,11 +229,6 @@ components:
229
229
  properties:
230
230
  hasAdminPolicy:
231
231
  $ref: '#/components/schemas/Druid'
232
- releaseTags:
233
- description: Tags for release
234
- type: array
235
- items:
236
- $ref: '#/components/schemas/ReleaseTag'
237
232
  required:
238
233
  - hasAdminPolicy
239
234
  AdminPolicyAccessTemplate:
@@ -1049,6 +1044,14 @@ components:
1049
1044
  $ref: '#/components/schemas/LanguageTag'
1050
1045
  use:
1051
1046
  $ref: '#/components/schemas/FileUse'
1047
+ sdrGeneratedText:
1048
+ description: Indicates if the text (OCR/captioning) was generated by SDR.
1049
+ type: boolean
1050
+ default: false
1051
+ correctedForAccessibility:
1052
+ description: Indicates if text that has been verified for accessibility/correctness.
1053
+ type: boolean
1054
+ default: false
1052
1055
  hasMessageDigests:
1053
1056
  type: array
1054
1057
  items:
@@ -1144,7 +1147,7 @@ components:
1144
1147
  items:
1145
1148
  $ref: '#/components/schemas/File'
1146
1149
  FileUse:
1147
- description: Use for the File.
1150
+ description: Use for the File (e.g. "transcription" for OCR).
1148
1151
  type: string
1149
1152
  nullable: true
1150
1153
  FolioCatalogLink:
@@ -1520,35 +1523,6 @@ components:
1520
1523
  valueAt:
1521
1524
  description: URL or other pointer to the location of the related resource information.
1522
1525
  type: string
1523
- ReleaseTag:
1524
- description: A tag that indicates the item or collection should be released.
1525
- type: object
1526
- additionalProperties: false
1527
- required:
1528
- - release
1529
- - what
1530
- properties:
1531
- who:
1532
- description: Who did this release
1533
- type: string
1534
- example: petucket
1535
- what:
1536
- description: What is being released. This item or the whole collection.
1537
- type: string
1538
- enum:
1539
- - self
1540
- - collection
1541
- example: self
1542
- date:
1543
- description: When did this action happen
1544
- type: string
1545
- format: date-time
1546
- to:
1547
- description: What platform is it released to
1548
- type: string
1549
- example: Searchworks
1550
- release:
1551
- type: boolean
1552
1526
  RequestAdminPolicy:
1553
1527
  description: Same as an AdminPolicy, but doesn't have an externalIdentifier as one will be created
1554
1528
  type: object
@@ -1792,6 +1766,14 @@ components:
1792
1766
  type: string
1793
1767
  use:
1794
1768
  $ref: '#/components/schemas/FileUse'
1769
+ sdrGeneratedText:
1770
+ description: Indicates if the text (OCR/captioning) was generated by SDR.
1771
+ type: boolean
1772
+ default: false
1773
+ correctedForAccessibility:
1774
+ description: Indicates if text that has been verified for accessibility/correctness.
1775
+ type: boolean
1776
+ default: false
1795
1777
  hasMessageDigests:
1796
1778
  type: array
1797
1779
  items:
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.96.0
4
+ version: 0.98.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-03-29 00:00:00.000000000 Z
11
+ date: 2024-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -164,20 +164,6 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '1.0'
167
- - !ruby/object:Gem::Dependency
168
- name: rss
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :runtime
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
167
  - !ruby/object:Gem::Dependency
182
168
  name: super_diff
183
169
  requirement: !ruby/object:Gem::Requirement
@@ -505,7 +491,6 @@ files:
505
491
  - lib/cocina/models/presentation.rb
506
492
  - lib/cocina/models/purl.rb
507
493
  - lib/cocina/models/related_resource.rb
508
- - lib/cocina/models/release_tag.rb
509
494
  - lib/cocina/models/request_admin_policy.rb
510
495
  - lib/cocina/models/request_administrative.rb
511
496
  - lib/cocina/models/request_collection.rb
@@ -525,6 +510,7 @@ files:
525
510
  - lib/cocina/models/symphony_catalog_link.rb
526
511
  - lib/cocina/models/title.rb
527
512
  - lib/cocina/models/use_and_reproduction_statement.rb
513
+ - lib/cocina/models/utils.rb
528
514
  - lib/cocina/models/validatable.rb
529
515
  - lib/cocina/models/validators/associated_name_validator.rb
530
516
  - lib/cocina/models/validators/catalog_links_validator.rb
@@ -536,6 +522,7 @@ files:
536
522
  - lib/cocina/models/validators/open_api_validator.rb
537
523
  - lib/cocina/models/validators/purl_validator.rb
538
524
  - lib/cocina/models/validators/validator.rb
525
+ - lib/cocina/models/validators/w3cdtf_validator.rb
539
526
  - lib/cocina/models/version.rb
540
527
  - lib/cocina/models/vocabulary.rb
541
528
  - lib/cocina/models/world_access.rb
@@ -562,7 +549,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
562
549
  - !ruby/object:Gem::Version
563
550
  version: '0'
564
551
  requirements: []
565
- rubygems_version: 3.5.6
552
+ rubygems_version: 3.5.9
566
553
  signing_key:
567
554
  specification_version: 4
568
555
  summary: Data models for the SDR
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cocina
4
- module Models
5
- # A tag that indicates the item or collection should be released.
6
- class ReleaseTag < Struct
7
- # Who did this release
8
- # example: petucket
9
- attribute? :who, Types::Strict::String
10
- # What is being released. This item or the whole collection.
11
- # example: self
12
- attribute :what, Types::Strict::String.enum('self', 'collection')
13
- # When did this action happen
14
- attribute? :date, Types::Params::DateTime
15
- # What platform is it released to
16
- # example: Searchworks
17
- attribute? :to, Types::Strict::String
18
- attribute :release, Types::Strict::Bool.default(false)
19
- end
20
- end
21
- end