pennmarc 1.3.0 → 1.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: 6f422c1bb424ebc17da2ba97c65d4e248b6704be27a6f0a5fbc6d871e17c995e
4
- data.tar.gz: cdf55d046c6ea17d28393c1d9b1b3bf8803d6435a53db34d3e824494d09f7b4c
3
+ metadata.gz: ce41a1f1d20b337d09c9efe7864702f2991fea918aadfaf2094e9a87c1291e47
4
+ data.tar.gz: 1b65ac76d70e6e9e6b9bf5c60d7bd9cfa3b352a2292486fb7e1668662bf81d9d
5
5
  SHA512:
6
- metadata.gz: c166a340a11acbabb7fed4b5ae05f20490e41d00783e03032516bcd5ef6bda4db764160379a5d617bbcee3d8adbc067a6288e68d3e2de9fdbb94b4468f1971a1
7
- data.tar.gz: 50dbc268e26a309062d811b336566ea61c5062725af13c14482ab31a8f91bb2ed2fa5b1f1d2b4c5e408b6104da6a871482778775a359d90396263c0548a193cc
6
+ metadata.gz: 6c094891accf90519201927873b4e711b649efee1ab191118d541b9a733ecb573b1c0719306c1a958056f461947279312bed0b4950438bf23c91c437b7c251e7
7
+ data.tar.gz: c5578566958775705e86f5be697558468a061e089a361ab1629fa4aaa45758d1fb56970c6651a0bcbd5539c71e6802c61bc2b88b1ade7953ba06a395e2f9d442
@@ -85,6 +85,36 @@ module PennMARC
85
85
  creators.to_h { |h| [h[:show], h[:facet]] }
86
86
  end
87
87
 
88
+ # Show more credited authors - both 100 field and 700 entries where the relator term is aut
89
+ # @param record [MARC::Record]
90
+ # @return [Array<String>] array of author/creator values for display
91
+ def extended_show(record, relator_map: Mappers.relator)
92
+ fields = record.fields(%w[100 700])
93
+ fields.filter_map { |field|
94
+ # for 700 entries, only include ones with relator code of aut
95
+ next if (field.tag == '700') && field['4']&.downcase != 'aut'
96
+
97
+ parse_show_value(field, relator_map: relator_map)
98
+ }.uniq
99
+ end
100
+
101
+ # Hash with extended creators show values as the fields and the corresponding facet as the values.
102
+ # Only include 100, and 700 with relator of aut
103
+ # @param record [MARC::Record]
104
+ # @param relator_map [Hash]
105
+ # @return [Hash]
106
+ def extended_show_facet_map(record, relator_map: Mappers.relator)
107
+ creators = record.fields(%w[100 700]).filter_map do |field|
108
+ # for 700 entries, only include ones with relator code of aut
109
+ next if (field.tag == '700') && field['4']&.downcase != 'aut'
110
+
111
+ show = parse_show_value(field, relator_map: relator_map)
112
+ facet = parse_facet_value(field, FACET_SOURCE_MAP[field.tag.to_i].chars)
113
+ { show: show, facet: facet }
114
+ end
115
+ creators.to_h { |h| [h[:show], h[:facet]] }
116
+ end
117
+
88
118
  # Returns the list of authors with name (subfield $a) only
89
119
  # @param record [MARC::Record]
90
120
  # @param main_tags_only [Boolean] only use TAGS; otherwise use both TAGS and CONTRIBUTOR_TAGS
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PennMARC
4
- VERSION = '1.3.0'
4
+ VERSION = '1.3.1'
5
5
  end
@@ -93,6 +93,52 @@ describe 'PennMARC::Creator' do
93
93
  end
94
94
  end
95
95
 
