cocina-models 0.16.0 → 0.17.0

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: 1be949cfe01f8591a3672f1aa22abd38d318334fd516d032eafc686ed59dec0a
4
- data.tar.gz: de24e56fc74e0e1beb891d68020f12b75075015557310be867775b6727ee722b
3
+ metadata.gz: 6e23b0e03fa39eb46ba0dd2f99befd2a1eea00a1294c44da2717892ede74a2c3
4
+ data.tar.gz: 1149930ef7b568cdd28b96447148d58dd9e83846133a7316a317c179dbd6330a
5
5
  SHA512:
6
- metadata.gz: 04edda64c833c0b8a3646c2d7b845a7741220809c7b3e6b6a6451a59c9dbc1b0df6370ab72d814c54b72b4e855d772152a0278dc1f99821bd20e7e00cb34ce97
7
- data.tar.gz: e514ee482591acf73c3cb13ecc69cd20d368c720715f56086d0515d5925e7164d3200ec90b2310bc14a4d4b1822edff45a9f7df43875da13da612faf1ae45c63
6
+ metadata.gz: 0cc112f49830c1b00a20fcad1c15d21e9563ba09fdf84406d55d5cbfb9e73a9612e7056b62d63629841b1c690f9fa06541e2a3a2c37d6f8f5995edc52ffa6342
7
+ data.tar.gz: cc12548903b6b5b1befc9a236611473f30af7323994f36de49822ad31f318770d1ecc8070344552b19019984b3899c2073bacead487ba9670123c17460873583
@@ -18,4 +18,4 @@ RSpec/MultipleExpectations:
18
18
  Enabled: false
19
19
 
20
20
  RSpec/ExampleLength:
21
- Max: 9
21
+ Max: 12
@@ -4,6 +4,7 @@ require 'cocina/models/version'
4
4
  require 'zeitwerk'
5
5
  require 'dry-struct'
6
6
  require 'dry-types'
7
+ require 'json'
7
8
 
8
9
  # Help Zeitwerk find some of our classes
9
10
  class CocinaModelsInflector < Zeitwerk::Inflector
@@ -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
  # An admin policy object.
@@ -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
 
@@ -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
  # Descriptive metadata. See http://sul-dlss.github.io/cocina-models/maps/Description.json
@@ -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))
@@ -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
  # Metadata for a file. See http://sul-dlss.github.io/cocina-models/maps/File.json
@@ -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
  # Metadata for a File Set. See http://sul-dlss.github.io/cocina-models/maps/Fileset.json
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.16.0'
5
+ VERSION = '0.17.0'
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.16.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-07 00:00:00.000000000 Z
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