pennmarc 1.0.23 → 1.0.25

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: 7c906223a9bcdb4ba4792ac50462b8c57e41e71fa1e83cd8e63018d360ebfe0a
4
- data.tar.gz: 5d1a420e07734370c95ab1f83d3c519a1d75a7faaa807f1d3ee436808779c586
3
+ metadata.gz: 8b540ecd84333f097b50a3682732229854b188fcde76921eb0ec184622a690dd
4
+ data.tar.gz: 9203fadee45b9ad65ec20880a1acbc23356000b748d32d07428ec093590cd55a
5
5
  SHA512:
6
- metadata.gz: 32e47c254c1a2bb78e861003c864bdbc22833439cff22ebe00148df081c74fed85f60e2f743b5ea65065e5db576e3a304710b1a68b2cdc1e08a1a5f7808e5fc3
7
- data.tar.gz: 6051840a95afdcb41640abf2c42ce699deddc93970c5d117cb445474d4f5998996ee05651ec1e59da3e45886e00f6c058b881b1bf9103de92deb5cf6d868ce80
6
+ metadata.gz: 6770815e8f5f828c15451fc71c04dbef6a131203e8c58d721c063b15f218d5814a71b37fd6c4f088a9c7164d5d989ff6933abc820094068921f218c937a87410
7
+ data.tar.gz: 94eee63c29ae06151816a532a5afb7db1f27490de798651c909dc07fd0f33de1b4a1ee26057b6e3a8abc5d15c54d09709df8942e6e21ad828c1296fe3191725e
@@ -12,6 +12,7 @@ module PennMARC
12
12
  PHYS_INVENTORY_TAG = 'hld'
13
13
  ELEC_INVENTORY_TAG = 'prt'
14
14
  ITEM_TAG = 'itm'
15
+ RELATED_RECORD_TAG = 'rel'
15
16
 
16
17
  # Subfields for HLD tags
17
18
  # Follow MARC 852 spec: https://www.loc.gov/marc/holdings/hd852.html, but names are translated into Alma parlance
@@ -5,14 +5,13 @@ module PennMARC
5
5
  class Access < Helper
6
6
  ONLINE = 'Online'
7
7
  AT_THE_LIBRARY = 'At the library'
8
+ RESOURCE_LINK_BASE_URL = 'hdl.library.upenn.edu'
8
9
 
9
10
  class << self
10
11
  # Based on enhanced metadata fields added by Alma publishing process or API, determine if the record has
11
12
  # electronic access or has physical holdings, and is therefore "Online" or "At the library". If a record is "At
12
13
  # the library", but has a link to a finding aid in the 856 field (matching certain criteria), also add 'Online' as
13
14
  # an access method.
14
- # @todo What if none of these criteria match? Should we include "At the library" by default? Records with no value
15
- # in this field would be lost if the user selects a facet value.
16
15
  # @param [MARC::Record] record
17
16
  # @return [Array]
18
17
  def facet(record)
@@ -24,7 +23,7 @@ module PennMARC
24
23
  return values if values.size == 2 # return early if all values are already present
25
24
 
26
25
  # only check if ONLINE isn't already there
27
- values << ONLINE if values.exclude?(ONLINE) && finding_aid_linkage?(record)
26
+ values << ONLINE if values.exclude?(ONLINE) && resource_link?(record)
28
27
  values.uniq
29
28
  end
30
29
 
@@ -44,20 +43,23 @@ module PennMARC
44
43
  field.tag.in? [Enriched::Pub::PHYS_INVENTORY_TAG, Enriched::Api::PHYS_INVENTORY_TAG]
45
44
  end
46
45
 
47
- # Check if a record contains an 856 entry for an online finding aid, meeting these criteria:
46
+ # Check if a record contains an 856 entry with a Penn Handle server link meeting these criteria:
48
47
  # 1. Indicator 1 is 4 (HTTP resource)
49
48
  # 2. Indicator 2 is NOT 2 (indicating the linkage is to a "related" thing)
50
49
  # 3. The URL specified in subfield u (URI) is a Penn Handle link
50
+ # 4. The subfield z does NOT include the string 'Finding aid'
51
51
  # See: https://www.loc.gov/marc/bibliographic/bd856.html