96
+ describe '.extended_show' do
97
+ let(:record) { marc_record fields: fields }
98
+
99
+ context 'with a single author record' do
100
+ let(:fields) do
101
+ [marc_field(tag: '100', subfields: { a: 'Surname, Name', '0': 'http://cool.uri/12345', d: '1900-2000',
102
+ e: 'author.', '4': 'http://cool.uri/vocabulary/relators/aut' }),
103
+ marc_field(tag: '880', subfields: { a: 'Surname, Alternative', '6': '100' })]
104
+ end
105
+
106
+ it 'returns single author values with no URIs anywhere (the same as show)' do
107
+ values = helper.extended_show(record)
108
+ expect(values).to contain_exactly 'Surname, Name 1900-2000, author.'
109
+ expect(values.join.downcase).not_to include 'http'
110
+ end
111
+ end
112
+
113
+ context 'with author records in 100 and 700' do
114
+ let(:fields) do
115
+ [marc_field(tag: '100', subfields: { a: 'Surname, Name', '0': 'http://cool.uri/12345', d: '1900-2000',
116
+ e: 'author.', '4': 'http://cool.uri/vocabulary/relators/aut' }),
117
+ marc_field(tag: '700', subfields: { a: 'Surname, Alternative', e: 'author', '6': '100', '4': 'aut' }),
118
+ marc_field(tag: '700', subfields: { a: 'Surname, Not Included', '6': '100', '4': 'edt' })]
119
+ end
120
+
121
+ it 'returns two authors' do
122
+ values = helper.extended_show(record)
123
+ expect(values).to contain_exactly 'Surname, Name 1900-2000, author.', 'Surname, Alternative, Author.'
124
+ expect(values.join.downcase).not_to include 'http'
125
+ end
126
+ end
127
+
128
+ context 'with no 100 or 700 fields' do
129
+ let(:fields) do
130
+ [marc_field(tag: '110', subfields: { a: 'Group of People', b: 'Annual Meeting', '4': 'aut' }),
131
+ marc_field(tag: '880', subfields: { '6': '110', a: 'Alt. Group Name', b: 'Alt. Annual Meeting' })]
132
+ end
133
+
134
+ it 'returns empty' do
135
+ values = helper.extended_show(record, relator_map: mapping)
136
+ expect(values).to be_empty
137
+ expect(values.join.downcase).not_to include 'http'
138
+ end
139
+ end
140
+ end
141
+
96
142
  describe '.authors_list' do
97
143
  let(:record) { marc_record fields: fields }
98
144
 
@@ -198,6 +244,26 @@ describe 'PennMARC::Creator' do
198
244
  end
199
245
  end
200
246
 
247
+ describe '.extended_show_facet_map' do
248
+ let(:record) do
249
+ marc_record fields: [
250
+ marc_field(tag: '100', subfields: { a: 'Surname, Name', '0': 'http://cool.uri/12345', d: '1900-2000',
251
+ e: 'author.', '4': 'http://cool.uri/vocabulary/relators/aut' }),
252
+ marc_field(tag: '700', subfields: { a: 'Group of People', b: 'Annual Meeting', '4': 'aut' }),
253
+ marc_field(tag: '700', subfields: { a: 'Second Group of People', b: 'Meeting', '4': 'aut' }),
254
+ marc_field(tag: '700', subfields: { a: 'Ignore (not author)', '4': 'edt' }),
255
+ marc_field(tag: '880', subfields: { a: 'Ignore', '6': '100' })
256
+ ]
257
+ end
258
+
259
+ it 'returns expected hash' do
260
+ values = helper.extended_show_facet_map(record, relator_map: mapping)
261
+ expect(values).to eq({ 'Surname, Name 1900-2000, author.' => 'Surname, Name 1900-2000',
262
+ 'Group of People Annual Meeting, Author.' => 'Group of People Annual Meeting',
263
+ 'Second Group of People Meeting, Author.' => 'Second Group of People Meeting' })
264
+ end
265
+ end
266
+
201
267
  describe '.show_aux' do
202
268
  let(:record) { marc_record fields: fields }
203
269
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pennmarc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Kanning
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2025-08-15 00:00:00.000000000 Z
15
+ date: 2025-08-21 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport