cocina-models 0.65.1 → 0.66.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: 896e1abaec6ec5cd04b1d3279e30723f0308ee96131656f8197a522fd910ff34
4
- data.tar.gz: e01d1e2ca3455bacd76c8fd95f4a07b2444983a356e338d03950fc4025acd40c
3
+ metadata.gz: def07c3b758899fb7dafda2ab26d7376318137895cb1335ab22404ab939e6e15
4
+ data.tar.gz: cb8f57478510d3f40a9241e944484437889dbf4b0b09e992696da7b9d1e595c1
5
5
  SHA512:
6
- metadata.gz: b82cf62f83fe5d2854fb618df552e487476be6ebc0d0926978e56de62cfae9df9d19eeaceddf506eeb99e84037d4561353563a83a1b93e11ca1feebbe377c2ac
7
- data.tar.gz: 2b479b5e1a73da2e3df558d515d403862312d81b5feb5faf62f1931065b6b074a80961a0a8b8c5492b505482f3adbe3d64f850c96d68c3a296faccf6ce3d6627
6
+ metadata.gz: 1de2f3d0703139311d8f58f1ec24b5b579b330c0461c645ebe76d153930ab91850d694a2b7a138a8ee6c63ee8ba5562f6c24ff044a7dd0bf40355eb1007afd51
7
+ data.tar.gz: ecdfd2b784a0e42c30e348d08dbe7a6f092c369d7830dd86b11c2ff8185fef4238068fdc4b5e7fe8af90d1d9477e17436d03fde5058855d97819a7270ebc304e
@@ -1,11 +1,12 @@
1
1
  **NOTE: Changes to openapi.yml require updating openapi.yml for sdr-api and dor-services-app and generating models - see README.**
2
2
 
3
- ## Why was this change made?
3
+ ## Why was this change made? 🤔
4
4
 
5
5
 
6
6
 