52
+ # @note Some electronic records do not have Portfolios in Alma, so we rely upon the Resource Link in the 856 to
53
+ # get these records included in the Online category.
52
54
  # @param [MARC::Record] record
53
55
  # @return [Boolean]
54
- def finding_aid_linkage?(record)
56
+ def resource_link?(record)
55
57
  record.fields('856').filter_map do |field|
56
58
  next if field.indicator2 == '2' || field.indicator1 != '4'
57
59
 
58
60
  subz = subfield_values(field, 'z')
59
61
  subfield_values(field, 'u').filter_map do |value|
60
- return true if subz.include?('Finding aid') && value.include?('hdl.library.upenn.edu')
62
+ return true if subz.exclude?('Finding aid') && value.include?(RESOURCE_LINK_BASE_URL)
61
63
  end
62
64
  end
63
65
  false
@@ -21,6 +21,12 @@ module PennMARC
21
21
 
22
22
  CONTRIBUTOR_TAGS = %w[700 710].freeze
23
23
 
24
+ FACET_SOURCE_MAP = {
25
+ 100 => 'abcdjq', 110 => 'abcdjq', 111 => 'abcen',
26
+ 700 => 'abcdjq', 710 => 'abcdjq', 711 => 'abcen',
27
+ 800 => 'abcdjq', 810 => 'abcdjq', 811 => 'abcen'
28
+ }.freeze
29
+
24
30
  # Author/Creator search field. Includes all subfield values (even ǂ0 URIs) from
25
31
  # {https://www.oclc.org/bibformats/en/1xx/100.html 100 Main Entry--Personal Name} and
26
32
  # {https://www.oclc.org/bibformats/en/1xx/110.html 110 Main Entry--Corporate Name}. Maps any relator codes found
@@ -51,19 +57,33 @@ module PennMARC
51
57
  end
52
58
 
53
59
  # Retrieve creator values for display from fields {https://www.loc.gov/marc/bibliographic/bd100.html 100}
54
- # and {https://www.loc.gov/marc/bibliographic/bd110.html 110} and their linked alternates. Appends any encoded
55
- # relationships found in $4. If there are no valid encoded relationships, uses the value found in $e.
60
+ # and {https://www.loc.gov/marc/bibliographic/bd110.html 110} and their linked alternates. First, joins subfields
61
+ # other than $0, $1, $4, $6, $8, $e, and w. Then, appends any encoded relators found in $4.
62
+ # If there are no valid encoded relators, uses the value found in $e.
56
63
  # @param [MARC::Record] record
57
64
  # @return [Array<String>] array of author/creator values for display
58
65
  def show(record, relator_map: Mappers.relator)
59
66
  fields = record.fields(TAGS)
