cocina-models 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b34aca3b7691b95a9cdd86bf7e40e8db0d57a1f6baadff61a1017b0eb93ba43
4
- data.tar.gz: b8510bc730ec149672f8f9d5697b903ed8f36d240947d1766085a77d7180aca6
3
+ metadata.gz: 918a0472029fa8a0ca3b66adb2984203f3d830ee30c449f44d9d3fa6a1ba7592
4
+ data.tar.gz: 1bb461d3aba413ceb273912c34abb20c87aae08fdece11356ccff6ef44b22415
5
5
  SHA512:
6
- metadata.gz: d74b5c6aa8e10e0d478fd128589f1bf32228f668b93040ac863ad71dc6a48e91e1631d031b12b3be0016b40b31da5ce5fed4a1ff58d592aa31c38013320f438a
7
- data.tar.gz: 5ed3710a39e6c4cc748dbc7ce180c7caccde3da5e7d7bc16f86db12909b83ad632e0d489a65f779bbfbc8c861583d0452021768796ead4a9838ae6186ae9d19f
6
+ metadata.gz: 245d6b97f84147c73c61404527d5bef0f3b3dccf8c18bf9d02183f65a3e5111af300c5b964e006c3bd547e3bd5de134ed5c4b8de3ca7242ae4430c4901ef0d05
7
+ data.tar.gz: 4c5cc681c427448de988238584d37986c6af158c553ebdf8fe7cbbbca118d4e946cd8d0bed5031a9b35f29a0c4f3ac99f3846db39662daa948332b14e3914fc0
@@ -41,6 +41,8 @@ module Cocina
41
41
  DRO.from_dynamic(dyn)
42
42
  when *Collection::TYPES
43
43
  Collection.from_dynamic(dyn)
44
+ when *AdminPolicy::TYPES
45
+ AdminPolicy.from_dynamic(dyn)
44
46
  else
45
47
  raise UnknownTypeError, "Unknown type: '#{dyn.fetch('type')}'"
46
48
  end
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  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.5.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