cocina-models 0.16.0 → 0.17.0
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 +1 -1
- data/lib/cocina/models.rb +1 -0
- data/lib/cocina/models/admin_policy.rb +0 -2
- data/lib/cocina/models/catalog_link.rb +19 -0
- data/lib/cocina/models/collection.rb +12 -2
- data/lib/cocina/models/description.rb +0 -2
- data/lib/cocina/models/dro.rb +16 -3
- data/lib/cocina/models/file.rb +0 -2
- data/lib/cocina/models/file_set.rb +0 -2
- data/lib/cocina/models/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6e23b0e03fa39eb46ba0dd2f99befd2a1eea00a1294c44da2717892ede74a2c3
|
|
4
|
+
data.tar.gz: 1149930ef7b568cdd28b96447148d58dd9e83846133a7316a317c179dbd6330a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0cc112f49830c1b00a20fcad1c15d21e9563ba09fdf84406d55d5cbfb9e73a9612e7056b62d63629841b1c690f9fa06541e2a3a2c37d6f8f5995edc52ffa6342
|
|
7
|
+
data.tar.gz: cc12548903b6b5b1befc9a236611473f30af7323994f36de49822ad31f318770d1ecc8070344552b19019984b3899c2073bacead487ba9670123c17460873583
|
data/.rubocop.yml
CHANGED
data/lib/cocina/models.rb
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cocina
|
|
4
|
+
module Models
|
|
5
|
+
# Metadata for a catalog link
|
|
6
|
+
class CatalogLink < Dry::Struct
|
|
7
|
+
attribute :catalog, Types::Strict::String
|
|
8
|
+
attribute :catalogRecordId, Types::Strict::String
|
|
9
|
+
|
|
10
|
+
def self.from_dynamic(dyn)
|
|
11
|
+
params = {
|
|
12
|
+
catalog: dyn['catalog'],
|
|
13
|
+
catalogRecordId: dyn['catalogRecordId']
|
|
14
|
+
}
|
|
15
|
+
CatalogLink.new(params)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'json'
|
|
4
|
-
|
|
5
3
|
module Cocina
|
|
6
4
|
module Models
|
|
7
5
|
# A digital repository collection. See http://sul-dlss.github.io/cocina-models/maps/Collection.json
|
|
@@ -39,7 +37,18 @@ module Cocina
|
|
|
39
37
|
end
|
|
40
38
|
end
|
|
41
39
|
|
|
40
|
+
# Identification sub-schema for the Collection
|
|
42
41
|
class Identification < Dry::Struct
|
|
42
|
+
attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).meta(omittable: true)
|
|
43
|
+
|
|
44
|
+
def self.from_dynamic(dyn)
|
|
45
|
+
params = {}
|
|
46
|
+
if dyn['catalogLinks']
|
|
47
|
+
params[:catalogLinks] = dyn['catalogLinks']
|
|
48
|
+
.map { |link| CatalogLink.from_dynamic(link) }
|
|
49
|
+
end
|
|
50
|
+
params
|
|
51
|
+
end
|
|
43
52
|
end
|
|
44
53
|
|
|
45
54
|
class Structural < Dry::Struct
|
|
@@ -68,6 +77,7 @@ module Cocina
|
|
|
68
77
|
# params[:access] = Access.from_dynamic(dyn['access']) if dyn['access']
|
|
69
78
|
params[:administrative] = Administrative.from_dynamic(dyn['administrative']) if dyn['administrative']
|
|
70
79
|
params[:description] = Description.from_dynamic(dyn.fetch('description'))
|
|
80
|
+
params[:identification] = Identification.from_dynamic(dyn['identification']) if dyn['identification']
|
|
71
81
|
Collection.new(params)
|
|
72
82
|
end
|
|
73
83
|
|
data/lib/cocina/models/dro.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'json'
|
|
4
|
-
|
|
5
3
|
module Cocina
|
|
6
4
|
module Models
|
|
7
5
|
# A digital repository object. See http://sul-dlss.github.io/cocina-models/maps/DRO.json
|
|
@@ -52,7 +50,19 @@ module Cocina
|
|
|
52
50
|
end
|
|
53
51
|
end
|
|
54
52
|
|
|
53
|
+
# Identification sub-schema for the DRO
|
|
55
54
|
class Identification < Dry::Struct
|
|
55
|
+
attribute :sourceId, Types::Strict::String.meta(omittable: true)
|
|
56
|
+
attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).meta(omittable: true)
|
|
57
|
+
def self.from_dynamic(dyn)
|
|
58
|
+
params = {}
|
|
59
|
+
params[:sourceId] = dyn['sourceId'] if dyn['sourceId']
|
|
60
|
+
if dyn['catalogLinks']
|
|
61
|
+
params[:catalogLinks] = dyn['catalogLinks']
|
|
62
|
+
.map { |link| CatalogLink.from_dynamic(link) }
|
|
63
|
+
end
|
|
64
|
+
params
|
|
65
|
+
end
|
|
56
66
|
end
|
|
57
67
|
|
|
58
68
|
# Structural sub-schema for the DRO
|
|
@@ -80,6 +90,7 @@ module Cocina
|
|
|
80
90
|
attribute(:identification, Identification.default { Identification.new })
|
|
81
91
|
attribute(:structural, Structural.default { Structural.new })
|
|
82
92
|
|
|
93
|
+
# rubocop:disable Metrics/AbcSize
|
|
83
94
|
def self.from_dynamic(dyn)
|
|
84
95
|
params = {
|
|
85
96
|
externalIdentifier: dyn['externalIdentifier'],
|
|
@@ -90,10 +101,12 @@ module Cocina
|
|
|
90
101
|
|
|
91
102
|
params[:access] = Access.from_dynamic(dyn['access']) if dyn['access']
|
|
92
103
|
params[:administrative] = Administrative.from_dynamic(dyn['administrative']) if dyn['administrative']
|
|
93
|
-
params[:structural] = Structural.from_dynamic(dyn['structural']) if dyn['structural']
|
|
94
104
|
params[:description] = Description.from_dynamic(dyn.fetch('description'))
|
|
105
|
+
params[:identification] = Identification.from_dynamic(dyn['identification']) if dyn['identification']
|
|
106
|
+
params[:structural] = Structural.from_dynamic(dyn['structural']) if dyn['structural']
|
|
95
107
|
DRO.new(params)
|
|
96
108
|
end
|
|
109
|
+
# rubocop:enable Metrics/AbcSize
|
|
97
110
|
|
|
98
111
|
def self.from_json(json)
|
|
99
112
|
from_dynamic(JSON.parse(json))
|
data/lib/cocina/models/file.rb
CHANGED
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.
|
|
4
|
+
version: 0.17.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: 2020-02-
|
|
11
|
+
date: 2020-02-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: dry-struct
|
|
@@ -177,6 +177,7 @@ files:
|
|
|
177
177
|
- docs/schema.md
|
|
178
178
|
- lib/cocina/models.rb
|
|
179
179
|
- lib/cocina/models/admin_policy.rb
|
|
180
|
+
- lib/cocina/models/catalog_link.rb
|
|
180
181
|
- lib/cocina/models/checkable.rb
|
|
181
182
|
- lib/cocina/models/collection.rb
|
|
182
183
|
- lib/cocina/models/description.rb
|