60
67
  fields += record.fields('880').select { |field| subfield_value?(field, '6', /^(#{TAGS.join('|')})/) }
61
68
  fields.filter_map { |field|
62
- creator = join_subfields(field, &subfield_not_in?(%w[0 1 4 6 8 e w]))
63
- append_relator(field: field, joined_subfields: creator, relator_term_sf: 'e', relator_map: relator_map)
69
+ parse_show_value(field, relator_map: relator_map)
64
70
  }.uniq
65
71
  end
66
72
 
73
+ # Hash with main creator show values as the fields and the corresponding facet as the values.
74
+ # Does not include linked 880s.
75
+ # @param [MARC::Record] record
76
+ # @param [Hash] relator_map
77
+ # @return [Hash]
78
+ def show_facet_map(record, relator_map: Mappers.relator)
79
+ creators = record.fields(TAGS).filter_map do |field|
80
+ show = parse_show_value(field, relator_map: relator_map)
81
+ facet = parse_facet_value(field, FACET_SOURCE_MAP[field.tag.to_i].chars)
82
+ { show: show, facet: facet }
83
+ end
84
+ creators.to_h { |h| [h[:show], h[:facet]] }
85
+ end
86
+
67
87
  # All author/creator values for display (like #show, but multivalued?) - no 880 linkage
68
88
  # Performs additional normalization of author names
69
89
  # @note ported from get_author_creator_values (indexed as author_creator_a) - shown on results page
@@ -94,14 +114,9 @@ module PennMARC
94
114
  # @param [MARC::Record] record
95
115
  # @return [Array<String>] array of author/creator values for faceting
96
116
  def facet(record)
97
- source_map = {
98
- 100 => 'abcdjq', 110 => 'abcdjq', 111 => 'abcen',
99
- 700 => 'abcdjq', 710 => 'abcdjq', 711 => 'abcen',
100
- 800 => 'abcdjq', 810 => 'abcdjq', 811 => 'abcen'
101
- }
102
- source_map.flat_map { |field_num, subfields|
117
+ FACET_SOURCE_MAP.flat_map { |field_num, subfields|
103
118
  record.fields(field_num.to_s).map do |field|
104
- trim_punctuation(join_subfields(field, &subfield_in?(subfields.chars)))
119
+ parse_facet_value(field, subfields.chars)
105
120
  end
106
121
  }.uniq
107
122
  end
@@ -117,7 +132,11 @@ module PennMARC
117
132
  }.uniq
118
133
  end
119
134
 
120
- # Conference detailed display, intended for record show page.
135
+ # Conference detailed display, intended for record show page. Retrieve conference values for record display from
136
+ # {https://www.loc.gov/marc/bibliographic/bd111.html 111}, {https://www.loc.gov/marc/bibliographic/bd711.html 711}
137
+ # , and their linked 880s. If there is no $i, we join subfield $i we join subfield values other than
138
+ # $0, $4, $5, $6, $8, $e, $j, and $w. to create the conference value. We then join the conference subunit value
139
+ # using subfields $e and $w. We append any relators, preferring those defined in $4 and using $j as a fallback.
121
140
  # @note ported from get_conference_values
122
141
  # @todo what is ǂi for?
123
142
  # @param [MARC::Record] record
@@ -126,15 +145,7 @@ module PennMARC
126
145
  conferences = record.fields(%w[111 711]).filter_map do |field|
127
146
  next unless field.indicator2.in? ['', ' ']
128
147
 
129
- conf = if subfield_undefined? field, 'i'
130
- join_subfields field, &subfield_not_in?(%w[0 4 5 6 8 e j w])
131
- else
132
- ''
133
- end
134
- sub_unit = join_subfields(field, &subfield_in?(%w[e w]))
135
- conf = [conf, sub_unit].compact_blank.join(' ')
136
-
137
- append_relator(field: field, joined_subfields: conf, relator_term_sf: 'j', relator_map: relator_map)
148
+ parse_conference_detail_show_value(field, relator_map: relator_map)
138
149
  end
139
150
  conferences += record.fields('880').filter_map do |field|
140
151
  next unless subfield_value? field, '6', /^(111|711)/
@@ -150,6 +161,24 @@ module PennMARC
150
161
  conferences.uniq
151
162
  end
152
163
 
164
+ # Return hash of detailed conference values mapped to their corresponding facets from fields
165
+ # {https://www.loc.gov/marc/bibliographic/bd111.html 111} and
166
+ # {https://www.loc.gov/marc/bibliographic/bd711.html 711}. Does not include linked 880s.
167
+ # @param [MARC::Record] record
168
+ # @param [Hash] relator_map
169
+ # @return [Hash]
170
+ def conference_detail_show_facet_map(record, relator_map: Mappers.relator)
171
+ conferences = record.fields(%w[111 711]).filter_map do |field|
172
+ next unless field.indicator2.in? ['', ' ']
173
+
174
+ show = parse_conference_detail_show_value(field, relator_map: relator_map)
175
+ facet = parse_facet_value(field, FACET_SOURCE_MAP[field.tag.to_i].chars)
176
+ { show: show, facet: facet }
177
+ end
178
+
179
+ conferences.to_h { |conf| [conf[:show], conf[:facet]] }
180
+ end
181
+
153
182
  # Conference name values for searching
154
183
  # @param [MARC::Record] record
155
184
  # @return [Array<String>]
@@ -264,6 +293,40 @@ module PennMARC
264
293
  before_comma = substring_before(name, ', ')
265
294
  "#{after_comma} #{before_comma}".squish
266
295
  end
296
+
297
+ # Parse creator facet value from given creator field and desired subfields
298
+ # @param [MARC::Field] field
299
+ # @param [Array<String>] subfields
300
+ # @return [String]
301
+ def parse_facet_value(field, subfields)
302
+ trim_punctuation(join_subfields(field, &subfield_in?(subfields)))
303
+ end
304
+
305
+ # Parse creator show value from given main creator fields (100/110).
306
+ # @param [MARC::Field] field
307
+ # @param [Hash] relator_map
308
+ # @return [String]
309
+ def parse_show_value(field, relator_map: Mappers.relator)
310
+ creator = join_subfields(field, &subfield_not_in?(%w[0 1 4 6 8 e w]))
311
+ append_relator(field: field, joined_subfields: creator, relator_term_sf: 'e', relator_map: relator_map)
312
+ end
313
+
314
+ # Parse detailed conference show value from given conference field (111/711). If there is no $i, we join subfield
315
+ # values other than $0, $4, $5, $6, $8, $e, $j, and $w to create conference value. We join subfields $e and $w to
316
+ # determine the subunit value. We append any relators, preferring those defined in $4 and using $j as a fallback.
317
+ # @param [MARC::Field] field
318
+ # @return [String]
319
+ def parse_conference_detail_show_value(field, relator_map: Mappers.relator)
320
+ conf = if subfield_undefined? field, 'i'
321
+ join_subfields field, &subfield_not_in?(%w[0 4 5 6 8 e j w])
322
+ else
323
+ ''
324
+ end
325
+ sub_unit = join_subfields(field, &subfield_in?(%w[e w]))
326
+ conf = [conf, sub_unit].compact_blank.join(' ')
327
+
328
+ append_relator(field: field, joined_subfields: conf, relator_term_sf: 'j', relator_map: relator_map)
329
+ end
267
330
  end
268
331
  end
269
332
  end
@@ -159,6 +159,18 @@ module PennMARC
159
159
  }.uniq
160
160
  end
161
161
 
162
+ # Gets any Host record MMS ID values from an Enriched::Pub::RELATED_RECORD_TAG field added during Alma enrichment.
163
+ # This aids in our handling of "bound with" records.
164
+ # @param [MARC::Record] record
165
+ # @return [Array<String>]
166
+ def host_record_id(record)
167
+ record.fields(Enriched::Pub::RELATED_RECORD_TAG).filter_map { |field|
168
+ next unless subfield_value?(field, 'c', /contains/i)
169
+
170
+ subfield_values field, :w
171
+ }.flatten.uniq
172
+ end
173
+
162
174
  private
163
175
 
164
176
  # Determine if subfield 'a' is an OCLC id.
@@ -18,7 +18,7 @@ module PennMARC
18
18
  # - 2: MeSH
19
19
  # - 4: Source not specified (local?)
20
20
  # - 7: Source specified in ǂ2
21
- SEARCH_SOURCE_INDICATORS = %w[0 1 2 4 7].freeze
21
+ VALID_SOURCE_INDICATORS = %w[0 1 2 4 7].freeze
22
22
 
23
23
  # Tags that serve as sources for Subject facet values
24
24
  DISPLAY_TAGS = %w[600 610 611 630 650 651].freeze
@@ -27,7 +27,7 @@ module PennMARC
27
27
  LOCAL_TAGS = %w[690 691 697].freeze
28
28
 
29
29
  # All Subjects for searching. This includes most subfield content from any field contained in {SEARCH_TAGS} or
30
- # 69X, including any linked 880 fields. Fields must have an indicator2 value in {SEARCH_SOURCE_INDICATORS}.
30
+ # 69X, including any linked 880 fields. Fields must have an indicator2 value in {VALID_SOURCE_INDICATORS}.
31
31
  # @todo this includes subfields that may not be desired like 1 (uri) and 2 (source code) but this might be OK for
32
32
  # a search (non-display) field?
33
33
  # @param [Hash] relator_map
@@ -179,12 +179,18 @@ module PennMARC
179
179
  end
180
180
  end
181
181
 
182
- # Is a field intended for display in a general subject field
182
+ # Is a field intended for display in a general subject field? To be included, the field tag is in either
183
+ # {DISPLAY_TAGS} or {LOCAL_TAGS}, and has an indicator 2 value that is in {VALID_SOURCE_INDICATORS}. If
184
+ # indicator 2 is '7' - indicating "source specified", the specified source must be in our approved source code
185
+ # list.
186
+ # @see Util.valid_subject_genre_source_code?
183
187
  # @param [MARC::DataField] field
184
188
  # @return [Boolean] whether a MARC field is intended for display under general "Subjects"
185
189
  def subject_general_display_field?(field)
186
190
  return false unless field.tag.in?(DISPLAY_TAGS + LOCAL_TAGS) && field.respond_to?(:indicator2)
187
191
 
192
+ return false if field.indicator2.present? && !field.indicator2.in?(VALID_SOURCE_INDICATORS)
193
+
188
194
  return false if field.indicator2 == '7' && !valid_subject_genre_source_code?(field)
189
195
 
190
196
  true
@@ -278,7 +284,7 @@ module PennMARC
278
284
  # @param [MARC::DataField] field
279
285
  # @return [Boolean]
280
286
  def subject_search_field?(field)
281
- return false unless field.respond_to?(:indicator2) && SEARCH_SOURCE_INDICATORS.include?(field.indicator2)
287
+ return false unless field.respond_to?(:indicator2) && VALID_SOURCE_INDICATORS.include?(field.indicator2)
282
288
 
283
289
  tag = if field.tag == '880'
284
290
  subfield_values(field, '6').first
@@ -3,33 +3,36 @@
3
3
  module PennMARC
4
4
  # This helper contains logic for parsing out Title and Title-related fields.
5
5
  class Title < Helper
6
- class << self
7
- # We use these fields when retrieving auxiliary titles in the *search_aux methods:
8
- # {https://www.loc.gov/marc/bibliographic/bd130.html 130},
9
- # {https://www.loc.gov/marc/bibliographic/bd210.html 210},
10
- # {https://www.loc.gov/marc/bibliographic/bd245.html 245},
11
- # {https://www.loc.gov/marc/bibliographic/bd246.html 246},
12
- # {https://www.loc.gov/marc/bibliographic/bd247.html 247},
13
- # {https://www.loc.gov/marc/bibliographic/bd440.html 440},
14
- # {https://www.loc.gov/marc/bibliographic/bd490.html 490},
15
- # {https://www.loc.gov/marc/bibliographic/bd730.html 730},
16
- # {https://www.loc.gov/marc/bibliographic/bd740.html 740},
17
- # {https://www.loc.gov/marc/bibliographic/bd830.html 830},
18
- # {https://www.loc.gov/marc/bibliographic/bd773.html 773},
19
- # {https://www.loc.gov/marc/bibliographic/bd774.html 774},
20
- # {https://www.loc.gov/marc/bibliographic/bd780.html 780},
21
- # {https://www.loc.gov/marc/bibliographic/bd785.html 785},
22
- # {https://www.loc.gov/marc/bibliographic/bd700.html 700},
23
- # {https://www.loc.gov/marc/bibliographic/bd710.html 710},
24
- # {https://www.loc.gov/marc/bibliographic/bd711.html 711},
25
- # {https://www.loc.gov/marc/bibliographic/bd505.html 505}
26
- AUX_TITLE_TAGS = {
27
- main: %w[130 210 240 245 246 247 440 490 730 740 830],
28
- related: %w[773 774 780 785],
29
- entity: %w[700 710 711],
30
- note: %w[505]
31
- }.freeze
6
+ # We use these fields when retrieving auxiliary titles in the *search_aux methods:
7
+ # {https://www.loc.gov/marc/bibliographic/bd130.html 130},
8
+ # {https://www.loc.gov/marc/bibliographic/bd210.html 210},
9
+ # {https://www.loc.gov/marc/bibliographic/bd245.html 245},
10
+ # {https://www.loc.gov/marc/bibliographic/bd246.html 246},
11
+ # {https://www.loc.gov/marc/bibliographic/bd247.html 247},
12
+ # {https://www.loc.gov/marc/bibliographic/bd440.html 440},
13
+ # {https://www.loc.gov/marc/bibliographic/bd490.html 490},
14
+ # {https://www.loc.gov/marc/bibliographic/bd730.html 730},
15
+ # {https://www.loc.gov/marc/bibliographic/bd740.html 740},
16
+ # {https://www.loc.gov/marc/bibliographic/bd830.html 830},
17
+ # {https://www.loc.gov/marc/bibliographic/bd773.html 773},
18
+ # {https://www.loc.gov/marc/bibliographic/bd774.html 774},
19
+ # {https://www.loc.gov/marc/bibliographic/bd780.html 780},
20
+ # {https://www.loc.gov/marc/bibliographic/bd785.html 785},
21
+ # {https://www.loc.gov/marc/bibliographic/bd700.html 700},
22
+ # {https://www.loc.gov/marc/bibliographic/bd710.html 710},
23
+ # {https://www.loc.gov/marc/bibliographic/bd711.html 711},
24
+ # {https://www.loc.gov/marc/bibliographic/bd505.html 505}
25
+ AUX_TITLE_TAGS = {
26
+ main: %w[130 210 240 245 246 247 440 490 730 740 830],
27
+ related: %w[773 774 780 785],
28
+ entity: %w[700 710 711],
29
+ note: %w[505]
30
+ }.freeze
31
+
32
+ # This text is used in Alma to indicate a Bib record is a "Host" record for other bibs (bound-withs)
33
+ HOST_BIB_TITLE = 'Host bibliographic record for boundwith'
32
34
 
35
+ class << self
33
36
  # Main Title Search field. Takes from {https://www.loc.gov/marc/bibliographic/bd245.html 245} and linked 880.
34
37
  # @note Ported from get_title_1_search_values.
35
38
  # @param [MARC::Record] record
@@ -217,6 +220,16 @@ module PennMARC
217
220
  }.uniq
218
221
  end
219
222
 
223
+ # Determine if the record is a "Host" bibliographic record for other bib records ("bound-withs")
224
+ # @param [MARC::Record] record
225
+ # @return [Boolean]
226
+ def host_bib_record?(record)
227
+ record.fields('245').any? do |f|
228
+ title = join_subfields(f, &subfield_in?(%w[a]))
229
+ title.include?(HOST_BIB_TITLE)
230
+ end
231
+ end
232
+
220
233
  private
221
234
 
222
235
  # Create prefix/filing hash for representing a title value with filing characters removed, with special
@@ -547,6 +547,12 @@ dent:
547
547
  - Health Sciences Libraries
548
548
  - Levy Dental Medicine Library
549
549
  display: Levy Dental Medicine Library - Stacks
550
+ dentpcare:
551
+ specific_location: Levy Dental Medicine Library - PCare
552
+ library:
553
+ - Health Sciences Libraries
554
+ - Levy Dental Medicine Library
555
+ display: Levy Dental Medicine Library - PCare
550
556
  dentrare:
551
557
  specific_location: Levy Dental Medicine Library - Rare Books
552
558
  library:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PennMARC
4
- VERSION = '1.0.23'
4
+ VERSION = '1.0.25'
5
5
  end
@@ -69,6 +69,17 @@ describe 'PennMARC::Access' do
69
69
  { z: 'Finding aid', u: 'http://hdl.library.upenn.edu/1017/d/pacscl/UPENN_RBML_MsColl200' }
70
70
  end
71
71
 
72
+ it 'does not include online access' do
73
+ expect(helper.facet(record)).to contain_exactly(PennMARC::Access::AT_THE_LIBRARY)
74
+ end
75
+ end
76
+
77
+ context 'with an 856 describing a resource link' do
78
+ let(:indicators) { { indicator1: '4', indicator2: '1' } }
79
+ let(:location_and_access_subfields) do
80
+ { z: 'Connect to resource', u: 'http://hdl.library.upenn.edu/1234' }
81
+ end
82
+
72
83
  it 'includes online access' do
73
84
  expect(helper.facet(record)).to contain_exactly(PennMARC::Access::ONLINE, PennMARC::Access::AT_THE_LIBRARY)
74
85
  end
@@ -95,6 +95,23 @@ describe 'PennMARC::Creator' do
95
95
  end
96
96
  end
97
97
 
98
+ describe '.show_facet_map' do
99
+ let(:record) do
100
+ marc_record fields: [
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: '110', subfields: { a: 'Group of People', b: 'Annual Meeting', '4': 'aut' }),
104
+ marc_field(tag: '880', subfields: { a: 'Ignore', '6': '100' })
105
+ ]
106
+ end
107
+
108
+ it 'returns expected hash' do
109
+ values = helper.show_facet_map(record, relator_map: mapping)
110
+ expect(values).to eq({ 'Surname, Name 1900-2000, author.' => 'Surname, Name 1900-2000',
111
+ 'Group of People Annual Meeting, Author.' => 'Group of People Annual Meeting' })
112
+ end
113
+ end
114
+
98
115
  describe '.show_aux' do
