cocina-models 0.54.0 → 0.55.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: 2aef820c19c5713ea051cebe2b29f458413bda243c7906f4e75e29f655c21119
4
- data.tar.gz: 43a183c9e4b8e7a993e5ed04b1379d3ffa40b0831a2a471cc63a048698799a26
3
+ metadata.gz: fbed8aec9255570088565182862681d94908cb165e5f6be489ad103052a5f708
4
+ data.tar.gz: 526b172620cbe31ea3ca59871d0ed0a816bec3c01726214fd3634bf54ec24eba
5
5
  SHA512:
6
- metadata.gz: 1fb48a8bc9573cb59fb8c9c36246aad1ddaa2afc4dc122c793b97c5d4fe5ee364f1a75c65b43ac5845f1ee4ce633a2739d17bd2d3e7ac15dfd88642c4911272c
7
- data.tar.gz: b5e4db39b12e7e300d2a45b8be2a06a2683cedaf9ea98aafe7716e36552a1432650c9f1c71438d07dc123f993290909eb3dbb71597cfda78005a91c064b09247
6
+ metadata.gz: 6a555879230729f246d468589fb3e5ec261cebc36ae17d1282b663ef1b0ff0a5bd4afc9e9ee9688978da98bf20e7f709f989a6b46934a103ad0fabe40ee2353a
7
+ data.tar.gz: 332f3a59c67779ccb81340a352baa9894e9c3c76cbf5ff2bed383b501c5ff9ec7fb6e1d80aa3610b9a3ee289448a6b93e59e50345bd97b7f9279acf684191db3
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'fileutils'
4
+
3
5
  module Cocina
4
6
  module Generator
5
7
  # Class for generating Cocina models from openapi.
@@ -33,23 +33,40 @@ module Cocina
33
33
 
34
34
  attr_reader :schemas
35
35
 
36
- # rubocop:disable Style/MultilineBlockChain
36
+ BASE = 'http://cocina.sul.stanford.edu/models/'
37
+
37
38
  def vocabs
38
- schemas.values.map do |schema|
39
- type_property = schema.properties['type']
40
- type_property.nil? ? [] : type_property.enum.to_a
41
- end
42
- .flatten
43
- .uniq
44
- .sort
45
- .filter { |vocab| vocab.start_with?('http://cocina.sul.stanford.edu/models') }
39
+ type_properties = schemas.values.map { |schema| schema.properties['type'] }.compact
40
+ type_properties.map(&:enum).flat_map(&:to_a)
41
+ .filter { |vocab| vocab.start_with?(BASE) }
42
+ .uniq
43
+ .sort
46
44
  end
47
- # rubocop:enable Style/MultilineBlockChain
48
45
 
49
46
  def vocab_methods
50
- # Note special handling of 3d
51
- vocabs.map do |vocab|
52
- name = vocab[38, vocab.size - 45].gsub('-', '_').gsub('3d', 'three_dimensional')
47
+ names = vocabs.each_with_object({}) do |vocab, object|
48
+ # Note special handling of 3d
49
+ namespaced = vocab.delete_prefix(BASE).delete_suffix('.jsonld')
50
+ .gsub('-', '_').gsub('3d', 'three_dimensional')
51
+ namespace, name = namespaced.include?('/') ? namespaced.split('/') : [:root, namespaced]
52
+ object[namespace] ||= {}
53
+ object[namespace][name] = vocab
54
+ end
55
+ draw_namespaced_methods(names)
56
+ end
57
+
58
+ def draw_namespaced_methods(names)
59
+ names.flat_map do |namespace, methods|
60
+ [].tap do |items|
61
+ items << "class #{namespace.capitalize}" unless namespace == :root
62
+ items << draw_ruby_methods(methods)
63
+ items << 'end' unless namespace == :root
64
+ end
65
+ end.join("\n")
66
+ end
67
+
68
+ def draw_ruby_methods(methods)
69
+ methods.map do |name, vocab|
53
70
  <<~RUBY