7
- ## How was this change tested?
7
+ ## How was this change tested? 🤨
8
+
9
+ ⚡ ⚠ If this change has cross service impact, ***run [integration tests](https://github.com/sul-dlss/infrastructure-integration-test)*** and/or test in [stage|qa] environment, in addition to specs. ⚡
8
10
 
9
11
 
10
12
 
11
- ## Which documentation and/or configurations were updated?
@@ -76,6 +76,7 @@ module Cocina
76
76
  run("rubocop -a #{filepath} > /dev/null")
77
77
  end
78
78
 
79
+ # rubocop:disable Metrics/AbcSize
79
80
  def clean_output
80
81
  FileUtils.mkdir_p(options[:output])
81
82
  files = Dir.glob("#{options[:output]}/*.rb")
@@ -83,8 +84,10 @@ module Cocina
83
84
  files.delete("#{options[:output]}/version.rb")
84
85
  files.delete("#{options[:output]}/checkable.rb")
85
86
  files.delete("#{options[:output]}/validator.rb")
87
+ files.delete("#{options[:output]}/validatable.rb")
86
88
  FileUtils.rm_f(files)
87
89
  end
90
+ # rubocop:enable Metrics/AbcSize
88
91
  end
89
92
  end
90
93
  end
@@ -16,11 +16,10 @@ module Cocina
16
16
  module Models
17
17
  class #{name} < Struct
18
18
 
19
+ #{validate}
19
20
  #{types}
20
21
 
21
22
  #{model_attributes}
22
-
23
- #{validate}
24
23
  end
25
24
  end
26
25
  end
@@ -64,10 +63,7 @@ module Cocina
64
63
  return '' unless validatable?
65
64
 
66
65
  <<~RUBY
67
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
68
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
69
- super(attributes, safe, &block)
70
- end
66
+ include Validatable
71
67
  RUBY
72
68
  end
73
69
 
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class AdminPolicy < Struct
6
+ include Validatable
7
+
6
8
  include Checkable
7
9
 
8
10
  TYPES = ['http://cocina.sul.stanford.edu/models/admin_policy.jsonld'].freeze
@@ -17,11 +19,6 @@ module Cocina
17
19
  attribute :version, Types::Strict::Integer
18
20
  attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
19
21
  attribute :description, Description.optional.meta(omittable: true)
20
-
21
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
22
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
23
- super(attributes, safe, &block)
24
- end
25
22
  end
26
23
  end
27
24
  end
@@ -3,8 +3,6 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class AdminPolicyAdministrative < Struct
6
- # This is an XML expression of the default access (see defaultAccess)
7
- attribute :defaultObjectRights, Types::Strict::String.default('<?xml version="1.0" encoding="UTF-8"?><rightsMetadata><access type="discover"><machine><world/></machine></access><access type="read"><machine><world/></machine></access><use><human type="useAndReproduction"/><human type="creativeCommons"/><machine type="creativeCommons" uri=""/><human type="openDataCommons"/><machine type="openDataCommons" uri=""/></use><copyright><human/></copyright></rightsMetadata>').meta(omittable: true)
8
6
  attribute :defaultAccess, AdminPolicyDefaultAccess.optional.meta(omittable: true)
9
7
  attribute :registrationWorkflow, Types::Strict::Array.of(Types::Strict::String).default([].freeze)
10
8
  # An additional workflow to start for objects managed by this admin policy once the end-accession workflow step is complete
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class Collection < Struct
6
+ include Validatable
7
+
6
8
  include Checkable
7
9
 
8
10
  TYPES = ['http://cocina.sul.stanford.edu/models/collection.jsonld',
@@ -26,11 +28,6 @@ module Cocina
26
28
  attribute :administrative, Administrative.optional.meta(omittable: true)
27
29
  attribute :description, Description.optional.meta(omittable: true)
28
30
  attribute :identification, CollectionIdentification.optional.meta(omittable: true)
29
-
30
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
31
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
32
- super(attributes, safe, &block)
33
- end
34
31
  end
35
32
  end
36
33
  end
@@ -10,9 +10,9 @@ module Cocina
10
10
  attribute :copyright, Types::Strict::String.optional.meta(omittable: true)
11
11
  # The human readable use and reproduction statement that applies
12
12
  # example: Property rights reside with the repository. Literary rights reside with the creators of the documents or their heirs. To obtain permission to publish or reproduce, please contact the Public Services Librarian of the Dept. of Special Collections (http://library.stanford.edu/spc).
13
- attribute :useAndReproductionStatement, Types::Strict::String.meta(omittable: true)
13
+ attribute :useAndReproductionStatement, Types::Strict::String.optional.meta(omittable: true)
14
14
  # The license governing reuse of the Collection. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
15
- attribute :license, Types::Strict::String.meta(omittable: true)
15
+ attribute :license, Types::Strict::String.optional.meta(omittable: true)
16
16
  end
17
17
  end
18
18
  end
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class Description < Struct
6
+ include Validatable
7
+
6
8
  attribute :title, Types::Strict::Array.of(Title).default([].freeze)
7
9
  attribute :contributor, Types::Strict::Array.of(Contributor).default([].freeze)
8
10
  attribute :event, Types::Strict::Array.of(Event).default([].freeze)
@@ -20,11 +22,6 @@ module Cocina
20
22
  attribute :valueAt, Types::Strict::String.meta(omittable: true)
21
23
  # Stanford persistent URL associated with the related resource. Note this is http, not https.
22
24
  attribute :purl, Types::Strict::String
23
-
24
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
25
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
26
- super(attributes, safe, &block)
27
- end
28
25
  end
29
26
  end
30
27
  end
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class DRO < Struct
6
+ include Validatable
7
+
6
8
  include Checkable
7
9
 
8
10
  TYPES = ['http://cocina.sul.stanford.edu/models/object.jsonld',
@@ -38,11 +40,6 @@ module Cocina
38
40
  attribute :identification, Identification.optional.meta(omittable: true)
39
41
  attribute :structural, DROStructural.optional.meta(omittable: true)
40
42
  attribute :geographic, Geographic.optional.meta(omittable: true)
41
-
42
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
43
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
44
- super(attributes, safe, &block)
45
- end
46
43
  end
47
44
  end
48
45
  end
@@ -20,7 +20,7 @@ module Cocina
20
20
  attribute :embargo, Embargo.optional.meta(omittable: true)
21
21
  # The human readable use and reproduction statement that applies
22
22
  # example: Property rights reside with the repository. Literary rights reside with the creators of the documents or their heirs. To obtain permission to publish or reproduce, please contact the Public Services Librarian of the Dept. of Special Collections (http://library.stanford.edu/spc).
23
- attribute :useAndReproductionStatement, Types::Strict::String.meta(omittable: true)
23
+ attribute :useAndReproductionStatement, Types::Strict::String.optional.meta(omittable: true)
24
24
  # The license governing reuse of the DRO. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
25
25
  attribute :license, Types::Strict::String.optional.enum('https://www.gnu.org/licenses/agpl.txt', 'https://www.apache.org/licenses/LICENSE-2.0', 'https://opensource.org/licenses/BSD-2-Clause', 'https://opensource.org/licenses/BSD-3-Clause', 'https://creativecommons.org/licenses/by/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode', 'https://creativecommons.org/licenses/by-nd/4.0/legalcode', 'https://creativecommons.org/licenses/by-sa/4.0/legalcode', 'https://creativecommons.org/publicdomain/zero/1.0/legalcode', 'https://opensource.org/licenses/cddl1', 'https://www.eclipse.org/legal/epl-2.0', 'https://www.gnu.org/licenses/gpl-3.0-standalone.html', 'https://www.isc.org/downloads/software-support-policy/isc-license/', 'https://www.gnu.org/licenses/lgpl-3.0-standalone.html', 'https://opensource.org/licenses/MIT', 'https://www.mozilla.org/MPL/2.0/', 'https://opendatacommons.org/licenses/by/1-0/', 'http://opendatacommons.org/licenses/odbl/1.0/', 'https://opendatacommons.org/licenses/odbl/1-0/', 'https://creativecommons.org/publicdomain/mark/1.0/', 'https://opendatacommons.org/licenses/pddl/1-0/', 'https://creativecommons.org/licenses/by/3.0/legalcode', 'https://creativecommons.org/licenses/by-sa/3.0/legalcode', 'https://creativecommons.org/licenses/by-nd/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc-sa/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc-nd/3.0/legalcode', 'http://cocina.sul.stanford.edu/licenses/none').meta(omittable: true)
26
26
  end
@@ -19,7 +19,7 @@ module Cocina
19
19
  attribute :releaseDate, Types::Params::DateTime
20
20
  # The human readable use and reproduction statement that applies when the embargo expires.
21
21
  # example: These materials are in the public domain.
22
- attribute :useAndReproductionStatement, Types::Strict::String.meta(omittable: true)
22
+ attribute :useAndReproductionStatement, Types::Strict::String.optional.meta(omittable: true)
23
23
  end
24
24
  end
25
25
  end
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class RequestAdminPolicy < Struct
6
+ include Validatable
7
+
6
8
  include Checkable
7
9
 
8
10
  TYPES = ['http://cocina.sul.stanford.edu/models/admin_policy.jsonld'].freeze
@@ -15,11 +17,6 @@ module Cocina
15
17
  attribute :version, Types::Strict::Integer
16
18
  attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
17
19
  attribute :description, RequestDescription.optional.meta(omittable: true)
18
-
19
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
20
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
21
- super(attributes, safe, &block)
22
- end
23
20
  end
24
21
  end
25
22
  end
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class RequestCollection < Struct
6
+ include Validatable
7
+
6
8
  include Checkable
7
9
 
8
10
  TYPES = ['http://cocina.sul.stanford.edu/models/collection.jsonld',
@@ -21,11 +23,6 @@ module Cocina
21
23
  attribute(:administrative, Administrative.default { Administrative.new })
22
24
  attribute :description, RequestDescription.optional.meta(omittable: true)
23
25
  attribute :identification, CollectionIdentification.optional.meta(omittable: true)
24
-
25
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
26
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
27
- super(attributes, safe, &block)
28
- end
29
26
  end
30
27
  end
31
28
  end
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class RequestDescription < Struct
6
+ include Validatable
7
+
6
8
  attribute :title, Types::Strict::Array.of(Title).default([].freeze)
7
9
  attribute :contributor, Types::Strict::Array.of(Contributor).default([].freeze)
8
10
  attribute :event, Types::Strict::Array.of(Event).default([].freeze)
@@ -18,11 +20,6 @@ module Cocina
18
20
  attribute :adminMetadata, DescriptiveAdminMetadata.optional.meta(omittable: true)
19
21
  # URL or other pointer to the location of the resource description.
20
22
  attribute :valueAt, Types::Strict::String.meta(omittable: true)
21
-
22
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
23
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
24
- super(attributes, safe, &block)
25
- end
26
23
  end
27
24
  end
28
25
  end
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class RequestDRO < Struct
6
+ include Validatable
7
+
6
8
  include Checkable
7
9
 
8
10
  TYPES = ['http://cocina.sul.stanford.edu/models/object.jsonld',
@@ -33,11 +35,6 @@ module Cocina
33
35
  attribute(:identification, RequestIdentification.default { RequestIdentification.new })
34
36
  attribute :structural, RequestDROStructural.optional.meta(omittable: true)
35
37
  attribute :geographic, Geographic.optional.meta(omittable: true)
36
-
37
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
38
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
39
- super(attributes, safe, &block)
40
- end
41
38
  end
42
39
  end
43
40
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ # Validate upon construction
6
+ module Validatable
7
+ extend ActiveSupport::Concern
8
+
9
+ class_methods do
10
+ def new(attributes = default_attributes, safe = false, validate = true, &block)
11
+ Validator.validate(self, attributes.with_indifferent_access) if validate && name
12
+ super(attributes, safe, &block)
13
+ end
14
+ end
15
+
16
+ def new(*args)
17
+ validate = args.first.delete(:validate) if args.present?
18
+ new_model = super(*args)
19
+ Validator.validate(new_model.class, new_model.to_h) if (validate || validate.nil?) && self.class.name
20
+ new_model
21
+ end
22
+ end
23
+ end
24
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.65.1'
5
+ VERSION = '0.66.0'
6
6
  end
7
7
  end
data/openapi.yml CHANGED
@@ -212,11 +212,6 @@ components:
212
212
  type: object
213
213
  additionalProperties: false
214
214
  properties:
215
- defaultObjectRights:
216
- type: string
217
- description: This is an XML expression of the default access (see defaultAccess)
218
- deprecated: true
219
- default: <?xml version="1.0" encoding="UTF-8"?><rightsMetadata><access type="discover"><machine><world/></machine></access><access type="read"><machine><world/></machine></access><use><human type="useAndReproduction"/><human type="creativeCommons"/><machine type="creativeCommons" uri=""/><human type="openDataCommons"/><machine type="openDataCommons" uri=""/></use><copyright><human/></copyright></rightsMetadata>
220
215
  defaultAccess:
221
216
  $ref: '#/components/schemas/AdminPolicyDefaultAccess'
222
217
  registrationWorkflow:
@@ -441,9 +436,11 @@ components:
441
436
  description: The human readable use and reproduction statement that applies
442
437
  example: Property rights reside with the repository. Literary rights reside with the creators of the documents or their heirs. To obtain permission to publish or reproduce, please contact the Public Services Librarian of the Dept. of Special Collections (http://library.stanford.edu/spc).
443
438
  type: string
439
+ nullable: true
444
440
  license:
445
441
  description: The license governing reuse of the Collection. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
446
442
  type: string
443
+ nullable: true
447
444
  CollectionIdentification:
448
445
  type: object
449
446
  additionalProperties: false
@@ -915,6 +912,7 @@ components:
915
912
  description: The human readable use and reproduction statement that applies
916
913
  example: Property rights reside with the repository. Literary rights reside with the creators of the documents or their heirs. To obtain permission to publish or reproduce, please contact the Public Services Librarian of the Dept. of Special Collections (http://library.stanford.edu/spc).
917
914
  type: string
915
+ nullable: true
918
916
  license:
919
917
  description: The license governing reuse of the DRO. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
920
918
  type: string
@@ -990,6 +988,7 @@ components:
990
988
  description: The human readable use and reproduction statement that applies when the embargo expires.
991
989
  example: These materials are in the public domain.
992
990
  type: string
991
+ nullable: true
993
992
  required:
994
993
  - releaseDate
995
994
  Event:
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.65.1
4
+ version: 0.66.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: 2022-02-09 00:00:00.000000000 Z
11
+ date: 2022-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -338,6 +338,7 @@ files:
338
338
  - lib/cocina/models/standard_barcode.rb
339
339
  - lib/cocina/models/stanford_access.rb
340
340
  - lib/cocina/models/title.rb
341
+ - lib/cocina/models/validatable.rb
341
342
  - lib/cocina/models/validator.rb
342
343
  - lib/cocina/models/version.rb
343
344
  - lib/cocina/models/vocab.rb
@@ -362,7 +363,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
362
363
  - !ruby/object:Gem::Version
363
364
  version: '0'
364
365
  requirements: []
365
- rubygems_version: 3.2.32
366
+ rubygems_version: 3.3.4
366
367
  signing_key:
367
368
  specification_version: 4
368
369
  summary: Data models for the SDR