cocina-models 0.70.0 → 0.71.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: ab6c36807c8585e07d8fc5529e6ef1aa08e88f7fc93d3dc7605aecb87e9138db
4
- data.tar.gz: 8a5c302070e2beab4c3606124e1b68e64a1ab1063c8c32d05e47a66db3325d78
3
+ metadata.gz: 5058bc2927b8788ad9c04142decbfcc7cf42b7daa3b84665d64dd00b432d8ff4
4
+ data.tar.gz: 524263003bc679432b5c120690775de4ebc14ef5fa6158337e0beff9c2bfb332
5
5
  SHA512:
6
- metadata.gz: 33fa2bd17896f666da8f4bdc1249a1e216f0344c0dc6d95e47b76a97b801a2ab1abf05fd1ca287e7bd23e134a34de8900e985e7db3bfea2e91b9c359be209722
7
- data.tar.gz: 93ac31afd9d5da0587d4798c8e3ae571853f0e2b3c85d6edcda231ab886d9fd4f3559e7616a70f2290629028faa745bc40406f47f0bbe5ec95574bbe084bb532
6
+ metadata.gz: b84f98459177c74cc822a8dee105412c7023c3fda2e953e1f760c482ae3a2967f610207bb53cd33c510e2b0c861834b4cf1998459b70035ac9b22aa55c83b910
7
+ data.tar.gz: '018baa839ef5774c3969f91acb9545fb04ddf3be652ae3f3fafbc6458ddd7ec1d7c4ae5d5d33a9a8eab36476519cd310a33b61da34e4f934bef35ef490dc83fd'
data/.rubocop.yml CHANGED
@@ -107,7 +107,7 @@ RSpec/StubbedMock: # (new in 1.44)
107
107
  Enabled: true
108
108
 
109
109
  RSpec/MultipleMemoizedHelpers:
110
- Max: 6
110
+ Enabled: false
111
111
 
112
112
  # ----- Style ------
113
113
 
data/README.md CHANGED
@@ -101,6 +101,16 @@ If for some reason the above method does not work, the sul-dlss/access-update-sc
101
101
 
