cocina-models 0.89.1 → 0.91.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: a0dbfb214630511f046a824a0f6774e203db38bcef1c7af9dc6118932148caa4
4
- data.tar.gz: d087a39d4cb3270cd01d8fc77beb0c053a45431867c47570715c09fc0868e856
3
+ metadata.gz: f7ef9101cd3e5b9e42625b2afbc651919ba5f8e1617d5372324cb950a8f78b23
4
+ data.tar.gz: 433c3651004d4f32c380f0cee4b38887fe2ef3bc550436e326af299db01d12b3
5
5
  SHA512:
6
- metadata.gz: b083699765ee6bd9715ff5fe575ca994220ebb7f1d8ec9e7526b15f2af320c8c99b7c85cabb843e00027f37fddf68a50cf91b2c2e7513b8cdc82e5cd16a70bfe
7
- data.tar.gz: f3d50447698ba52af5d8f71565cd77235970f318ba78105de1e88dc4bd23134d9e826d167ad745adfd3aeeb0d2add3bf854fad0f713f512984188b5e9ea355c3
6
+ metadata.gz: 74cfeeb356d0fd34295010870f2e81c2ef08d9db3c3679ec1b22a8e6f6325bfb62058a23654c024d58a19a59a8b1dd73d611cfec749f2adce2aa6ac938f46c92
7
+ data.tar.gz: 906583af0a50b81f26f4c487b3288196f918d116f617c253ce10cc72564e7f459bb1ff422bc0af6def4d222571232fa4e1c52609be82e5226eb4d85f92f1c42c
data/.circleci/config.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  version: 2.1
2
2
  orbs:
3
- ruby-rails: sul-dlss/ruby-rails@3.2.0
3
+ ruby-rails: sul-dlss/ruby-rails@4.1.0
4
4
  workflows:
5
5
  build:
6
6
  jobs:
data/.rubocop.yml CHANGED
@@ -101,7 +101,6 @@ Metrics/MethodLength:
101
101
  - 'lib/cocina/models/mapping/normalizers/mods/subject_normalizer.rb'
102
102
  - 'lib/cocina/models/mapping/normalizers/mods_normalizer.rb'
103
103
 
104
-
105
104
  # Offense count: 37
106
105
  # Configuration parameters: IgnoredMethods.
107
106
  Metrics/PerceivedComplexity:
@@ -111,6 +110,10 @@ Metrics/PerceivedComplexity:
111
110
  - 'lib/cocina/models/mapping/to_mods/*'
112
111
  - 'lib/cocina/models/mapping/normalizers/**/*'
113
112
 
113
+ Naming/PredicateName:
114
+ ForbiddenPrefixes:
115
+ - is_
116
+
114
117
  # ----- RSpec ------
115
118
 
116
119
  RSpec/BeEq: # new in 2.9.0
@@ -295,7 +298,7 @@ RSpec/IdenticalEqualityAssertion: # new in 2.4
295
298
  Enabled: true
296
299
  RSpec/SubjectDeclaration: # new in 2.5
297
300
  Enabled: true
298
- RSpec/FactoryBot/SyntaxMethods: # new in 2.7
301
+ FactoryBot/SyntaxMethods: # new in 2.7
299
302
  Enabled: true
300
303
  RSpec/Rails/AvoidSetupHook: # new in 2.4
301
304
  Enabled: true
@@ -384,9 +387,9 @@ RSpec/PendingWithoutReason: # new in 2.16
384
387
  Enabled: true
385
388
  RSpec/SortMetadata: # new in 2.14
386
389
  Enabled: true
387
- RSpec/FactoryBot/ConsistentParenthesesStyle: # new in 2.14
390
+ FactoryBot/ConsistentParenthesesStyle: # new in 2.14
388
391
  Enabled: true
389
- RSpec/FactoryBot/FactoryNameStyle: # new in 2.16
392
+ FactoryBot/FactoryNameStyle: # new in 2.16
390
393
  Enabled: true
391
394
  RSpec/Rails/InferredSpecType: # new in 2.14
392
395
  Enabled: true
@@ -394,3 +397,62 @@ RSpec/Rails/MinitestAssertions: # new in 2.17
394
397
  Enabled: true
395
398
  Style/RedundantHeredocDelimiterQuotes: # new in 1.45
396
399
  Enabled: true
