cocina-models 0.75.0 → 0.76.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +40 -12
  3. data/.rubocop_todo.yml +71 -2
  4. data/README.md +10 -3
  5. data/cocina-models.gemspec +2 -0
  6. data/description_types.yml +165 -38
  7. data/docs/description_types.md +469 -216
  8. data/lib/cocina/generator/generator.rb +7 -12
  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/name_title_group_builder.rb +0 -4
  19. data/lib/cocina/models/builders/title_builder.rb +0 -2
  20. data/lib/cocina/models/citation_only_access.rb +2 -2
  21. data/lib/cocina/models/collection_access.rb +4 -4
  22. data/lib/cocina/models/collection_identification.rb +1 -1
  23. data/lib/cocina/models/collection_with_metadata.rb +2 -2
  24. data/lib/cocina/models/contributor.rb +4 -4
  25. data/lib/cocina/models/controlled_digital_lending_access.rb +2 -2
  26. data/lib/cocina/models/dark_access.rb +4 -4
  27. data/lib/cocina/models/description.rb +3 -3
  28. data/lib/cocina/models/descriptive_basic_value.rb +13 -13
  29. data/lib/cocina/models/descriptive_parallel_contributor.rb +5 -5
  30. data/lib/cocina/models/descriptive_parallel_event.rb +3 -3
  31. data/lib/cocina/models/descriptive_value.rb +13 -13
  32. data/lib/cocina/models/descriptive_value_language.rb +6 -6
  33. data/lib/cocina/models/dro.rb +1 -1
  34. data/lib/cocina/models/dro_access.rb +8 -8
  35. data/lib/cocina/models/dro_with_metadata.rb +3 -3
  36. data/lib/cocina/models/embargo.rb +5 -5
  37. data/lib/cocina/models/event.rb +3 -3
  38. data/lib/cocina/models/file.rb +4 -4
  39. data/lib/cocina/models/file_access.rb +4 -4
  40. data/lib/cocina/models/identification.rb +2 -2
  41. data/lib/cocina/models/language.rb +12 -12
  42. data/lib/cocina/models/location_based_access.rb +1 -1
  43. data/lib/cocina/models/location_based_download_access.rb +1 -1
  44. data/lib/cocina/models/mapping/error_notifier.rb +36 -0
  45. data/lib/cocina/models/mapping/from_mods/access.rb +177 -0
  46. data/lib/cocina/models/mapping/from_mods/admin_metadata.rb +217 -0
  47. data/lib/cocina/models/mapping/from_mods/alt_rep_group.rb +26 -0
  48. data/lib/cocina/models/mapping/from_mods/authority.rb +51 -0
  49. data/lib/cocina/models/mapping/from_mods/contributor.rb +161 -0
  50. data/lib/cocina/models/mapping/from_mods/description.rb +99 -0
  51. data/lib/cocina/models/mapping/from_mods/description_builder.rb +61 -0
  52. data/lib/cocina/models/mapping/from_mods/event.rb +543 -0
  53. data/lib/cocina/models/mapping/from_mods/form.rb +381 -0
  54. data/lib/cocina/models/mapping/from_mods/geographic.rb +219 -0
  55. data/lib/cocina/models/mapping/from_mods/hydrus_default_title_builder.rb +28 -0
  56. data/lib/cocina/models/mapping/from_mods/identifier.rb +51 -0
  57. data/lib/cocina/models/mapping/from_mods/identifier_builder.rb +71 -0
  58. data/lib/cocina/models/mapping/from_mods/identifier_type.rb +292 -0
  59. data/lib/cocina/models/mapping/from_mods/language.rb +36 -0
  60. data/lib/cocina/models/mapping/from_mods/language_script.rb +30 -0
  61. data/lib/cocina/models/mapping/from_mods/language_term.rb +106 -0
  62. data/lib/cocina/models/mapping/from_mods/name_builder.rb +307 -0
  63. data/lib/cocina/models/mapping/from_mods/note.rb +162 -0
  64. data/lib/cocina/models/mapping/from_mods/part_builder.rb +147 -0
  65. data/lib/cocina/models/mapping/from_mods/primary.rb +27 -0
  66. data/lib/cocina/models/mapping/from_mods/purl.rb +53 -0
  67. data/lib/cocina/models/mapping/from_mods/related_resource.rb +105 -0
  68. data/lib/cocina/models/mapping/from_mods/subject.rb +413 -0
  69. data/lib/cocina/models/mapping/from_mods/subject_authority_codes.rb +794 -0
  70. data/lib/cocina/models/mapping/from_mods/title.rb +160 -0
  71. data/lib/cocina/models/mapping/from_mods/title_builder.rb +106 -0
  72. data/lib/cocina/models/mapping/from_mods/title_builder_strategy.rb +19 -0
  73. data/lib/cocina/models/mapping/from_mods/value_uri.rb +25 -0
  74. data/lib/cocina/models/mapping/normalizers/base.rb +16 -0
  75. data/lib/cocina/models/mapping/normalizers/mods/geo_extension_normalizer.rb +69 -0
  76. data/lib/cocina/models/mapping/normalizers/mods/name_normalizer.rb +191 -0
  77. data/lib/cocina/models/mapping/normalizers/mods/origin_info_normalizer.rb +157 -0
  78. data/lib/cocina/models/mapping/normalizers/mods/subject_normalizer.rb +296 -0
  79. data/lib/cocina/models/mapping/normalizers/mods/title_normalizer.rb +91 -0
  80. data/lib/cocina/models/mapping/normalizers/mods_normalizer.rb +409 -0
  81. data/lib/cocina/models/mapping/purl.rb +28 -0
  82. data/lib/cocina/models/mapping/to_mods/access.rb +155 -0
  83. data/lib/cocina/models/mapping/to_mods/admin_metadata.rb +129 -0
  84. data/lib/cocina/models/mapping/to_mods/contributor.rb +49 -0
  85. data/lib/cocina/models/mapping/to_mods/description.rb +63 -0
  86. data/lib/cocina/models/mapping/to_mods/event.rb +200 -0
  87. data/lib/cocina/models/mapping/to_mods/form.rb +292 -0
  88. data/lib/cocina/models/mapping/to_mods/geographic.rb +151 -0
  89. data/lib/cocina/models/mapping/to_mods/id_generator.rb +25 -0
  90. data/lib/cocina/models/mapping/to_mods/identifier.rb +57 -0
  91. data/lib/cocina/models/mapping/to_mods/language.rb +82 -0
  92. data/lib/cocina/models/mapping/to_mods/mods_writer.rb +38 -0
  93. data/lib/cocina/models/mapping/to_mods/name_title_group.rb +29 -0
  94. data/lib/cocina/models/mapping/to_mods/name_writer.rb +228 -0
  95. data/lib/cocina/models/mapping/to_mods/note.rb +105 -0
  96. data/lib/cocina/models/mapping/to_mods/part_writer.rb +115 -0
  97. data/lib/cocina/models/mapping/to_mods/related_resource.rb +108 -0
  98. data/lib/cocina/models/mapping/to_mods/role_writer.rb +50 -0
  99. data/lib/cocina/models/mapping/to_mods/subject.rb +486 -0
  100. data/lib/cocina/models/mapping/to_mods/title.rb +260 -0
  101. data/lib/cocina/models/object_metadata.rb +2 -2
  102. data/lib/cocina/models/presentation.rb +2 -2
  103. data/lib/cocina/models/related_resource.rb +9 -9
  104. data/lib/cocina/models/release_tag.rb +4 -4
  105. data/lib/cocina/models/request_admin_policy.rb +1 -1
  106. data/lib/cocina/models/request_administrative.rb +1 -1
  107. data/lib/cocina/models/request_collection.rb +2 -2
  108. data/lib/cocina/models/request_description.rb +3 -3
  109. data/lib/cocina/models/request_dro.rb +4 -4
  110. data/lib/cocina/models/request_file.rb +5 -5
  111. data/lib/cocina/models/request_identification.rb +1 -1
  112. data/lib/cocina/models/sequence.rb +1 -1
  113. data/lib/cocina/models/source.rb +4 -4
  114. data/lib/cocina/models/standard.rb +5 -5
  115. data/lib/cocina/models/stanford_access.rb +2 -2
  116. data/lib/cocina/models/title.rb +13 -13
  117. data/lib/cocina/models/validators/dark_validator.rb +4 -2
  118. data/lib/cocina/models/validators/open_api_validator.rb +0 -4
  119. data/lib/cocina/models/version.rb +1 -1
  120. data/lib/cocina/models/world_access.rb +2 -2
  121. data/lib/cocina/models.rb +4 -0
  122. data/lib/cocina/rspec/factories.rb +157 -0
  123. data/lib/cocina/rspec.rb +2 -0
  124. data/openapi.yml +4 -4
  125. metadata +88 -3
  126. data/docs/_config.yml +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ec67ece77b9025a117182d0213342e180e7b87dcd003a44e3d9dffeb03d08e1
