pennmarc 1.0.5 → 1.0.6

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: 9aa7e5cf7ade86fc51db4d35791eed5e3e38784e35d33bd9b82379a91ab3786e
4
- data.tar.gz: 8b2668fbfd1fc645b203e23f12cfe5681014a870fa504f45c7c0b034682be325
3
+ metadata.gz: cb8a665310aaf17d406fcfbfe562894a71f17d35b2d63173ca587a9c0e343b54
4
+ data.tar.gz: 671549b45eb522db5f4350aa0743bcd16585398c6c07f71e2d2a772367a0f33c
5
5
  SHA512:
6
- metadata.gz: aff6902488cb0d85bee32f3a3c5f4b613c8c5867ab3b594af40dad4c54e501b735b79fbed1ba8656c1144b87b58a9edc6e0ed961cc62603c7ccefb0c244b3117
7
- data.tar.gz: e262a56ed0512de8c93c4ef0f94f87c322904d44ed845a64b9eb8dc58c8c3cc9c62675d52e314c5cd15eba0d7f4daea4725675af0c3e96ac7cb501a55074edf7
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 primarily on the "enhanced MARC" fields added by Alma, determine if the record has
11
- # electronic access or has physical holding, and is therefore "Online" or "At the library". If a record is "At the
12
- # library", but has a link to a finding aid in the 856 field (matching certain criteria), also add 'Online' as an
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.tag == EnrichedMarc::TAG_HOLDING
21
- next ONLINE if field.tag == EnrichedMarc::TAG_ELECTRONIC_INVENTORY
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PennMARC
4
- VERSION = '1.0.5'
4
+ VERSION = '1.0.6'
5
5
  end
@@ -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) do
11
- marc_record fields: [marc_field(tag: 'prt')]
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
- it 'returns expected access value' do
15
- expect(helper.facet(record)).to contain_exactly(PennMARC::Access::ONLINE)
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) do
21
- marc_record fields: [marc_field(tag: 'hld')]
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
- it 'returns expected access value' do
25
- expect(helper.facet(record)).to contain_exactly(PennMARC::Access::AT_THE_LIBRARY)
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: 'hld'),
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
 
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.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Kanning