99
116
  let(:record) { marc_record fields: fields }
100
117
 
@@ -257,6 +274,22 @@ describe 'PennMARC::Creator' do
257
274
  end
258
275
  end
259
276
 
277
+ describe '.conference_detail_show_facet_map' do
278
+ let(:record) do
279
+ marc_record fields: [
280
+ marc_field(tag: '111', subfields: { a: 'Council of Trent', d: '(1545-1563 :', c: 'Trento, Italy)' }),
281
+ marc_field(tag: '711', subfields: { a: 'Code4Lib', n: '(18th :', d: '2024 :', c: 'Ann Arbor, MI)' }),
282
+ marc_field(tag: '880', subfields: { a: 'Alt Ignore', '6': '111' })
283
+ ]
284
+ end
285
+
286
+ it 'returns the expected hash' do
287
+ value = helper.conference_detail_show_facet_map(record)
288
+ expect(value).to eq({ 'Council of Trent (1545-1563 : Trento, Italy)' => 'Council of Trent Trento, Italy)',
289
+ 'Code4Lib (18th : 2024 : Ann Arbor, MI)' => 'Code4Lib (18th : Ann Arbor, MI)' })
290
+ end
291
+ end
292
+
260
293
  describe '.conference_search' do
261
294
  let(:record) do