400
+
401
+ Metrics/CollectionLiteralLength: # new in 1.47
402
+ Enabled: true
403
+ Style/DirEmpty: # new in 1.48
404
+ Enabled: true
405
+ Style/FileEmpty: # new in 1.48
406
+ Enabled: true
407
+ RSpec/RedundantAround: # new in 2.19
408
+ Enabled: true
409
+ RSpec/SkipBlockInsideExample: # new in 2.19
410
+ Enabled: true
411
+ RSpec/Rails/TravelAround: # new in 2.19
412
+ Enabled: true
413
+
414
+ Lint/DuplicateMatchPattern: # new in 1.50
415
+ Enabled: true
416
+ Style/DataInheritance: # new in 1.49
417
+ Enabled: true
418
+ Style/ExactRegexpMatch: # new in 1.51
419
+ Enabled: true
420
+ Style/RedundantArrayConstructor: # new in 1.52
421
+ Enabled: true
422
+ Style/RedundantFilterChain: # new in 1.52
423
+ Enabled: true
424
+ Style/RedundantLineContinuation: # new in 1.49
425
+ Enabled: true
426
+ Style/RedundantRegexpConstructor: # new in 1.52
427
+ Enabled: true
428
+ FactoryBot/AssociationStyle: # new in 2.23
429
+ Enabled: true
430
+ FactoryBot/FactoryAssociationWithStrategy: # new in 2.23
431
+ Enabled: true
432
+ FactoryBot/RedundantFactoryOption: # new in 2.23
433
+ Enabled: true
434
+ RSpec/BeEmpty: # new in 2.20
435
+ Enabled: true
436
+ RSpec/ContainExactly: # new in 2.19
437
+ Enabled: true
438
+ RSpec/IndexedLet: # new in 2.20
439
+ Enabled: true
440
+ RSpec/MatchArray: # new in 2.19
441
+ Enabled: true
442
+
443
+ Lint/MixedCaseRange: # new in 1.53
444
+ Enabled: true
445
+ Lint/RedundantRegexpQuantifiers: # new in 1.53
446
+ Enabled: true
447
+ Style/RedundantCurrentDirectoryInPath: # new in 1.53
448
+ Enabled: true
449
+ Style/RedundantRegexpArgument: # new in 1.53
450
+ Enabled: true
451
+ Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
452
+ Enabled: true
453
+ Style/YAMLFileRead: # new in 1.53
454
+ Enabled: true
455
+ RSpec/ReceiveMessages: # new in 2.23
456
+ Enabled: true
457
+ RSpec/Rails/NegationBeValid: # new in 2.23
458
+ Enabled: true
data/.rubocop_todo.yml CHANGED
@@ -1,15 +1,14 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config --auto-gen-only-exclude`
3
- # on 2023-02-07 01:43:53 UTC using RuboCop version 1.44.1.
3
+ # on 2023-06-20 05:46:00 UTC using RuboCop version 1.52.1.
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: 3
9
+ # Offense count: 8
10
10
  # Configuration parameters: EnforcedStyle, AllowedGems, Include.
11
11
  # SupportedStyles: Gemfile, gems.rb, gemspec
12
- # AllowedGems: bundler
13
12
  # Include: **/*.gemspec, **/Gemfile, **/gems.rb
14
13
  Gemspec/DevelopmentDependencies:
15
14
  Exclude:
@@ -20,14 +19,6 @@ Lint/NoReturnInBeginEndBlocks:
20
19
  Exclude:
21
20
  - 'lib/cocina/models/mapping/to_mods/description.rb'
22
21
 
23
- # Offense count: 2
24
- # This cop supports safe autocorrection (--autocorrect).
25
- # Configuration parameters: AllowedMethods.
26
- # AllowedMethods: present?, blank?, presence, try, try!, in?
27
- Lint/SafeNavigationChain:
28
- Exclude:
29
- - 'lib/cocina/generator/schema_base.rb'
30
-
31
22
  # Offense count: 13
32
23
  # This cop supports safe autocorrection (--autocorrect).
33
24
  # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
@@ -45,30 +36,16 @@ Lint/UnusedMethodArgument:
45
36
  - 'lib/cocina/models/mapping/from_mods/subject.rb'
46
37
  - 'lib/cocina/models/mapping/to_mods/event.rb'
47
38
 
48
- # Offense count: 95
49
- # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
39
+ # Offense count: 98
40
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
50
41
  Metrics/AbcSize:
51
42
  Max: 40
52
43
 
53
44
  # Offense count: 43
54
- # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
45
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
55
46
  Metrics/CyclomaticComplexity:
56
47
  Max: 12
57
48
 
58
- # Offense count: 1
59
- # Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
60
- Metrics/MethodLength:
61
- Exclude:
62
- - 'spec/cocina/models/file_access_spec.rb'
63
- - 'spec/cocina/models/dro_access_spec.rb'
64
- - 'lib/cocina/rspec/factories.rb'
65
- - 'lib/cocina/models/mapping/to_mods/*'
66
- - 'lib/cocina/models/mapping/from_mods/*'
67
- - 'lib/cocina/models/mapping/normalizers/mods/origin_info_normalizer.rb'
68
- - 'lib/cocina/models/mapping/normalizers/mods/subject_normalizer.rb'
69
- - 'lib/cocina/models/mapping/normalizers/mods_normalizer.rb'
70
- - 'lib/cocina/generator/schema_base.rb'
71
-
72
49
  # Offense count: 1
73
50
  # Configuration parameters: Max, CountKeywordArgs, MaxOptionalParameters.
74
51
  Metrics/ParameterLists:
@@ -83,7 +60,7 @@ RSpec/DescribeClass:
83
60
  # Offense count: 87
84
61
  # Configuration parameters: CountAsOne.
85
62
  RSpec/ExampleLength:
86
- Max: 128
63
+ Max: 103
87
64
 
88
65
  # Offense count: 10
89
66
  # Configuration parameters: Max, AllowedGroups.
@@ -122,9 +99,9 @@ Style/MultilineBlockChain:
122
99
  - 'lib/cocina/models/mapping/to_mods/form.rb'
123
100
  - 'lib/cocina/models/mapping/to_mods/subject.rb'
124
101
 
125
- # Offense count: 225
102
+ # Offense count: 239
126
103
  # This cop supports safe autocorrection (--autocorrect).
127
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
104
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
128
105
  # URISchemes: http, https
129
106
  Layout/LineLength:
130
- Max: 187
107
+ Max: 267
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocina-models (0.89.1)
4
+ cocina-models (0.91.0)
5
5
  activesupport
6
6
  deprecation
7
7
  dry-struct (~> 1.0)
@@ -11,7 +11,7 @@ PATH
11
11
  jsonpath
12
12
  nokogiri
13
13
  openapi3_parser
14
- openapi_parser (>= 0.11.1, < 1.0)
14
+ openapi_parser (~> 1.0)
15
15
  rss
16
16
  super_diff
17
17
  thor
@@ -20,25 +20,26 @@ PATH
20
20
  GEM
21
21
  remote: https://rubygems.org/
22
22
  specs:
23
- activesupport (7.0.4.2)
23
+ activesupport (7.0.8)
24
24
  concurrent-ruby (~> 1.0, >= 1.0.2)
25
25
  i18n (>= 1.6, < 2)
26
26
  minitest (>= 5.1)
27
27
  tzinfo (~> 2.0)
28
28
  ast (2.4.2)
29
29
  attr_extras (7.1.0)
30
+ base64 (0.1.1)
30
31
  byebug (11.1.3)
31
- committee (4.99.1)
32
+ committee (5.0.0)
32
33
  json_schema (~> 0.14, >= 0.14.3)
33
- openapi_parser (>= 0.11.1, < 1.0)
34
+ openapi_parser (~> 1.0)
34
35
  rack (>= 1.5)
35
- commonmarker (0.23.8)
36
+ commonmarker (0.23.10)
36
37
  concurrent-ruby (1.2.2)
37
38
  deprecation (1.1.0)
38
39
  activesupport
39
40
  diff-lcs (1.5.0)
40
41
  docile (1.4.0)
41
- dry-core (1.0.0)
42
+ dry-core (1.0.1)
42
43
  concurrent-ruby (~> 1.0)
43
44
  zeitwerk (~> 2.6)
44
45
  dry-inflector (1.0.0)
@@ -61,70 +62,77 @@ GEM
61
62
  activesupport (>= 3.0, < 8.0)
62
63
  equivalent-xml (0.6.0)
63
64
  nokogiri (>= 1.4.3)
64
- i18n (1.12.0)
65
+ i18n (1.14.1)
65
66
  concurrent-ruby (~> 1.0)
66
67
  ice_nine (0.11.2)
67
68
  json (2.6.3)
68
69
  json_schema (0.21.0)
69
- jsonpath (1.1.2)
70
+ jsonpath (1.1.3)
70
71
  multi_json
71
- mini_portile2 (2.8.1)
72
- minitest (5.18.0)
72
+ language_server-protocol (3.17.0.3)
73
+ mini_portile2 (2.8.4)
74
+ minitest (5.20.0)
73
75
  multi_json (1.15.0)
74
- nokogiri (1.14.2)
75
- mini_portile2 (~> 2.8.0)
76
+ nokogiri (1.15.4)
77
+ mini_portile2 (~> 2.8.2)
76
78
  racc (~> 1.4)
77
79
  openapi3_parser (0.9.2)
78
80
  commonmarker (~> 0.17)
79
- openapi_parser (0.15.0)
80
- optimist (3.0.1)
81
- parallel (1.22.1)
82
- parser (3.2.1.0)
81
+ openapi_parser (1.0.0)
82
+ optimist (3.1.0)
83
+ parallel (1.23.0)
84
+ parser (3.2.2.3)
83
85
  ast (~> 2.4.1)
86
+ racc
84
87
  patience_diff (1.2.0)
85
88
  optimist (~> 3.0)
86
- racc (1.6.2)
87
- rack (3.0.4.2)
89
+ racc (1.7.1)
90
+ rack (3.0.8)
88
91
  rainbow (3.1.1)
89
92
  rake (13.0.6)
90
- regexp_parser (2.7.0)
91
- rexml (3.2.5)
93
+ regexp_parser (2.8.1)
94
+ rexml (3.2.6)
92
95
  rspec (3.12.0)
93
96
  rspec-core (~> 3.12.0)
94
97
  rspec-expectations (~> 3.12.0)
95
98
  rspec-mocks (~> 3.12.0)
96
- rspec-core (3.12.1)
99
+ rspec-core (3.12.2)
97
100
  rspec-support (~> 3.12.0)
98
- rspec-expectations (3.12.2)
101
+ rspec-expectations (3.12.3)
99
102
  diff-lcs (>= 1.2.0, < 2.0)
100
103
  rspec-support (~> 3.12.0)
101
- rspec-mocks (3.12.3)
104
+ rspec-mocks (3.12.6)
102
105
  diff-lcs (>= 1.2.0, < 2.0)
103
106
  rspec-support (~> 3.12.0)
104
- rspec-support (3.12.0)
107
+ rspec-support (3.12.1)
105
108
  rspec_junit_formatter (0.6.0)
106
109
  rspec-core (>= 2, < 4, != 2.12.0)
107
- rss (0.2.9)
110
+ rss (0.3.0)
108
111
  rexml
109
- rubocop (1.48.0)
112
+ rubocop (1.56.3)
113
+ base64 (~> 0.1.1)
110
114
  json (~> 2.3)
115
+ language_server-protocol (>= 3.17.0)
111
116
  parallel (~> 1.10)
112
- parser (>= 3.2.0.0)
117
+ parser (>= 3.2.2.3)
113
118
  rainbow (>= 2.2.2, < 4.0)
114
119
  regexp_parser (>= 1.8, < 3.0)
115
120
  rexml (>= 3.2.5, < 4.0)
116
- rubocop-ast (>= 1.26.0, < 2.0)
121
+ rubocop-ast (>= 1.28.1, < 2.0)
117
122
  ruby-progressbar (~> 1.7)
118
123
  unicode-display_width (>= 2.4.0, < 3.0)
119
- rubocop-ast (1.27.0)
124
+ rubocop-ast (1.29.0)
120
125
  parser (>= 3.2.1.0)
121
- rubocop-capybara (2.17.1)
126
+ rubocop-capybara (2.18.0)
122
127
  rubocop (~> 1.41)
128
+ rubocop-factory_bot (2.23.1)
129
+ rubocop (~> 1.33)
123
130
  rubocop-rake (0.6.0)
124
131
  rubocop (~> 1.0)
125
- rubocop-rspec (2.18.1)
132
+ rubocop-rspec (2.24.0)
126
133
  rubocop (~> 1.33)
127
134
  rubocop-capybara (~> 2.17)
135
+ rubocop-factory_bot (~> 2.22)
128
136
  ruby-progressbar (1.13.0)
129
137
  simplecov (0.22.0)
130
138
  docile (~> 1.1)
@@ -132,15 +140,15 @@ GEM
132
140
  simplecov_json_formatter (~> 0.1)
133
141
  simplecov-html (0.12.3)
134
142
  simplecov_json_formatter (0.1.4)
135
- super_diff (0.9.0)
143
+ super_diff (0.10.0)
136
144
  attr_extras (>= 6.2.4)
137
145
  diff-lcs
138
146
  patience_diff
139
- thor (1.2.1)
147
+ thor (1.2.2)
140
148
  tzinfo (2.0.6)
141
149
  concurrent-ruby (~> 1.0)
142
150
  unicode-display_width (2.4.2)
143
- zeitwerk (2.6.7)
151
+ zeitwerk (2.6.11)
144
152
 
145
153
  PLATFORMS
146
154
  ruby
@@ -159,4 +167,4 @@ DEPENDENCIES
159
167
  simplecov
160
168
 
161
169
  BUNDLED WITH
162
- 2.3.17
170
+ 2.4.13
data/README.md CHANGED
@@ -132,7 +132,7 @@ The release process is much like any other gem. First bump the version in `lib/c
132
132
  ```
133
133
  bundle exec rake release
134
134
  ```
