cocina-models 0.74.0 → 0.76.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +40 -11
  3. data/.rubocop_todo.yml +71 -2
  4. data/README.md +19 -3
  5. data/cocina-models.gemspec +2 -0
  6. data/description_types.yml +167 -39
  7. data/docs/description_types.md +470 -216
  8. data/lib/cocina/generator/generator.rb +7 -15
  9. data/lib/cocina/generator/schema.rb +1 -3
  10. data/lib/cocina/generator/schema_base.rb +0 -8
  11. data/lib/cocina/generator/schema_ref.rb +1 -1
  12. data/lib/cocina/generator/schema_value.rb +14 -4
  13. data/lib/cocina/models/access.rb +4 -4
  14. data/lib/cocina/models/admin_policy.rb +1 -1
  15. data/lib/cocina/models/admin_policy_access_template.rb +7 -7
  16. data/lib/cocina/models/admin_policy_administrative.rb +1 -1
  17. data/lib/cocina/models/admin_policy_with_metadata.rb +3 -3
  18. data/lib/cocina/models/builders/dro_rights_description_builder.rb +69 -0
  19. data/lib/cocina/models/builders/name_title_group_builder.rb +130 -0
  20. data/lib/cocina/models/builders/rights_description_builder.rb +83 -0
  21. data/lib/cocina/models/builders/title_builder.rb +211 -0
  22. data/lib/cocina/models/citation_only_access.rb +2 -2
  23. data/lib/cocina/models/collection_access.rb +4 -4
  24. data/lib/cocina/models/collection_identification.rb +1 -1
  25. data/lib/cocina/models/collection_with_metadata.rb +2 -2
  26. data/lib/cocina/models/contributor.rb +4 -4
  27. data/lib/cocina/models/controlled_digital_lending_access.rb +2 -2
  28. data/lib/cocina/models/dark_access.rb +4 -4
  29. data/lib/cocina/models/description.rb +3 -3
  30. data/lib/cocina/models/descriptive_basic_value.rb +13 -13
  31. data/lib/cocina/models/descriptive_parallel_contributor.rb +5 -5
  32. data/lib/cocina/models/descriptive_parallel_event.rb +3 -3
  33. data/lib/cocina/models/descriptive_value.rb +13 -13
  34. data/lib/cocina/models/descriptive_value_language.rb +6 -6
  35. data/lib/cocina/models/dro.rb +1 -1
  36. data/lib/cocina/models/dro_access.rb +8 -8
  37. data/lib/cocina/models/dro_with_metadata.rb +3 -3
  38. data/lib/cocina/models/embargo.rb +5 -5
  39. data/lib/cocina/models/event.rb +3 -3
  40. data/lib/cocina/models/file.rb +4 -4
  41. data/lib/cocina/models/file_access.rb +4 -4
  42. data/lib/cocina/models/identification.rb +2 -2
  43. data/lib/cocina/models/language.rb +12 -12
  44. data/lib/cocina/models/location_based_access.rb +1 -1
  45. data/lib/cocina/models/location_based_download_access.rb +1 -1
  46. data/lib/cocina/models/mapping/error_notifier.rb +36 -0
  47. data/lib/cocina/models/mapping/from_mods/access.rb +177 -0
  48. data/lib/cocina/models/mapping/from_mods/admin_metadata.rb +217 -0
  49. data/lib/cocina/models/mapping/from_mods/alt_rep_group.rb +26 -0
  50. data/lib/cocina/models/mapping/from_mods/authority.rb +51 -0
  51. data/lib/cocina/models/mapping/from_mods/contributor.rb +161 -0
  52. data/lib/cocina/models/mapping/from_mods/description.rb +99 -0
  53. data/lib/cocina/models/mapping/from_mods/description_builder.rb +61 -0
  54. data/lib/cocina/models/mapping/from_mods/event.rb +543 -0
  55. data/lib/cocina/models/mapping/from_mods/form.rb +381 -0
  56. data/lib/cocina/models/mapping/from_mods/geographic.rb +219 -0
  57. data/lib/cocina/models/mapping/from_mods/hydrus_default_title_builder.rb +28 -0
  58. data/lib/cocina/models/mapping/from_mods/identifier.rb +51 -0
  59. data/lib/cocina/models/mapping/from_mods/identifier_builder.rb +71 -0
  60. data/lib/cocina/models/mapping/from_mods/identifier_type.rb +292 -0
  61. data/lib/cocina/models/mapping/from_mods/language.rb +36 -0
  62. data/lib/cocina/models/mapping/from_mods/language_script.rb +30 -0
  63. data/lib/cocina/models/mapping/from_mods/language_term.rb +106 -0
  64. data/lib/cocina/models/mapping/from_mods/name_builder.rb +307 -0
  65. data/lib/cocina/models/mapping/from_mods/note.rb +162 -0
  66. data/lib/cocina/models/mapping/from_mods/part_builder.rb +147 -0
  67. data/lib/cocina/models/mapping/from_mods/primary.rb +27 -0
  68. data/lib/cocina/models/mapping/from_mods/purl.rb +53 -0
  69. data/lib/cocina/models/mapping/from_mods/related_resource.rb +105 -0
  70. data/lib/cocina/models/mapping/from_mods/subject.rb +413 -0
  71. data/lib/cocina/models/mapping/from_mods/subject_authority_codes.rb +794 -0
  72. data/lib/cocina/models/mapping/from_mods/title.rb +160 -0
  73. data/lib/cocina/models/mapping/from_mods/title_builder.rb +106 -0
  74. data/lib/cocina/models/mapping/from_mods/title_builder_strategy.rb +19 -0
  75. data/lib/cocina/models/mapping/from_mods/value_uri.rb +25 -0
  76. data/lib/cocina/models/mapping/normalizers/base.rb +16 -0
  77. data/lib/cocina/models/mapping/normalizers/mods/geo_extension_normalizer.rb +69 -0
  78. data/lib/cocina/models/mapping/normalizers/mods/name_normalizer.rb +191 -0
  79. data/lib/cocina/models/mapping/normalizers/mods/origin_info_normalizer.rb +157 -0
  80. data/lib/cocina/models/mapping/normalizers/mods/subject_normalizer.rb +296 -0
  81. data/lib/cocina/models/mapping/normalizers/mods/title_normalizer.rb +91 -0
  82. data/lib/cocina/models/mapping/normalizers/mods_normalizer.rb +409 -0
  83. data/lib/cocina/models/mapping/purl.rb +28 -0
  84. data/lib/cocina/models/mapping/to_mods/access.rb +155 -0
  85. data/lib/cocina/models/mapping/to_mods/admin_metadata.rb +129 -0
  86. data/lib/cocina/models/mapping/to_mods/contributor.rb +49 -0
  87. data/lib/cocina/models/mapping/to_mods/description.rb +63 -0
  88. data/lib/cocina/models/mapping/to_mods/event.rb +200 -0
  89. data/lib/cocina/models/mapping/to_mods/form.rb +292 -0
  90. data/lib/cocina/models/mapping/to_mods/geographic.rb +151 -0
  91. data/lib/cocina/models/mapping/to_mods/id_generator.rb +25 -0
  92. data/lib/cocina/models/mapping/to_mods/identifier.rb +57 -0
  93. data/lib/cocina/models/mapping/to_mods/language.rb +82 -0
  94. data/lib/cocina/models/mapping/to_mods/mods_writer.rb +38 -0
  95. data/lib/cocina/models/mapping/to_mods/name_title_group.rb +29 -0
  96. data/lib/cocina/models/mapping/to_mods/name_writer.rb +228 -0
  97. data/lib/cocina/models/mapping/to_mods/note.rb +105 -0
  98. data/lib/cocina/models/mapping/to_mods/part_writer.rb +115 -0
  99. data/lib/cocina/models/mapping/to_mods/related_resource.rb +108 -0
  100. data/lib/cocina/models/mapping/to_mods/role_writer.rb +50 -0
  101. data/lib/cocina/models/mapping/to_mods/subject.rb +486 -0
  102. data/lib/cocina/models/mapping/to_mods/title.rb +260 -0
  103. data/lib/cocina/models/object_metadata.rb +2 -2
  104. data/lib/cocina/models/presentation.rb +2 -2
  105. data/lib/cocina/models/related_resource.rb +9 -9
  106. data/lib/cocina/models/release_tag.rb +4 -4
  107. data/lib/cocina/models/request_admin_policy.rb +1 -1
  108. data/lib/cocina/models/request_administrative.rb +1 -1
  109. data/lib/cocina/models/request_collection.rb +2 -2
  110. data/lib/cocina/models/request_description.rb +3 -3
  111. data/lib/cocina/models/request_dro.rb +4 -4
  112. data/lib/cocina/models/request_file.rb +5 -5
  113. data/lib/cocina/models/request_identification.rb +1 -1
  114. data/lib/cocina/models/sequence.rb +1 -1
  115. data/lib/cocina/models/source.rb +4 -4
  116. data/lib/cocina/models/standard.rb +5 -5
  117. data/lib/cocina/models/stanford_access.rb +2 -2
  118. data/lib/cocina/models/title.rb +13 -13
  119. data/lib/cocina/models/validators/associated_name_validator.rb +77 -0
  120. data/lib/cocina/models/validators/dark_validator.rb +4 -2
  121. data/lib/cocina/models/validators/open_api_validator.rb +0 -4
  122. data/lib/cocina/models/validators/validator.rb +1 -0
  123. data/lib/cocina/models/version.rb +1 -1
  124. data/lib/cocina/models/world_access.rb +2 -2
  125. data/lib/cocina/models.rb +4 -0
  126. data/lib/cocina/rspec/factories.rb +157 -0
  127. data/lib/cocina/rspec.rb +2 -0
  128. data/openapi.yml +4 -4
  129. metadata +93 -6
  130. data/docs/_config.yml +0 -1
  131. data/lib/cocina/models/dro_rights_description_builder.rb +0 -67
  132. data/lib/cocina/models/rights_description_builder.rb +0 -81
  133. data/lib/cocina/models/title_builder.rb +0 -208
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de6cff9bb4c5ec4f7b2533f024c37a6536d4c94ca1ba19cb91f4203ee8e9588f
4
- data.tar.gz: 2b01b63cbccae36d295b825ffd44f435dd03e95ea84daf54caa62b13d696f9c5
3
+ metadata.gz: ff6e03954275e59dcc8fbf693f3aeef4b90742767771865508e81541f53f1cbf
4
+ data.tar.gz: dacc3005506e32d5cca5b599477d1c450844272715e9500f8242bc19bf69972b
5
5
  SHA512:
