cocina-models 0.87.0 → 0.87.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/Gemfile.lock +1 -1
- data/lib/cocina/generator/schema_base.rb +14 -3
- data/lib/cocina/generator/schema_value.rb +1 -1
- data/lib/cocina/models/collection_identification.rb +1 -1
- data/lib/cocina/models/identification.rb +2 -2
- data/lib/cocina/models/related_resource.rb +1 -1
- data/lib/cocina/models/request_identification.rb +1 -1
- data/lib/cocina/models/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90ae20c8c80e4bbcf51179f0c6cba44c76f3f1551962f4da938d297c152ed77d
|
4
|
+
data.tar.gz: b71a9f5c05e153ebdf93f623164a7a77c12aeae2de32b96757096a7d2f747cfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26f2fe285a9249a70015b31b7fb30983d3f4fff6befe671508f56ac57d6bbcb901f5740290fcd3bcfb6a5e7ccc9697ccf8032b0d3aa07d6a743485ce34cb9c1d
|
7
|
+
data.tar.gz: cf8992389b7097a416f5050d196758145dd958abeef155a672fa21ffdef382f5e025e6b101dd2f26baf427aef2b195b43b93431b9faaae569d1386efe9cafb1d
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -24,10 +24,16 @@ module Cocina
|
|
24
24
|
key || schema_doc.name
|
25
25
|
end
|
26
26
|
|
27
|
-
# Allows
|
28
|
-
#
|
27
|
+
# Allows nullable values to be set to nil. This is useful when doing an
|
28
|
+
# update and you want to clear out a value. The logic also permits custom
|
29
|
+
# types (e.g., `Barcode`, `SourceId`) to be nullable if they are not
|
30
|
+
# required.
|
29
31
|
def optional
|
30
|
-
|
32
|
+
return '.optional' if nullable ||
|
33
|
+
relaxed ||
|
34
|
+
(custom_type? && !required)
|
35
|
+
|
36
|
+
''
|
31
37
|
end
|
32
38
|
|
33
39
|
def quote(item)
|
@@ -60,6 +66,11 @@ module Cocina
|
|
60
66
|
"# Validation of this property is relaxed. See the openapi for full validation.\n"
|
61
67
|
end
|
62
68
|
|
69
|
+
# dry-types-based types contain the word `Types` (e.g., `Types::String`), and custom types (e.g., `SourceId`) do not
|
70
|
+
def custom_type?
|
71
|
+
!dry_datatype(schema_doc).match?('Types')
|
72
|
+
end
|
73
|
+
|
63
74
|
def dry_datatype(doc)
|
64
75
|
return doc.name if doc.name.present? && schemas.include?(doc.name)
|
65
76
|
|
@@ -5,7 +5,6 @@ module Cocina
|
|
5
5
|
# Class for generating from an openapi value
|
6
6
|
class SchemaValue < SchemaBase
|
7
7
|
def generate
|
8
|
-
# optional has to come before default or the default value that gets set will be nil.
|
9
8
|
if required && !relaxed
|
10
9
|
"#{preamble}attribute :#{name.camelize(:lower)}, #{type}"
|
11
10
|
else
|
@@ -16,6 +15,7 @@ module Cocina
|
|
16
15
|
private
|
17
16
|
|
18
17
|
def type
|
18
|
+
# optional has to come before default or the default value that gets set will be nil.
|
19
19
|
"#{dry_datatype(schema_doc)}#{optional}#{default}#{enum}"
|
20
20
|
end
|
21
21
|
|
@@ -7,7 +7,7 @@ module Cocina
|
|
7
7
|
# Unique identifier in some other system. This is because a large proportion of what is deposited in SDR, historically and currently, are representations of objects that are also represented in other systems. For example, digitized paper and A/V collections have physical manifestations, and those physical objects are managed in systems that have their own identifiers. Similarly, books have barcodes, archival materials have collection numbers and physical locations, etc. The sourceId allows determining if an item has been deposited before and where to look for the original item if you're looking at its SDR representation. The format is: "namespace:identifier"
|
8
8
|
|
9
9
|
# example: sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026
|
10
|
-
attribute? :sourceId, SourceId
|
10
|
+
attribute? :sourceId, SourceId.optional
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -4,10 +4,10 @@ module Cocina
|
|
4
4
|
module Models
|
5
5
|
class Identification < Struct
|
6
6
|
# A barcode
|
7
|
-
attribute? :barcode, Barcode
|
7
|
+
attribute? :barcode, Barcode.optional
|
8
8
|
attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).default([].freeze)
|
9
9
|
# Digital Object Identifier (https://www.doi.org)
|
10
|
-
attribute? :doi, DOI
|
10
|
+
attribute? :doi, DOI.optional
|
11
11
|
# Unique identifier in some other system. This is because a large proportion of what is deposited in SDR, historically and currently, are representations of objects that are also represented in other systems. For example, digitized paper and A/V collections have physical manifestations, and those physical objects are managed in systems that have their own identifiers. Similarly, books have barcodes, archival materials have collection numbers and physical locations, etc. The sourceId allows determining if an item has been deposited before and where to look for the original item if you're looking at its SDR representation. The format is: "namespace:identifier"
|
12
12
|
|
13
13
|
# example: sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026
|
@@ -20,7 +20,7 @@ module Cocina
|
|
20
20
|
attribute? :standard, Standard.optional
|
21
21
|
attribute :subject, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
22
22
|
# Stanford persistent URL associated with the related resource.
|
23
|
-
attribute? :purl, Purl
|
23
|
+
attribute? :purl, Purl.optional
|
24
24
|
attribute? :access, DescriptiveAccessMetadata.optional
|
25
25
|
attribute :relatedResource, Types::Strict::Array.of(RelatedResource).default([].freeze)
|
26
26
|
attribute? :adminMetadata, DescriptiveAdminMetadata.optional
|
@@ -5,7 +5,7 @@ module Cocina
|
|
5
5
|
# Same as a Identification, but requires a sourceId and doesn't permit a DOI.
|
6
6
|
class RequestIdentification < Struct
|
7
7
|
# A barcode
|
8
|
-
attribute? :barcode, Barcode
|
8
|
+
attribute? :barcode, Barcode.optional
|
9
9
|
attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).default([].freeze)
|
10
10
|
# Unique identifier in some other system. This is because a large proportion of what is deposited in SDR, historically and currently, are representations of objects that are also represented in other systems. For example, digitized paper and A/V collections have physical manifestations, and those physical objects are managed in systems that have their own identifiers. Similarly, books have barcodes, archival materials have collection numbers and physical locations, etc. The sourceId allows determining if an item has been deposited before and where to look for the original item if you're looking at its SDR representation. The format is: "namespace:identifier"
|
11
11
|
|
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.87.
|
4
|
+
version: 0.87.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|