54
71
  def self.#{name}
55
72
  "#{vocab}"
@@ -13,6 +13,7 @@ module Cocina
13
13
  attribute :note, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
14
14
  # URL or other pointer to the location of the contributor information.
15
15
  attribute :valueAt, Types::Strict::String.meta(omittable: true)
16
+ attribute :parallelContributor, Types::Strict::Array.of(DescriptiveParallelContributor).meta(omittable: true)
16
17
  end
17
18
  end
18
19
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class DescriptiveParallelContributor < Struct
6
+ attribute :name, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
7
+ # Entity type of the contributor (person, organization, etc.).
8
+ attribute :type, Types::Strict::String.meta(omittable: true)
9
+ # Status of the contributor relative to other parallel contributors (e.g. the primary author among a group of contributors).
10
+ attribute :status, Types::Strict::String.meta(omittable: true)
11
+ attribute :role, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
12
+ attribute :identifier, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
13
+ attribute :note, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
14
+ # URL or other pointer to the location of the contributor information.
15
+ attribute :valueAt, Types::Strict::String.meta(omittable: true)
16
+ attribute :valueLanguage, DescriptiveValueLanguage.optional.meta(omittable: true)
17
+ end
18
+ end
19
+ end
@@ -5,7 +5,22 @@ module Cocina
5
5
  class FileSet < Struct
6
6
  include Checkable
7
7
 
8
- TYPES = ['http://cocina.sul.stanford.edu/models/fileset.jsonld'].freeze
8
+ TYPES = ['http://cocina.sul.stanford.edu/models/resources/audio.jsonld',
9
+ 'http://cocina.sul.stanford.edu/models/resources/attachment.jsonld',
10
+ 'http://cocina.sul.stanford.edu/models/resources/document.jsonld',
11
+ 'http://cocina.sul.stanford.edu/models/resources/file.jsonld',
12
+ 'http://cocina.sul.stanford.edu/models/resources/image.jsonld',
13
+ 'http://cocina.sul.stanford.edu/models/resources/main-augmented.jsonld',
14
+ 'http://cocina.sul.stanford.edu/models/resources/main-original.jsonld',
15
+ 'http://cocina.sul.stanford.edu/models/resources/media.jsonld',
16
+ 'http://cocina.sul.stanford.edu/models/resources/object.jsonld',
17
+ 'http://cocina.sul.stanford.edu/models/resources/page.jsonld',
18
+ 'http://cocina.sul.stanford.edu/models/resources/permissions.jsonld',
19
+ 'http://cocina.sul.stanford.edu/models/resources/preview.jsonld',
20
+ 'http://cocina.sul.stanford.edu/models/resources/supplement.jsonld',
21
+ 'http://cocina.sul.stanford.edu/models/resources/3d.jsonld',
22
+ 'http://cocina.sul.stanford.edu/models/resources/thumb.jsonld',
23
+ 'http://cocina.sul.stanford.edu/models/resources/video.jsonld'].freeze
9
24
 
10
25
  # The content type of the Fileset.
11
26
  attribute :type, Types::Strict::String.enum(*FileSet::TYPES)
@@ -5,7 +5,22 @@ module Cocina
5
5
  class RequestFileSet < Struct
6
6
  include Checkable
7
7
 
