cocina_display 2.2.0 → 2.3.1

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: 3465ccfb8142f2351977032932d4e38e8ea97188bbeea980073eb145780c7465
4
- data.tar.gz: 9a7c59a505bc7eaa88b3ae0cb81becd67f508eeff72d39b9db4725db4a0403e4
3
+ metadata.gz: 314d08be365121515add19014c2c3d6593d1016fd3ce5e53928c991ce209b64a
4
+ data.tar.gz: 31cc7393ccaf6285f7e1df378a22d3347c23d4853a0eb34bfe3402b3d5818045
5
5
  SHA512:
6
- metadata.gz: cc5c29815d9d5250cfc63eb5546db9eae7374d50f4308089dce8eb7cc5383193ebb125fb4fe0a07226602b3f631fc75aa4fbec78b7796794ad2c27c7c9717217
7
- data.tar.gz: 7046fcda48d7004206e5b1ee3f724f591f7cc8306c9e560226fb48832ff041f1bdff0c4d28e45d38090e356a8e1375d3da1d39c2ff3a13316e4870d83c7fd0d3
6
+ metadata.gz: ae4df0a3875374c472f8360110281e519e8bd423f68bfb29f61e618cf8f39e4a99182273ae6d61b77373cd298d827110a50acb3d7c9fafc1e80fe5f996576e74
7
+ data.tar.gz: af43069ebf9d00828814b9d313ed1f670beb94591cc2a15d28fcaa24bd72773cca3b48b23429fd7a1e195b65e3ea258c073e56e9382722b2bd45aa8244374b9a
@@ -12,8 +12,7 @@ afa: Afroasiatic (Other)
12
12
  afh: Afrihili (Artificial language)
13
13
  afr: Afrikaans
14
14
  ain: Ainu
15
- # ajm is deprecated
16
- ajm: Aljamía
15
+ ajm: Aljamía # deprecated
17
16
  aka: Akan
18
17
  akk: Akkadian
19
18
  alb: Albanian
@@ -32,8 +31,7 @@ arn: Mapuche
32
31
  arp: Arapaho
33
32
  art: Artificial (Other)
34
33
  arw: Arawak
35
- # ase from iso639-3
36
- ase: American Sign Language
34
+ ase: American Sign Language # from iso639-3
37
35
  asm: Assamese
38
36
  ast: Bable
39
37
  ath: Athapascan (Other)
@@ -75,8 +73,7 @@ bur: Burmese
75
73
  byn: Bilin
76
74
  cad: Caddo
77
75
  cai: Central American Indian (Other)
78
- # cam is deprecated
79
- cam: Khmer
76
+ cam: Khmer # deprecated
80
77
  car: Carib
81
78
  cat: Catalan
82
79
  cau: Caucasian (Other)
@@ -119,6 +116,7 @@ den: Slavey
119
116
  dgr: Tlicho
120
117
  din: Dinka
121
118
  div: Divehi
119
+ dnt: Mid Grand Valley Dani # from iso639-3
122
120
  doi: Dogri
123
121
  dra: Dravidian (Other)
124
122
  dsb: Lower Sorbian
@@ -129,26 +127,21 @@ dyu: Dyula
129
127
  dzo: Dzongkha
130
128
  efi: Efik
131
129
  egy: Egyptian
132
- # per RFC 5646 and ISO 15924
133
- egy-Egyd: Egyptian, Demotic
130
+ egy-Egyd: Egyptian, Demotic # per RFC 5646 and ISO 15924
134
131
  eka: Ekajuk
135
132
  elx: Elamite
136
133
  eng: English
137
134
  enm: English, Middle (1100-1500)
138
135
  epo: Esperanto
139
- # esk is deprecated
140
- esk: Eskimo languages
141
- # esp is deprecated
142
- esp: Esperanto
136
+ esk: Eskimo languages # deprecated
137
+ esp: Esperanto # deprecated
143
138
  est: Estonian
144
- # eth is deprecated
145
- eth: Ethiopic
139
+ eth: Ethiopic # deprecated
146
140
  ewe: Ewe
147
141
  ewo: Ewondo
148
142
  fan: Fang
149
143
  fao: Faroese
150
- # far is deprecated
151
- far: Faroese
144
+ far: Faroese # deprecated
152
145
  fat: Fanti
153
146
  fij: Fijian
154
147
  fil: Filipino
@@ -156,8 +149,7 @@ fin: Finnish
156
149
  fiu: Finno-Ugrian (Other)