102
102
  [sul-dlss/sdr-deploy](https://github.com/sul-dlss/sdr-deploy) has a flag in the deploy script to limit deploys to cocina dependent applications. Refer to instructions in the [sdr-deploy/README](https://github.com/sul-dlss/sdr-deploy/blob/main/README.md#only-deploy-repos-related-to-cocina-models-update).
103
103
 
104
+ Note that running the integration tests is currently the best way we have to check for unintended effects and/or bugs when rolling out cocina-models changes.
105
+
106
+ #### Step 5A: Deploy to QA and/or Stage
107
+
108
+ #### Step 5B: Run infrastructure_integration_tests
109
+
110
+ It is safest to ensure _all_ the integration tests run cleanly. However, patch releases of cocina-models may only warrant running individual tests that exercise the changes.
111
+
112
+ #### Step 5C: Deploy to Production
113
+
104
114
  **[Turn off Google Books](https://sul-gbooks-prod.stanford.edu/features) when deploying to production.** This avoids failed deposit due to a temporary Cocina model mismatch. Unlike other applications, the deposits will fail without retry and require manual remediation.
105
115
 
106
116
  ## Usage conventions
@@ -108,6 +118,7 @@ If for some reason the above method does not work, the sul-dlss/access-update-sc
108
118
  The following are the recommended naming conventions for code using Cocina models:
109
119
 
110
120
  * `cocina_item`: `Cocina::Models::DRO` instance
121
+ * `cocina_agreement`: `Cocina::Models::DRO` with type of Cocina::Models::ObjectType.agreement
111
122
  * `cocina_admin_policy`: `Cocina::Models::AdminPolicy` instance
112
123
  * `cocina_collection`: `Cocina::Models::Collection` instance
113
124
  * `cocina_object`: `Cocina::Models::DRO` or `Cocina::Models::AdminPolicy` or `Cocina::Models::Collection` instance
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.required_ruby_version = '>= 2.7'
26
26
 
27
27
  spec.add_dependency 'activesupport'
28
+ spec.add_dependency 'deprecation'
28
29
  spec.add_dependency 'dry-struct', '~> 1.0'
29
30
  spec.add_dependency 'dry-types', '~> 1.1'
30
31
  spec.add_dependency 'openapi3_parser' # Parsing openapi doc
@@ -12,7 +12,7 @@ module Cocina
12
12
  # Unique identifier in some other system. This is because a large proportion of what is deposited in SDR, historically and currently, are representations of objects that are also represented in other systems. For example, digitized paper and A/V collections have physical manifestations, and those physical objects are managed in systems that have their own identifiers. Similarly, books have barcodes, archival materials have collection numbers and physical locations, etc. The sourceId allows determining if an item has been deposited before and where to look for the original item if you're looking at its SDR representation. The format is: "namespace:identifier"
13
13
 
14
14
  # example: sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026
15
- attribute :sourceId, Types::Strict::String.meta(omittable: true)
15
+ attribute :sourceId, Types::Strict::String
16
16
  end
17
17
  end
18
18
  end
@@ -1,30 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'deprecation'
4
+
3
5
  module Cocina
4
6
  module Models
5
7
  # TitleBuilder selects the prefered title from the cocina object for solr indexing
6
8
  # rubocop:disable Metrics/ClassLength
7
9
  class TitleBuilder
8
- # @param [Cocina::Models::D*] cocina_object is the object to extract the title for
10
+ extend Deprecation
11
+ # @param [[Array<Cocina::Models::Title,Cocina::Models::DescriptiveValue>] titles the titles to consider
9
12
  # @param [Symbol] strategy ":first" is the strategy for selection when primary or display title are missing
10
13
  # @param [Boolean] add_punctuation determines if the title should be formmated with punctuation
11
14
  # @return [String] the title value for Solr
12
- def self.build(cocina_object, strategy: :first, add_punctuation: true)
13
- new(cocina_object, strategy: strategy, add_punctuation: add_punctuation).build_title
15
+ def self.build(titles, strategy: :first, add_punctuation: true)
16
+ if titles.respond_to?(:description)
17
+ Deprecation.warn(self, "Calling TitleBuilder.build with a #{titles.class} is deprecated. It must be called with an array of titles")
18
+ titles = titles.description.title
19
+ end
20
+ new(strategy: strategy, add_punctuation: add_punctuation).build(titles)
14
21
  end
15
22
 
16
- def initialize(cocina_object, strategy:, add_punctuation:)
17
- @cocina_object = cocina_object
23
+ def initialize(strategy:, add_punctuation:)
18
24
  @strategy = strategy
19
25
  @add_punctuation = add_punctuation
20
26
  end
21
27
 
28
+ # @param [[Array<Cocina::Models::Title>] titles the titles to consider
22
29
  # @return [String] the title value for Solr
23
- def build_title
24
- @titles = cocina_object.description.title
25
-
26
- cocina_title = primary_title || untyped_title
27
- cocina_title = other_title if cocina_title.blank?
30
+ def build(titles)
31
+ cocina_title = primary_title(titles) || untyped_title(titles)
32
+ cocina_title = other_title(titles) if cocina_title.blank?
28
33
 
29
34
  if strategy == :first
30
35
  extract_title(cocina_title)
@@ -35,7 +40,7 @@ module Cocina
35
40
 
36
41
  private
37
42
 
38
- attr_reader :cocina_object, :strategy, :titles
43
+ attr_reader :strategy
39
44
 
40
45
  def extract_title(cocina_title)
41
46
  result = if cocina_title.value
@@ -44,7 +49,7 @@ module Cocina
44
49
  title_from_structured_values(cocina_title.structuredValue,
45
50
  non_sorting_char_count(cocina_title))
46
51
  elsif cocina_title.parallelValue.present?
47
- return cocina_title.parallelValue.first.value
52
+ return build(cocina_title.parallelValue)
48
53
  end
49
54
  remove_trailing_punctuation(result.strip) if result.present?
50
55
  end
@@ -54,7 +59,7 @@ module Cocina
54
59
  end
55
60
 
56
61
  # @return [Cocina::Models::Title, nil] title that has status=primary
57
- def primary_title
62
+ def primary_title(titles)
58
63
  primary_title = titles.find do |title|
59
64
  title.status == 'primary'
60
65
  end
@@ -69,7 +74,7 @@ module Cocina
69
74
  end
70
75
  end
71
76
 
72
- def untyped_title
77
+ def untyped_title(titles)
73
78
  method = strategy == :first ? :find : :select
74
79
  untyped_title_for(titles.public_send(method))
75
80
  end
@@ -86,7 +91,7 @@ module Cocina
86
91
  end
87
92
 
88
93
  # This handles 'main title', 'uniform' or 'translated'
89
- def other_title
94
+ def other_title(titles)
90
95
  if strategy == :first
91
96
  titles.first
92
97
  else
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.70.0'
5
+ VERSION = '0.71.0'
6
6
  end
7
7
  end
data/openapi.yml CHANGED
@@ -1256,6 +1256,8 @@ components:
1256
1256
  $ref: '#/components/schemas/DOI'
1257
1257
  sourceId:
1258
1258
  $ref: '#/components/schemas/SourceId'
1259
+ required:
1260
+ - sourceId
1259
1261
  Language:
1260
1262
  description: Languages, scripts, symbolic systems, and notations used in all
1261
1263
  or part of a resource or its descriptive metadata.
@@ -1424,7 +1426,7 @@ components:
1424
1426
  format: date-time
1425
1427
  lock:
1426
1428
  description: Key for optimistic locking. The contents of the key is not specified.
1427
- type: string
1429
+ type: string
1428
1430
  required:
1429
1431
  - lock
1430
1432
  Presentation:
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.70.0
4
+ version: 0.71.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: 2022-03-22 00:00:00.000000000 Z
11
+ date: 2022-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: deprecation
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: dry-struct
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -396,7 +410,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
396
410
  - !ruby/object:Gem::Version
397
411
  version: '0'
398
412
  requirements: []
399
- rubygems_version: 3.3.9
413
+ rubygems_version: 3.2.32
400
414
  signing_key:
401
415
  specification_version: 4
402
416
  summary: Data models for the SDR