4
- data.tar.gz: 3ee4eee501728b92c356760c660514789082da70c41c990fc3822f5833a7f47d
3
+ metadata.gz: ff6e03954275e59dcc8fbf693f3aeef4b90742767771865508e81541f53f1cbf
4
+ data.tar.gz: dacc3005506e32d5cca5b599477d1c450844272715e9500f8242bc19bf69972b
5
5
  SHA512:
6
- metadata.gz: 4b0b94409167d640cfd84c7202468664ec32887405b17973e05ebdd77a55f608e53ad2c2956aabc85ac09dd9edecb6281eaafea7822d77bdea1075301e04aae6
7
- data.tar.gz: 821ba48bca0b9c92031eb6ba2dbde666f2116c6c7f9076663730636f1c61f11e098551f2e81b975dea06289bd9ba09aa4f498ef67b36dbfa76d6581f29c515c4
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,13 +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
- - spec/cocina/models/builders/name_title_group_builder_spec.rb
103
-
104
119
  RSpec/MultipleExpectations:
105
120
  Enabled: false
106
121
 
@@ -283,3 +298,16 @@ RSpec/Rails/AvoidSetupHook: # new in 2.4
283
298
  Enabled: true
284
299
  Style/NestedFileDirname: # new in 1.26
285
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
 
@@ -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.