157
150
  fon: Fon
158
151
  fre: French
159
- # fri is deprecated
160
- fri: Frisian
152
+ fri: Frisian # deprecated
161
153
  frm: French, Middle (ca. 1300-1600)
162
154
  fro: French, Old (ca. 842-1300)
163
155
  frr: North Frisian
@@ -166,12 +158,9 @@ fry: Frisian
166
158
  ful: Fula
167
159
  fur: Friulian
168
160
  gaa: Gã
169
- # gae is deprecated
170
- gae: Scottish Gaelic
171
- # gag is deprecated
172
- gag: Galician
173
- # gal is deprecated
174
- gal: Oromo
161
+ gae: Scottish Gaelic # deprecated
162
+ gag: Galician # deprecated
163
+ gal: Oromo # deprecated
175
164
  gay: Gayo
176
165
  gba: Gbaya
177
166
  gem: Germanic (Other)
@@ -193,8 +182,7 @@ grc: Greek, Ancient (to 1453)
193
182
  gre: Greek, Modern (1453-)
194
183
  grn: Guarani
195
184
  gsw: Swiss German
196
- # gua is deprecated
197
- gua: Guarani
185
+ gua: Guarani # deprecated
198
186
  guj: Gujarati
199
187
  gwi: Gwich'in
200
188
  hai: Haida
@@ -227,12 +215,10 @@ inc: Indic (Other)
227
215
  ind: Indonesian
228
216
  ine: Indo-European (Other)
229
217
  inh: Ingush
230
- # int is deprecated
231
- int: Interlingua (International Auxiliary Language Association)
218
+ int: Interlingua (International Auxiliary Language Association) # deprecated
232
219
  ipk: Inupiaq
233
220
  ira: Iranian (Other)
234
- # iri is deprecated
235
- iri: Irish
221
+ iri: Irish # deprecated
236
222
  iro: Iroquoian (Other)
237
223
  ita: Italian
238
224
  jav: Javanese
@@ -273,17 +259,14 @@ kru: Kurukh
273
259
  kua: Kuanyama
274
260
  kum: Kumyk
275
261
  kur: Kurdish
276
- # kus is deprecated
277
- kus: Kusaie
262
+ kus: Kusaie # deprecated
278
263
  kut: Kootenai
279
264
  lad: Ladino
280
265
  lah: Lahndā
281
266
  lam: Lamba (Zambia and Congo)
282
- # lan is deprecated
283
- lan: Occitan (post 1500)
267
+ lan: Occitan (post 1500) # deprecated
284
268
  lao: Lao
285
- # lap is deprecated
286
- lap: Sami
269
+ lap: Sami # deprecated
287
270
  lat: Latin
288
271
  lav: Latvian
289
272
  lez: Lezgian
@@ -312,8 +295,7 @@ mao: Maori
312
295
  map: Austronesian (Other)
313
296
  mar: Marathi
314
297
  mas: Maasai
315
- # max is deprecated
316
- max: Manx
298
+ max: Manx # deprecated
317
299
  may: Malay
318
300
  mdf: Moksha
319
301
  mdr: Mandar
@@ -323,16 +305,14 @@ mic: Micmac
323
305
  min: Minangkabau
324
306
  # mis: Miscellaneous languages
325
307
  mkh: Mon-Khmer (Other)
326
- # mla is deprecated
327
- mla: Malagasy
308
+ mla: Malagasy # deprecated
328
309
  mlg: Malagasy
329
310
  mlt: Maltese
330
311
  mnc: Manchu
331
312
  mni: Manipuri
332
313
  mno: Manobo languages
333
314
  moh: Mohawk
334
- # mol is deprecated
335
- mol: Moldavian
315
+ mol: Moldavian # deprecated
336
316
  mon: Mongolian
337
317
  mos: Mooré
338
318
  # mul: Multiple languages
@@ -396,6 +376,7 @@ por: Portuguese
396
376
  pra: Prakrit languages
397
377
  pro: Provençal (to 1500)
398
378
  pus: Pushto
379
+ quc: K'iche' # from iso639-3
399
380
  que: Quechua
400
381
  raj: Rajasthani
401
382
  rap: Rapanui
@@ -414,27 +395,24 @@ sai: South American Indian (Other)
414
395
  sal: Salishan languages
415
396
  sam: Samaritan Aramaic
416
397
  san: Sanskrit
417
- # sao is deprecated
418
- sao: Samoan
398
+ sao: Samoan # deprecated
419
399
  sas: Sasak
420
400
  sat: Santali
421
- # scc is deprecated
422
- scc: Serbian
401
+ scc: Serbian # deprecated
423
402
  scn: Sicilian Italian
424
403
  sco: Scots
425
- # scr is deprecated
426
- scr: Croatian
404
+ scr: Croatian # deprecated
427
405
  sel: Selkup
428
406
  sem: Semitic (Other)
429
407
  sga: Irish, Old (to 1100)
430
408
  sgn: Sign languages
431
409
  shn: Shan
432
- # sho is deprecated
433
- sho: Shona
410
+ sho: Shona # deprecated
434
411
  sid: Sidamo
435
412
  sin: Sinhalese
436
413
  sio: Siouan (Other)
437
414
  sit: Sino-Tibetan (Other)
415
+ skr: Saraiki # from iso639-3
438
416
  sla: Slavic (Other)
439
417
  slo: Slovak
440
418
  slv: Slovenian
@@ -447,8 +425,7 @@ smo: Samoan
447
425
  sms: Skolt Sami
448
426
  sna: Shona
449
427
  snd: Sindhi
450
- # snh is deprecated
451
- snh: Sinhalese
428
+ snh: Sinhalese # deprecated
452
429
  snk: Soninke
453
430
  sog: Sogdian
454
431
  som: Somali
@@ -460,8 +437,7 @@ srn: Sranan
460
437
  srp: Serbian
461
438
  srr: Serer
462
439
  ssa: Nilo-Saharan (Other)
463
- # sso is deprecated
464
- sso: Sotho
440
+ sso: Sotho # deprecated
465
441
  ssw: Swazi
466
442
  suk: Sukuma
467
443
  sun: Sundanese
@@ -469,19 +445,15 @@ sus: Susu
469
445
  sux: Sumerian
470
446
  swa: Swahili
471
447
  swe: Swedish
472
- # swz is deprecated
473
- swz: Swazi
448
+ swz: Swazi # deprecated
474
449
  syc: Syriac
475
450
  syr: Syriac, Modern
476
- # tag is deprecated
477
- tag: Tagalog
451
+ tag: Tagalog # deprecated
478
452
  tah: Tahitian
479
453
  tai: Tai (Other)
480
- # taj is deprecated
481
- taj: Tajik
454
+ taj: Tajik # deprecated
482
455
  tam: Tamil
483
- # tar is deprecated
484
- tar: Tatar
456
+ tar: Tatar # deprecated
485
457
  tat: Tatar
486
458
  tel: Telugu
487
459
  tem: Temne
@@ -501,13 +473,12 @@ tmh: Tamashek
501
473
  tog: Tonga (Nyasa)
502
474
  ton: Tongan
503
475
  tpi: Tok Pisin
504
- # tru is deprecated
505
- tru: Truk
476
+ tru: Truk # deprecated
477
+ trw: Torwali # from iso639-3
506
478
  tsi: Tsimshian
507
479
  tsn: Tswana
508
480
  tso: Tsonga
509
- # tsw is deprecated
510
- tsw: Tswana
481
+ tsw: Tswana # deprecated
511
482
  tuk: Turkmen
512
483
  tum: Tumbuka
513
484
  tup: Tupi languages
@@ -6,6 +6,7 @@ module CocinaDisplay
6
6
  include CocinaDisplay::Concerns::Accesses
7
7
  include CocinaDisplay::Concerns::Events
8
8
  include CocinaDisplay::Concerns::Contributors
9
+ include CocinaDisplay::Concerns::Druid
9
10
  include CocinaDisplay::Concerns::Identifiers
10
11
  include CocinaDisplay::Concerns::Notes
11
12
  include CocinaDisplay::Concerns::Titles
@@ -0,0 +1,24 @@
1
+ module CocinaDisplay
2
+ module Concerns
3
+ # Methods for extracting and formatting identifiers from Cocina records.
4
+ module Druid
5
+ # The DRUID for the object, with the +druid:+ prefix.
6
+ # @note A {RelatedResource} may not have a DRUID, but could have a purl URL.
7
+ # @return [String, nil]
8
+ # @example
9
+ # record.druid #=> "druid:bb099mt5053"
10
+ def druid
11
+ cocina_doc["externalIdentifier"]
12
+ end
13
+
14
+ # The DRUID for the object, without the +druid:+ prefix.
15
+ # @note A {RelatedResource} may not have a DRUID.
16
+ # @return [String, nil]
17
+ # @example
18
+ # record.bare_druid #=> "bb099mt5053"
19
+ def bare_druid
20
+ druid&.delete_prefix("druid:")
21
+ end
22
+ end
23
+ end
24
+ end
@@ -2,24 +2,6 @@ module CocinaDisplay
2
2
  module Concerns
3
3
  # Methods for extracting and formatting identifiers from Cocina records.
4
4
  module Identifiers
5
- # The DRUID for the object, with the +druid:+ prefix.
6
- # @note A {RelatedResource} may not have a DRUID.
7
- # @return [String, nil]
8
- # @example
9
- # record.druid #=> "druid:bb099mt5053"
10
- def druid
11
- cocina_doc["externalIdentifier"] || purl_url&.split("/")&.last
12
- end
13
-
14
- # The DRUID for the object, without the +druid:+ prefix.
15
- # @note A {RelatedResource} may not have a DRUID.
16
- # @return [String, nil]
17
- # @example
18
- # record.bare_druid #=> "bb099mt5053"
19
- def bare_druid
20
- druid&.delete_prefix("druid:")
21
- end
22
-
23
5
  # The DOI for the object, if there is one – just the identifier part.
24
6
  # @return [String, nil]
25
7
  # @example
@@ -101,10 +101,11 @@ module CocinaDisplay
101
101
  end
102
102
 
103
103
  # DRUIDs of virtual objects this object is a part of.
104
+ # NOTE: not all virtual objects have this relationship in the description.related_resources.
104
105
  # @return [Array<String>]
105
106
  # @example "hj097bm8879"
106
107
  def virtual_object_parents
107
- related_resources.filter { |res| res.type == "part of" }.map(&:druid).compact_blank
108
+ related_resources.filter_map { |res| res.purl_url&.split("/")&.last if res.type == "part of" }.compact_blank
108
109
  end
109
110
 
110
111
  # The thumbnail file for this object, if any.
@@ -53,7 +53,7 @@ module CocinaDisplay
53
53
 
54
54
  Role.marc_relators.fetch(code)
55
55
  rescue
56
- CocinaDisplay.notifier&.notify("Invalid marc relator: #{code}")
56
+ CocinaDisplay.notifier&.notify("Invalid marc relator.", context: {code: code})
57
57
  nil
58
58
  end
59
59
 
@@ -83,7 +83,7 @@ module CocinaDisplay
83
83
  # @return [String]
84
84
  def self.normalize_to_edtf(value)
85
85
  unless value
86
- notifier&.notify("Invalid date value: #{value}")
86
+ notifier&.notify("Invalid date value.", context: {value: value})
87
87
  return
88
88
  end
89
89
 
@@ -513,7 +513,7 @@ module CocinaDisplay
513
513
  begin
514
514
  date = ISO8601::Date.new(value)
515
515
  rescue ISO8601::Errors::UnknownPattern
516
- notifier&.notify("Invalid date value \"#{value}\" for iso8601 encoding")
516
+ notifier&.notify("Invalid date value for iso8601 encoding.", context: {value: value})
517
517
  return nil
518
518
  end
519
519
 
@@ -532,7 +532,7 @@ module CocinaDisplay
532
532
  when /^\d{4}-\d{3}$/, /^\d{7}$/
533
533
  ::Date.edtf(date.to_s)
534
534
  else
535
- notifier&.notify("Unhandled date value \"#{value}\" for iso8601 encoding")
535
+ notifier&.notify("Unhandled date value for iso8601 encoding.", context: {value: value})
536
536
  nil
537
537
  end
538
538
  end
@@ -542,7 +542,7 @@ module CocinaDisplay
542
542
  class W3cdtfFormat < Date
543
543
  def self.normalize_to_edtf(value)
544
544
  unless value
545
- notifier&.notify("Invalid date value: #{value}")
545
+ notifier&.notify("Invalid date value for W3CDTF encoding.", context: {value: value})
546
546
  return
547
547
  end
548
548
  super.gsub("-00", "")
@@ -10,9 +10,9 @@ module CocinaDisplay
10
10
 
11
11
  # Initialize the File with Cocina file data.
12
12
  # @param cocina [Hash] Cocina structured data for a single file
13
- # @param druid [String, nil] DRUID of the object this file belongs to
13
+ # @param druid [String] DRUID (without "druid:" prefix) of the object this file belongs to
14
14
  # @note Staging objects can't infer their DRUID and need it passed in explicitly.
