pennmarc 1.2.21 → 1.2.22
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 +4 -4
- data/lib/pennmarc/helpers/creator.rb +31 -35
- data/lib/pennmarc/version.rb +1 -1
- data/spec/lib/pennmarc/helpers/creator_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5f3095fc6bb6a688539dc03d57678dcfe48a4e50c86e2f304f24c95c2520c3e
|
4
|
+
data.tar.gz: 7549c5774d952dd35062ee36b039e4db6137cfdb90840453752d60b0f817a455
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2aff101e41d22473fa7da490ab347c04487ad6a0ae2e7a35cd91dfb8a4ab7251d397b0c5dcbc6ab64920821407d357cbd7c5673b46dfd7ca00f02c173eff03f2
|
7
|
+
data.tar.gz: e21ff016f09df155db0eaee8aec6132a86696c8609bf65ffc8cad2a246dff29cdfdb44d49d9b574d33cd42876eeecd70c973a86610d52b39710953001b790951
|
@@ -1,25 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module PennMARC
|
4
|
-
# Do Creator & Author field processing. Main methods pull from 110 and 111 fields.
|
5
|
-
# return data structures intended for generating "search" links, but some of the split subfield parsing remains from
|
6
|
-
# ported methods in case we need to replicate that functionality.
|
4
|
+
# Do Creator & Author field processing. Main methods pull from 110 and 111 fields.
|
7
5
|
# @todo can there ever be multiple 100 fields?
|
8
6
|
# can ǂe and ǂ4 both be used at the same time? seems to result in duplicate values
|
9
7
|
class Creator < Helper
|
10
8
|
# Main tags for Author/Creator information
|
11
9
|
TAGS = %w[100 110].freeze
|
12
10
|
|
11
|
+
# For creator fields intended for display, these subfields are ignored
|
12
|
+
DISPLAY_EXCLUDED_SUBFIELDS = %w[a 0 1 4 5 6 8 t].freeze
|
13
|
+
|
14
|
+
# For creator fields intended for searching, these subfields are ignored
|
15
|
+
SEARCH_EXCLUDED_SUBFIELDS = %w[a 1 4 5 6 8 t].freeze
|
16
|
+
|
13
17
|
# Aux tags for Author/Creator information, for use in search_aux method
|
14
18
|
AUX_TAGS = %w[100 110 111 400 410 411 700 710 711 800 810 811].freeze
|
15
19
|
|
16
20
|
CONFERENCE_SEARCH_TAGS = %w[111 711 811].freeze
|
17
21
|
CORPORATE_SEARCH_TAGS = %w[110 710 810].freeze
|
18
22
|
|
19
|
-
# subfields NOT to join when combining raw subfield values
|
20
|
-
NAME_EXCLUDED_SUBFIELDS = %w[a 1 4 5 6 8 t].freeze
|
21
|
-
|
22
23
|
CONTRIBUTOR_TAGS = %w[700 710].freeze
|
24
|
+
CONTRIBUTOR_DISPLAY_SUBFIELDS = %w[a b c d j q u 3].freeze
|
23
25
|
|
24
26
|
FACET_SOURCE_MAP = {
|
25
27
|
100 => 'abcdjq', 110 => 'abcdjq', 111 => 'abcen',
|
@@ -28,14 +30,12 @@ module PennMARC
|
|
28
30
|
}.freeze
|
29
31
|
|
30
32
|
class << self
|
31
|
-
# Author/Creator search field
|
33
|
+
# Author/Creator search field, from tags
|
32
34
|
# {https://www.oclc.org/bibformats/en/1xx/100.html 100 Main Entry--Personal Name} and
|
33
|
-
# {https://www.oclc.org/bibformats/en/1xx/110.html 110 Main Entry--Corporate Name}.
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
# @todo shouldn't indicator1 tell us the order of the name? do we not trust the indicator?
|
38
|
-
# @note ported from get_author_creator_1_search_values
|
35
|
+
# {https://www.oclc.org/bibformats/en/1xx/110.html 110 Main Entry--Corporate Name}. Includes subfield values
|
36
|
+
# except for those in the {DISPLAY_EXCLUDED_SUBFIELDS} constant. Maps any relator codes found in ǂ4. To better
|
37
|
+
# handle name searches, returns names as both "First Last" and "Last, First" if a comma is found in ǂa. Also
|
38
|
+
# indexes any linked values in the 880.
|
39
39
|
# @param record [MARC::Record]
|
40
40
|
# @param relator_map [Hash]
|
41
41
|
# @return [Array<String>] array of author/creator values for indexing
|
@@ -49,18 +49,18 @@ module PennMARC
|
|
49
49
|
# {https://www.loc.gov/marc/bibliographic/bd700.html MARC 700},
|
50
50
|
# {https://www.loc.gov/marc/bibliographic/bd710.html MARC 710},
|
51
51
|
# and {https://www.loc.gov/marc/bibliographic/bd711.html MARC 711}. The 800, 810 and 8111 tags are similar in
|
52
|
-
# theme to the 7xx fields but apply to serial records.
|
53
|
-
#
|
52
|
+
# theme to the 7xx fields but apply to serial records. Includes all subfield values except those in the
|
53
|
+
# {SEARCH_EXCLUDED_SUBFIELDS} constant.
|
54
54
|
# @param record [MARC::Record]
|
55
55
|
# @return [Array<String>] array of extended author/creator values for indexing
|
56
56
|
def search_aux(record, relator_map: Mappers.relator)
|
57
57
|
name_search_values record: record, tags: AUX_TAGS, relator_map: relator_map
|
58
58
|
end
|
59
59
|
|
60
|
-
# Retrieve creator values for display from fields {https://www.loc.gov/marc/bibliographic/bd100.html 100}
|
61
|
-
#
|
62
|
-
#
|
63
|
-
# If there are no valid encoded relators, uses the value found in $e.
|
60
|
+
# Retrieve creator values for display from fields {https://www.loc.gov/marc/bibliographic/bd100.html 100},
|
61
|
+
# {https://www.loc.gov/marc/bibliographic/bd110.html 110} and their linked alternates. First, join each subfield
|
62
|
+
# value except for those defined in the {DISPLAY_EXCLUDED_SUBFIELDS} constant. Then, appends any encoded relators
|
63
|
+
# found in $4. If there are no valid encoded relators, uses the value found in $e.
|
64
64
|
# @param record [MARC::Record]
|
65
65
|
# @return [Array<String>] array of author/creator values for display
|
66
66
|
def show(record, relator_map: Mappers.relator)
|
@@ -91,13 +91,7 @@ module PennMARC
|
|
91
91
|
# @param first_initial_only [Boolean] only use the first initial instead of first name
|
92
92
|
# @return [Array<String>] names of the authors
|
93
93
|
def authors_list(record, main_tags_only: false, first_initial_only: false)
|
94
|
-
|
95
|
-
TAGS
|
96
|
-
else
|
97
|
-
TAGS + CONTRIBUTOR_TAGS
|
98
|
-
end
|
99
|
-
|
100
|
-
fields = record.fields(tags)
|
94
|
+
fields = record.fields(main_tags_only ? TAGS : TAGS + CONTRIBUTOR_TAGS)
|
101
95
|
fields.filter_map { |field|
|
102
96
|
if field['a'].present?
|
103
97
|
name = trim_trailing(:comma, field['a'])
|
@@ -164,7 +158,7 @@ module PennMARC
|
|
164
158
|
}.uniq
|
165
159
|
end
|
166
160
|
|
167
|
-
# Author/Creator sort. Does not map
|
161
|
+
# Author/Creator sort. Does not map or include any relator codes.
|
168
162
|
# @todo This includes any URI from ǂ0 which could help to disambiguate in sorts, but ǂ1 is excluded...
|
169
163
|
# @note ported from get_author_creator_sort_values
|
170
164
|
# @param record [MARC::Record]
|
@@ -177,8 +171,6 @@ module PennMARC
|
|
177
171
|
# Author/Creator for faceting. Grabs values from a plethora of fields, joins defined subfields, then trims some
|
178
172
|
# punctuation (@see Util.trim_punctuation)
|
179
173
|
# @todo should trim_punctuation apply to each subfield value, or the joined values? i think the joined values
|
180
|
-
# @note ported from author_creator_xfacet2_input - is this the best choice? check the copyField declarations -
|
181
|
-
# franklin uses author_creator_f
|
182
174
|
# @param record [MARC::Record]
|
183
175
|
# @return [Array<String>] array of author/creator values for faceting
|
184
176
|
def facet(record)
|
@@ -267,7 +259,7 @@ module PennMARC
|
|
267
259
|
|
268
260
|
# Retrieve contributor values for display from fields {https://www.oclc.org/bibformats/en/7xx/700.html 700}
|
269
261
|
# and {https://www.oclc.org/bibformats/en/7xx/710.html 710} and their linked alternates. Joins subfields
|
270
|
-
#
|
262
|
+
# defined in {CONTRIBUTOR_DISPLAY_SUBFIELDS}, then appends resulting string with any encoded relationships
|
271
263
|
# found in $4. If there are no valid encoded relationships, uses the value found in $e.
|
272
264
|
# @note legacy version returns array of hash objects including data for display link
|
273
265
|
# @param record [MARC::Record]
|
@@ -281,7 +273,7 @@ module PennMARC
|
|
281
273
|
if vernacular
|
282
274
|
fields += record.fields('880').select { |f| subfield_value?(f, '6', /^(#{CONTRIBUTOR_TAGS.join('|')})/) }
|
283
275
|
end
|
284
|
-
sf = name_only ? %w[a] :
|
276
|
+
sf = name_only ? %w[a] : CONTRIBUTOR_DISPLAY_SUBFIELDS
|
285
277
|
fields.filter_map { |field|
|
286
278
|
next if indicator_2_options.exclude?(field.indicator2) && field.tag.in?(CONTRIBUTOR_TAGS)
|
287
279
|
next if subfield_defined? field, 'i'
|
@@ -299,11 +291,11 @@ module PennMARC
|
|
299
291
|
# @return [Array<String>] name values from given tags
|
300
292
|
def name_search_values(record:, tags:, relator_map:)
|
301
293
|
acc = record.fields(tags).filter_map do |field|
|
302
|
-
name_from_main_entry field, relator_map, should_convert_name_order: false
|
294
|
+
name_from_main_entry field, relator_map, should_convert_name_order: false, for_display: false
|
303
295
|
end
|
304
296
|
|
305
297
|
acc += record.fields(tags).filter_map do |field|
|
306
|
-
name_from_main_entry field, relator_map, should_convert_name_order: true
|
298
|
+
name_from_main_entry field, relator_map, should_convert_name_order: true, for_display: false
|
307
299
|
end
|
308
300
|
|
309
301
|
acc += record.fields(['880']).filter_map do |field|
|
@@ -323,15 +315,17 @@ module PennMARC
|
|
323
315
|
# @param field [MARC::Field]
|
324
316
|
# @param mapping [Hash]
|
325
317
|
# @param should_convert_name_order [Boolean]
|
318
|
+
# @param for_display [Boolean]
|
326
319
|
# @return [String] joined subfield values for value from field
|
327
|
-
def name_from_main_entry(field, mapping, should_convert_name_order: false)
|
320
|
+
def name_from_main_entry(field, mapping, should_convert_name_order: false, for_display: true)
|
321
|
+
subfield_exclude_spec = for_display ? DISPLAY_EXCLUDED_SUBFIELDS : SEARCH_EXCLUDED_SUBFIELDS
|
328
322
|
relator_term_sf = relator_term_subfield(field)
|
329
323
|
name = field.filter_map { |sf|
|
330
324
|
if sf.code == 'a'
|
331
325
|
should_convert_name_order ? convert_name_order(sf.value) : trim_trailing(:comma, sf.value)
|
332
326
|
elsif sf.code == relator_term_sf
|
333
327
|
next
|
334
|
-
elsif
|
328
|
+
elsif subfield_exclude_spec.exclude?(sf.code)
|
335
329
|
sf.value
|
336
330
|
end
|
337
331
|
}.join(' ')
|
@@ -341,6 +335,8 @@ module PennMARC
|
|
341
335
|
relator_term_sf: relator_term_sf,
|
342
336
|
relator_map: mapping)
|
343
337
|
|
338
|
+
return name_and_relator unless for_display
|
339
|
+
|
344
340
|
name_and_relator + (%w[. -].member?(name_and_relator.last) ? '' : '.')
|
345
341
|
end
|
346
342
|
|
data/lib/pennmarc/version.rb
CHANGED
@@ -52,8 +52,8 @@ describe 'PennMARC::Creator' do
|
|
52
52
|
it 'contains the expected search_aux field values for a single author work' do
|
53
53
|
expect(helper.search_aux(record, relator_map: mapping)).to contain_exactly(
|
54
54
|
'Author Fancy active 24th century AD, Author.',
|
55
|
-
'Author, Added
|
56
|
-
'Added Author
|
55
|
+
'Author, Added',
|
56
|
+
'Added Author',
|
57
57
|
'Alt Author Alt Fanciness',
|
58
58
|
'Alt Added Author'
|
59
59
|
)
|
@@ -328,7 +328,7 @@ describe 'PennMARC::Creator' do
|
|
328
328
|
describe '.conference_show' do
|
329
329
|
let(:record) do
|
330
330
|
marc_record fields: [
|
331
|
-
marc_field(tag: '111', subfields: { a: 'MARC History Symposium', '4': 'aut' }),
|
331
|
+
marc_field(tag: '111', subfields: { a: 'MARC History Symposium', '0': 'http://cool.uri/12345', '4': 'aut' }),
|
332
332
|
marc_field(tag: '880', subfields: { a: 'Alt. MARC History Symposium', '6': '111' })
|
333
333
|
]
|
334
334
|
end
|
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.2.
|
4
|
+
version: 1.2.22
|
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-06-
|
15
|
+
date: 2025-06-26 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activesupport
|