135
- which pushes the gem to rubygems.org. Next write up the release notes: https://github.com/sul-dlss/cocina-models/releases .
135
+ which pushes the gem to rubygems.org.
136
136
 
137
137
  ### Step 2: Update client gems coupled to the models
138
138
 
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.add_dependency 'openapi3_parser' # Parsing openapi doc
36
36
  # Match these version requirements to what committee wants,
37
37
  # so that our client (non-committee) users have the same dependencies.
38
- spec.add_dependency 'openapi_parser', '>= 0.11.1', '< 1.0'
38
+ spec.add_dependency 'openapi_parser', '~> 1.0'
39
39
  spec.add_dependency 'rss' # used for date/time validation
40
40
  spec.add_dependency 'super_diff'
41
41
  spec.add_dependency 'thor'
@@ -24,6 +24,11 @@ module Cocina
24
24
  generate_for(schema) if schema
25
25
  end
26
26
 
27
+ %w[DRO Collection AdminPolicy].each do |schema_name|
28
+ schema = schema_for(schema_name, lite: true)
29
+ filepaths << generate_for(schema)
30
+ end
31
+
27
32
  auto_format(filepaths)
28
33
  generate_vocab
29
34
  generate_descriptive_docs
@@ -94,13 +99,13 @@ module Cocina
94
99
  @schemas ||= Openapi3Parser.load_file(options[:openapi]).components.schemas
95
100
  end
96
101
 
97
- def schema_for(schema_name)
102
+ def schema_for(schema_name, lite: false)
98
103
  schema_doc = schemas[schema_name]
99
104
  return nil if schema_doc.nil?
100
105
 
101
106
  case schema_doc.type
102
107
  when 'object'
103
- Schema.new(schema_doc, schemas: schemas.keys)
108
+ Schema.new(schema_doc, schemas: schemas.keys, lite: lite)
104
109
  when 'string'
105
110
  Datatype.new(schema_doc, schemas: schemas.keys)
106
111
  when NilClass
@@ -71,7 +71,7 @@ module Cocina
71
71
  end
72
72
 
73
73
  def validatable?
74
- !schema_doc.node_context.document.paths["/validate/#{schema_doc.name}"].nil?
74
+ !schema_doc.node_context.document.paths["/validate/#{schema_doc.name}"].nil? && !lite
75
75
  end
76
76
 
77
77
  def properties
@@ -119,12 +119,14 @@ module Cocina
119
119
 
120
120
  def schema_properties_for(doc)
121
121
  doc.properties.map do |key, properties_doc|
122
- property_class_for(properties_doc).new(properties_doc,
123
- key: key,
124
- required: doc.requires?(key),
125
- nullable: properties_doc.nullable?,
126
- parent: self,
127
- schemas: schemas)
122
+ clazz = property_class_for(properties_doc)
123
+ clazz.new(properties_doc,
124
+ key: key,
125
+ required: doc.requires?(key),
126
+ relaxed: lite && clazz != SchemaValue,
127
+ nullable: properties_doc.nullable?,
128
+ parent: self,
129
+ schemas: schemas)
128
130
  end
129
131
  end
130
132
  end
@@ -4,9 +4,9 @@ module Cocina
4
4
  module Generator
5
5
  # Base class for generating from openapi
6
6
  class SchemaBase
7
- attr_reader :schema_doc, :key, :required, :nullable, :parent, :relaxed, :schemas
7
+ attr_reader :schema_doc, :key, :required, :nullable, :parent, :relaxed, :schemas, :lite
8
8
 
9
- def initialize(schema_doc, key: nil, required: false, nullable: false, parent: nil, relaxed: false, schemas: [])
9
+ def initialize(schema_doc, key: nil, required: false, nullable: false, parent: nil, relaxed: false, schemas: [], lite: false)
10
10
  @schema_doc = schema_doc
11
11
  @key = key
12
12
  @required = required
@@ -14,6 +14,7 @@ module Cocina
14
14
  @parent = parent
15
15
  @relaxed = relaxed
16
16
  @schemas = schemas
17
+ @lite = lite
17
18
  end
18
19
 
19
20
  def filename
@@ -21,7 +22,7 @@ module Cocina
21
22
  end
22
23
 
23
24
  def name
24
- key || schema_doc.name
25
+ "#{key || schema_doc.name}#{lite ? 'Lite' : ''}"
25
26
  end
26
27
 
