pennmarc 1.0.25 → 1.0.26
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 +4 -4
- data/.rubocop_todo.yml +8 -9
- data/lib/pennmarc/helpers/creator.rb +139 -65
- data/lib/pennmarc/helpers/edition.rb +5 -3
- data/lib/pennmarc/helpers/note.rb +24 -19
- data/lib/pennmarc/helpers/production.rb +113 -20
- data/lib/pennmarc/test/marc_helpers.rb +83 -0
- data/lib/pennmarc/util.rb +98 -69
- data/lib/pennmarc/version.rb +1 -1
- data/lib/pennmarc.rb +7 -0
- data/spec/lib/pennmarc/helpers/access_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/citation_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/classification_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/creator_spec.rb +103 -2
- data/spec/lib/pennmarc/helpers/database_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/date_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/edition_spec.rb +4 -2
- data/spec/lib/pennmarc/helpers/format_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/genre_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/identifer_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/inventory_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/language_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/link_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/location_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/note_spec.rb +22 -29
- data/spec/lib/pennmarc/helpers/production_spec.rb +121 -22
- data/spec/lib/pennmarc/helpers/relation_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/series_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/subject_spec.rb +0 -2
- data/spec/lib/pennmarc/helpers/title_spec.rb +0 -2
- data/spec/lib/pennmarc/marc_util_spec.rb +0 -2
- data/spec/lib/pennmarc/parser_spec.rb +1 -1
- data/spec/spec_helper.rb +7 -0
- data/spec/support/fixture_helpers.rb +10 -0
- metadata +4 -3
- data/spec/support/marc_spec_helpers.rb +0 -85
data/spec/spec_helper.rb
CHANGED
@@ -2,8 +2,12 @@
|
|
2
2
|
|
3
3
|
$LOAD_PATH.unshift(__dir__) unless $LOAD_PATH.include?(__dir__)
|
4
4
|
|
5
|
+
# Require spec-specific helpers dir
|
5
6
|
Dir[File.join(__dir__, 'support', '**', '*.rb')].each { |f| require f }
|
6
7
|
|
8
|
+
# Require test helpers from gem lib
|
9
|
+
Dir[File.join(__dir__, '../lib/pennmarc/test', '*.rb')].each { |f| require f }
|
10
|
+
|
7
11
|
require 'pennmarc'
|
8
12
|
|
9
13
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
@@ -22,6 +26,9 @@ require 'pennmarc'
|
|
22
26
|
#
|
23
27
|
# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
24
28
|
RSpec.configure do |config|
|
29
|
+
# Include MarcHelpers by default
|
30
|
+
config.include(PennMARC::Test::MarcHelpers)
|
31
|
+
|
25
32
|
# rspec-expectations config goes here. You can use an alternate
|
26
33
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
27
34
|
# assertions if you prefer.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FixtureHelpers
|
4
|
+
# Get the path for a test MARC XML file
|
5
|
+
# @param [String] filename of MARCXML fixture
|
6
|
+
# @return [String] full path of MARCXML fixture
|
7
|
+
def marc_xml_path(filename)
|
8
|
+
File.join File.dirname(__FILE__), '..', 'fixtures', 'marcxml', filename
|
9
|
+
end
|
10
|
+
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.0.
|
4
|
+
version: 1.0.26
|
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: 2024-
|
13
|
+
date: 2024-07-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/pennmarc/mappings/locations.yml
|
124
124
|
- lib/pennmarc/mappings/relator.yml
|
125
125
|
- lib/pennmarc/parser.rb
|
126
|
+
- lib/pennmarc/test/marc_helpers.rb
|
126
127
|
- lib/pennmarc/util.rb
|
127
128
|
- lib/pennmarc/version.rb
|
128
129
|
- pennmarc.gemspec
|
@@ -150,7 +151,7 @@ files:
|
|
150
151
|
- spec/lib/pennmarc/marc_util_spec.rb
|
151
152
|
- spec/lib/pennmarc/parser_spec.rb
|
152
153
|
- spec/spec_helper.rb
|
153
|
-
- spec/support/
|
154
|
+
- spec/support/fixture_helpers.rb
|
154
155
|
homepage: https://gitlab.library.upenn.edu/dld/catalog/pennmarc
|
155
156
|
licenses:
|
156
157
|
- MIT
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'nokogiri'
|
4
|
-
require 'marc'
|
5
|
-
|
6
|
-
module MarcSpecHelpers
|
7
|
-
# Return a MARC::XMLReader that will parse a given file and return MARC::Record objects
|
8
|
-
# @param [String] filename of MARCXML fixture
|
9
|
-
# @return [MARC::Record, NilClass]
|
10
|
-
def record_from(filename)
|
11
|
-
MARC::XMLReader.new(marc_xml_path(filename)).first
|
12
|
-
end
|
13
|
-
|
14
|
-
# Get the path for a test MARC XML file
|
15
|
-
# @param [String] filename of MARCXML fixture
|
16
|
-
# @return [String] full path of MARCXML fixture
|
17
|
-
def marc_xml_path(filename)
|
18
|
-
File.join File.dirname(__FILE__), '..', 'fixtures', 'marcxml', filename
|
19
|
-
end
|
20
|
-
|
21
|
-
# Create an isolated MARC::Subfield object for use in specs or as part of a MARC::Field
|
22
|
-
# @param [String] code
|
23
|
-
# @param [String] value
|
24
|
-
# @return [MARC::Subfield]
|
25
|
-
def marc_subfield(code, value)
|
26
|
-
MARC::Subfield.new code.to_s, value
|
27
|
-
end
|
28
|
-
|
29
|
-
# Return a new ControlField (000-009)
|
30
|
-
# @param [String] tag
|
31
|
-
# @param [String] value
|
32
|
-
# @return [MARC::ControlField]
|
33
|
-
def marc_control_field(tag:, value:)
|
34
|
-
MARC::ControlField.new tag, value
|
35
|
-
end
|
36
|
-
|
37
|
-
# Create an isolated MARC::DataField object for use in specs
|
38
|
-
# Can pass in tag, indicators and subfields (using simple hash structure). E.g.,
|
39
|
-
# marc_field(tag: '650', indicator2: '7'),
|
40
|
-
# subfields: { a: 'Tax planning',
|
41
|
-
# m: ['Multiple', 'Subfields']
|
42
|
-
# z: 'United States.',
|
43
|
-
# '0': http://id.loc.gov/authorities/subjects/sh2008112546 }
|
44
|
-
# )
|
45
|
-
# @param [String (frozen)] tag MARC tag, e.g., 001, 665
|
46
|
-
# @param [String (frozen)] indicator1 MARC indicator, e.g., 0
|
47
|
-
# @param [String (frozen)] indicator2
|
48
|
-
# @param [Hash] subfields hash of subfield values as code => value or code => [value, value]
|
49
|
-
# @return [MARC::DataField]
|
50
|
-
def marc_field(tag: 'TST', indicator1: ' ', indicator2: ' ', subfields: {})
|
51
|
-
subfield_objects = subfields.each_with_object([]) do |(code, value), array|
|
52
|
-
Array.wrap(value).map { |v| array << marc_subfield(code, v) }
|
53
|
-
end
|
54
|
-
MARC::DataField.new tag, indicator1, indicator2, *subfield_objects
|
55
|
-
end
|
56
|
-
|
57
|
-
# Return a MARC::Record containing passed in DataFields
|
58
|
-
# @param [Array<MARC::DataField>] fields
|
59
|
-
# @param [String, nil] leader
|
60
|
-
# @return [MARC::Record]
|
61
|
-
def marc_record(fields: [], leader: nil)
|
62
|
-
record = MARC::Record.new
|
63
|
-
fields.each { |field| record << field }
|
64
|
-
record.leader = leader if leader
|
65
|
-
record
|
66
|
-
end
|
67
|
-
|
68
|
-
# Mock map for location lookup using Location helper
|
69
|
-
# The location codes :dent and :stor are the two outermost keys
|
70
|
-
# :specific_location, :library, :display are the inner keys that store location values
|
71
|
-
# @example
|
72
|
-
# location_map[:stor][:library] #=> 'LIBRA'
|
73
|
-
# @return [Hash]
|
74
|
-
def location_map
|
75
|
-
{ dent: { specific_location: 'Levy Dental Medicine Library - Stacks',
|
76
|
-
library: ['Health Sciences Libraries', 'Levy Dental Medicine Library'],
|
77
|
-
display: 'Levy Dental Medicine Library - Stacks' },
|
78
|
-
stor: { specific_location: 'LIBRA',
|
79
|
-
library: 'LIBRA',
|
80
|
-
display: 'LIBRA' },
|
81
|
-
vanp: { specific_location: 'Van Pelt - Stacks',
|
82
|
-
library: 'Van Pelt-Dietrich Library Center',
|
83
|
-
display: 'Van Pelt Library' } }
|
84
|
-
end
|
85
|
-
end
|