6
- metadata.gz: 6cff72fbbe94becd71a3ad92f622650dba10b7a26d3eef9f34d8c856e47b2bfd87551f0e8a6bccd7974c36347d33f7a20c906e417e7a70346fa00f0d43f4a66f
7
- data.tar.gz: fc2e259a1d7c9a2efeda647d6db82bce3a9116736b1d69fbd01e07bfae2f169a5b56510ad7e29b2b10a9efe3ecc9896b0bf16f203e27ad752cc2c3df55730a09
6
+ metadata.gz: bf5f815fb3c09ae4cba6d0e1cf16aafd7502cb731f523004c643806579475d6ac11882845a5d0178732f8d3c9edad56901bf8e05df7d5681a0afdc0032f14058
7
+ data.tar.gz: 5b88e55c0e25e6dad32a4326a2063bf5a72fedc8146e90a7ead461a1fad0bb1f0f293d360f16884daf5582fa16f4e95fdb61307487e21b7a28b2250c69c1d9ad
data/.rubocop.yml CHANGED
@@ -11,15 +11,13 @@ AllCops:
11
11
 
12
12
  # ----- Layout ------
13
13
 
14
- Layout/LineLength:
15
- Max: 114
16
- Exclude:
17
- - lib/cocina/models/*
18
-
19
14
  Layout/BeginEndAlignment: # (new in 0.91)
20
15
  Enabled: true
21
16
  Layout/EmptyLinesAroundAttributeAccessor:
22
17
  Enabled: true
18
+ Layout/LineLength:
19
+ Exclude:
20
+ - lib/cocina/models/*
23
21
  Layout/SpaceAroundMethodCallOperator:
24
22
  Enabled: true
25
23
 
@@ -79,12 +77,36 @@ Metrics/BlockLength:
79
77
  - cocina-models.gemspec
80
78
  - spec/cocina/**/*
81
79
  - lib/cocina/rspec/matchers.rb
80
+ - 'spec/support/mods_mapping_spec_helper.rb'
81
+
82
+ # Offense count: 16
83
+ # Configuration parameters: CountComments, CountAsOne.
84
+ Metrics/ClassLength:
85
+ Max: 100
86
+ Exclude:
87
+ - 'lib/cocina/rspec/factories.rb'
82
88
 
83
89
  Metrics/MethodLength:
84
90
  Max: 14
85
91
  Exclude:
86
92
  - 'spec/cocina/models/file_access_spec.rb'
87
93
  - 'spec/cocina/models/dro_access_spec.rb'
94
+ - 'lib/cocina/rspec/factories.rb'
95
+ - 'lib/cocina/models/mapping/to_mods/*'
96
+ - 'lib/cocina/models/mapping/from_mods/*'
97
+ - 'lib/cocina/models/mapping/normalizers/mods/origin_info_normalizer.rb'
98
+ - 'lib/cocina/models/mapping/normalizers/mods/subject_normalizer.rb'
99
+ - 'lib/cocina/models/mapping/normalizers/mods_normalizer.rb'
100
+
101
+
102
+ # Offense count: 37
103
+ # Configuration parameters: IgnoredMethods.
104
+ Metrics/PerceivedComplexity:
105
+ # Max: 20
106
+ Exclude:
107
+ - 'lib/cocina/models/mapping/from_mods/*'
108
+ - 'lib/cocina/models/mapping/to_mods/*'
109
+ - 'lib/cocina/models/mapping/normalizers/**/*'
88
110
 