27
28
  # Allows nullable values to be set to nil. This is useful when doing an
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class AdminPolicyLite < Struct
6
+ include Checkable
7
+
8
+ TYPES = ['https://cocina.sul.stanford.edu/models/admin_policy'].freeze
9
+
10
+ # The version of Cocina with which this object conforms.
11
+ # example: 1.2.3
12
+ attribute :cocinaVersion, CocinaVersion.default(VERSION)
13
+ attribute :type, Types::Strict::String.enum(*AdminPolicyLite::TYPES)
14
+ # example: druid:bc123df4567
15
+ attribute :externalIdentifier, Druid
16
+ attribute :label, Types::Strict::String
17
+ attribute :version, Types::Strict::Integer
18
+ attribute? :administrative, AdminPolicyAdministrative.optional
19
+ attribute? :description, Description.optional
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ # A group of Digital Repository Objects that indicate some type of conceptual grouping within the domain that is worth reusing across the system.
6
+ class CollectionLite < Struct
7
+ include Checkable
8
+
9
+ TYPES = ['https://cocina.sul.stanford.edu/models/collection',
10
+ 'https://cocina.sul.stanford.edu/models/curated-collection',
11
+ 'https://cocina.sul.stanford.edu/models/user-collection',
12
+ 'https://cocina.sul.stanford.edu/models/exhibit',
13
+ 'https://cocina.sul.stanford.edu/models/series'].freeze
14
+
15
+ # The version of Cocina with which this object conforms.
16
+ # example: 1.2.3
17
+ attribute :cocinaVersion, CocinaVersion.default(VERSION)
18
+ # The content type of the Collection. Selected from an established set of values.
19
+ attribute :type, Types::Strict::String.enum(*CollectionLite::TYPES)
20
+ # example: druid:bc123df4567
21
+ attribute :externalIdentifier, Druid
22
+ # Primary processing label (can be same as title) for a Collection.
23
+ attribute :label, Types::Strict::String
24
+ # Version for the Collection within SDR.
25
+ attribute :version, Types::Strict::Integer
26
+ attribute? :access, CollectionAccess.optional
27
+ attribute? :administrative, Administrative.optional
28
+ attribute? :description, Description.optional
29
+ attribute? :identification, CollectionIdentification.optional
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ # Domain-defined abstraction of a 'work'. Digital Repository Objects' abstraction is describable for our domain’s purposes, i.e. for management needs within our system.
6
+ class DROLite < Struct
7
+ include Checkable
8
+
9
+ TYPES = ['https://cocina.sul.stanford.edu/models/object',
10
+ 'https://cocina.sul.stanford.edu/models/3d',
11
+ 'https://cocina.sul.stanford.edu/models/agreement',
12
+ 'https://cocina.sul.stanford.edu/models/book',
13
+ 'https://cocina.sul.stanford.edu/models/document',
14
+ 'https://cocina.sul.stanford.edu/models/geo',
15
+ 'https://cocina.sul.stanford.edu/models/image',
16
+ 'https://cocina.sul.stanford.edu/models/page',
17
+ 'https://cocina.sul.stanford.edu/models/photograph',
18
+ 'https://cocina.sul.stanford.edu/models/manuscript',
19
+ 'https://cocina.sul.stanford.edu/models/map',
20
+ 'https://cocina.sul.stanford.edu/models/media',
21
+ 'https://cocina.sul.stanford.edu/models/track',
22
+ 'https://cocina.sul.stanford.edu/models/webarchive-binary',
23
+ 'https://cocina.sul.stanford.edu/models/webarchive-seed'].freeze
24
+
25
+ # The version of Cocina with which this object conforms.
26
+ # example: 1.2.3
27
+ attribute :cocinaVersion, CocinaVersion.default(VERSION)
28
+ # The content type of the DRO. Selected from an established set of values.
29
+ attribute :type, Types::Strict::String.enum(*DROLite::TYPES)
30
+ # example: druid:bc123df4567
31
+ attribute :externalIdentifier, Druid
32
+ # Primary processing label (can be same as title) for a DRO.
33
+ attribute :label, Types::Strict::String
34
+ # Version for the DRO within SDR.
35
+ attribute :version, Types::Strict::Integer
36
+ attribute? :access, DROAccess.optional
37
+ attribute? :administrative, Administrative.optional
38
+ attribute? :description, Description.optional
39
+ attribute? :identification, Identification.optional
40
+ attribute? :structural, DROStructural.optional
41
+ attribute? :geographic, Geographic.optional
42
+ end
43
+ end
44
+ end
@@ -11,14 +11,10 @@ module Cocina
11
11
  'https://cocina.sul.stanford.edu/models/resources/document',
12
12
  'https://cocina.sul.stanford.edu/models/resources/file',
13
13
  'https://cocina.sul.stanford.edu/models/resources/image',
14
- 'https://cocina.sul.stanford.edu/models/resources/main-augmented',
15
- 'https://cocina.sul.stanford.edu/models/resources/main-original',
16
14
  'https://cocina.sul.stanford.edu/models/resources/media',
17
15
  'https://cocina.sul.stanford.edu/models/resources/object',
18
16
  'https://cocina.sul.stanford.edu/models/resources/page',
19
- 'https://cocina.sul.stanford.edu/models/resources/permissions',
20
17
  'https://cocina.sul.stanford.edu/models/resources/preview',
21
- 'https://cocina.sul.stanford.edu/models/resources/supplement',
22
18
  'https://cocina.sul.stanford.edu/models/resources/3d',
23
19
  'https://cocina.sul.stanford.edu/models/resources/thumb',
24
20
  'https://cocina.sul.stanford.edu/models/resources/video'].freeze
@@ -10,14 +10,10 @@ module Cocina
10
10
  property :document
11
11
  property :file
12
12
  property :image
13
- property :'main-augmented'
14
- property :'main-original'
15
13
  property :media
16
14
  property :object
17
15
  property :page
18
- property :permissions
19
16
  property :preview
20
- property :supplement
21
17
  property :thumb
22
18
  property :video
23
19
  end
@@ -145,7 +145,7 @@ module Cocina
145
145
  return if raw_type.blank?
146
146
 
147
147
  first_event_type = event_type(origin_info_nodes.first)
148
- return first_event_type if origin_info_nodes.all? { |node| event_type(node) == first_event_type }
148
+ first_event_type if origin_info_nodes.all? { |node| event_type(node) == first_event_type }
149
149
  end
150
150
 
151
151
  # @return String displayLabel for the cocina event if it is the same for all the origin_info_nodes, o.w. nil
@@ -154,7 +154,7 @@ module Cocina
154
154
  return if raw_label.blank?
