pennmarc 1.0.30 → 1.0.32
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/Gemfile +0 -1
- data/Gemfile.lock +0 -2
- data/lib/pennmarc/heading_control.rb +9 -5
- data/lib/pennmarc/helpers/access.rb +4 -4
- data/lib/pennmarc/helpers/citation.rb +2 -2
- data/lib/pennmarc/helpers/classification.rb +10 -7
- data/lib/pennmarc/helpers/creator.rb +27 -25
- data/lib/pennmarc/helpers/database.rb +8 -8
- data/lib/pennmarc/helpers/date.rb +5 -5
- data/lib/pennmarc/helpers/edition.rb +7 -7
- data/lib/pennmarc/helpers/format.rb +36 -40
- data/lib/pennmarc/helpers/genre.rb +5 -5
- data/lib/pennmarc/helpers/identifier.rb +18 -18
- data/lib/pennmarc/helpers/inventory.rb +7 -7
- data/lib/pennmarc/helpers/inventory_entry/base.rb +2 -2
- data/lib/pennmarc/helpers/language.rb +4 -4
- data/lib/pennmarc/helpers/link.rb +6 -6
- data/lib/pennmarc/helpers/location.rb +14 -14
- data/lib/pennmarc/helpers/note.rb +2 -2
- data/lib/pennmarc/helpers/production.rb +7 -6
- data/lib/pennmarc/helpers/relation.rb +14 -14
- data/lib/pennmarc/helpers/series.rb +19 -19
- data/lib/pennmarc/helpers/subject.rb +28 -28
- data/lib/pennmarc/helpers/title.rb +18 -18
- data/lib/pennmarc/mappings/headings_override.yml +12 -8
- data/lib/pennmarc/parser.rb +5 -5
- data/lib/pennmarc/test/marc_helpers.rb +11 -11
- data/lib/pennmarc/util.rb +18 -18
- data/lib/pennmarc/version.rb +1 -1
- data/pennmarc.gemspec +0 -1
- data/spec/lib/pennmarc/heading_control_spec.rb +17 -10
- data/spec/lib/pennmarc/helpers/creator_spec.rb +15 -12
- data/spec/lib/pennmarc/marc_util_spec.rb +12 -0
- data/spec/support/fixture_helpers.rb +1 -1
- metadata +2 -16
@@ -8,7 +8,7 @@ module PennMARC
|
|
8
8
|
# Genre values for searching. We're less picky about what is included here to enable discovery via any included
|
9
9
|
# 655 data.
|
10
10
|
#
|
11
|
-
# @param [MARC::Record]
|
11
|
+
# @param record [MARC::Record]
|
12
12
|
# @return [Array<String>] array of genre values for search
|
13
13
|
def search(record)
|
14
14
|
record.fields('655').map { |field|
|
@@ -26,7 +26,7 @@ module PennMARC
|
|
26
26
|
# @todo subfields e and w do not appear in the documentation for 655, but we give them special consideration here,
|
27
27
|
# what gives?
|
28
28
|
# @note legacy method returns a link object
|
29
|
-
# @param [MARC::Record]
|
29
|
+
# @param record [MARC::Record]
|
30
30
|
# @return [Array<String>] array of genre values for display
|
31
31
|
def show(record)
|
32
32
|
record.fields(%w[655 880]).filter_map { |field|
|
@@ -46,7 +46,7 @@ module PennMARC
|
|
46
46
|
# Genre values for faceting. We only set Genre facet values for movies (videos) and manuscripts(?)
|
47
47
|
# @todo the Genre facet in Franklin is pretty ugly. It could be cleaned up by limiting the subfields included
|
48
48
|
# here and cleaning up punctuation.
|
49
|
-
# @param [MARC::Record]
|
49
|
+
# @param record [MARC::Record]
|
50
50
|
# @return [Array<String>]
|
51
51
|
def facet(record)
|
52
52
|
format_code = record.leader[6] || ' '
|
@@ -61,8 +61,8 @@ module PennMARC
|
|
61
61
|
|
62
62
|
private
|
63
63
|
|
64
|
-
# @param [MARC::DataField]
|
65
|
-
# @return [
|
64
|
+
# @param field [MARC::DataField]
|
65
|
+
# @return [Boolean]
|
66
66
|
def allowed_genre_field?(field)
|
67
67
|
field.indicator2.in?(%w[0 4]) || subfield_value_in?(field, '2', PennMARC::HeadingControl::ALLOWED_SOURCE_CODES)
|
68
68
|
end
|
@@ -6,7 +6,7 @@ module PennMARC
|
|
6
6
|
class << self
|
7
7
|
# Get Alma MMS ID value
|
8
8
|
#
|
9
|
-
# @param [MARC::Record]
|
9
|
+
# @param record [MARC::Record]
|
10
10
|
# @return [String]
|
11
11
|
def mmsid(record)
|
12
12
|
record.fields('001').first.value
|
@@ -16,7 +16,7 @@ module PennMARC
|
|
16
16
|
# {https://www.oclc.org/bibformats/en/0xx/020.html 020 field}, and subfield 'a', 'l', and 'z' of the
|
17
17
|
# the {https://www.oclc.org/bibformats/en/0xx/020.html 022 field}.
|
18
18
|
#
|
19
|
-
# @param [MARC::Record]
|
19
|
+
# @param record [MARC::Record]
|
20
20
|
# @return [Array<String>]
|
21
21
|
def isxn_search(record)
|
22
22
|
record.fields(%w[020 022]).filter_map { |field|
|
@@ -31,7 +31,7 @@ module PennMARC
|
|
31
31
|
# Get ISBN values for display from the {https://www.oclc.org/bibformats/en/0xx/020.html 020 field}
|
32
32
|
# and related {https://www.oclc.org/bibformats/en/8xx/880.html 880 field}.
|
33
33
|
#
|
34
|
-
# @param [MARC::Record]
|
34
|
+
# @param record [MARC::Record]
|
35
35
|
# @return [Array<String>]
|
36
36
|
def isbn_show(record)
|
37
37
|
values = record.fields('020').filter_map do |field|
|
@@ -45,7 +45,7 @@ module PennMARC
|
|
45
45
|
# Get ISSN values for display from the {https://www.oclc.org/bibformats/en/0xx/022.html 022 field} and related
|
46
46
|
# {https://www.oclc.org/bibformats/en/8xx/880.html 880 field}.
|
47
47
|
#
|
48
|
-
# @param [MARC::Record]
|
48
|
+
# @param record [MARC::Record]
|
49
49
|
# @return [Array<String>]
|
50
50
|
def issn_show(record)
|
51
51
|
values = record.fields('022').filter_map do |field|
|
@@ -58,7 +58,7 @@ module PennMARC
|
|
58
58
|
|
59
59
|
# Get numeric OCLC ID of first {https://www.oclc.org/bibformats/en/0xx/035.html 035 field}
|
60
60
|
# with an OCLC ID defined in subfield 'a'.
|
61
|
-
# @param [MARC::Record]
|
61
|
+
# @param record [MARC::Record]
|
62
62
|
# @return [String, nil]
|
63
63
|
def oclc_id_show(record)
|
64
64
|
ids = Array.wrap(record.fields('035')
|
@@ -81,7 +81,7 @@ module PennMARC
|
|
81
81
|
|
82
82
|
# Retrieve valid and invalid numeric OCLC IDs from {https://www.oclc.org/bibformats/en/0xx/035.html 035 field}
|
83
83
|
# for search.
|
84
|
-
# @param [MARC::Record]
|
84
|
+
# @param record [MARC::Record]
|
85
85
|
# @return [Array<String>]
|
86
86
|
def oclc_id_search(record)
|
87
87
|
record.fields('035').flat_map { |field|
|
@@ -108,7 +108,7 @@ module PennMARC
|
|
108
108
|
# {https://www.oclc.org/bibformats/en/8xx/880.html 880 field}. We do not return DOI values stored in 024 ǂ2,
|
109
109
|
# see {PennMARC::Identifier.doi_show} for parsing DOI values.
|
110
110
|
#
|
111
|
-
# @param [MARC::Record]
|
111
|
+
# @param record [MARC::Record]
|
112
112
|
# @return [Array<string>]
|
113
113
|
def publisher_number_show(record)
|
114
114
|
record.fields(%w[024 028 880]).filter_map { |field|
|
@@ -126,7 +126,7 @@ module PennMARC
|
|
126
126
|
# Get publisher issued identifiers for searching of a record. Values extracted from fields
|
127
127
|
# {https://www.oclc.org/bibformats/en/0xx/024.html 024} and {https://www.oclc.org/bibformats/en/0xx/028.html 028}.
|
128
128
|
#
|
129
|
-
# @param [MARC::Record]
|
129
|
+
# @param record [MARC::Record]
|
130
130
|
# @return [Array<String>]
|
131
131
|
def publisher_number_search(record)
|
132
132
|
record.fields(%w[024 028]).filter_map { |field|
|
@@ -136,7 +136,7 @@ module PennMARC
|
|
136
136
|
end
|
137
137
|
|
138
138
|
# Retrieve fingerprint for display from the {https://www.oclc.org/bibformats/en/0xx/026.html 026} field
|
139
|
-
# @param [MARC::Record]
|
139
|
+
# @param record [MARC::Record]
|
140
140
|
# @return [Array<String>]
|
141
141
|
def fingerprint_show(record)
|
142
142
|
record.fields('026').map { |field|
|
@@ -146,7 +146,7 @@ module PennMARC
|
|
146
146
|
|
147
147
|
# Retrieve DOI values stored in {https://www.oclc.org/bibformats/en/0xx/024.html 024}.
|
148
148
|
# Penn MARC records give the first indicator a value of '7' and ǂ2 a value of 'doi' to denote that ǂa is a doi.
|
149
|
-
# @param [MARC::Record]
|
149
|
+
# @param record [MARC::Record]
|
150
150
|
# @return [Array<String>]
|
151
151
|
def doi_show(record)
|
152
152
|
record.fields('024').filter_map { |field|
|
@@ -161,7 +161,7 @@ module PennMARC
|
|
161
161
|
|
162
162
|
# Gets any Host record MMS ID values from an Enriched::Pub::RELATED_RECORD_TAG field added during Alma enrichment.
|
163
163
|
# This aids in our handling of "bound with" records.
|
164
|
-
# @param [MARC::Record]
|
164
|
+
# @param record [MARC::Record]
|
165
165
|
# @return [Array<String>]
|
166
166
|
def host_record_id(record)
|
167
167
|
record.fields(Enriched::Pub::RELATED_RECORD_TAGS).filter_map { |field|
|
@@ -175,19 +175,19 @@ module PennMARC
|
|
175
175
|
|
176
176
|
# Determine if subfield 'a' is an OCLC id.
|
177
177
|
#
|
178
|
-
# @param [MARC::Subfield]
|
179
|
-
# @return [
|
178
|
+
# @param subfield [MARC::Subfield]
|
179
|
+
# @return [Boolean]
|
180
180
|
def subfield_a_is_oclc?(subfield)
|
181
181
|
subfield.code == 'a' && subfield_is_oclc?(subfield)
|
182
182
|
end
|
183
183
|
|
184
|
-
# @param [MARC::Subfield]
|
185
|
-
# @return [
|
184
|
+
# @param subfield [MARC::Subfield]
|
185
|
+
# @return [Boolean]
|
186
186
|
def subfield_is_oclc?(subfield)
|
187
187
|
(subfield.value =~ /^\(OCoLC\).*/).present?
|
188
188
|
end
|
189
189
|
|
190
|
-
# @param [MARC::Subfield]
|
190
|
+
# @param subfield [MARC::Subfield]
|
191
191
|
# @return [MatchData, nil]
|
192
192
|
def match_oclc_number(subfield)
|
193
193
|
/^\s*\(OCoLC\)[^1-9]*([1-9][0-9]*).*$/.match(subfield.value)
|
@@ -197,8 +197,8 @@ module PennMARC
|
|
197
197
|
# Converts ISBN10 (ten-digit) to validated ISBN13 (thirteen-digit) and returns both values. If passed
|
198
198
|
# ISBN13 parameter, only returns validated ISBN13 value.
|
199
199
|
#
|
200
|
-
#
|
201
|
-
#
|
200
|
+
# @param isbn [String]
|
201
|
+
# @return [Array<String, String>, nil]
|
202
202
|
def normalize_isbn(isbn)
|
203
203
|
StdNum::ISBN.allNormalizedValues(isbn)
|
204
204
|
end
|
@@ -18,7 +18,7 @@ module PennMARC
|
|
18
18
|
|
19
19
|
class << self
|
20
20
|
# Hash of Physical holdings information
|
21
|
-
# @param [MARC::Record]
|
21
|
+
# @param record [MARC::Record]
|
22
22
|
# @return [Array, nil]
|
23
23
|
def physical(record)
|
24
24
|
source = enrichment_source(record)
|
@@ -30,7 +30,7 @@ module PennMARC
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# Hash of Electronic inventory information
|
33
|
-
# @param [MARC::Record]
|
33
|
+
# @param record [MARC::Record]
|
34
34
|
# @return [Array, nil]
|
35
35
|
def electronic(record)
|
36
36
|
source = enrichment_source(record)
|
@@ -42,14 +42,14 @@ module PennMARC
|
|
42
42
|
end
|
43
43
|
|
44
44
|
# Count of all electronic portfolios
|
45
|
-
# @param [MARC::Record]
|
45
|
+
# @param record [MARC::Record]
|
46
46
|
# @return [Integer]
|
47
47
|
def electronic_portfolio_count(record)
|
48
48
|
record.count { |field| field.tag.in? %w[AVE prt] }
|
49
49
|
end
|
50
50
|
|
51
51
|
# Count of all physical holdings
|
52
|
-
# @param [MARC::Record]
|
52
|
+
# @param record [MARC::Record]
|
53
53
|
# @return [Integer]
|
54
54
|
def physical_holding_count(record)
|
55
55
|
record.count { |field| field.tag.in? %w[AVA hld] }
|
@@ -58,7 +58,7 @@ module PennMARC
|
|
58
58
|
private
|
59
59
|
|
60
60
|
# Determine the source of the MARC inventory enrichment
|
61
|
-
# @param [MARC::Record]
|
61
|
+
# @param record [MARC::Record]
|
62
62
|
# @return [Symbol, nil]
|
63
63
|
def enrichment_source(record)
|
64
64
|
if pub_enrichment_tags?(record)
|
@@ -70,7 +70,7 @@ module PennMARC
|
|
70
70
|
|
71
71
|
# Does the record include tags from Publishing inventory enrichment?
|
72
72
|
# @todo move to Util?
|
73
|
-
# @param [MARC::Record]
|
73
|
+
# @param record [MARC::Record]
|
74
74
|
# @return [Boolean]
|
75
75
|
def pub_enrichment_tags?(record)
|
76
76
|
record.tags.intersect?(
|
@@ -80,7 +80,7 @@ module PennMARC
|
|
80
80
|
|
81
81
|
# Does the record include tags from API inventory enrichment?
|
82
82
|
# @todo move to Util?
|
83
|
-
# @param [MARC::Record]
|
83
|
+
# @param record [MARC::Record]
|
84
84
|
# @return [Boolean]
|
85
85
|
def api_enrichment_tags?(record)
|
86
86
|
record.tags.intersect?(
|
@@ -6,8 +6,8 @@ module PennMARC
|
|
6
6
|
class Base
|
7
7
|
attr_reader :source, :field, :mapper
|
8
8
|
|
9
|
-
# @param [MARC::DataField]
|
10
|
-
# @param [Symbol]
|
9
|
+
# @param inventory_field [MARC::DataField]
|
10
|
+
# @param source [Symbol]
|
11
11
|
def initialize(inventory_field, source)
|
12
12
|
@source = source
|
13
13
|
@field = inventory_field
|
@@ -12,7 +12,7 @@ module PennMARC
|
|
12
12
|
class << self
|
13
13
|
# Get language values for display from the {https://www.oclc.org/bibformats/en/5xx/546.html 546 field} and
|
14
14
|
# related 880.
|
15
|
-
# @param [MARC::Record]
|
15
|
+
# @param record [MARC::Record]
|
16
16
|
# @return [Array<String>] language values and notes
|
17
17
|
def show(record)
|
18
18
|
values = record.fields('546').map do |field|
|
@@ -31,9 +31,9 @@ module PennMARC
|
|
31
31
|
# multilingual items, items that involve translation, and items where the medium of communication is a sign
|
32
32
|
# language. https://www.loc.gov/marc/bibliographic/bd041.html
|
33
33
|
#
|
34
|
-
# @param [MARC::Record]
|
35
|
-
# @param [Hash]
|
36
|
-
# @param [Hash]
|
34
|
+
# @param record [MARC::Record]
|
35
|
+
# @param iso_639_2_mapping [Hash] iso-639-2 spec hash for language code translation
|
36
|
+
# @param iso_639_3_mapping [Hash] iso-639-3 spec hash for language code translation
|
37
37
|
# @return [Array<String>] array of language values
|
38
38
|
def values(record, iso_639_2_mapping: Mappers.iso_639_2_language, iso_639_3_mapping: Mappers.iso_639_3_language)
|
39
39
|
values = record.fields('041').filter_map { |field|
|
@@ -6,12 +6,12 @@ module PennMARC
|
|
6
6
|
class << self
|
7
7
|
# @todo the legacy code here is a hot mess for a number of reasons, what do we need this field to do?
|
8
8
|
# @note port the needed parts from get_offsite_display, don't return HTML
|
9
|
-
# @param [MARC::Record]
|
9
|
+
# @param record [MARC::Record]
|
10
10
|
# @return [Object]
|
11
11
|
def offsite(record); end
|
12
12
|
|
13
13
|
# Full text links from MARC 856 fields.
|
14
|
-
# @param [MARC::Record]
|
14
|
+
# @param record [MARC::Record]
|
15
15
|
# @return [Array] array of hashes
|
16
16
|
def full_text_links(record)
|
17
17
|
indicator2_options = %w[0 1]
|
@@ -19,7 +19,7 @@ module PennMARC
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# Web text links from MARC 856 fields.
|
22
|
-
# @param [MARC::Record]
|
22
|
+
# @param record [MARC::Record]
|
23
23
|
# @return [Array] array of hashes
|
24
24
|
def web_links(record)
|
25
25
|
indicator2_options = ['2', ' ', '']
|
@@ -30,7 +30,7 @@ module PennMARC
|
|
30
30
|
|
31
31
|
# Extract subfield 3 and z/y depending on the presence of either. Extract link url and assemble array
|
32
32
|
# with text and link.
|
33
|
-
# @param [MARC::Field]
|
33
|
+
# @param field [MARC::Field]
|
34
34
|
# @return [Array]
|
35
35
|
def link_text_and_url(field)
|
36
36
|
subfield3 = subfield_values(field, 3)
|
@@ -42,8 +42,8 @@ module PennMARC
|
|
42
42
|
|
43
43
|
# Assemble array of link text, link URL values from 856 fields. Ensure indicator1 (access method)
|
44
44
|
# is always 4 (HTTP) and indicator2 (relationship) can be specified by caller method.
|
45
|
-
# @param [MARC::Record]
|
46
|
-
# @param [Array]
|
45
|
+
# @param record [MARC::Record]
|
46
|
+
# @param indicator2_options [Array]
|
47
47
|
# @return [Array]
|
48
48
|
def links_from_record(record, indicator2_options)
|
49
49
|
record.fields('856').filter_map do |field|
|
@@ -12,8 +12,8 @@ module PennMARC
|
|
12
12
|
# {PennMARC::Enriched} maps enriched marc fields and subfields created during Alma publishing.
|
13
13
|
# @see https://developers.exlibrisgroup.com/alma/apis/docs/bibs/R0VUIC9hbG1hd3MvdjEvYmlicy97bW1zX2lkfQ==/
|
14
14
|
# Alma documentation for these added fields
|
15
|
-
# @param [MARC::Record]
|
16
|
-
# @param [Hash]
|
15
|
+
# @param record [MARC::Record]
|
16
|
+
# @param location_map [Hash] hash with location_code as key and location hash as value
|
17
17
|
# @return [Array<String>] Array of library locations retrieved from location_map
|
18
18
|
def library(record, location_map: Mappers.location)
|
19
19
|
location(record: record, location_map: location_map, display_value: 'library')
|
@@ -25,8 +25,8 @@ module PennMARC
|
|
25
25
|
# {PennMARC::Enriched} maps enriched marc fields and subfields created during Alma publishing.
|
26
26
|
# @see https://developers.exlibrisgroup.com/alma/apis/docs/bibs/R0VUIC9hbG1hd3MvdjEvYmlicy97bW1zX2lkfQ==/
|
27
27
|
# Alma documentation for these added fields
|
28
|
-
# @param [MARC::Record]
|
29
|
-
# @param [Hash]
|
28
|
+
# @param record [MARC::Record]
|
29
|
+
# @param location_map [Hash] hash with location_code as key and location hash as value
|
30
30
|
# @return [Array<String>] Array of specific locations retrieved from location_map
|
31
31
|
def specific_location(record, location_map: Mappers.location)
|
32
32
|
location(record: record, location_map: location_map, display_value: 'specific_location')
|
@@ -37,9 +37,9 @@ module PennMARC
|
|
37
37
|
# {PennMARC::Enriched} maps enriched marc fields and subfields created during Alma publishing.
|
38
38
|
# @see https://developers.exlibrisgroup.com/alma/apis/docs/bibs/R0VUIC9hbG1hd3MvdjEvYmlicy97bW1zX2lkfQ==/
|
39
39
|
# Alma documentation for these added fields
|
40
|
-
# @param [MARC::Record]
|
41
|
-
# @param [Symbol | String]
|
42
|
-
# @param [Hash]
|
40
|
+
# @param record [MARC::Record]
|
41
|
+
# @param display_value [Symbol | String] field in location hash to retrieve
|
42
|
+
# @param location_map [Hash] hash with location_code as key and location hash as value
|
43
43
|
# @return [Array<String>]
|
44
44
|
def location(record:, display_value:, location_map:)
|
45
45
|
# get enriched marc location tag and relevant subfields
|
@@ -71,7 +71,7 @@ module PennMARC
|
|
71
71
|
|
72
72
|
# Determine enriched marc location tag, location code subfield, and call number subfield,
|
73
73
|
# giving priority to using 'itm', 'AVA', or 'AVE' fields.
|
74
|
-
# @param [MARC::Record]
|
74
|
+
# @param record [MARC::Record]
|
75
75
|
# @return [Hash<String, String>] containing location tag and subfield code
|
76
76
|
# - `:tag` (String): The enriched marc location tag
|
77
77
|
# - `:location_code_sf` (String): The subfield code where location code is stored
|
@@ -111,8 +111,8 @@ module PennMARC
|
|
111
111
|
# map, we ignore it, for faceting purposes. We also ignore the location code 'web'. We don't facet for 'web'
|
112
112
|
# which is the 'Penn Library Web' location used in Voyager. This location should eventually go away completely
|
113
113
|
# with data cleanup in Alma.
|
114
|
-
# @param [location_map]
|
115
|
-
# @param [location_code]
|
114
|
+
# @param location_map [location_map] hash with location_code as key and location hash as value
|
115
|
+
# @param location_code [location_code] retrieved from record
|
116
116
|
# @return [Boolean]
|
117
117
|
def location_code_to_ignore?(location_map, location_code)
|
118
118
|
location_map.key?(location_code.to_sym) == false || location_code == WEB_LOCATION_CODE
|
@@ -120,10 +120,10 @@ module PennMARC
|
|
120
120
|
|
121
121
|
# Retrieves a specific location override based on location code and call number. Specific location overrides are
|
122
122
|
# located in `location_overrides.yml`.
|
123
|
-
# @param [String | Symbol]
|
124
|
-
# @param [String]
|
125
|
-
# @param [MARC::Field]
|
126
|
-
# @param [String]
|
123
|
+
# @param display_value [String | Symbol]
|
124
|
+
# @param location_code [String]
|
125
|
+
# @param field [MARC::Field]
|
126
|
+
# @param call_num_sf [String]
|
127
127
|
# @return [String, Nil]
|
128
128
|
def specific_location_override(display_value:, location_code:, field:, call_num_sf:)
|
129
129
|
return unless display_value.to_sym == :specific_location
|
@@ -172,7 +172,7 @@ module PennMARC
|
|
172
172
|
end
|
173
173
|
|
174
174
|
# Retrieve "With" notes for display from field {https://www.loc.gov/marc/bibliographic/bd501.html 501}
|
175
|
-
# @param record [
|
175
|
+
# @param record [MARC::Record]
|
176
176
|
# @return [Array<String>]
|
177
177
|
def bound_with_show(record)
|
178
178
|
record.fields('501').filter_map { |field| join_subfields(field, &subfield_in?(['a'])).presence }.uniq
|
@@ -183,7 +183,7 @@ module PennMARC
|
|
183
183
|
# For system details: extract subfield ǂ3 plus other subfields as specified by passed-in block. Pays special
|
184
184
|
# attention to punctuation, joining subfield ǂ3 values with a colon-space (': ').
|
185
185
|
# @param field [MARC::DataField]
|
186
|
-
# @
|
186
|
+
# @yieldparam & [Proc]
|
187
187
|
# @return [String]
|
188
188
|
def sub3_and_other_subs(field, &)
|
189
189
|
sub3 = field.filter_map { |sf| trim_trailing('period', sf.value) if sf.code == '3' }.join(': ')
|
@@ -109,8 +109,8 @@ module PennMARC
|
|
109
109
|
# {https://www.loc.gov/marc/bibliographic/bd245.html 245},
|
110
110
|
# {https://www.loc.gov/marc/bibliographic/bd260.html 260}-262 and their linked alternates,
|
111
111
|
# and {https://www.loc.gov/marc/bibliographic/bd264.html 264} and its linked alternate.
|
112
|
-
# @param [MARC::Record]
|
113
|
-
# @param [Boolean]
|
112
|
+
# @param record [MARC::Record]
|
113
|
+
# @param with_year [Boolean] return results with publication year if true
|
114
114
|
# @return [Array<String>]
|
115
115
|
def publication_citation_show(record, with_year: true)
|
116
116
|
values = record.fields('245').first(1).flat_map { |field| subfield_values(field, 'f') }
|
@@ -131,14 +131,14 @@ module PennMARC
|
|
131
131
|
end
|
132
132
|
|
133
133
|
# Returns the place of publication for RIS
|
134
|
-
# @param [MARC::Record]
|
134
|
+
# @param record [MARC::Record]
|
135
135
|
# @return [Array<String>]
|
136
136
|
def publication_ris_place_of_pub(record)
|
137
137
|
get_publication_ris_values(record, 'a')
|
138
138
|
end
|
139
139
|
|
140
140
|
# Returns the publisher for RIS
|
141
|
-
# @param [MARC::Record]
|
141
|
+
# @param record [MARC::Record]
|
142
142
|
# @return [Array<String>]
|
143
143
|
def publication_ris_publisher(record)
|
144
144
|
get_publication_ris_values(record, 'b')
|
@@ -202,8 +202,9 @@ module PennMARC
|
|
202
202
|
end
|
203
203
|
|
204
204
|
# Returns the publication value of the given subfield
|
205
|
-
# @param [MARC::Record]
|
206
|
-
# @param [String]
|
205
|
+
# @param record [MARC::Record]
|
206
|
+
# @param subfield [String]
|
207
|
+
# @return [Array<String>]
|
207
208
|
def get_publication_ris_values(record, subfield)
|
208
209
|
values = record.fields('245').first(1).flat_map { |field| subfield_values(field, 'f') }
|
209
210
|
|
@@ -13,7 +13,7 @@ module PennMARC
|
|
13
13
|
# Get values for "{https://www.oclc.org/bibformats/en/7xx/773.html Host Item}" for this record. Values contained
|
14
14
|
# in this field should be sufficient to locate host item record.
|
15
15
|
#
|
16
|
-
# @param [MARC::Record]
|
16
|
+
# @param record [MARC::Record]
|
17
17
|
# @return [Array<String>] contained in values for display
|
18
18
|
def contained_in_show(record)
|
19
19
|
record.fields('773').map { |field|
|
@@ -23,21 +23,21 @@ module PennMARC
|
|
23
23
|
|
24
24
|
# Get "chronology" information from specially-prefixed 650 (subject) fields
|
25
25
|
# @todo why do we stuff chronology data in a 650 field?
|
26
|
-
# @param [MARC::Record]
|
26
|
+
# @param record [MARC::Record]
|
27
27
|
# @return [Array] array of chronology values
|
28
28
|
def chronology_show(record)
|
29
29
|
prefixed_subject_and_alternate(record, CHRONOLOGY_PREFIX)
|
30
30
|
end
|
31
31
|
|
32
32
|
# Get notes for Related Collections from {https://www.oclc.org/bibformats/en/5xx/544.html MARC 544}.
|
33
|
-
# @param [MARC::Record]
|
33
|
+
# @param record [MARC::Record]
|
34
34
|
# @return [Array]
|
35
35
|
def related_collections_show(record)
|
36
36
|
datafield_and_linked_alternate(record, '544')
|
37
37
|
end
|
38
38
|
|
39
39
|
# Get notes for "Publication About" from {https://www.oclc.org/bibformats/en/5xx/581.html MARC 581}.
|
40
|
-
# @param [MARC::Record]
|
40
|
+
# @param record [MARC::Record]
|
41
41
|
# @return [Array]
|
42
42
|
def publications_about_show(record)
|
43
43
|
datafield_and_linked_alternate(record, '581')
|
@@ -45,8 +45,8 @@ module PennMARC
|
|
45
45
|
|
46
46
|
# Get related work from {RELATED_WORK_FIELDS} in the 7XX range. Require presence of sf t (title) and absence of
|
47
47
|
# an indicator2 value. Prefix returned values with sf i value. Also map relator codes found in sf 4. Ignore sf 0.
|
48
|
-
# @param [MARC::Record]
|
49
|
-
# @param [Hash]
|
48
|
+
# @param record [MARC::Record]
|
49
|
+
# @param relator_map [Hash]
|
50
50
|
# @return [Array]
|
51
51
|
def related_work_show(record, relator_map: Mappers.relator)
|
52
52
|
fields = record.fields(RELATED_WORK_FIELDS)
|
@@ -71,8 +71,8 @@ module PennMARC
|
|
71
71
|
# "Analytical Entry" meaning that the record is contained by the matching field. Map relator codes in sf 4. Ignore
|
72
72
|
# values in sf 0, 5, 6, and 8.
|
73
73
|
# @todo is it okay to include 880 $4 here? Legacy includes untranslated $4, why?
|
74
|
-
# @param [MARC::Record]
|
75
|
-
# @param [Hash]
|
74
|
+
# @param record [MARC::Record]
|
75
|
+
# @param relator_map [Hash]
|
76
76
|
# @return [Array<String>]
|
77
77
|
def contains_show(record, relator_map: Mappers.relator)
|
78
78
|
fields = record.fields(CONTAINS_FIELDS)
|
@@ -93,7 +93,7 @@ module PennMARC
|
|
93
93
|
|
94
94
|
# Get "Constituent Unit" values from {https://www.oclc.org/bibformats/en/7xx/774.html MARC 774}. Include
|
95
95
|
# subfield values in i, a, s and t.
|
96
|
-
# @param [MARC::Record]
|
96
|
+
# @param record [MARC::Record]
|
97
97
|
# @return [Array]
|
98
98
|
def constituent_unit_show(record)
|
99
99
|
values = record.fields('774').filter_map do |field|
|
@@ -105,7 +105,7 @@ module PennMARC
|
|
105
105
|
|
106
106
|
# Get "Has Supplement" values from {https://www.oclc.org/bibformats/en/7xx/770.html MARC 770}. Ignore
|
107
107
|
# subfield values in 6 and 8.
|
108
|
-
# @param [MARC::Record]
|
108
|
+
# @param record [MARC::Record]
|
109
109
|
# @return [Array]
|
110
110
|
def has_supplement_show(record)
|
111
111
|
datafield_and_linked_alternate(record, '770')
|
@@ -114,10 +114,10 @@ module PennMARC
|
|
114
114
|
private
|
115
115
|
|
116
116
|
# Handle common behavior when a relator field references a title in subfield i
|
117
|
-
# @param [MARC::DataField]
|
118
|
-
# @param [String, nil]
|
119
|
-
# @param [Hash, nil]
|
120
|
-
# @param [Proc]
|
117
|
+
# @param field [MARC::DataField]
|
118
|
+
# @param relator_term_sf [String, nil] subfield that holds relator term
|
119
|
+
# @param relator_map [Hash, nil] map relator in sf4 using this map, optional
|
120
|
+
# @param join_selector [Proc]
|
121
121
|
# @return [String] extracted and processed values from field
|
122
122
|
def values_with_title_prefix(field, relator_term_sf: nil, relator_map: nil, &join_selector)
|
123
123
|
subi = remove_paren_value_from_subfield_i(field) || ''
|
@@ -18,8 +18,8 @@ module PennMARC
|
|
18
18
|
DISPLAY_TAGS = %w[800 810 811 830 400 410 411 440 490].freeze
|
19
19
|
|
20
20
|
# Fields for display that pertain to series information.
|
21
|
-
# @param [MARC::Record]
|
22
|
-
# @param [Hash]
|
21
|
+
# @param record [MARC::Record]
|
22
|
+
# @param relator_map [Hash]
|
23
23
|
# @return [Array<String>] array of series information
|
24
24
|
def show(record, relator_map: Mappers.relator)
|
25
25
|
tags_present = DISPLAY_TAGS.select { |tag| record[tag].present? }
|
@@ -36,8 +36,8 @@ module PennMARC
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# Values from series fields for display.
|
39
|
-
# @param [MARC::Record]
|
40
|
-
# @param [Hash]
|
39
|
+
# @param record [MARC::Record]
|
40
|
+
# @param relator_map [Hash]
|
41
41
|
# @return [Array<String>] array of series values
|
42
42
|
def values(record, relator_map: Mappers.relator)
|
43
43
|
series_8x = record.fields(%w[800 810 811 830]).first
|
@@ -48,7 +48,7 @@ module PennMARC
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# Series fields for search.
|
51
|
-
# @param [MARC::Record]
|
51
|
+
# @param record [MARC::Record]
|
52
52
|
# @return [Array<String>] array of series values
|
53
53
|
def search(record)
|
54
54
|
values = record.fields(%w[400 410 411]).filter_map do |field|
|
@@ -83,7 +83,7 @@ module PennMARC
|
|
83
83
|
# is generated from this field, the introductory term or phrase may be generated based on the value in the second
|
84
84
|
# indicator position for display.
|
85
85
|
# https://www.loc.gov/marc/bibliographic/bd780.html
|
86
|
-
# @param [MARC::Record]
|
86
|
+
# @param record [MARC::Record]
|
87
87
|
# @return [Array<String>] continues fields string
|
88
88
|
def get_continues_show(record)
|
89
89
|
continues(record, '780').uniq
|
@@ -93,7 +93,7 @@ module PennMARC
|
|
93
93
|
# generated from this field, the introductory phrase may be generated based on the value in the second indicator
|
94
94
|
# position for display.
|
95
95
|
# https://www.loc.gov/marc/bibliographic/bd785.html
|
96
|
-
# @param [MARC::Record]
|
96
|
+
# @param record [MARC::Record]
|
97
97
|
# @return [Array<String>] continued by fields string
|
98
98
|
def get_continued_by_show(record)
|
99
99
|
continues(record, '785').uniq
|
@@ -104,9 +104,9 @@ module PennMARC
|
|
104
104
|
# If any of these values: 800 810 811 400 410 411 are present, return a string with series information and
|
105
105
|
# appended values.
|
106
106
|
# @note added 2017/04/10: filter out 0 (authority record numbers) added by Alma
|
107
|
-
# @param [MARC::Record]
|
108
|
-
# @param [String]
|
109
|
-
# @param [Hash]
|
107
|
+
# @param record [MARC::Record]
|
108
|
+
# @param first_tag [String]
|
109
|
+
# @param relator_mapping [Hash]
|
110
110
|
# @return [Array<Hash>] array of author show entry hashes
|
111
111
|
def author_show_entries(record, first_tag, relator_mapping)
|
112
112
|
record.fields(first_tag).map do |field|
|
@@ -126,8 +126,8 @@ module PennMARC
|
|
126
126
|
|
127
127
|
# If any of these values: 830 440 490 are present, return a string with series information and appended values.
|
128
128
|
# @note added 2017/04/10: filter out 0 (authority record numbers) added by Alma
|
129
|
-
# @param [MARC::Record]
|
130
|
-
# @param [String]
|
129
|
+
# @param record [MARC::Record]
|
130
|
+
# @param first_tag [String]
|
131
131
|
# @return [Array<String>] array of author show entry strings
|
132
132
|
def title_show_entries(record, first_tag)
|
133
133
|
record.fields(first_tag).map do |field|
|
@@ -139,8 +139,8 @@ module PennMARC
|
|
139
139
|
|
140
140
|
# Assemble an array of hashes that includes the remaining show entries.
|
141
141
|
# @note added 2017/04/10: filter out 0 (authority record numbers) added by Alma
|
142
|
-
# @param [MARC::Record]
|
143
|
-
# @param [Array<String>]
|
142
|
+
# @param record [MARC::Record]
|
143
|
+
# @param tags_present [Array<String>]
|
144
144
|
# @return [Array<Hash>] array of remaining show entry hashes
|
145
145
|
def remaining_show_entries(record, tags_present)
|
146
146
|
record.fields(tags_present.drop(1)).map do |field|
|
@@ -156,7 +156,7 @@ module PennMARC
|
|
156
156
|
# is linked to the associated regular field by subfield $6 (Linkage). A subfield $6 in the associated field also
|
157
157
|
# links that field to the 880 field. The data in field 880 may be in more than one script. This function exists
|
158
158
|
# because it differs than the tradition use of linked_alternate.
|
159
|
-
# @param [MARC::Record]
|
159
|
+
# @param record [MARC::Record]
|
160
160
|
# @return [Array<String>]
|
161
161
|
def series_880_fields(record)
|
162
162
|
record.fields('880').filter_map do |field|
|
@@ -168,8 +168,8 @@ module PennMARC
|
|
168
168
|
|
169
169
|
# Assemble a formatted string of a given field.
|
170
170
|
# @note added 2017/04/10: filter out 0 (authority record numbers) added by Alma
|
171
|
-
# @param [MARC::Field]
|
172
|
-
# @param [Hash]
|
171
|
+
# @param field [MARC::Field]
|
172
|
+
# @param relator_mapping [Hash]
|
173
173
|
# @return [String] series 4xx field
|
174
174
|
def series_field(field, relator_mapping)
|
175
175
|
subfields = if field.tag.start_with? '4'
|
@@ -189,8 +189,8 @@ module PennMARC
|
|
189
189
|
end
|
190
190
|
|
191
191
|
# Get subfields from a given field (continues or continued_by).
|
192
|
-
# @param [MARC::Record]
|
193
|
-
# @param [String]
|
192
|
+
# @param record [MARC::Record]
|
193
|
+
# @param tag [String]
|
194
194
|
# @return [Array<String>] joined subfields
|
195
195
|
def continues(record, tag)
|
196
196
|
record.fields.filter_map do |field|
|