cocina-models 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cocina/models.rb +2 -0
- data/lib/cocina/models/admin_policy.rb +61 -0
- data/lib/cocina/models/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 918a0472029fa8a0ca3b66adb2984203f3d830ee30c449f44d9d3fa6a1ba7592
|
4
|
+
data.tar.gz: 1bb461d3aba413ceb273912c34abb20c87aae08fdece11356ccff6ef44b22415
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 245d6b97f84147c73c61404527d5bef0f3b3dccf8c18bf9d02183f65a3e5111af300c5b964e006c3bd547e3bd5de134ed5c4b8de3ca7242ae4430c4901ef0d05
|
7
|
+
data.tar.gz: 4c5cc681c427448de988238584d37986c6af158c553ebdf8fe7cbbbca118d4e946cd8d0bed5031a9b35f29a0c4f3ac99f3846db39662daa948332b14e3914fc0
|
data/lib/cocina/models.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Cocina
|
6
|
+
module Models
|
7
|
+
# An admin policy object.
|
8
|
+
class AdminPolicy < Dry::Struct
|
9
|
+
TYPES = %w[http://cocina.sul.stanford.edu/models/admin_policy.jsonld].freeze
|
10
|
+
|
11
|
+
# Subschema for access concerns
|
12
|
+
class Access < Dry::Struct
|
13
|
+
def self.from_dynamic(_dyn)
|
14
|
+
params = {}
|
15
|
+
Access.new(params)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Subschema for administrative concerns
|
20
|
+
class Administrative < Dry::Struct
|
21
|
+
def self.from_dynamic(_dyn)
|
22
|
+
params = {}
|
23
|
+
Administrative.new(params)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Identification < Dry::Struct
|
28
|
+
end
|
29
|
+
|
30
|
+
class Structural < Dry::Struct
|
31
|
+
end
|
32
|
+
|
33
|
+
attribute :externalIdentifier, Types::Strict::String
|
34
|
+
attribute :type, Types::String.enum(*TYPES)
|
35
|
+
attribute :label, Types::Strict::String
|
36
|
+
attribute :version, Types::Coercible::Integer
|
37
|
+
attribute(:access, Access.default { Access.new })
|
38
|
+
attribute(:administrative, Administrative.default { Administrative.new })
|
39
|
+
attribute(:identification, Identification.default { Identification.new })
|
40
|
+
attribute(:structural, Structural.default { Structural.new })
|
41
|
+
|
42
|
+
def self.from_dynamic(dyn)
|
43
|
+
params = {
|
44
|
+
externalIdentifier: dyn['externalIdentifier'],
|
45
|
+
type: dyn['type'],
|
46
|
+
label: dyn['label'],
|
47
|
+
version: dyn['version']
|
48
|
+
}
|
49
|
+
|
50
|
+
# params[:access] = Access.from_dynamic(dyn['access']) if dyn['access']
|
51
|
+
# params[:administrative] = Administrative.from_dynamic(dyn['administrative']) if dyn['administrative']
|
52
|
+
|
53
|
+
AdminPolicy.new(params)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.from_json(json)
|
57
|
+
from_dynamic(JSON.parse(json))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocina-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- docs/sampleETD/xn109qc9773_bibframe.ttl
|
155
155
|
- docs/sampleETD/xn109qc9773_taco.json
|
156
156
|
- lib/cocina/models.rb
|
157
|
+
- lib/cocina/models/admin_policy.rb
|
157
158
|
- lib/cocina/models/collection.rb
|
158
159
|
- lib/cocina/models/dro.rb
|
159
160
|
- lib/cocina/models/types.rb
|