8
- TYPES = ['http://cocina.sul.stanford.edu/models/fileset.jsonld'].freeze
8
+ TYPES = ['http://cocina.sul.stanford.edu/models/resources/audio.jsonld',
9
+ 'http://cocina.sul.stanford.edu/models/resources/attachment.jsonld',
10
+ 'http://cocina.sul.stanford.edu/models/resources/document.jsonld',
11
+ 'http://cocina.sul.stanford.edu/models/resources/file.jsonld',
12
+ 'http://cocina.sul.stanford.edu/models/resources/image.jsonld',
13
+ 'http://cocina.sul.stanford.edu/models/resources/main-augmented.jsonld',
14
+ 'http://cocina.sul.stanford.edu/models/resources/main-original.jsonld',
15
+ 'http://cocina.sul.stanford.edu/models/resources/media.jsonld',
16
+ 'http://cocina.sul.stanford.edu/models/resources/object.jsonld',
17
+ 'http://cocina.sul.stanford.edu/models/resources/page.jsonld',
18
+ 'http://cocina.sul.stanford.edu/models/resources/permissions.jsonld',
19
+ 'http://cocina.sul.stanford.edu/models/resources/preview.jsonld',
20
+ 'http://cocina.sul.stanford.edu/models/resources/supplement.jsonld',
21
+ 'http://cocina.sul.stanford.edu/models/resources/3d.jsonld',
22
+ 'http://cocina.sul.stanford.edu/models/resources/thumb.jsonld',
23
+ 'http://cocina.sul.stanford.edu/models/resources/video.jsonld'].freeze
9
24
 
10
25
  attribute :type, Types::Strict::String.enum(*RequestFileSet::TYPES)
11
26
  attribute :label, Types::Strict::String
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.54.0'
5
+ VERSION = '0.55.0'
6
6
  end
7
7
  end
@@ -40,10 +40,6 @@ module Cocina
40
40
  'http://cocina.sul.stanford.edu/models/file.jsonld'
41
41
  end
42
42
 
43
- def self.fileset
44
- 'http://cocina.sul.stanford.edu/models/fileset.jsonld'
45
- end
46
-
47
43
  def self.geo
48
44
  'http://cocina.sul.stanford.edu/models/geo.jsonld'
49
45
  end
@@ -95,6 +91,72 @@ module Cocina
95
91
  def self.webarchive_seed
96
92
  'http://cocina.sul.stanford.edu/models/webarchive-seed.jsonld'
97
93
  end
94
+
95
+ class Resources
96
+ def self.three_dimensional
97
+ 'http://cocina.sul.stanford.edu/models/resources/3d.jsonld'
98
+ end
99
+
100
+ def self.attachment
101
+ 'http://cocina.sul.stanford.edu/models/resources/attachment.jsonld'
102
+ end
103
+
104
+ def self.audio
105
+ 'http://cocina.sul.stanford.edu/models/resources/audio.jsonld'
106
+ end
107
+
108
+ def self.document
109
+ 'http://cocina.sul.stanford.edu/models/resources/document.jsonld'
110
+ end
111
+
112
+ def self.file
113
+ 'http://cocina.sul.stanford.edu/models/resources/file.jsonld'
114
+ end
115
+
116
+ def self.image
117
+ 'http://cocina.sul.stanford.edu/models/resources/image.jsonld'
118
+ end
119
+
120
+ def self.main_augmented
121
+ 'http://cocina.sul.stanford.edu/models/resources/main-augmented.jsonld'
122
+ end
123
+
124
+ def self.main_original
125
+ 'http://cocina.sul.stanford.edu/models/resources/main-original.jsonld'
126
+ end
127
+
128
+ def self.media
129
+ 'http://cocina.sul.stanford.edu/models/resources/media.jsonld'
130
+ end
131
+
132
+ def self.object
133
+ 'http://cocina.sul.stanford.edu/models/resources/object.jsonld'
134
+ end
135
+
136
+ def self.page
137
+ 'http://cocina.sul.stanford.edu/models/resources/page.jsonld'
138
+ end
139
+
140
+ def self.permissions
141
+ 'http://cocina.sul.stanford.edu/models/resources/permissions.jsonld'
142
+ end
143
+
144
+ def self.preview
145
+ 'http://cocina.sul.stanford.edu/models/resources/preview.jsonld'
146
+ end
147
+
148
+ def self.supplement
149
+ 'http://cocina.sul.stanford.edu/models/resources/supplement.jsonld'
150
+ end
151
+
152
+ def self.thumb
153
+ 'http://cocina.sul.stanford.edu/models/resources/thumb.jsonld'
154
+ end
155
+
156
+ def self.video
157
+ 'http://cocina.sul.stanford.edu/models/resources/video.jsonld'
158
+ end
159
+ end
98
160
  end
99
161
  end
100
162
  end
data/openapi.yml CHANGED
@@ -347,6 +347,11 @@ components:
347
347
  valueAt:
348
348
  description: URL or other pointer to the location of the contributor information.
349
349
  type: string
350
+ parallelContributor:
351
+ description: For multiple representations of information about the same contributor (e.g. in different languages).
352
+ type: array
353
+ items:
354
+ $ref: "#/components/schemas/DescriptiveParallelContributor"
350
355
  Description:
351
356
  type: object
352
357
  additionalProperties: false
@@ -581,6 +586,43 @@ components:
581
586
  type: array
582
587
  items:
583
588
  $ref: "#/components/schemas/DescriptiveValue"
589
+ DescriptiveParallelContributor:
590
+ description: Value model for multiple representations of information about the same contributor (e.g. in different languages).
591
+ type: object
592
+ additionalProperties: false
593
+ properties:
594
+ name:
595
+ description: Names associated with a contributor.
596
+ type: array
597
+ items:
598
+ $ref: "#/components/schemas/DescriptiveValue"
599
+ type:
600
+ description: Entity type of the contributor (person, organization, etc.).
601
+ type: string
602
+ status:
603
+ description: Status of the contributor relative to other parallel contributors (e.g. the primary author among a group of contributors).
604
+ type: string
605
+ role:
606
+ description: Relationships of the contributor to the resource or to an event in its history.
607
+ type: array
608
+ items:
609
+ $ref: "#/components/schemas/DescriptiveValue"
610
+ identifier:
611
+ description: Identifiers and URIs associated with the contributor entity.
612
+ type: array
613
+ items:
614
+ $ref: "#/components/schemas/DescriptiveValue"
615
+ note:
616
+ description: Other information associated with the contributor.
617
+ type: array
618
+ items:
619
+ $ref: "#/components/schemas/DescriptiveValue"
620
+ valueAt:
621
+ description: URL or other pointer to the location of the contributor information.
622
+ type: string
623
+ valueLanguage:
624
+ # description: Language of the descriptive element value
625
+ $ref: "#/components/schemas/DescriptiveValueLanguage"
584
626
  DescriptiveParallelEvent:
585
627
  description: Value model for multiple representations of information about the same event (e.g. in different languages).
586
628
  type: object
@@ -981,7 +1023,22 @@ components:
981
1023
  description: The content type of the Fileset.
982
1024
  type: string
983
1025
  enum:
984
- - 'http://cocina.sul.stanford.edu/models/fileset.jsonld'
1026
+ - 'http://cocina.sul.stanford.edu/models/resources/audio.jsonld'
1027
+ - 'http://cocina.sul.stanford.edu/models/resources/attachment.jsonld'
1028
+ - 'http://cocina.sul.stanford.edu/models/resources/document.jsonld'
1029
+ - 'http://cocina.sul.stanford.edu/models/resources/file.jsonld'
1030
+ - 'http://cocina.sul.stanford.edu/models/resources/image.jsonld'
1031
+ - 'http://cocina.sul.stanford.edu/models/resources/main-augmented.jsonld'
1032
+ - 'http://cocina.sul.stanford.edu/models/resources/main-original.jsonld'
1033
+ - 'http://cocina.sul.stanford.edu/models/resources/media.jsonld'
1034
+ - 'http://cocina.sul.stanford.edu/models/resources/object.jsonld'
1035
+ - 'http://cocina.sul.stanford.edu/models/resources/page.jsonld'
1036
+ - 'http://cocina.sul.stanford.edu/models/resources/permissions.jsonld'
1037
+ - 'http://cocina.sul.stanford.edu/models/resources/preview.jsonld'
1038
+ - 'http://cocina.sul.stanford.edu/models/resources/supplement.jsonld'
1039
+ - 'http://cocina.sul.stanford.edu/models/resources/3d.jsonld'
1040
+ - 'http://cocina.sul.stanford.edu/models/resources/thumb.jsonld'
1041
+ - 'http://cocina.sul.stanford.edu/models/resources/video.jsonld'
985
1042
  externalIdentifier:
986
1043
  type: string
987
1044
  label:
@@ -1398,7 +1455,22 @@ components:
1398
1455
  type:
1399
1456
  type: string
1400
1457
  enum:
1401
- - 'http://cocina.sul.stanford.edu/models/fileset.jsonld'
1458
+ - 'http://cocina.sul.stanford.edu/models/resources/audio.jsonld'
1459
+ - 'http://cocina.sul.stanford.edu/models/resources/attachment.jsonld'
1460
+ - 'http://cocina.sul.stanford.edu/models/resources/document.jsonld'
1461
+ - 'http://cocina.sul.stanford.edu/models/resources/file.jsonld'
1462
+ - 'http://cocina.sul.stanford.edu/models/resources/image.jsonld'
1463
+ - 'http://cocina.sul.stanford.edu/models/resources/main-augmented.jsonld'
1464
+ - 'http://cocina.sul.stanford.edu/models/resources/main-original.jsonld'
1465
+ - 'http://cocina.sul.stanford.edu/models/resources/media.jsonld'
1466
+ - 'http://cocina.sul.stanford.edu/models/resources/object.jsonld'
1467
+ - 'http://cocina.sul.stanford.edu/models/resources/page.jsonld'
1468
+ - 'http://cocina.sul.stanford.edu/models/resources/permissions.jsonld'
1469
+ - 'http://cocina.sul.stanford.edu/models/resources/preview.jsonld'
1470
+ - 'http://cocina.sul.stanford.edu/models/resources/supplement.jsonld'
1471
+ - 'http://cocina.sul.stanford.edu/models/resources/3d.jsonld'
1472
+ - 'http://cocina.sul.stanford.edu/models/resources/thumb.jsonld'
1473
+ - 'http://cocina.sul.stanford.edu/models/resources/video.jsonld'
1402
1474
  label:
1403
1475
  type: string
1404
1476
  version:
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.54.0
4
+ version: 0.55.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-11 00:00:00.000000000 Z
11
+ date: 2021-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -271,6 +271,7 @@ files:
271
271
  - lib/cocina/models/descriptive_basic_value.rb
272
272
  - lib/cocina/models/descriptive_geographic_metadata.rb
273
273
  - lib/cocina/models/descriptive_grouped_value.rb
274
+ - lib/cocina/models/descriptive_parallel_contributor.rb
274
275
  - lib/cocina/models/descriptive_parallel_event.rb
275
276
  - lib/cocina/models/descriptive_parallel_value.rb
276
277
  - lib/cocina/models/descriptive_structured_value.rb
@@ -314,7 +315,7 @@ files:
314
315
  homepage: https://github.com/sul-dlss/cocina-models
315
316
  licenses: []
316
317
  metadata: {}
317
- post_install_message:
318
+ post_install_message:
318
319
  rdoc_options: []
319
320
  require_paths:
320
321
  - lib
@@ -329,8 +330,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
329
330
  - !ruby/object:Gem::Version
330
331
  version: '0'
331
332
  requirements: []
332
- rubygems_version: 3.0.6
333
- signing_key:
333
+ rubygems_version: 3.1.4
334
+ signing_key:
334
335
  specification_version: 4
335
336
  summary: Data models for the SDR
336
337
  test_files: []