pennmarc 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pennmarc/helpers/access.rb +22 -6
- data/lib/pennmarc/version.rb +1 -1
- data/spec/lib/pennmarc/helpers/access_spec.rb +29 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb8a665310aaf17d406fcfbfe562894a71f17d35b2d63173ca587a9c0e343b54
|
4
|
+
data.tar.gz: 671549b45eb522db5f4350aa0743bcd16585398c6c07f71e2d2a772367a0f33c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a1374b40186e61a56e33924a6f76561877af209e3b8486b185599766e5cc7bc1b45362cf4f3f9e18fc5cf2cb4328b46f8b0f83b0e2c374a1f31164bce3b8483
|
7
|
+
data.tar.gz: 7a098756899b310a694dbcc1409516de62ff9897b624ac4783b793de145ac61c497bc183409343269e5e33b7b21a07728fa74148fe6af2ad8aaef8149acd71c5
|
@@ -5,20 +5,22 @@ module PennMARC
|
|
5
5
|
class Access < Helper
|
6
6
|
ONLINE = 'Online'
|
7
7
|
AT_THE_LIBRARY = 'At the library'
|
8
|
+
ELEC_AVAILABILITY_TAG = 'AVE'
|
9
|
+
PHYS_AVAILABILITY_TAG = 'AVA'
|
8
10
|
|
9
11
|
class << self
|
10
|
-
# Based
|
11
|
-
# electronic access or has physical
|
12
|
-
# library", but has a link to a finding aid in the 856 field (matching certain criteria), also add 'Online' as
|
13
|
-
# access method.
|
12
|
+
# Based on enhanced metadata fields added by Alma publishing process or API, determine if the record has
|
13
|
+
# electronic access or has physical holdings, and is therefore "Online" or "At the library". If a record is "At
|
14
|
+
# the library", but has a link to a finding aid in the 856 field (matching certain criteria), also add 'Online' as
|
15
|
+
# an access method.
|
14
16
|
# @todo What if none of these criteria match? Should we include "At the library" by default? Records with no value
|
15
17
|
# in this field would be lost if the user selects a facet value.
|
16
18
|
# @param [MARC::Record] record
|
17
19
|
# @return [Array]
|
18
20
|
def facet(record)
|
19
21
|
acc = record.filter_map do |field|
|
20
|
-
next AT_THE_LIBRARY if field
|
21
|
-
next ONLINE if field
|
22
|
+
next AT_THE_LIBRARY if physical_holding_tag?(field)
|
23
|
+
next ONLINE if electronic_holding_tag?(field)
|
22
24
|
end
|
23
25
|
|
24
26
|
return acc if acc.size == 2 # return early if all values are already present
|
@@ -29,6 +31,20 @@ module PennMARC
|
|
29
31
|
|
30
32
|
private
|
31
33
|
|
34
|
+
# Does the record have added electronic holding info?
|
35
|
+
# @param [MARC::Field] field
|
36
|
+
# @return [Boolean]
|
37
|
+
def electronic_holding_tag?(field)
|
38
|
+
field.tag.in? [EnrichedMarc::TAG_ELECTRONIC_INVENTORY, ELEC_AVAILABILITY_TAG]
|
39
|
+
end
|
40
|
+
|
41
|
+
# Does the record have added physical holding info?
|
42
|
+
# @param [MARC::Field] field
|
43
|
+
# @return [Boolean]
|
44
|
+
def physical_holding_tag?(field)
|
45
|
+
field.tag.in? [EnrichedMarc::TAG_HOLDING, PHYS_AVAILABILITY_TAG]
|
46
|
+
end
|
47
|
+
|
32
48
|
# Check if a record contains an 856 entry for an online finding aid, meeting these criteria:
|
33
49
|
# 1. Indicator 1 is 4 (HTTP resource)
|
34
50
|
# 2. Indicator 2 is NOT 2 (indicating the linkage is to a "related" thing)
|
data/lib/pennmarc/version.rb
CHANGED
@@ -7,28 +7,48 @@ describe 'PennMARC::Access' do
|
|
7
7
|
|
8
8
|
describe '.facet' do
|
9
9
|
context 'with an electronic record' do
|
10
|
-
let(:record)
|
11
|
-
|
10
|
+
let(:record) { marc_record fields: [marc_field(tag: tag)] }
|
11
|
+
|
12
|
+
context 'with enrichment via the Alma publishing process' do
|
13
|
+
let(:tag) { PennMARC::EnrichedMarc::TAG_ELECTRONIC_INVENTORY }
|
14
|
+
|
15
|
+
it 'returns expected access value' do
|
16
|
+
expect(helper.facet(record)).to contain_exactly(PennMARC::Access::ONLINE)
|
17
|
+
end
|
12
18
|
end
|
13
19
|
|
14
|
-
|
15
|
-
|
20
|
+
context 'with enrichment with availability info via the Alma API' do
|
21
|
+
let(:tag) { PennMARC::Access::ELEC_AVAILABILITY_TAG }
|
22
|
+
|
23
|
+
it 'returns expected access value' do
|
24
|
+
expect(helper.facet(record)).to contain_exactly(PennMARC::Access::ONLINE)
|
25
|
+
end
|
16
26
|
end
|
17
27
|
end
|
18
28
|
|
19
29
|
context 'with a print record' do
|
20
|
-
let(:record)
|
21
|
-
|
30
|
+
let(:record) { marc_record fields: [marc_field(tag: tag)] }
|
31
|
+
|
32
|
+
context 'with enrichment via the Alma publishing process' do
|
33
|
+
let(:tag) { PennMARC::EnrichedMarc::TAG_HOLDING }
|
34
|
+
|
35
|
+
it 'returns expected access value' do
|
36
|
+
expect(helper.facet(record)).to contain_exactly(PennMARC::Access::AT_THE_LIBRARY)
|
37
|
+
end
|
22
38
|
end
|
23
39
|
|
24
|
-
|
25
|
-
|
40
|
+
context 'with enrichment with availability info via the Alma API' do
|
41
|
+
let(:tag) { PennMARC::Access::PHYS_AVAILABILITY_TAG }
|
42
|
+
|
43
|
+
it 'returns expected access value' do
|
44
|
+
expect(helper.facet(record)).to contain_exactly(PennMARC::Access::AT_THE_LIBRARY)
|
45
|
+
end
|
26
46
|
end
|
27
47
|
end
|
28
48
|
|
29
49
|
context 'with a record containing a link to a finding aid (as a handle link)' do
|
30
50
|
let(:record) do
|
31
|
-
marc_record fields: [marc_field(tag:
|
51
|
+
marc_record fields: [marc_field(tag: PennMARC::EnrichedMarc::TAG_HOLDING),
|
32
52
|
marc_field(tag: '856', subfields: location_and_access_subfields, **indicators)]
|
33
53
|
end
|
34
54
|
|