cocina-models 0.87.0 → 0.87.1

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: 272a5d8e2b026dc773452921e549241338c6c8cda4f21b3ae6da3b7511f7cec6
4
- data.tar.gz: f3471e9e52d279444b8ef4bac802d116c71b23d5d937363c084f322204b9ce1f
3
+ metadata.gz: 90ae20c8c80e4bbcf51179f0c6cba44c76f3f1551962f4da938d297c152ed77d
4
+ data.tar.gz: b71a9f5c05e153ebdf93f623164a7a77c12aeae2de32b96757096a7d2f747cfa
5
5
  SHA512:
6
- metadata.gz: a44093101a258a2d88b83f82955dc81c81624419baf0cf55892eb976e04ac770ddf34d8c60e5649522c1c4b14687aed0715b14b92ede2a8858af839ff2bb6b8e
7
- data.tar.gz: a95e82570f152ac1498d072c0ee7320c0da738a45b80949cb098c722838d9495cd4e6c6e74aa78cf40ba6f3b88ea846779cc2adbddd42d161929ae8bd79a7856
6
+ metadata.gz: 26f2fe285a9249a70015b31b7fb30983d3f4fff6befe671508f56ac57d6bbcb901f5740290fcd3bcfb6a5e7ccc9697ccf8032b0d3aa07d6a743485ce34cb9c1d
7
+ data.tar.gz: cf8992389b7097a416f5050d196758145dd958abeef155a672fa21ffdef382f5e025e6b101dd2f26baf427aef2b195b43b93431b9faaae569d1386efe9cafb1d
data/.rubocop.yml CHANGED
@@ -392,3 +392,5 @@ RSpec/Rails/InferredSpecType: # new in 2.14
392
392
  Enabled: true
393
393
  RSpec/Rails/MinitestAssertions: # new in 2.17
394
394
  Enabled: true
395
+ Style/RedundantHeredocDelimiterQuotes: # new in 1.45
396
+ Enabled: true
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocina-models (0.87.0)
4
+ cocina-models (0.87.1)
5
5
  activesupport
6
6
  deprecation
7
7
  dry-struct (~> 1.0)
@@ -24,10 +24,16 @@ module Cocina
24
24
  key || schema_doc.name
25
25
  end
26
26
 
27
- # Allows nillable values to be set to nil. This is useful when doing
28
- # an update and you want to clear out a value.
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
- nullable || relaxed ? '.optional' : ''
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.87.0'
5
+ VERSION = '0.87.1'
6
6
  end
7
7
  end
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.0
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-14 00:00:00.000000000 Z
11
+ date: 2023-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport