pennmarc 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +32 -8
- data/Gemfile.lock +3 -0
- data/README.md +2 -2
- data/lib/pennmarc/helpers/format.rb +2 -2
- data/lib/pennmarc/helpers/identifier.rb +75 -25
- data/lib/pennmarc/helpers/note.rb +0 -2
- data/lib/pennmarc/helpers/series.rb +1 -2
- data/lib/pennmarc/helpers/subject.rb +2 -1
- data/lib/pennmarc/helpers/title.rb +1 -1
- data/lib/pennmarc/version.rb +5 -0
- data/pennmarc.gemspec +5 -1
- data/spec/lib/pennmarc/helpers/identifer_spec.rb +60 -15
- data/spec/lib/pennmarc/helpers/series_spec.rb +4 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28dc70104803899434767b340182cb8eecff8c402cfb5e8547058d560a45a1e5
|
4
|
+
data.tar.gz: 1fc0897f12ffb24de8bc0f40b69474d29264c036e33ba4ea97390b60a9f60c43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c82d8a22f480a768a8f6cce3cb7bc2ed25f7d5b202e3b492ac572a6f5bfec0d801098e1d74db8eb470573a2afbdd9314a90e18955a576c9ff5dee42aa2fbc5cd
|
7
|
+
data.tar.gz: d3c69ce76e13c50b0f2da649ea9499dcb93a734944d298cb783e71e0c4bc59c76fad0ea344353124f024524d11b5f8c92318771d780848506d50940f483c427b
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,11 +1,35 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 10000`
|
3
|
-
# on 2023-08-
|
3
|
+
# on 2023-08-25 13:55:25 UTC using RuboCop version 1.51.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
+
# Offense count: 2
|
10
|
+
# This cop supports safe autocorrection (--autocorrect).
|
11
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
12
|
+
# SupportedStyles: with_first_argument, with_fixed_indentation
|
13
|
+
Layout/ArgumentAlignment:
|
14
|
+
Exclude:
|
15
|
+
- 'spec/lib/pennmarc/helpers/series_spec.rb'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# This cop supports safe autocorrection (--autocorrect).
|
19
|
+
# Configuration parameters: EnforcedStyle.
|
20
|
+
# SupportedStyles: empty_lines, no_empty_lines
|
21
|
+
Layout/EmptyLinesAroundBlockBody:
|
22
|
+
Exclude:
|
23
|
+
- 'spec/lib/pennmarc/helpers/identifer_spec.rb'
|
24
|
+
|
25
|
+
# Offense count: 1
|
26
|
+
# This cop supports safe autocorrection (--autocorrect).
|
27
|
+
# Configuration parameters: EnforcedStyle.
|
28
|
+
# SupportedStyles: final_newline, final_blank_line
|
29
|
+
Layout/TrailingEmptyLines:
|
30
|
+
Exclude:
|
31
|
+
- 'spec/lib/pennmarc/helpers/identifer_spec.rb'
|
32
|
+
|
9
33
|
# Offense count: 22
|
10
34
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
11
35
|
Metrics/AbcSize:
|
@@ -86,7 +110,7 @@ Metrics/PerceivedComplexity:
|
|
86
110
|
- 'lib/pennmarc/helpers/title.rb'
|
87
111
|
- 'lib/pennmarc/util.rb'
|
88
112
|
|
89
|
-
# Offense count:
|
113
|
+
# Offense count: 4
|
90
114
|
# This cop supports safe autocorrection (--autocorrect).
|
91
115
|
# Configuration parameters: EnforcedStyle, BlockForwardingName.
|
92
116
|
# SupportedStyles: anonymous, explicit
|
@@ -104,7 +128,7 @@ Naming/PredicateName:
|
|
104
128
|
Exclude:
|
105
129
|
- 'lib/pennmarc/helpers/relation.rb'
|
106
130
|
|
107
|
-
# Offense count:
|
131
|
+
# Offense count: 1
|
108
132
|
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
|
109
133
|
# SupportedStyles: snake_case, normalcase, non_integer
|
110
134
|
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
|
@@ -135,9 +159,9 @@ RSpec/NestedGroups:
|
|
135
159
|
- 'spec/lib/pennmarc/helpers/format_spec.rb'
|
136
160
|
|
137
161
|
# Offense count: 2
|
138
|
-
# This cop supports
|
139
|
-
# Configuration parameters:
|
140
|
-
#
|
141
|
-
|
162
|
+
# This cop supports safe autocorrection (--autocorrect).
|
163
|
+
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
164
|
+
# URISchemes: http, https
|
165
|
+
Layout/LineLength:
|
142
166
|
Exclude:
|
143
|
-
- 'lib/pennmarc/helpers/
|
167
|
+
- 'spec/lib/pennmarc/helpers/creator_spec.rb'
|
data/Gemfile.lock
CHANGED
@@ -21,6 +21,8 @@ GEM
|
|
21
21
|
minitest (5.18.0)
|
22
22
|
nokogiri (1.15.2-arm64-darwin)
|
23
23
|
racc (~> 1.4)
|
24
|
+
nokogiri (1.15.2-x64-mingw-ucrt)
|
25
|
+
racc (~> 1.4)
|
24
26
|
nokogiri (1.15.2-x86_64-linux)
|
25
27
|
racc (~> 1.4)
|
26
28
|
parallel (1.23.0)
|
@@ -101,6 +103,7 @@ GEM
|
|
101
103
|
PLATFORMS
|
102
104
|
arm64-darwin-21
|
103
105
|
arm64-darwin-22
|
106
|
+
x64-mingw-ucrt
|
104
107
|
x86_64-linux
|
105
108
|
|
106
109
|
DEPENDENCIES
|
data/README.md
CHANGED
@@ -73,7 +73,7 @@ rspec
|
|
73
73
|
|
74
74
|
1. Update the version in `pennmarc.gemspec`
|
75
75
|
2. Run `gem build pennmarc.gemspec` with the latest code
|
76
|
-
3. Run `gem push pennmarc-{version number here}`(e.g. `gem push pennmarc-1.0.0`) to push to RubyGems. You will need access and MFA setup with RubyGems.
|
76
|
+
3. Run `gem push pennmarc-{version number here}.gem`(e.g. `gem push pennmarc-1.0.0.gem`) to push to RubyGems. You will need access and MFA setup with RubyGems.
|
77
77
|
|
78
78
|
## QA
|
79
79
|
|
@@ -89,4 +89,4 @@ MARC_FILE=path/to/marc.xml bundle exec rake pennmarc:parse
|
|
89
89
|
- rake task or some similar command to return a full set of values extracted from a specified marcxml file
|
90
90
|
- Pipeline to run tests and publish to Rubygems
|
91
91
|
- rubocop check
|
92
|
-
- rdoc/yard coverage checks?
|
92
|
+
- rdoc/yard coverage checks?
|
@@ -41,10 +41,10 @@ module PennMARC
|
|
41
41
|
results += record.fields('880').map do |f|
|
42
42
|
subfield_to_ignore = if subfield_value?(f, 6, /^300/)
|
43
43
|
%w[3 6 8]
|
44
|
-
elsif subfield_value?(f, 6, /^(254|255|310|342|352|362)/)
|
45
|
-
%w[6 8]
|
46
44
|
elsif subfield_value?(f, 6, /^340/)
|
47
45
|
%w[0 2 6 8]
|
46
|
+
else
|
47
|
+
%w[6 8]
|
48
48
|
end
|
49
49
|
join_subfields(f, &subfield_not_in?(subfield_to_ignore))
|
50
50
|
end
|
@@ -23,7 +23,7 @@ module PennMARC
|
|
23
23
|
if field.tag == '020'
|
24
24
|
field.filter_map { |subfield| normalize_isbn(subfield.value) if subfield_in?(%w[a z]).call(subfield) }
|
25
25
|
else
|
26
|
-
field.filter_map { |subfield| subfield.value if subfield_in?(%w[a l z]).call(subfield) }
|
26
|
+
field.filter_map { |subfield| subfield.value if subfield_in?(%w[a l m y z]).call(subfield) }
|
27
27
|
end
|
28
28
|
}.flatten.uniq
|
29
29
|
end
|
@@ -33,14 +33,12 @@ module PennMARC
|
|
33
33
|
#
|
34
34
|
# @param [MARC::Record] record
|
35
35
|
# @return [Array<String>]
|
36
|
-
# @todo look into z subfield for 020 field, should we show cancelled isbn?
|
37
36
|
def isbn_show(record)
|
38
37
|
isbn_values = record.fields('020').filter_map do |field|
|
39
|
-
joined_isbn = join_subfields(field, &subfield_in?(%w[a
|
38
|
+
joined_isbn = join_subfields(field, &subfield_in?(%w[a]))
|
40
39
|
joined_isbn.presence
|
41
40
|
end
|
42
|
-
isbn_values
|
43
|
-
isbn_values
|
41
|
+
isbn_values + linked_alternate(record, '020', &subfield_in?(%w[a]))
|
44
42
|
end
|
45
43
|
|
46
44
|
# Get ISSN values for display from the {https://www.oclc.org/bibformats/en/0xx/022.html 022 field} and related
|
@@ -50,30 +48,50 @@ module PennMARC
|
|
50
48
|
# @return [Array<String>]
|
51
49
|
def issn_show(record)
|
52
50
|
issn_values = record.fields('022').filter_map do |field|
|
53
|
-
joined_issn = join_subfields(field, &subfield_in?(%w[a
|
51
|
+
joined_issn = join_subfields(field, &subfield_in?(%w[a]))
|
54
52
|
joined_issn.presence
|
55
53
|
end
|
56
|
-
issn_values
|
57
|
-
issn_values
|
54
|
+
issn_values + linked_alternate(record, '022', &subfield_in?(%w[a]))
|
58
55
|
end
|
59
56
|
|
60
57
|
# Get numeric OCLC ID of first {https://www.oclc.org/bibformats/en/0xx/035.html 035 field}
|
61
58
|
# with an OCLC ID defined in subfield 'a'.
|
62
|
-
#
|
63
|
-
# @todo We should evaluate this to return a single value in the future since subfield a is non-repeatable
|
64
59
|
# @param [MARC::Record] record
|
65
|
-
# @return [
|
66
|
-
def
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
oclc_id.flat_map do |field|
|
60
|
+
# @return [String, nil]
|
61
|
+
def oclc_id_show(record)
|
62
|
+
ids = Array.wrap(record.fields('035')
|
63
|
+
.find { |field| field.any? { |subfield| subfield_a_is_oclc?(subfield) } })
|
64
|
+
ids.flat_map { |field|
|
71
65
|
field.filter_map do |subfield|
|
72
66
|
# skip unless subfield 'a' is an oclc id value
|
73
67
|
next unless subfield_a_is_oclc?(subfield)
|
74
68
|
|
75
69
|
# search for numeric part of oclc id (e.g. '610094484' in '(OCoLC)ocn610094484')
|
76
|
-
match =
|
70
|
+
match = match_oclc_number(subfield)
|
71
|
+
|
72
|
+
# skip unless search to find numeric part of oclc id has a match
|
73
|
+
next unless match
|
74
|
+
|
75
|
+
match[1]
|
76
|
+
end
|
77
|
+
}.first
|
78
|
+
end
|
79
|
+
|
80
|
+
# Retrieve valid and invalid numeric OCLC IDs from {https://www.oclc.org/bibformats/en/0xx/035.html 035 field}
|
81
|
+
# for search.
|
82
|
+
# @param [MARC::Record] record
|
83
|
+
# @return [Array<String>]
|
84
|
+
def oclc_id_search(record)
|
85
|
+
record.fields('035').flat_map do |field|
|
86
|
+
field.filter_map do |subfield|
|
87
|
+
# skip unless subfield 'a' or 'z'
|
88
|
+
next unless subfield.code.in?(%w[a z])
|
89
|
+
|
90
|
+
# skip unless subfield value matches OCLC ID
|
91
|
+
next unless subfield_is_oclc?(subfield)
|
92
|
+
|
93
|
+
# search for numeric part of oclc id
|
94
|
+
match = match_oclc_number(subfield)
|
77
95
|
|
78
96
|
# skip unless search to find numeric part of oclc id has a match
|
79
97
|
next unless match
|
@@ -85,17 +103,22 @@ module PennMARC
|
|
85
103
|
|
86
104
|
# Get publisher issued identifiers from fields {https://www.oclc.org/bibformats/en/0xx/024.html 024},
|
87
105
|
# {https://www.oclc.org/bibformats/en/0xx/024.html 028}, and related
|
88
|
-
# {https://www.oclc.org/bibformats/en/8xx/880.html 880 field}.
|
106
|
+
# {https://www.oclc.org/bibformats/en/8xx/880.html 880 field}. We do not return DOI values stored in 024 ǂ2,
|
107
|
+
# see {PennMARC::Identifier.doi_show} for parsing DOI values.
|
89
108
|
#
|
90
109
|
# @param [MARC::Record] record
|
91
110
|
# @return [Array<string>]
|
92
111
|
def publisher_number_show(record)
|
93
|
-
|
94
|
-
|
95
|
-
|
112
|
+
record.fields(%w[024 028 880]).filter_map do |field|
|
113
|
+
next if field.tag == '880' && subfield_value_not_in?(field, '6', %w[024 028])
|
114
|
+
|
115
|
+
# do not return doi values from 024 ǂ2
|
116
|
+
if field.tag == '024' && subfield_value_in?(field, '2', %w[doi])
|
117
|
+
join_subfields(field, &subfield_not_in?(%w[a 2 5 6])).presence
|
118
|
+
else
|
119
|
+
join_subfields(field, &subfield_not_in?(%w[5 6])).presence
|
120
|
+
end
|
96
121
|
end
|
97
|
-
publisher_numbers += linked_alternate(record, %w[024 028], &subfield_not_in?(%w[5 6]))
|
98
|
-
publisher_numbers
|
99
122
|
end
|
100
123
|
|
101
124
|
# Get publisher issued identifiers for searching of a record. Values extracted from fields
|
@@ -119,6 +142,21 @@ module PennMARC
|
|
119
142
|
end
|
120
143
|
end
|
121
144
|
|
145
|
+
# Retrieve DOI values stored in {https://www.oclc.org/bibformats/en/0xx/024.html 024}.
|
146
|
+
# Penn MARC records give the first indicator a value of '7' and ǂ2 a value of 'doi' to denote that ǂa is a doi.
|
147
|
+
# @param [MARC::Record] record
|
148
|
+
# @return [Array<String>]
|
149
|
+
def doi_show(record)
|
150
|
+
record.fields('024').filter_map do |field|
|
151
|
+
# skip unless indicator1 is '7'
|
152
|
+
next unless field.indicator1.in?(%w[7])
|
153
|
+
# skip unless ǂ2 is the string literal 'doi'
|
154
|
+
next unless subfield_value_in?(field, '2', %w[doi])
|
155
|
+
|
156
|
+
join_subfields(field, &subfield_in?(%w[a]))
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
122
160
|
private
|
123
161
|
|
124
162
|
# Determine if subfield 'a' is an OCLC id.
|
@@ -126,11 +164,23 @@ module PennMARC
|
|
126
164
|
# @param [MARC::Subfield]
|
127
165
|
# @return [TrueClass, FalseClass]
|
128
166
|
def subfield_a_is_oclc?(subfield)
|
129
|
-
subfield.code == 'a' && subfield
|
167
|
+
subfield.code == 'a' && subfield_is_oclc?(subfield)
|
168
|
+
end
|
169
|
+
|
170
|
+
# @param [MARC::Subfield]
|
171
|
+
# @return [TrueClass, FalseClass]
|
172
|
+
def subfield_is_oclc?(subfield)
|
173
|
+
(subfield.value =~ /^\(OCoLC\).*/).present?
|
174
|
+
end
|
175
|
+
|
176
|
+
# @param [MARC::Subfield]
|
177
|
+
# @return [MatchData, nil]
|
178
|
+
def match_oclc_number(subfield)
|
179
|
+
/^\s*\(OCoLC\)[^1-9]*([1-9][0-9]*).*$/.match(subfield.value)
|
130
180
|
end
|
131
181
|
|
132
182
|
# Normalize isbn value using {https://github.com/billdueber/library_stdnums library_stdnums gem}.
|
133
|
-
# Converts ISBN10 (ten-digit) to validated ISBN13 (
|
183
|
+
# Converts ISBN10 (ten-digit) to validated ISBN13 (thirteen-digit) and returns both values. If passed
|
134
184
|
# ISBN13 parameter, only returns validated ISBN13 value.
|
135
185
|
#
|
136
186
|
# @param [String] isbn
|
@@ -11,8 +11,6 @@ module PennMARC
|
|
11
11
|
# {https://www.oclc.org/bibformats/en/5xx/550.html 550}, {https://www.oclc.org/bibformats/en/5xx/580.html 580},
|
12
12
|
# {https://www.oclc.org/bibformats/en/5xx/586.html 586}, {https://www.oclc.org/bibformats/en/5xx/588.html 588},
|
13
13
|
# and their linked alternates.
|
14
|
-
# @todo legacy implementation used conditional to separate join logic for 588 field. However, this doesn't seem
|
15
|
-
# necessary because 588 only has subfields 'a', '5', '6', and '8'. Do we need to look into this?
|
16
14
|
# @param [MARC::Record] record
|
17
15
|
# @return [Array<String>]
|
18
16
|
def notes_show(record)
|
@@ -4,7 +4,6 @@ module PennMARC
|
|
4
4
|
# Do Series and series-related field processing. Many of these fields are added entries that are justified by
|
5
5
|
# corresponding series statements (usually 490). These fields provide information about the published series in which
|
6
6
|
# a book, encoded finding aid, or other published work has appeared
|
7
|
-
# @todo We may want to include 410 in the display tags, since it is included in references below.
|
8
7
|
class Series < Helper
|
9
8
|
class << self
|
10
9
|
# 800 - Series Added Entry-Personal Name - https://www.loc.gov/marc/bibliographic/bd800.html
|
@@ -16,7 +15,7 @@ module PennMARC
|
|
16
15
|
# 411 - Series Statement/Added Entry Meeting Name - https://www.loc.gov/marc/bibliographic/bd411.html
|
17
16
|
# 440 - Series Statement/Added Entry-Title - https://www.loc.gov/marc/bibliographic/bd440.html
|
18
17
|
# 490 - Series Statement - https://www.loc.gov/marc/bibliographic/bd490.html
|
19
|
-
DISPLAY_TAGS = %w[800 810 811 830 400 411 440 490].freeze
|
18
|
+
DISPLAY_TAGS = %w[800 810 811 830 400 410 411 440 490].freeze
|
20
19
|
|
21
20
|
# Fields for display that pertain to series information.
|
22
21
|
# @param [MARC::Record] record
|
@@ -168,7 +168,8 @@ module PennMARC
|
|
168
168
|
def format_term(type:, term:)
|
169
169
|
return unless type.in? %i[facet display]
|
170
170
|
|
171
|
-
|
171
|
+
# attempt to handle poorly coded record
|
172
|
+
normalize_single_subfield(term[:parts].first) if term[:count] == 1 && term[:parts].first.present?
|
172
173
|
|
173
174
|
case type.to_sym
|
174
175
|
when :facet
|
@@ -89,7 +89,7 @@ module PennMARC
|
|
89
89
|
end
|
90
90
|
raw_title = join_subfields(title_field, &subfield_in?(['a'])) # get title from subfield a
|
91
91
|
value = if offset.between?(1, 9)
|
92
|
-
{ prefix: raw_title[0..offset - 1]
|
92
|
+
{ prefix: raw_title[0..offset - 1]&.strip, filing: raw_title[offset..]&.strip }
|
93
93
|
elsif raw_title.present?
|
94
94
|
handle_bracket_prefix raw_title
|
95
95
|
else
|
data/pennmarc.gemspec
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'pennmarc/version'
|
6
|
+
|
3
7
|
Gem::Specification.new do |s|
|
4
8
|
s.name = 'pennmarc'
|
5
|
-
s.version =
|
9
|
+
s.version = PennMARC::VERSION
|
6
10
|
s.summary = 'Penn Libraries Catalog MARC parsing wisdom for cross-project usage'
|
7
11
|
s.description = 'This gem provides methods for parsing a Penn Libraries MARCXML record into string, array and date
|
8
12
|
objects for use in discovery or preservation applications.'
|
@@ -16,13 +16,16 @@ describe 'PennMARC::Identifier' do
|
|
16
16
|
describe '.isxn_search' do
|
17
17
|
let(:record) do
|
18
18
|
marc_record fields: [
|
19
|
-
marc_field(tag: '020', subfields: { a: '9781594205071', z: '
|
20
|
-
marc_field(tag: '022',
|
19
|
+
marc_field(tag: '020', subfields: { a: '9781594205071', z: '1555975275' }),
|
20
|
+
marc_field(tag: '022',
|
21
|
+
subfields: { a: '0008-6533', l: '0300-7162', m: 'cancelled', y: 'incorrect', z: '0799-5946' })
|
21
22
|
]
|
22
23
|
end
|
23
24
|
|
24
25
|
it 'returns expected search values' do
|
25
|
-
expect(helper.isxn_search(record)).to contain_exactly('9781594205071', '
|
26
|
+
expect(helper.isxn_search(record)).to contain_exactly('9781594205071', '1555975275', '9781555975272',
|
27
|
+
'1594205078', '0300-7162', '0008-6533', '0799-5946',
|
28
|
+
'cancelled', 'incorrect')
|
26
29
|
end
|
27
30
|
|
28
31
|
it 'converts ISBN10 values to ISBN13' do
|
@@ -40,9 +43,9 @@ describe 'PennMARC::Identifier' do
|
|
40
43
|
]
|
41
44
|
end
|
42
45
|
|
43
|
-
it 'returns expected
|
44
|
-
expect(helper.isbn_show(record)).to contain_exactly('9781594205071
|
45
|
-
'0735222789
|
46
|
+
it 'returns expected ǂa values' do
|
47
|
+
expect(helper.isbn_show(record)).to contain_exactly('9781594205071', '0805073698',
|
48
|
+
'0735222789')
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
@@ -55,13 +58,13 @@ describe 'PennMARC::Identifier' do
|
|
55
58
|
]
|
56
59
|
end
|
57
60
|
|
58
|
-
it 'returns
|
59
|
-
expect(helper.issn_show(record)).to contain_exactly('0008-6533
|
60
|
-
'1080-6512
|
61
|
+
it 'returns ǂa values' do
|
62
|
+
expect(helper.issn_show(record)).to contain_exactly('0008-6533', '2470-6302',
|
63
|
+
'1080-6512')
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
64
|
-
describe '.
|
67
|
+
describe '.oclc_id_show' do
|
65
68
|
let(:record) do
|
66
69
|
marc_record fields: [
|
67
70
|
marc_field(tag: '035', subfields: { a: '(PU)4422776-penndb-Voyager' }),
|
@@ -71,7 +74,21 @@ describe 'PennMARC::Identifier' do
|
|
71
74
|
end
|
72
75
|
|
73
76
|
it 'returns expected show values' do
|
74
|
-
expect(helper.
|
77
|
+
expect(helper.oclc_id_show(record)).to eq '610094484'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '.oclc_id_search' do
|
82
|
+
let(:record) do
|
83
|
+
marc_record fields: [
|
84
|
+
marc_field(tag: '035', subfields: { a: '(PU)4422776-penndb-Voyager' }),
|
85
|
+
marc_field(tag: '035', subfields: { z: '(OCoLC)ocn610094484' }),
|
86
|
+
marc_field(tag: '035', subfields: { a: '(OCoLC)ocn1483169584' })
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'returns expected search values' do
|
91
|
+
expect(helper.oclc_id_search(record)).to contain_exactly('610094484', '1483169584')
|
75
92
|
end
|
76
93
|
end
|
77
94
|
|
@@ -79,9 +96,11 @@ describe 'PennMARC::Identifier' do
|
|
79
96
|
let(:record) do
|
80
97
|
marc_record fields: [
|
81
98
|
marc_field(tag: '024', subfields: { a: '602537854325', '6': '880-01' }),
|
99
|
+
marc_field(tag: '024', subfields: { a: '10.18574/9781479842865', '2': 'doi' }),
|
82
100
|
marc_field(tag: '028', subfields: { a: 'B002086600', b: 'Island Def Jam Music Group', '6': '880-01' }),
|
83
101
|
marc_field(tag: '880', subfields: { a: '523458735206', '6': '024' }),
|
84
|
-
marc_field(tag: '880', subfields: { a: '006680200B', b: 'Island', '6': '028' })
|
102
|
+
marc_field(tag: '880', subfields: { a: '006680200B', b: 'Island', '6': '028' }),
|
103
|
+
marc_field(tag: '880', subfields: { a: '006680200B', b: 'Island', '6': '021' })
|
85
104
|
]
|
86
105
|
end
|
87
106
|
|
@@ -90,18 +109,26 @@ describe 'PennMARC::Identifier' do
|
|
90
109
|
'B002086600 Island Def Jam Music Group',
|
91
110
|
'523458735206', '006680200B Island')
|
92
111
|
end
|
112
|
+
|
113
|
+
it 'does not return DOI values' do
|
114
|
+
expect(helper.publisher_number_show(record)).not_to include('10.18574/9781479842865')
|
115
|
+
expect(helper.publisher_number_show(record)).not_to include('doi')
|
116
|
+
|
117
|
+
end
|
93
118
|
end
|
94
119
|
|
95
120
|
describe '.publisher_number_search' do
|
96
121
|
let(:record) do
|
97
122
|
marc_record fields: [
|
98
|
-
marc_field(tag: '024', subfields: { a: '602537854325' }),
|
123
|
+
marc_field(tag: '024', subfields: { a: '602537854325', b: 'exclude' }),
|
124
|
+
marc_field(tag: '024', subfields: { a: '10.18574/9781479842865', '2': 'doi' }),
|
99
125
|
marc_field(tag: '028', subfields: { a: 'B002086600', b: 'Island Def Jam Music Group' })
|
100
126
|
]
|
101
127
|
end
|
102
128
|
|
103
|
-
it 'returns
|
104
|
-
expect(helper.publisher_number_search(record)).to contain_exactly('
|
129
|
+
it 'returns publisher numbers from 024/028 ǂa and DOI values in 024 ǂ2' do
|
130
|
+
expect(helper.publisher_number_search(record)).to contain_exactly('10.18574/9781479842865', '602537854325',
|
131
|
+
'B002086600')
|
105
132
|
end
|
106
133
|
end
|
107
134
|
|
@@ -117,4 +144,22 @@ describe 'PennMARC::Identifier' do
|
|
117
144
|
expect(helper.fingerprint_show(record)).to contain_exactly('dete nkck vess lodo Anno Domini MDCXXXVI 3')
|
118
145
|
end
|
119
146
|
end
|
147
|
+
|
148
|
+
describe '.doi_show' do
|
149
|
+
let(:record) do
|
150
|
+
marc_record fields: [
|
151
|
+
marc_field(tag: '024', indicator1: '7', subfields: { a: '10.1038/sdata.2016.18 ', '2': 'doi' }),
|
152
|
+
marc_field(tag: '024', indicator1: '7', subfields: { a: '10.18574/9781479842865', '2': 'doi' }),
|
153
|
+
marc_field(tag: '024', indicator1: '7',
|
154
|
+
subfields: { a: '10.1016.12.31/nature.S0735-1097(98)2000/12?/31/34:7-7', '2': 'doi' }),
|
155
|
+
marc_field(tag: '024', indicator1: '7', subfields: { a: 'excluded', '2': 'non doi' }),
|
156
|
+
marc_field(tag: '024', indicator1: '0', subfields: { a: 'excluded', '2': 'doi' })
|
157
|
+
]
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'returns valid DOI values' do
|
161
|
+
expect(helper.doi_show(record)).to contain_exactly('10.1016.12.31/nature.S0735-1097(98)2000/12?/31/34:7-7',
|
162
|
+
'10.1038/sdata.2016.18', '10.18574/9781479842865')
|
163
|
+
end
|
164
|
+
end
|
120
165
|
end
|
@@ -6,7 +6,8 @@ describe 'PennMARC::Series' do
|
|
6
6
|
let(:helper) { PennMARC::Series }
|
7
7
|
let(:mapping) { { aut: 'Author' } }
|
8
8
|
let(:record) do
|
9
|
-
marc_record fields: [marc_field(tag: '
|
9
|
+
marc_record fields: [marc_field(tag: '410', subfields: { a: 'Evil Giant Megacorp' }),
|
10
|
+
marc_field(tag: '490', subfields: { a: 'Teachings of the feathered pillow' }),
|
10
11
|
marc_field(tag: '880', subfields: { '6': '490', a: 'Учения пернатой подушки' }),
|
11
12
|
marc_field(tag: '800', subfields: { a: 'Bean Bagatolvski', d: '1997-', v: 'bk. 1' }),
|
12
13
|
marc_field(tag: '780', subfields: { a: 'National Comfort Association' }),
|
@@ -20,7 +21,7 @@ describe 'PennMARC::Series' do
|
|
20
21
|
it 'returns the series' do
|
21
22
|
expect(helper.show(record, relator_map: mapping)).to contain_exactly('Bean Bagatolvski 1997- bk. 1',
|
22
23
|
'Teachings of the feathered pillow',
|
23
|
-
'Учения пернатой подушки')
|
24
|
+
'Учения пернатой подушки', 'Evil Giant Megacorp')
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
@@ -32,7 +33,7 @@ describe 'PennMARC::Series' do
|
|
32
33
|
|
33
34
|
describe '.search' do
|
34
35
|
it 'returns the search values' do
|
35
|
-
expect(helper.search(record)).to contain_exactly('Bean Bagatolvski 1997- bk. 1')
|
36
|
+
expect(helper.search(record)).to contain_exactly('Bean Bagatolvski 1997- bk. 1', 'Evil Giant Megacorp')
|
36
37
|
end
|
37
38
|
|
38
39
|
it 'returns an empty array if no values are found' do
|
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.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Kanning
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-10-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/pennmarc/mappings/relator.yml
|
113
113
|
- lib/pennmarc/parser.rb
|
114
114
|
- lib/pennmarc/util.rb
|
115
|
+
- lib/pennmarc/version.rb
|
115
116
|
- pennmarc.gemspec
|
116
117
|
- spec/fixtures/marcxml/test.xml
|
117
118
|
- spec/lib/pennmarc/helpers/citation_spec.rb
|