155
155
 
156
156
  first_label = display_label(origin_info_nodes.first)
157
- return first_label if origin_info_nodes.all? { |node| display_label(node) == first_label }
157
+ first_label if origin_info_nodes.all? { |node| display_label(node) == first_label }
158
158
  end
159
159
 
160
160
  def add_info_to_event(event, origin_info_node)
@@ -93,7 +93,8 @@ module Cocina
93
93
 
94
94
  def build_subject
95
95
  return [build_subject_for_center_point] unless centerpoint.empty?
96
- return build_subject_for_bounding_box unless envelope.empty?
96
+
97
+ build_subject_for_bounding_box unless envelope.empty?
97
98
  end
98
99
 
99
100
  def build_subject_for_center_point
@@ -235,7 +235,7 @@ module Cocina
235
235
  cocina_roles = role_nodes.filter_map { |role_node| role_for(role_node) }.presence
236
236
  return if cocina_roles.blank?
237
237
 
238
- return 'event' if cocina_roles.first[:value] == 'event'
238
+ 'event' if cocina_roles.first[:value] == 'event'
239
239
  end
240
240
 
241
241
  def activity_date?(name_part_node)
@@ -6,6 +6,7 @@ module Cocina
6
6
  module Mapping
7
7
  module FromMods
8
8
  # Helper class - provides subject authority codes
9
+ # rubocop:disable Metrics/CollectionLiteralLength
9
10
  class SubjectAuthorityCodes
10
11
  # Subject codes: https://id.loc.gov/vocabulary/subjectSchemes.html
11
12
  # curl https://id.loc.gov/vocabulary/subjectSchemes.madsrdf.json | jq '[.[0]."http://www.loc.gov/mads/rdf/v1#hasMADSSchemeMember"[]."@id"[44:]]'
@@ -787,6 +788,7 @@ module Cocina
787
788
  + CARTOGRAPHIC_CODES + OCCUPATION_CODES + COUNTRY_CODES + GEOGRAPHIC_CODES \
788
789
  + ISO_CODES + MARC_CODES + PARKER + OTHER_CODES
789
790
  end
791
+ # rubocop:enable Metrics/CollectionLiteralLength
790
792
  end
791
793
  end
792
794
  end
@@ -108,7 +108,6 @@ module Cocina
108
108
  # rubocop:enable Metrics/CyclomaticComplexity
109
109
  # rubocop:enable Metrics/AbcSize
110
110
 
111
- # rubocop:disable Naming/PredicateName
112
111
  def has_authority?(nodes)
113
112
  nodes_to_a(nodes).all? { |node| node[:authority] }
114
113
  end
@@ -116,7 +115,6 @@ module Cocina
116
115
  def has_same_authority?(nodes, same_node)
117
116
  nodes_to_a(nodes).all? { |node| same_node[:authority] == node[:authority] || (lcsh_or_naf?(same_node) && lcsh_or_naf?(node)) }
118
117
  end
119
- # rubocop:enable Naming/PredicateName
120
118
 
121
119
  def lcsh_or_naf?(node)
122
120
  %w[lcsh naf].include?(node[:authority])
@@ -136,7 +134,6 @@ module Cocina
136
134
  end
137
135
 
138
136
  # rubocop:disable Naming/MethodName
139
- # rubocop:disable Naming/PredicateName
140
137
  def has_authorityURI?(nodes)
141
138
  nodes_to_a(nodes).all? { |node| node[:authorityURI] }
142
139
  end
@@ -156,9 +153,8 @@ module Cocina
156
153
  def add_valueURI(nodes, from_node)
157
154
  nodes_to_a(nodes).each { |node| node[:valueURI] = from_node[:valueURI] }
158
155
  end
159
- # rubocop:enable Naming/MethodName
160
- # rubocop:enable Naming/PredicateName
161
156
 
157
+ # rubocop:enable Naming/MethodName
162
158
  def nodes_to_a(nodes)
163
159
  nodes.is_a?(Nokogiri::XML::NodeSet) ? nodes : [nodes]
164
160
  end
@@ -10,14 +10,10 @@ module Cocina
10
10
  'https://cocina.sul.stanford.edu/models/resources/document',
11
11
  'https://cocina.sul.stanford.edu/models/resources/file',
12
12
  'https://cocina.sul.stanford.edu/models/resources/image',
13
- 'https://cocina.sul.stanford.edu/models/resources/main-augmented',
14
- 'https://cocina.sul.stanford.edu/models/resources/main-original',
15
13
  'https://cocina.sul.stanford.edu/models/resources/media',
16
14
  'https://cocina.sul.stanford.edu/models/resources/object',
17
15
  'https://cocina.sul.stanford.edu/models/resources/page',
18
- 'https://cocina.sul.stanford.edu/models/resources/permissions',
19
16
  'https://cocina.sul.stanford.edu/models/resources/preview',
20
- 'https://cocina.sul.stanford.edu/models/resources/supplement',
21
17
  'https://cocina.sul.stanford.edu/models/resources/3d',
22
18
  'https://cocina.sul.stanford.edu/models/resources/thumb',
23
19
  'https://cocina.sul.stanford.edu/models/resources/video'].freeze
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.89.1'
5
+ VERSION = '0.91.0'
6
6
  end
7
7
  end
data/lib/cocina/models.rb CHANGED
@@ -23,6 +23,7 @@ class CocinaModelsInflector < Zeitwerk::Inflector
23
23
  'dro' => 'DRO',
24
24
  'request_dro' => 'RequestDRO',
25
25
  'dro_access' => 'DROAccess',
26
+ 'dro_lite' => 'DROLite',
26
27
  'dro_structural' => 'DROStructural',
27
28
  'dro_with_metadata' => 'DROWithMetadata',
28
29
  'request_dro_structural' => 'RequestDROStructural',
@@ -75,6 +76,8 @@ module Cocina
75
76
  end
76
77
  # rubocop:enable Naming/MethodName
77
78
 
79
+ METADATA_KEYS = %i[created modified lock].freeze
80
+
78
81
  # @param [Hash] dyn a ruby hash representation of the JSON serialization of a collection or DRO
79
82
  # @param [boolean] validate
80
83
  # @return [DRO,Collection,AdminPolicy]
@@ -84,11 +87,11 @@ module Cocina
84
87
  def self.build(dyn, validate: true)
85
88
  clazz = case type_for(dyn)
86
89
  when *DRO::TYPES
87
- DRO
90
+ has_metadata?(dyn) ? DROWithMetadata : DRO
88
91
  when *Collection::TYPES
89
- Collection
92
+ has_metadata?(dyn) ? ColectionWithMetadata : Collection
90
93
  when *AdminPolicy::TYPES
91
- AdminPolicy
94
+ has_metadata?(dyn) ? AdminPolicyWithMetadata : AdminPolicy
92
95
  else
93
96
  raise UnknownTypeError, "Unknown type: '#{dyn.with_indifferent_access.fetch('type')}'"
94
97
  end
@@ -115,11 +118,36 @@ module Cocina
115
118
  clazz.new(dyn, false, validate)
116
119
  end
117
120
 
121
+ # Build "lite" versions of DROs, Collections, and AdminPolicies.
122
+ # Lite versions do not require attributes that are required in the normal versions.
123
+ # For example, "description" is required for a DRO, but optional for a DROLite.
124
+ # Lite versions also are not validated / validatable.
125
+ # Lite versions are useful for instantiating partially populated cocina objects similar to an
126
+ # ActiveRecord instantiated using .select (See https://guides.rubyonrails.org/active_record_querying.html#selecting-specific-fields)
127
+ # @param [Hash] dyn a ruby hash representation of the JSON serialization of a Collection, DRO, or AdminPolicy
128
+ # @return [DROLite,CollectionLite,AdminPolicyLite]
129
+ # @raises [UnknownTypeError] if a valid type is not found in the data
130
+ # @raises [ValidationError] if a type field cannot be found in the data
131
+ def self.build_lite(dyn)
132
+ clazz = case type_for(dyn)
133
+ when *DRO::TYPES
134
+ DROLite
135
+ when *Collection::TYPES
136
+ CollectionLite
137
+ when *AdminPolicy::TYPES
138
+ AdminPolicyLite
139
+ else
140
+ raise UnknownTypeError, "Unknown type: '#{dyn.with_indifferent_access.fetch('type')}'"
141
+ end
142
+ # dyn for lite may contain extra keys
143
+ clazz.new(dyn.with_indifferent_access.slice(*clazz.attribute_names))
144
+ end
145
+
118
146
  # Coerces DROWithMetadata, CollectionWithMetadata, AdminPolicyWithMetadata to DRO, Collection, AdminPolicy
119
147
  # @param [DROWithMetadata,CollectionWithMetadata,AdminPolicyWithMetadata] cocina_object
120
148
  # @return [DRO,Collection,AdminPolicy]
121
149
  def self.without_metadata(cocina_object)
122
- build(cocina_object.to_h.except(:created, :modified, :lock), validate: false)
150
+ build(cocina_object.to_h.except(*METADATA_KEYS), validate: false)
123
151
  end
124
152
 
125
153
  # Adds metadata to a DRO, Collection, AdminPolicy
@@ -158,6 +186,13 @@ module Cocina
158
186
  end
159
187
  private_class_method :type_for
160
188
 
189
+ def self.has_metadata?(dyn)
190
+ # Intentionally checking both string- and symbol-type keys in the hash via `#[]`
191
+ # instead of `#with_indifferent_access` (and/or `#fetch`) in order to be more memory-efficient
192
+ METADATA_KEYS.any? { |key| dyn[key] || dyn[key.to_s] }
193
+ end
194
+ private_class_method :has_metadata?
195
+
161
196
  def self.druid_regex
162
197
  @druid_regex ||= begin
163
198
  str = Openapi3Parser.load_file('openapi.yml').components.schemas['Druid'].pattern