262
295
  marc_record fields: [
@@ -161,4 +161,18 @@ describe 'PennMARC::Identifier' do
161
161
  '10.1038/sdata.2016.18', '10.18574/9781479842865')
162
162
  end
163
163
  end
164
+
165
+ describe '.host_record_id' do
166
+ let(:record) do
167
+ marc_record fields: [
168
+ marc_field(tag: PennMARC::Enriched::Pub::RELATED_RECORD_TAG, subfields: { w: '123456789', c: 'Contains',
169
+ a: 'Title' }),
170
+ marc_field(tag: PennMARC::Enriched::Pub::RELATED_RECORD_TAG, subfields: { w: '666666666', c: 'Contained In' })
171
+ ]
172
+ end
173
+
174
+ it 'returns only the desired host record MMS ID values' do
175
+ expect(helper.host_record_id(record)).to contain_exactly '123456789'
176
+ end
177
+ end
164
178
  end
@@ -288,6 +288,22 @@ describe 'PennMARC::Subject' do
288
288
  'Early works to 1950.')
289
289
  end
290
290
  end
291
+
292
+ context 'with a mix of allowed and disallowed heading sources' do
293
+ let(:fields) do
294
+ [marc_field(tag: '650', indicator2: '7', subfields: {
295
+ '2': 'fast',
296
+ a: 'Philosophy in motion pictures.',
297
+ '0': 'http://id.loc.gov/authorities/subjects/sh92003501'
298
+ }),
299
+ marc_field(tag: '650', indicator2: '7', subfields: { '2': 'gnd', a: 'Filmästhetik.' }),
300
+ marc_field(tag: '650', indicator2: '6', subfields: { a: 'Cinéma et arts.' })]
301
+ end
302
+
303
+ it 'includes only permitted headings from approved ontologies' do
304
+ expect(values).to contain_exactly 'Philosophy in motion pictures.'
305
+ end
306
+ end
291
307
  end
292
308
 
293
309
  describe '.childrens_show' do
@@ -249,4 +249,24 @@ describe 'PennMARC::Title' do
249
249
  expect(values).not_to include 'Linkage', '247'
250
250
  end
251
251
  end
252
+
253
+ describe '.host_bib_record?' do
254
+ let(:record) { marc_record fields: [marc_field(tag: '245', subfields: subfields)] }
255
+
256
+ context 'with a host record' do
257
+ let(:subfields) { { a: "#{PennMARC::Title::HOST_BIB_TITLE} for 123456789" } }
258
+
259
+ it 'returns true' do
260
+ expect(helper.host_bib_record?(record)).to be true
261
+ end
262
+ end
263
+
264
+ context 'with a non-host record' do
265
+ let(:subfields) { { a: 'Regular record' } }
266
+
267
+ it 'returns false' do
268
+ expect(helper.host_bib_record?(record)).to be false
269
+ end
270
+ end
271
+ end
252
272
  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.0.23
4
+ version: 1.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Kanning
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-06-04 00:00:00.000000000 Z
13
+ date: 2024-06-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport