pennmarc 1.0.25 → 1.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +8 -9
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/README.md +16 -1
- data/lib/pennmarc/heading_control.rb +22 -4
- 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/helpers/subject.rb +32 -22
- data/lib/pennmarc/mappers.rb +22 -10
- data/lib/pennmarc/mappings/headings_override.yml +8 -0
- data/lib/pennmarc/mappings/headings_remove.yml +2 -0
- 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/pennmarc.gemspec +2 -1
- data/spec/lib/pennmarc/heading_control_spec.rb +45 -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 +19 -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 +23 -3
- data/spec/support/marc_spec_helpers.rb +0 -85
@@ -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
|