cocina_display 1.9.0 → 1.10.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: d724bfbe5e313a116cdba675f7d4f563662e8370f9ede927bef32a8cb7f90f26
4
- data.tar.gz: e3fccfd8188a3f21ad05beb49d281bca8e24cf7e03524b51bd03fde4facbfa90
3
+ metadata.gz: 03c9a2548b9c996e4083311c34980125df77e41dc01ffa613e1539f9524b623a
4
+ data.tar.gz: ec9d5c04f50fb1cba69384b40c8ab9b009e8f8e9046b8e4dd67b15dd22f60479
5
5
  SHA512:
6
- metadata.gz: 1a3bcecb41e8a3ca656f079f2fb7f09aa256669e868c0ca34c1b42e5e60ed3e083b1f1bb862122f0a9864fbfd989406a961671b560edff1ba8d29e9620b0c62c
7
- data.tar.gz: 5f1b3688911de060ff1a7ef6a31f4e98a300d217a42fb27cf76d401766a4d741a93821d26f0bdb7549506e462911d0a9da3f5fc25c68d041b7a7d2cc12285b29
6
+ metadata.gz: f3f777efbd5262a640b9e9c93e63411d7c52c6aaf603b3203742a0af5108c8ece948918b6900db17dd42ec92e63c17f71a15b739fc2ced4c82d4b8f4e05d6af7
7
+ data.tar.gz: 91633c63df3e10220d5a8c564f2900194546d14b96ca6b115ddcbb12fff8a2f182bda92023dfd32ff5f6486f1fda3c93a8b578e93ae3075c4d5812bbfd39ffea
@@ -88,6 +88,7 @@ module CocinaDisplay
88
88
 
89
89
  # DisplayData for Contributors, one per role (excluding publisher).
90
90
  # Contributors with no role are grouped under a default heading.
91
+ # @note For displaying publisher information, use {publication_display_data}.
91
92
  # @return [Array<DisplayData>]
92
93
  def contributor_display_data
93
94
  contributors_by_role.except("publisher").map do |role, contributors|
@@ -135,6 +135,13 @@ module CocinaDisplay
135
135
  CocinaDisplay::DisplayData.from_objects(event_dates)
136
136
  end
137
137
 
138
+ # DisplayData for publisher and publication place.
139
+ # @return [Array<CocinaDisplay::DisplayData>]
140
+ def publication_display_data
141
+ CocinaDisplay::DisplayData.from_strings(publication_places, label: "Place") +
142
+ CocinaDisplay::DisplayData.from_strings(publisher_names, label: "Publisher")
143
+ end
144
+
138
145
  # The earliest preferred publication date as a CocinaDisplay::Dates::Date object.
139
146
  # Considers publication, creation, and capture dates in that order.
140
147
  # Prefers dates marked as primary and those with a declared encoding.
@@ -9,6 +9,7 @@ module CocinaDisplay
9
9
  def searchworks_resource_types
10
10
  mapped_values = resource_type_values.flat_map { |resource_type| searchworks_resource_type(resource_type) }
11
11
  mapped_values << "Dataset" if dataset?
12
+ mapped_values << "Software/Multimedia" if digital_only?
12
13
  mapped_values.uniq
13
14
  end
14
15
 
@@ -187,13 +188,21 @@ module CocinaDisplay
187
188
 
188
189
  private
189
190
 
190
- # Map a resource type to SearchWorks format value(s).
191
+ # Is the object a digital resource without a more specific resource type?
192
+ # @return [Boolean]
193
+ def digital_only?
194
+ resource_type_values.all?("digital")
195
+ end
196
+
197
+ # Map a MODS or LC resource type to SearchWorks format value(s).
191
198
  # @param resource_type [String] The resource type to map.
192
199
  # @return [Array<String>]
193
200
  def searchworks_resource_type(resource_type)
194
201
  values = []
195
202
 
196
203
  case resource_type
204
+ when "dataset"
205
+ values << "Dataset"
197
206
  when "cartographic"
198
207
  values << "Map"
199
208
  when "manuscript", "mixed material"
@@ -202,10 +211,10 @@ module CocinaDisplay
202
211
  values << "Video/Film"
203
212
  when "notated music"
204
213
  values << "Music score"
205
- when "software, multimedia"
214
+ when "software, multimedia", "multimedia"
206
215
  # Prevent GIS datasets from being labeled as "Software"