@@ -15,10 +15,13 @@ module Cocina
15
15
  SUPPORTED_TYPES = %i[
16
16
  admin_policy
17
17
  admin_policy_with_metadata
18
+ admin_policy_lite
18
19
  collection
19
20
  collection_with_metadata
21
+ collection_lite
20
22
  dro
21
23
  dro_with_metadata
24
+ dro_lite
22
25
  request_admin_policy
23
26
  request_collection
24
27
  request_dro
@@ -88,6 +91,10 @@ module Cocina
88
91
  Cocina::Models.build(build_dro_properties(**DRO_DEFAULTS.merge(attributes)))
89
92
  end
90
93
 
94
+ def self.build_dro_lite(attributes)
95
+ Cocina::Models.build_lite(build_dro_properties(**DRO_DEFAULTS.merge(attributes)))
96
+ end
97
+
91
98
  # rubocop:disable Metrics/ParameterLists
92
99
  def self.build_request_dro_properties(type:, version:, label:, title:, source_id:, admin_policy_id:,
93
100
  barcode: nil, catkeys: [], folio_instance_hrids: [], collection_ids: [])
@@ -166,6 +173,10 @@ module Cocina
166
173
  Cocina::Models.build(build_collection_properties(**COLLECTION_DEFAULTS.merge(attributes)))
167
174
  end
168
175
 
176
+ def self.build_collection_lite(attributes)
177
+ Cocina::Models.build_lite(build_collection_properties(**COLLECTION_DEFAULTS.merge(attributes)))
178
+ end
179
+
169
180
  def self.build_request_collection(attributes)
170
181
  Cocina::Models.build_request(build_request_collection_properties(**REQUEST_COLLECTION_DEFAULTS.merge(attributes)))
171
182
  end
@@ -174,6 +185,10 @@ module Cocina
174
185
  Cocina::Models.build(build_admin_policy_properties(**ADMIN_POLICY_DEFAULTS.merge(attributes)))
175
186
  end
176
187
 
188
+ def self.build_admin_policy_lite(attributes)
189
+ Cocina::Models.build_lite(build_admin_policy_properties(**ADMIN_POLICY_DEFAULTS.merge(attributes)))
190
+ end
191
+
177
192
  def self.build_request_admin_policy(attributes)
178
193
  Cocina::Models.build_request(build_request_admin_policy_properties(**REQUEST_ADMIN_POLICY_DEFAULTS.merge(attributes)))
179
194
  end
data/openapi.yml CHANGED
@@ -1109,14 +1109,10 @@ components:
1109
1109
  - 'https://cocina.sul.stanford.edu/models/resources/document'
1110
1110
  - 'https://cocina.sul.stanford.edu/models/resources/file'
1111
1111
  - 'https://cocina.sul.stanford.edu/models/resources/image'
1112
- - 'https://cocina.sul.stanford.edu/models/resources/main-augmented'
1113
- - 'https://cocina.sul.stanford.edu/models/resources/main-original'
1114
1112
  - 'https://cocina.sul.stanford.edu/models/resources/media'
1115
1113
  - 'https://cocina.sul.stanford.edu/models/resources/object'
1116
1114
  - 'https://cocina.sul.stanford.edu/models/resources/page'
1117
- - 'https://cocina.sul.stanford.edu/models/resources/permissions'
1118
1115
  - 'https://cocina.sul.stanford.edu/models/resources/preview'
1119
- - 'https://cocina.sul.stanford.edu/models/resources/supplement'
1120
1116
  - 'https://cocina.sul.stanford.edu/models/resources/3d'
1121
1117
  - 'https://cocina.sul.stanford.edu/models/resources/thumb'
1122
1118
  - 'https://cocina.sul.stanford.edu/models/resources/video'
@@ -1813,14 +1809,10 @@ components:
1813
1809
  - 'https://cocina.sul.stanford.edu/models/resources/document'
1814
1810
  - 'https://cocina.sul.stanford.edu/models/resources/file'
1815
1811
  - 'https://cocina.sul.stanford.edu/models/resources/image'
1816
- - 'https://cocina.sul.stanford.edu/models/resources/main-augmented'
1817
- - 'https://cocina.sul.stanford.edu/models/resources/main-original'
1818
1812
  - 'https://cocina.sul.stanford.edu/models/resources/media'
1819
1813
  - 'https://cocina.sul.stanford.edu/models/resources/object'
1820
1814
  - 'https://cocina.sul.stanford.edu/models/resources/page'
1821
- - 'https://cocina.sul.stanford.edu/models/resources/permissions'
1822
1815
  - 'https://cocina.sul.stanford.edu/models/resources/preview'
1823
- - 'https://cocina.sul.stanford.edu/models/resources/supplement'
1824
1816
  - 'https://cocina.sul.stanford.edu/models/resources/3d'
1825
1817
  - 'https://cocina.sul.stanford.edu/models/resources/thumb'
1826
1818
  - 'https://cocina.sul.stanford.edu/models/resources/video'
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.89.1
4
+ version: 0.91.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-07 00:00:00.000000000 Z
11
+ date: 2023-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -140,20 +140,14 @@ dependencies:
140
140
  name: openapi_parser
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: 0.11.1
146
- - - "<"
143
+ - - "~>"
147
144
  - !ruby/object:Gem::Version
148
145
  version: '1.0'
149
146
  type: :runtime
150
147
  prerelease: false
151
148
  version_requirements: !ruby/object:Gem::Requirement
152
149
  requirements:
153
- - - ">="
154
- - !ruby/object:Gem::Version
155
- version: 0.11.1
156
- - - "<"
150
+ - - "~>"
157
151
  - !ruby/object:Gem::Version
158
152
  version: '1.0'
159
153
  - !ruby/object:Gem::Dependency
@@ -367,6 +361,7 @@ files:
367
361
  - lib/cocina/models/admin_policy.rb
368
362
  - lib/cocina/models/admin_policy_access_template.rb
369
363
  - lib/cocina/models/admin_policy_administrative.rb
364
+ - lib/cocina/models/admin_policy_lite.rb
370
365
  - lib/cocina/models/admin_policy_with_metadata.rb
371
366
  - lib/cocina/models/administrative.rb
372
367
  - lib/cocina/models/applies_to.rb
@@ -384,6 +379,7 @@ files:
384
379
  - lib/cocina/models/collection.rb
385
380
  - lib/cocina/models/collection_access.rb
386
381
  - lib/cocina/models/collection_identification.rb
382
+ - lib/cocina/models/collection_lite.rb
387
383
  - lib/cocina/models/collection_with_metadata.rb
388
384
  - lib/cocina/models/contributor.rb
389
385
  - lib/cocina/models/controlled_digital_lending_access.rb
@@ -407,6 +403,7 @@ files:
407
403
  - lib/cocina/models/doi_pattern.rb
408
404
  - lib/cocina/models/dro.rb
409
405
  - lib/cocina/models/dro_access.rb
406
+ - lib/cocina/models/dro_lite.rb
410
407
  - lib/cocina/models/dro_structural.rb
411
408
  - lib/cocina/models/dro_with_metadata.rb
412
409
  - lib/cocina/models/druid.rb
@@ -533,7 +530,7 @@ homepage: https://github.com/sul-dlss/cocina-models
533
530
  licenses: []
534
531
  metadata:
535
532
  rubygems_mfa_required: 'true'
536
- post_install_message:
533
+ post_install_message:
537
534
  rdoc_options: []
538
535
  require_paths:
539
536
  - lib
@@ -549,7 +546,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
549
546
  version: '0'
550
547
  requirements: []
551
548
  rubygems_version: 3.3.7
552
- signing_key:
549
+ signing_key:
553
550
  specification_version: 4
554
551
  summary: Data models for the SDR
555
552
  test_files: []