pennmarc 1.2.18 → 1.2.19
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: 000b00c70e9c8d7e21a755f490a167aab853654d6c709cf53081607e9053ead2
|
4
|
+
data.tar.gz: 17fcc4f50b4fd28843e318e63a152759fec88d0efc4b3ccb8af2aabfb8ab7e1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '009d28e75c876d7d83d2a3834d494cb24eee0ce00ef6d172ce1f16e858af2aba23f0c65837a46907a2ae3c3d71237711789553604614a9a470fae79fae47e0a2'
|
7
|
+
data.tar.gz: 38a430b6eb4bbbdad006d57175dce8c830ef3cf0e1a3732a096e313bb08803e3b178e023fe7da2e5be84ee1a420bd28b527e77583cfed41420034e86acc4210d
|
@@ -1,11 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# MARC encoding level
|
4
|
-
# See
|
5
|
-
# Not sure how this is used
|
3
|
+
# MARC {https://www.oclc.org/bibformats/en/fixedfield/elvl.html encoding level values} and a means of ranking them.
|
4
|
+
# See the `EncodingRank` helper for usage.
|
6
5
|
module PennMARC
|
7
6
|
module EncodingLevel
|
8
|
-
#
|
7
|
+
# {https://www.loc.gov/marc/bibliographic/bdleader.html Official MARC codes}
|
9
8
|
FULL = ' '
|
10
9
|
FULL_NOT_EXAMINED = '1'
|
11
10
|
UNFULL_NOT_EXAMINED = '2'
|
@@ -17,7 +16,8 @@ module PennMARC
|
|
17
16
|
UNKNOWN = 'u'
|
18
17
|
NOT_APPLICABLE = 'z'
|
19
18
|
|
20
|
-
#
|
19
|
+
# {https://www.oclc.org/bibformats/en/fixedfield/elvl.html OCLC extension codes}. These are deprecated but still
|
20
|
+
# found in our records.
|
21
21
|
OCLC_FULL = 'I'
|
22
22
|
OCLC_MINIMAL = 'K'
|
23
23
|
OCLC_BATCH_LEGACY = 'L'
|
@@ -27,9 +27,9 @@ module PennMARC
|
|
27
27
|
RANK = {
|
28
28
|
# top 4 (per nelsonrr), do not differentiate among "good" records
|
29
29
|
FULL => 0,
|
30
|
-
FULL_NOT_EXAMINED => 0,
|
31
|
-
OCLC_FULL => 0,
|
32
|
-
CORE => 0,
|
30
|
+
FULL_NOT_EXAMINED => 0,
|
31
|
+
OCLC_FULL => 0,
|
32
|
+
CORE => 0,
|
33
33
|
UNFULL_NOT_EXAMINED => 4,
|
34
34
|
ABBREVIATED => 5,
|
35
35
|
PRELIMINARY => 6,
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PennMARC
|
4
|
+
# Extract encoding level and provide an opinionated rating of the encoding level
|
5
|
+
class EncodingRank < Helper
|
6
|
+
class << self
|
7
|
+
LEADER_POSITION = 17
|
8
|
+
|
9
|
+
# Return a value corresponding to the {https://www.oclc.org/bibformats/en/fixedfield/elvl.html encoding level}
|
10
|
+
# from the MARC leader. Lower numbers indicate a higher level of description. See {PennMARC::EncodingLevel} for
|
11
|
+
# hash that determines the ranking. We still consider some "legacy" OCLC non-numeric codes here, though they are
|
12
|
+
# no longer recommended for use by OCLC. If an invalid value is found, nil is returned.
|
13
|
+
# @param [MARC::Record] record
|
14
|
+
# @return [Integer, nil]
|
15
|
+
def sort(record:)
|
16
|
+
EncodingLevel::RANK[
|
17
|
+
record.leader[LEADER_POSITION]
|
18
|
+
]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/pennmarc/version.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'PennMARC::EncodingRank' do
|
4
|
+
let(:helper) { PennMARC::EncodingRank }
|
5
|
+
|
6
|
+
describe '.sort' do
|
7
|
+
let(:record) { marc_record leader: leader }
|
8
|
+
let(:result) { helper.sort record: record }
|
9
|
+
let(:leader) { " #{level} " }
|
10
|
+
|
11
|
+
context 'with an empty value' do
|
12
|
+
let(:level) { PennMARC::EncodingLevel::FULL }
|
13
|
+
|
14
|
+
it 'returns 0' do
|
15
|
+
expect(result).to eq 0
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'with an official MARC code present' do
|
20
|
+
let(:level) { PennMARC::EncodingLevel::MINIMAL }
|
21
|
+
|
22
|
+
it 'returns 7' do
|
23
|
+
expect(result).to eq 7
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'with an OCLC extension code' do
|
28
|
+
let(:level) { PennMARC::EncodingLevel::OCLC_BATCH }
|
29
|
+
|
30
|
+
it 'returns 9' do
|
31
|
+
expect(result).to eq 9
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with an unhandled value' do
|
36
|
+
let(:level) { 'T' }
|
37
|
+
|
38
|
+
it 'returns nil' do
|
39
|
+
expect(result).to be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
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.2.
|
4
|
+
version: 1.2.19
|
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-06-
|
15
|
+
date: 2025-06-05 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activesupport
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/pennmarc/helpers/database.rb
|
115
115
|
- lib/pennmarc/helpers/date.rb
|
116
116
|
- lib/pennmarc/helpers/edition.rb
|
117
|
+
- lib/pennmarc/helpers/encoding_rank.rb
|
117
118
|
- lib/pennmarc/helpers/format.rb
|
118
119
|
- lib/pennmarc/helpers/genre.rb
|
119
120
|
- lib/pennmarc/helpers/helper.rb
|
@@ -155,6 +156,7 @@ files:
|
|
155
156
|
- spec/lib/pennmarc/helpers/database_spec.rb
|
156
157
|
- spec/lib/pennmarc/helpers/date_spec.rb
|
157
158
|
- spec/lib/pennmarc/helpers/edition_spec.rb
|
159
|
+
- spec/lib/pennmarc/helpers/encoding_rank_spec.rb
|
158
160
|
- spec/lib/pennmarc/helpers/format_spec.rb
|
159
161
|
- spec/lib/pennmarc/helpers/genre_spec.rb
|
160
162
|
- spec/lib/pennmarc/helpers/identifer_spec.rb
|