207
216
  values << "Software/Multimedia" unless cartographic? || dataset?
208
- when "sound recording-musical", "sound recording-nonmusical", "sound recording"
217
+ when "sound recording-musical", "sound recording-nonmusical", "sound recording", "audio"
209
218
  values << "Sound recording"
210
219
  when "still image"
211
220
  values << "Image"
@@ -219,7 +228,7 @@ module CocinaDisplay
219
228
  else
220
229
  values << "Book"
221
230
  end
222
- when "three dimensional object"
231
+ when "three dimensional object", "artifact", "tactile"
223
232
  values << "Object"
224
233
  end
225
234
 
@@ -5,7 +5,7 @@ module CocinaDisplay
5
5
  module Forms
6
6
  # A form associated with part or all of a Cocina object.
7
7
  class Form
8
- attr_reader :cocina
8
+ attr_reader :cocina, :delimiter
9
9
 
10
10
  # Create a Form object from Cocina structured data.
11
11
  # Delegates to subclasses for specific types.
@@ -24,8 +24,10 @@ module CocinaDisplay
24
24
 
25
25
  # Create a Form object from Cocina structured data.
26
26
  # @param cocina [Hash]
27
- def initialize(cocina)
27
+ # @param delimiter [String] The delimiter to use when flattening for display
28
+ def initialize(cocina, delimiter: " > ")
28
29
  @cocina = cocina
30
+ @delimiter = delimiter
29
31
  end
30
32
 
31
33
  # The value to use for display.
@@ -37,7 +39,7 @@ module CocinaDisplay
37
39
  # Single concatenated string value for the form.
38
40
  # @return [String]
39
41
  def flat_value
40
- Utils.compact_and_join(values, delimiter: " > ")
42
+ Utils.compact_and_join(values, delimiter: delimiter)
41
43
  end
42
44
 
43
45
  # The raw values from the Cocina data, flattened if nested.
@@ -2,12 +2,14 @@ module CocinaDisplay
2
2
  module Subjects
3
3
  # Base class for subjects in Cocina structured data.
4
4
  class Subject
5
- attr_reader :cocina
5
+ attr_reader :cocina, :delimiter
6
6
 
7
7
  # Initialize a Subject object with Cocina structured data.
8
8
  # @param cocina [Hash] The Cocina structured data for the subject.
9
- def initialize(cocina)
9
+ # @param delimiter [String] The delimiter to use when flattening for display
10
+ def initialize(cocina, delimiter: " > ")
10
11
  @cocina = cocina
12
+ @delimiter = delimiter
11
13
  end
12
14
 
13
15
  # The top-level type of the subject.
@@ -20,7 +22,7 @@ module CocinaDisplay
20
22
  # Array of display strings for each value in the subject.
21
23
  # Used for search, where each value should be indexed separately.
22
24
  # @return [Array<String>]
23
- def display_values
25
+ def values
24
26
  subject_values.map(&:to_s).compact_blank
25
27
  end
26
28
 
@@ -28,13 +30,13 @@ module CocinaDisplay
28
30
  # Genre values are capitalized; other subject values are not.
29
31
  # @return [String]
30
32
  def to_s
31
- (type == "genre") ? display_value&.upcase_first : display_value
33
+ (type == "genre") ? flat_value&.upcase_first : flat_value
32
34
  end
33
35
 
34
36
  # A string representation of the entire subject, concatenated for display.
35
37
  # @return [String]
36
- def display_value
37
- Utils.compact_and_join(display_values, delimiter: " > ")
38
+ def flat_value
39
+ Utils.compact_and_join(values, delimiter: delimiter)
38
40
  end
39
41
 
40
42
  # Label used to render the subject for display.
@@ -2,5 +2,5 @@
2
2
 
3
3
  # :nodoc:
4
4
  module CocinaDisplay
5
- VERSION = "1.9.0" # :nodoc:
5
+ VERSION = "1.10.0" # :nodoc:
6
6
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocina_display
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Budak
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2026-02-25 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: janeway-jsonpath
@@ -298,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
298
298
  - !ruby/object:Gem::Version
299
299
  version: '0'
300
300
  requirements: []
301
- rubygems_version: 3.6.9
301
+ rubygems_version: 3.6.2
302
302
  specification_version: 4
303
303
  summary: Helpers for rendering Cocina metadata
304
304
  test_files: []