89
111
  # ----- RSpec ------
90
112
 
@@ -94,12 +116,6 @@ RSpec/BeEq: # new in 2.9.0
94
116
  RSpec/BeNil: # new in 2.9.0
95
117
  Enabled: true
96
118
 
97
- RSpec/ExampleLength:
98
- Max: 18
99
- Exclude:
100
- - spec/cocina/models/description_spec.rb
101
- - spec/cocina/models/dro_shared_examples.rb
102
-
103
119
  RSpec/MultipleExpectations:
104
120
  Enabled: false
105
121
 
@@ -282,3 +298,16 @@ RSpec/Rails/AvoidSetupHook: # new in 2.4
282
298
  Enabled: true
283
299
  Style/NestedFileDirname: # new in 1.26
284
300
  Enabled: true
301
+
302
+ Lint/RefinementImportMethods: # new in 1.27
303
+ Enabled: true
304
+ Security/CompoundHash: # new in 1.28
305
+ Enabled: true
306
+ Style/FetchEnvVar: # new in 1.28
307
+ Enabled: true
308
+ Style/ObjectThen: # new in 1.28
309
+ Enabled: true
310
+ Style/RedundantInitialize: # new in 1.27
311
+ Enabled: true
312
+ RSpec/VerifiedDoubleReference: # new in 2.10.0
313
+ Enabled: true
data/.rubocop_todo.yml CHANGED
@@ -1,11 +1,16 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config --auto-gen-only-exclude`
3
- # on 2022-01-14 00:32:36 UTC using RuboCop version 1.24.1.
3
+ # on 2022-04-27 19:20:35 UTC using RuboCop version 1.28.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ # Offense count: 1
10
+ Lint/NoReturnInBeginEndBlocks:
11
+ Exclude:
12
+ - 'lib/cocina/models/mapping/to_mods/description.rb'
13
+
9
14
  # Offense count: 1
10
15
  # Configuration parameters: AllowedMethods.
11
16
  # AllowedMethods: present?, blank?, presence, try, try!, in?
@@ -13,14 +18,78 @@ Lint/SafeNavigationChain:
13
18
  Exclude:
14
19
  - 'lib/cocina/generator/schema_base.rb'
15
20
 
21
+ # Offense count: 13
22
+ # This cop supports safe auto-correction (--auto-correct).
23
+ # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
24
+ Lint/UnusedMethodArgument:
25
+ Exclude:
26
+ - 'lib/cocina/models/mapping/from_mods/admin_metadata.rb'
27
+ - 'lib/cocina/models/mapping/from_mods/contributor.rb'
28
+ - 'lib/cocina/models/mapping/from_mods/event.rb'
29
+ - 'lib/cocina/models/mapping/from_mods/form.rb'
30
+ - 'lib/cocina/models/mapping/from_mods/geographic.rb'
31
+ - 'lib/cocina/models/mapping/from_mods/hydrus_default_title_builder.rb'
32
+ - 'lib/cocina/models/mapping/from_mods/identifier.rb'
33
+ - 'lib/cocina/models/mapping/from_mods/language.rb'
34
+ - 'lib/cocina/models/mapping/from_mods/note.rb'
35
+ - 'lib/cocina/models/mapping/from_mods/subject.rb'
36
+ - 'lib/cocina/models/mapping/to_mods/event.rb'
37
+
38
+ # Offense count: 95
39
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
40
+ Metrics/AbcSize:
41
+ Max: 40
42
+
43
+ # Offense count: 42
44
+ # Configuration parameters: IgnoredMethods.
45
+ Metrics/CyclomaticComplexity:
46
+ Max: 12
47
+
16
48
  # Offense count: 1
17
49
  # Configuration parameters: Max, CountKeywordArgs, MaxOptionalParameters.
18
50
  Metrics/ParameterLists:
19
51
  Exclude:
20
52
  - 'lib/cocina/generator/schema_base.rb'
21
53
 
54
+ # Offense count: 41
55
+ # Configuration parameters: IgnoredMetadata.
56
+ RSpec/DescribeClass:
57
+ Enabled: false
58
+
59
+ # Offense count: 89
60
+ # Configuration parameters: CountAsOne.
61
+ RSpec/ExampleLength:
62
+ Max: 128
63
+
64
+ # Offense count: 9
65
+ # Configuration parameters: Max.
66
+ RSpec/NestedGroups:
67
+ Exclude:
68
+ - 'spec/cocina/models/mapping/normalizers/mods/origin_info_normalizer_spec.rb'
69
+
22
70
  # Offense count: 1
23
- # Configuration parameters: MinBodyLength.
71
+ # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
24
72
  Style/GuardClause:
25
73
  Exclude:
26
74
  - 'lib/cocina/generator/schema_base.rb'
75
+
76
+ # Offense count: 1
77
+ # This cop supports safe auto-correction (--auto-correct).
78
+ Style/IfUnlessModifier:
79
+ Exclude:
80
+ - 'lib/cocina/models/validators/open_api_validator.rb'
81
+
82
+ # Offense count: 9
83
+ Style/MultilineBlockChain:
84
+ Exclude:
85
+ - 'lib/cocina/models/mapping/to_mods/access.rb'
86
+ - 'lib/cocina/models/mapping/to_mods/contributor.rb'
87
+ - 'lib/cocina/models/mapping/to_mods/form.rb'
88
+ - 'lib/cocina/models/mapping/to_mods/subject.rb'
89
+
90
+ # Offense count: 206
91
+ # This cop supports safe auto-correction (--auto-correct).
92
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
93
+ # URISchemes: http, https
94
+ Layout/LineLength:
95
+ Max: 187
data/README.md CHANGED
@@ -6,11 +6,18 @@
6
6
 
7
7
  # Cocina::Models
8
8
 
9
- This is a Ruby implementation of the SDR data model (named "COCINA"). The data being modeled includes digital repository objects.
9
+ The cocina-models gem is a Ruby implementation of the Stanford Digital Repository (SDR) data model, which we named "Cocina." The data being modeled is oriented around digital repository objects.
10
10
 
11
- Validation is performed by openapi (using OpenAPIParser). Modeling is provided by dry-struct and dry-types. Together, these provide a way for consumers to validate objects against models and to manipulate those objects.
11
+ The data model is expressed in an OpenAPI specification that lives in this codebase. Expressing the model in such a spec allows for rich validation (using gems such as `OpenAPIParser` and `committee`). The gem provides a set of generators (see below) to generate Ruby classes from the specification, with modeling provided by dry-struct / dry-types. Together, these provide a way for consumers to validate objects against models and to manipulate those objects.
12
12
 
13
- This is a work in progress that will ultimately implement the full [COCINA data model](http://sul-dlss.github.io/cocina-models/). See also [architecture documentation](https://sul-dlss.github.io/taco-truck/COCINA.html#cocina-data-models--shapes).
13
+ Note that the data model encodes properties as camelCase, which the team believes to be consistent with other HTTP APIs and the original design of the Cocina data model. While using camelCase in Ruby code may look and feel wrong, we did explore automagic conversion between camelCase in the model and snake_case in the Ruby context. We ultimately concluded that we have enough representations of the data model in enough codebases to reasonably worry about data inconsistency problems, none of which we need in our work on SDR.
14
+
15
+ ## Configuration
16
+
17
+ Set the PURL url base:
18
+ ```ruby
19
+ Cocina::Models::Mapping::Purl.base_url = Settings.release.purl_base_url
20
+ ```
14
21
 
15
22
  ## Generate models from openapi.yml
16
23
 
@@ -42,6 +49,15 @@ The generator is tested via its output when run against `openapi.yml`, viz., the
42
49
 
43
50
  Beyond what is necessary to test the generator, the Cocina model classes are not tested, i.e., they are assumed to be as specified in `openapi.yml`.
44
51
 
52
+ ## Testing validation changes
53
+
54
+ If there is a possibility that a model 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-deploy since it requires deploying a branch of cocina-models.
55
+
56
+ 1. Create a cocina-models branch containing the proposed change and push to Github.
57
+ 2. On sdr-deploy, check out `main`, update the `Gemfile` so that cocina-models references the branch, and `bundle install`.
58
+ 3. Run `bin/validate-cocina`.
59
+ 4. Check `validate-cocina.csv` for validation errors.
60
+
45
61
  ## Releasing
46
62
 
47
63
  ### Step 0: Share intent to change the models
@@ -28,6 +28,8 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency 'deprecation'
29
29
  spec.add_dependency 'dry-struct', '~> 1.0'
30
30
  spec.add_dependency 'dry-types', '~> 1.1'
31
+ spec.add_dependency 'equivalent-xml' # for diffing MODS
32
+ spec.add_dependency 'nokogiri'
31
33
  spec.add_dependency 'openapi3_parser' # Parsing openapi doc
32
34
  # Match these version requirements to what committee wants,
33
35
  # so that our client (non-committee) users have the same dependencies.