15
- def initialize(cocina, base_url: "https://stacks.stanford.edu", druid: nil)
15
+ def initialize(cocina, druid:, base_url: "https://stacks.stanford.edu")
16
16
  @cocina = cocina
17
17
  @base_url = base_url
18
18
  @druid = druid
@@ -92,42 +92,24 @@ module CocinaDisplay
92
92
  # @return [String, nil]
93
93
  # @example "ts786ny5936%2FPC0170_s1_E_0204"
94
94
  def iiif_id
95
- ERB::Util.url_encode(file_id.delete_suffix(".jp2")) if file_id.present? && jp2_image?
95
+ ERB::Util.url_encode(file_id.delete_suffix(".jp2")) if jp2_image?
96
96
  end
97
97
 
98
98
  # Generate a download URL for this file from stacks.
99
- # @return [String, nil]
99
+ # @return [String]
100
100
  def download_url
101
- return unless file_id.present?
102
-
103
- "#{base_url}/file/druid:#{file_id}"
101
+ "#{base_url}/file/druid:#{druid}/#{ERB::Util.url_encode(filename)}"
104
102
  end
105
103
 
106
104
  private
107
105
 
108
- # External identifier for the file, minus the URL prefix.
109
- # @return [String, nil]
110
- # @note Staging and production formats differ.
111
- # @example production
112
- # "fn851zf9475-fn851zf9475_1/fn851zf9475_00_0001.jp2"
113
- # @example staging
114
- # "ddbd323d-0dd9-4f14-ba72-336c2bccfb29"
115
- def external_id
116
- cocina["externalIdentifier"]&.delete_prefix("https://cocina.sul.stanford.edu/file/")
117
- end
118
-
119
- # The DRUID of the object this file belongs to.
120
- # @note Staging objects can't infer this from the externalIdentifier.
121
- # @return [String, nil]
122
- def druid
123
- @druid || external_id.split("-").first if external_id.present?
124
- end
106
+ attr_reader :druid
125
107
 
126
108
  # Combination of the DRUID and filename to uniquely identify the file.
127
- # @return [String, nil]
109
+ # @return [String]
128
110
  # @example "ts786ny5936/PC0170_s1_E_0204.jp2"
129
111
  def file_id
130
- "#{druid}/#{filename}" if druid.present? && filename.present?
112
+ "#{druid}/#{filename}"
131
113
  end
132
114
  end
133
115
  end
@@ -10,9 +10,9 @@ module CocinaDisplay
10
10
 
11
11
  # Initialize the FileSet with Cocina structural data.
12
12
  # @param cocina [Hash] Cocina structured data for a single FileSet
13
+ # @param druid [String] DRUID (without "druid:" prefix) of the object this fileset belongs to
13
14
  # @param base_url [String] URL to Stacks environment that will serve this fileset
14
- # @param druid [String, nil] DRUID of the object this fileset belongs to
15
- def initialize(cocina, base_url: "https://stacks.stanford.edu", druid: nil)
15
+ def initialize(cocina, druid:, base_url: "https://stacks.stanford.edu")
16
16
  @cocina = cocina
17
17
  @base_url = base_url
18
18
  @druid = druid
@@ -2,5 +2,5 @@
2
2
 
3
3
  # :nodoc:
4
4
  module CocinaDisplay
5
- VERSION = "2.2.0" # :nodoc:
5
+ VERSION = "2.3.1" # :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: 2.2.0
4
+ version: 2.3.1
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-04-20 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: janeway-jsonpath
@@ -247,6 +247,7 @@ files:
247
247
  - lib/cocina_display/concerns.rb
248
248
  - lib/cocina_display/concerns/accesses.rb
249
249
  - lib/cocina_display/concerns/contributors.rb
250
+ - lib/cocina_display/concerns/druid.rb
250
251
  - lib/cocina_display/concerns/events.rb
251
252
  - lib/cocina_display/concerns/forms.rb
252
253
  - lib/cocina_display/concerns/geospatial.rb
@@ -319,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
319
320
  - !ruby/object:Gem::Version
320
321
  version: '0'
321
322
  requirements: []
322
- rubygems_version: 4.0.7
323
+ rubygems_version: 3.6.2
323
324
  specification_version: 4
324
325
  summary: Helpers for rendering Cocina metadata
325
326
  test_files: []