cocina-models 0.6.0 → 0.7.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/.rubocop_todo.yml +23 -0
- data/docs/maps/File.json +26 -2
- data/docs/maps/Fileset.json +7 -0
- data/lib/cocina/models/dro.rb +9 -0
- data/lib/cocina/models/file.rb +82 -0
- data/lib/cocina/models/file_set.rb +57 -0
- data/lib/cocina/models/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d545662f72b0cc61f2d380d2a659b5eceedd07261e3bbcbf093748bb83313921
|
4
|
+
data.tar.gz: 0e7dfe39087cf1550e6d5ec421cfc19247e1345dc1ccc6789936a11b5f48f143
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87e6e541b2de60c90a0a788367cef62a1c3d55ab8f2bbf687fd85a1198a025e81fe2ccd258a1cc59ce5bbcaa1dbfe3020aa8c687cba29d813af5e9df09df9c97
|
7
|
+
data.tar.gz: b35a5fecfbcef1376ca2d61d7b046787814c6a0a106fa4625fff4c6c024dab56803426f5253e36bfd2ed9723c6ea8363480ee88323ba74efce436d00cbf41509
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2019-10-24 15:36:09 -0500 using RuboCop version 0.74.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 18
|
12
|
+
|
13
|
+
# Offense count: 1
|
14
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
15
|
+
Metrics/MethodLength:
|
16
|
+
Max: 14
|
17
|
+
|
18
|
+
# Offense count: 2
|
19
|
+
# Configuration parameters: Max.
|
20
|
+
RSpec/ExampleLength:
|
21
|
+
Exclude:
|
22
|
+
- 'spec/cocina/models/dro_spec.rb'
|
23
|
+
- 'spec/cocina/models/file_spec.rb'
|
data/docs/maps/File.json
CHANGED
@@ -34,7 +34,21 @@
|
|
34
34
|
},
|
35
35
|
"hasMessageDigests": {
|
36
36
|
"description": "The output of the message digest algorithm.",
|
37
|
-
"type": "
|
37
|
+
"type": "array",
|
38
|
+
"items": {
|
39
|
+
"required": ["type", "digest"],
|
40
|
+
"properties": {
|
41
|
+
"type": {
|
42
|
+
"description": "The algorithm that was used",
|
43
|
+
"type": "string",
|
44
|
+
"enum": ["md5", "sha1"]
|
45
|
+
},
|
46
|
+
"digest": {
|
47
|
+
"description": "The digest value",
|
48
|
+
"type": "string"
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
38
52
|
},
|
39
53
|
"hasMimeType": {
|
40
54
|
"description": "MIME Type of the File.",
|
@@ -46,7 +60,17 @@
|
|
46
60
|
},
|
47
61
|
"presentation": {
|
48
62
|
"description": "Presentation data for the File.",
|
49
|
-
"type": "object"
|
63
|
+
"type": "object",
|
64
|
+
"properties": {
|
65
|
+
"height": {
|
66
|
+
"description": "Height in pixels",
|
67
|
+
"type": "integer",
|
68
|
+
},
|
69
|
+
"width": {
|
70
|
+
"description": "Width in pixels",
|
71
|
+
"type": "integer",
|
72
|
+
},
|
73
|
+
}
|
50
74
|
},
|
51
75
|
"size": {
|
52
76
|
"description": "Size of the File (binary) in bytes.",
|
data/docs/maps/Fileset.json
CHANGED
@@ -121,6 +121,13 @@
|
|
121
121
|
"type": "object",
|
122
122
|
"required": ["isContainedBy"],
|
123
123
|
"properties": {
|
124
|
+
"contains": {
|
125
|
+
"description": "Files that are members of the fileset.",
|
126
|
+
"type": "array",
|
127
|
+
"items": {
|
128
|
+
"type": "string"
|
129
|
+
}
|
130
|
+
},
|
124
131
|
"isContainedBy": {
|
125
132
|
"description": "Parent DRO that is represented by the files in this Fileset.",
|
126
133
|
"type": "string"
|
data/lib/cocina/models/dro.rb
CHANGED
@@ -66,7 +66,15 @@ module Cocina
|
|
66
66
|
class Identification < Dry::Struct
|
67
67
|
end
|
68
68
|
|
69
|
+
# Structural sub-schema for the DRO
|
69
70
|
class Structural < Dry::Struct
|
71
|
+
attribute :contains, Types::Strict::Array.of(Types::Coercible::String).meta(omittable: true)
|
72
|
+
|
73
|
+
def self.from_dynamic(dyn)
|
74
|
+
params = {}
|
75
|
+
params[:contains] = dyn['contains'] if dyn['contains']
|
76
|
+
Structural.new(params)
|
77
|
+
end
|
70
78
|
end
|
71
79
|
|
72
80
|
attribute :externalIdentifier, Types::Strict::String
|
@@ -88,6 +96,7 @@ module Cocina
|
|
88
96
|
|
89
97
|
params[:access] = Access.from_dynamic(dyn['access']) if dyn['access']
|
90
98
|
params[:administrative] = Administrative.from_dynamic(dyn['administrative']) if dyn['administrative']
|
99
|
+
params[:structural] = Structural.from_dynamic(dyn['structural']) if dyn['structural']
|
91
100
|
|
92
101
|
DRO.new(params)
|
93
102
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Cocina
|
6
|
+
module Models
|
7
|
+
# Metadata for a file. See http://sul-dlss.github.io/cocina-models/maps/File.json
|
8
|
+
class File < Dry::Struct
|
9
|
+
TYPES = %w[
|
10
|
+
http://cocina.sul.stanford.edu/models/file.jsonld
|
11
|
+
].freeze
|
12
|
+
|
13
|
+
class Identification < Dry::Struct
|
14
|
+
end
|
15
|
+
|
16
|
+
class Structural < Dry::Struct
|
17
|
+
end
|
18
|
+
|
19
|
+
# Represents a digest value for a file
|
20
|
+
class Fixity < Dry::Struct
|
21
|
+
attribute :type, Types::String.enum('md5', 'sha1')
|
22
|
+
attribute :digest, Types::Strict::String
|
23
|
+
|
24
|
+
def self.from_dynamic(dyn)
|
25
|
+
params = {
|
26
|
+
type: dyn['type'],
|
27
|
+
digest: dyn['digest']
|
28
|
+
}
|
29
|
+
|
30
|
+
Fixity.new(params)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Represents some technical aspect of the file
|
35
|
+
class Presentation < Dry::Struct
|
36
|
+
attribute :height, Types::Coercible::Integer.optional.default(nil)
|
37
|
+
attribute :width, Types::Coercible::Integer.optional.default(nil)
|
38
|
+
|
39
|
+
def self.from_dynamic(dyn)
|
40
|
+
params = {
|
41
|
+
height: dyn['height'],
|
42
|
+
width: dyn['width']
|
43
|
+
}
|
44
|
+
|
45
|
+
Presentation.new(params)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
attribute :externalIdentifier, Types::Strict::String
|
50
|
+
attribute :type, Types::String.enum(*TYPES)
|
51
|
+
attribute :label, Types::Strict::String
|
52
|
+
attribute :filename, Types::String.optional.default(nil)
|
53
|
+
attribute :use, Types::String.enum('original', 'preservation', 'access').optional.default(nil)
|
54
|
+
attribute :size, Types::Coercible::Integer.optional.default(nil)
|
55
|
+
attribute :hasMessageDigests, Types::Strict::Array.of(Fixity).default([])
|
56
|
+
attribute :presentation, Presentation.optional.default(Presentation.new)
|
57
|
+
attribute :version, Types::Coercible::Integer
|
58
|
+
attribute(:identification, Identification.default { Identification.new })
|
59
|
+
attribute(:structural, Structural.default { Structural.new })
|
60
|
+
|
61
|
+
def self.from_dynamic(dyn)
|
62
|
+
params = {
|
63
|
+
externalIdentifier: dyn['externalIdentifier'],
|
64
|
+
type: dyn['type'],
|
65
|
+
label: dyn['label'],
|
66
|
+
version: dyn['version'],
|
67
|
+
size: dyn['size'],
|
68
|
+
use: dyn['use']
|
69
|
+
}
|
70
|
+
params[:presentation] = Presentation.from_dynamic(dyn['presentation']) if dyn['presentation']
|
71
|
+
if dyn['hasMessageDigests']
|
72
|
+
params[:hasMessageDigests] = dyn['hasMessageDigests'].map { |p| Fixity.from_dynamic(p) }
|
73
|
+
end
|
74
|
+
File.new(params)
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.from_json(json)
|
78
|
+
from_dynamic(JSON.parse(json))
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Cocina
|
6
|
+
module Models
|
7
|
+
# Metadata for a File Set. See http://sul-dlss.github.io/cocina-models/maps/Fileset.json
|
8
|
+
class FileSet < Dry::Struct
|
9
|
+
TYPES = %w[
|
10
|
+
http://cocina.sul.stanford.edu/models/fileset.jsonld
|
11
|
+
].freeze
|
12
|
+
|
13
|
+
class Identification < Dry::Struct
|
14
|
+
end
|
15
|
+
|
16
|
+
# Structural sub-schema for the FileSet
|
17
|
+
class Structural < Dry::Struct
|
18
|
+
attribute :contains, Types::Strict::Array.of(Types::Coercible::String).meta(omittable: true)
|
19
|
+
|
20
|
+
def self.from_dynamic(dyn)
|
21
|
+
params = {}
|
22
|
+
params[:contains] = dyn['contains'] if dyn['contains']
|
23
|
+
Structural.new(params)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
attribute :externalIdentifier, Types::Strict::String
|
28
|
+
attribute :type, Types::String.enum(*TYPES)
|
29
|
+
attribute :label, Types::Strict::String
|
30
|
+
attribute :version, Types::Coercible::Integer
|
31
|
+
attribute(:identification, Identification.default { Identification.new })
|
32
|
+
attribute(:structural, Structural.default { Structural.new })
|
33
|
+
|
34
|
+
def self.from_dynamic(dyn)
|
35
|
+
params = {
|
36
|
+
externalIdentifier: dyn['externalIdentifier'],
|
37
|
+
type: dyn['type'],
|
38
|
+
label: dyn['label'],
|
39
|
+
version: dyn['version'],
|
40
|
+
size: dyn['size'],
|
41
|
+
use: dyn['use']
|
42
|
+
}
|
43
|
+
params[:presentation] = Presentation.from_dynamic(dyn['presentation']) if dyn['presentation']
|
44
|
+
if dyn['hasMessageDigests']
|
45
|
+
params[:hasMessageDigests] = dyn['hasMessageDigests'].map { |p| Fixity.from_dynamic(p) }
|
46
|
+
end
|
47
|
+
params[:structural] = Structural.from_dynamic(dyn['structural']) if dyn['structural']
|
48
|
+
|
49
|
+
FileSet.new(params)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.from_json(json)
|
53
|
+
from_dynamic(JSON.parse(json))
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
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.
|
4
|
+
version: 0.7.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: 2019-10-
|
11
|
+
date: 2019-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|
@@ -157,6 +157,8 @@ files:
|
|
157
157
|
- lib/cocina/models/admin_policy.rb
|
158
158
|
- lib/cocina/models/collection.rb
|
159
159
|
- lib/cocina/models/dro.rb
|
160
|
+
- lib/cocina/models/file.rb
|
161
|
+
- lib/cocina/models/file_set.rb
|
160
162
|
- lib/cocina/models/types.rb
|
161
163
|
- lib/cocina/models/version.rb
|
162
164
|
homepage: https://github.com/sul-dlss-labs/cocina-models
|