pennmarc 1.3.1 → 1.3.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b69f7173f51a48c0748bf1d537392c6bda0919312009c85bd70e603cf4cb0240
|
4
|
+
data.tar.gz: fa0e2d2c724e26734890fcc1fe4e20899a6141d0e0f0cdebe9e242b03070be35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ed0b2699d095d4f07483e38fd99d8bcc52d2fd69f8c6b94dfba410a8d6f42329dda379e7eb8809ec43687d8552cc38471f85859ff0d73c0888026845caed1e6
|
7
|
+
data.tar.gz: 62d4f90ff259a2188fc0cc5eee803cd18e9f1a83d15874de77ef956e6dd836ae6a822a433770c0e56e2f583c15f696919be30f7298c080b4404d27e3f247d245
|
@@ -5,7 +5,8 @@ module PennMARC
|
|
5
5
|
class Access < Helper
|
6
6
|
ONLINE = 'Online'
|
7
7
|
AT_THE_LIBRARY = 'At the library'
|
8
|
-
|
8
|
+
HANDLE_BASE_URL = 'hdl.library.upenn.edu'
|
9
|
+
COLENDA_BASE_URL = 'colenda.library.upenn.edu'
|
9
10
|
|
10
11
|
class << self
|
11
12
|
# Based on enhanced metadata fields added by Alma publishing process or API, determine if the record has
|
@@ -46,7 +47,7 @@ module PennMARC
|
|
46
47
|
# Check if a record contains an 856 entry with a Penn Handle server link meeting these criteria:
|
47
48
|
# 1. Indicator 1 is 4 (HTTP resource)
|
48
49
|
# 2. Indicator 2 is NOT 2 (indicating the linkage is to a "related" thing)
|
49
|
-
# 3. The URL specified in subfield u (URI) is a Penn Handle link
|
50
|
+
# 3. The URL specified in subfield u (URI) is a Penn Handle link or Penn Colenda link
|
50
51
|
# 4. The subfield z does NOT include the string 'Finding aid'
|
51
52
|
# See: https://www.loc.gov/marc/bibliographic/bd856.html
|
52
53
|
# @note Some electronic records do not have Portfolios in Alma, so we rely upon the Resource Link in the 856 to
|
@@ -54,15 +55,19 @@ module PennMARC
|
|
54
55
|
# @param record [MARC::Record]
|
55
56
|
# @return [Boolean]
|
56
57
|
def resource_link?(record)
|
57
|
-
record.fields('856').
|
58
|
-
|
58
|
+
record.fields('856').any? { |field| valid_resource_field?(field) }
|
59
|
+
end
|
60
|
+
|
61
|
+
# Check if a field contains valid resource
|
62
|
+
# @param field [MARC::Field]
|
63
|
+
# @return [Boolean]
|
64
|
+
def valid_resource_field?(field)
|
65
|
+
return false if field.indicator2 == '2' || field.indicator1 != '4'
|
66
|
+
return false if subfield_values(field, 'z')&.include?('Finding aid')
|
59
67
|
|
60
|
-
|
61
|
-
|
62
|
-
return true if subz.exclude?('Finding aid') && value.include?(RESOURCE_LINK_BASE_URL)
|
63
|
-
end
|
68
|
+
subfield_values(field, 'u').any? do |value|
|
69
|
+
[HANDLE_BASE_URL, COLENDA_BASE_URL].any? { |url| value.include?(url) }
|
64
70
|
end
|
65
|
-
false
|
66
71
|
end
|
67
72
|
end
|
68
73
|
end
|
@@ -85,28 +85,28 @@ 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
|
88
|
+
# Show more credited authors - both 100 field and 700 entries where the relator (codes e or 4) is author/aut
|
89
89
|
# @param record [MARC::Record]
|
90
90
|
# @return [Array<String>] array of author/creator values for display
|
91
91
|
def extended_show(record, relator_map: Mappers.relator)
|
92
92
|
fields = record.fields(%w[100 700])
|
93
93
|
fields.filter_map { |field|
|
94
|
-
# for 700 entries, only include ones with relator code
|
95
|
-
next if
|
94
|
+
# for 700 entries, only include ones with relator code ('4') = aut, or code 'e' = 'author'
|
95
|
+
next if field.tag == '700' && !(field['4']&.downcase == 'aut' || field['e']&.downcase&.start_with?('author'))
|
96
96
|
|
97
97
|
parse_show_value(field, relator_map: relator_map)
|
98
98
|
}.uniq
|
99
99
|
end
|
100
100
|
|
101
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
|
102
|
+
# Only include 100, and 700 with relator (codes e or 4) of author/aut
|
103
103
|
# @param record [MARC::Record]
|
104
104
|
# @param relator_map [Hash]
|
105
105
|
# @return [Hash]
|
106
106
|
def extended_show_facet_map(record, relator_map: Mappers.relator)
|
107
107
|
creators = record.fields(%w[100 700]).filter_map do |field|
|
108
|
-
# for 700 entries, only include ones with relator code
|
109
|
-
next if
|
108
|
+
# for 700 entries, only include ones with relator code ('4') = aut, or code 'e' = 'author'
|
109
|
+
next if field.tag == '700' && !(field['4']&.downcase == 'aut' || field['e']&.downcase&.start_with?('author'))
|
110
110
|
|
111
111
|
show = parse_show_value(field, relator_map: relator_map)
|
112
112
|
facet = parse_facet_value(field, FACET_SOURCE_MAP[field.tag.to_i].chars)
|
data/lib/pennmarc/version.rb
CHANGED
@@ -44,7 +44,7 @@ describe 'PennMARC::Access' do
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
context 'with a record containing a link to
|
47
|
+
context 'with a record containing a link to an online resource' do
|
48
48
|
let(:record) do
|
49
49
|
marc_record fields: [marc_field(tag: PennMARC::Enriched::Pub::PHYS_INVENTORY_TAG),
|
50
50
|
marc_field(tag: '856', subfields: location_and_access_subfields, **indicators)]
|
@@ -72,7 +72,7 @@ describe 'PennMARC::Access' do
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
context 'with an 856 describing a resource link' do
|
75
|
+
context 'with an 856 describing a handle resource link' do
|
76
76
|
let(:indicators) { { indicator1: '4', indicator2: '1' } }
|
77
77
|
let(:location_and_access_subfields) do
|
78
78
|
{ z: 'Connect to resource', u: 'http://hdl.library.upenn.edu/1234' }
|
@@ -82,6 +82,28 @@ describe 'PennMARC::Access' do
|
|
82
82
|
expect(helper.facet(record)).to contain_exactly(PennMARC::Access::ONLINE, PennMARC::Access::AT_THE_LIBRARY)
|
83
83
|
end
|
84
84
|
end
|
85
|
+
|
86
|
+
context 'with an 856 describing a colenda resource link' do
|
87
|
+
let(:indicators) { { indicator1: '4', indicator2: '1' } }
|
88
|
+
let(:location_and_access_subfields) do
|
89
|
+
{ z: 'Connect to resource', u: 'http://colenda.library.upenn.edu/1234' }
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'includes online access' do
|
93
|
+
expect(helper.facet(record)).to contain_exactly(PennMARC::Access::ONLINE, PennMARC::Access::AT_THE_LIBRARY)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'with an 856 describing some other resource link' do
|
98
|
+
let(:indicators) { { indicator1: '4', indicator2: '1' } }
|
99
|
+
let(:location_and_access_subfields) do
|
100
|
+
{ z: 'Connect to resource', u: 'http://vanpelt.upenn.edu/something' }
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'does not includes online access' do
|
104
|
+
expect(helper.facet(record)).not_to include PennMARC::Access::ONLINE
|
105
|
+
end
|
106
|
+
end
|
85
107
|
end
|
86
108
|
end
|
87
109
|
end
|
@@ -114,13 +114,16 @@ describe 'PennMARC::Creator' do
|
|
114
114
|
let(:fields) do
|
115
115
|
[marc_field(tag: '100', subfields: { a: 'Surname, Name', '0': 'http://cool.uri/12345', d: '1900-2000',
|
116
116
|
e: 'author.', '4': 'http://cool.uri/vocabulary/relators/aut' }),
|
117
|
-
marc_field(tag: '700', subfields: { a: 'Surname, Alternative',
|
117
|
+
marc_field(tag: '700', subfields: { a: 'Surname, Alternative', '6': '100', '4': 'aut' }),
|
118
|
+
marc_field(tag: '700', subfields: { a: 'Surname, Third', e: 'author.', '6': '100' }),
|
119
|
+
marc_field(tag: '700', subfields: { a: 'Surname, Ignore', e: 'editor.', '6': '100' }),
|
118
120
|
marc_field(tag: '700', subfields: { a: 'Surname, Not Included', '6': '100', '4': 'edt' })]
|
119
121
|
end
|
120
122
|
|
121
|
-
it 'returns
|
123
|
+
it 'returns three authors' do
|
122
124
|
values = helper.extended_show(record)
|
123
|
-
expect(values).to contain_exactly 'Surname, Name 1900-2000, author.',
|
125
|
+
expect(values).to contain_exactly 'Surname, Name 1900-2000, author.',
|
126
|
+
'Surname, Alternative, Author.', 'Surname, Third, author.'
|
124
127
|
expect(values.join.downcase).not_to include 'http'
|
125
128
|
end
|
126
129
|
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.3.
|
4
|
+
version: 1.3.2
|
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
|
+
date: 2025-08-22 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activesupport
|