pennmarc 0.0.2 → 1.0.0

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.rubocop_todo.yml +151 -0
  4. data/Gemfile +1 -1
  5. data/lib/pennmarc/helpers/creator.rb +47 -13
  6. data/lib/pennmarc/helpers/database.rb +8 -8
  7. data/lib/pennmarc/helpers/date.rb +16 -15
  8. data/lib/pennmarc/helpers/edition.rb +14 -11
  9. data/lib/pennmarc/helpers/format.rb +16 -5
  10. data/lib/pennmarc/helpers/genre.rb +12 -11
  11. data/lib/pennmarc/helpers/identifier.rb +16 -7
  12. data/lib/pennmarc/helpers/language.rb +1 -1
  13. data/lib/pennmarc/helpers/link.rb +6 -0
  14. data/lib/pennmarc/helpers/location.rb +14 -14
  15. data/lib/pennmarc/helpers/note.rb +52 -2
  16. data/lib/pennmarc/helpers/relation.rb +9 -9
  17. data/lib/pennmarc/helpers/series.rb +182 -85
  18. data/lib/pennmarc/helpers/subject.rb +11 -11
  19. data/lib/pennmarc/helpers/title.rb +1 -1
  20. data/lib/pennmarc/parser.rb +2 -99
  21. data/lib/pennmarc/util.rb +11 -11
  22. data/pennmarc.gemspec +2 -2
  23. data/spec/lib/pennmarc/helpers/citation_spec.rb +1 -2
  24. data/spec/lib/pennmarc/helpers/creator_spec.rb +46 -11
  25. data/spec/lib/pennmarc/helpers/date_spec.rb +5 -5
  26. data/spec/lib/pennmarc/helpers/edition_spec.rb +1 -4
  27. data/spec/lib/pennmarc/helpers/format_spec.rb +29 -9
  28. data/spec/lib/pennmarc/helpers/genre_spec.rb +3 -3
  29. data/spec/lib/pennmarc/helpers/identifer_spec.rb +15 -0
  30. data/spec/lib/pennmarc/helpers/location_spec.rb +9 -8
  31. data/spec/lib/pennmarc/helpers/note_spec.rb +67 -2
  32. data/spec/lib/pennmarc/helpers/series_spec.rb +54 -0
  33. data/spec/lib/pennmarc/helpers/subject_spec.rb +8 -8
  34. data/spec/lib/pennmarc/helpers/title_spec.rb +3 -1
  35. data/spec/lib/pennmarc/marc_util_spec.rb +9 -8
  36. data/spec/lib/pennmarc/parser_spec.rb +2 -2
  37. data/spec/spec_helper.rb +1 -1
  38. metadata +7 -17
@@ -30,10 +30,10 @@ module PennMARC
30
30
  # including any linked 880 fields. Fields must have an indicator2 value in {SEARCH_SOURCE_INDICATORS}.
31
31
  # @todo this includes subfields that may not be desired like 1 (uri) and 2 (source code) but this might be OK for
32
32
  # a search (non-display) field?
33
- # @param [Hash] relator_map
33
+ # @param [Hash] relator_mapping
34
34
  # @param [MARC::Record] record
35
35
  # @return [Array] array of all subject values for search
36
- def search(record, relator_map)
36
+ def search(record, relator_mapping = relator_map)
37
37
  subject_fields(record, type: :search).filter_map do |field|
38
38
  subj_parts = field.filter_map do |subfield|
39
39
  # TODO: use term hash here? pro/chr would be rejected...
@@ -48,7 +48,7 @@ module PennMARC
48
48
  # TODO: use relation mapping method from Title helper? for potential URI support?
49
49
  # sf 4 should contain a 3-letter code or URI "that specifies the relationship from the entity described
50
50
  # in the record to the entity referenced in the field"
51
- "#{subfield.value} #{relator_map[subfield.value.to_sym]}".strip
51
+ "#{subfield.value} #{relator_mapping[subfield.value.to_sym]}".strip
52
52
  else
53
53
  subfield.value
54
54
  end
@@ -79,12 +79,12 @@ module PennMARC
79
79
  # @param [MARC::Record] record
80
80
  # @return [Array] array of all subject values for display
81
81
  def show(record)
82
- subject_fields(record, type: :all).filter_map do |field|
82
+ subject_fields(record, type: :all).filter_map { |field|
83
83
  term_hash = build_subject_hash(field)
84
84
  next if term_hash.blank? || term_hash[:count]&.zero?
85
85
 
86
86
  format_term type: :display, term: term_hash
87
- end.uniq
87
+ }.uniq
88
88
  end
89
89
 
90
90
  # Get Subjects from "Children" ontology
@@ -93,12 +93,12 @@ module PennMARC
93
93
  # @return [Array] array of children's subject values for display
94
94
  def childrens_show(record)
95
95
  subject_fields(record, type: :display, options: { tags: DISPLAY_TAGS, indicator2: '1' })
96
- .filter_map do |field|
96
+ .filter_map { |field|
97
97
  term_hash = build_subject_hash(field)
98
98
  next if term_hash.blank? || term_hash[:count]&.zero?
99
99
 
100
100
  format_term type: :display, term: term_hash
101
- end.uniq
101
+ }.uniq
102
102
  end
103
103
 
104
104
  # Get Subjects from "MeSH" ontology
@@ -107,12 +107,12 @@ module PennMARC
107
107
  # @return [Array] array of MeSH subject values for display
108
108
  def medical_show(record)
109
109
  subject_fields(record, type: :display, options: { tags: DISPLAY_TAGS, indicator2: '2' })
110
- .filter_map do |field|
110
+ .filter_map { |field|
111
111
  term_hash = build_subject_hash(field)
112
112
  next if term_hash.blank? || term_hash[:count]&.zero?
113
113
 
114
114
  format_term type: :display, term: term_hash
115
- end.uniq
115
+ }.uniq
116
116
  end
117
117
 
118
118
  # Get Subject values from {DISPLAY_TAGS} where indicator2 is 4 and {LOCAL_TAGS}. Do not include any values where
@@ -123,14 +123,14 @@ module PennMARC
123
123
  def local_show(record)
124
124
  local_fields = subject_fields(record, type: :display, options: { tags: DISPLAY_TAGS, indicator2: '4' }) +
125
125
  subject_fields(record, type: :local)
126
- local_fields.filter_map do |field|
126
+ local_fields.filter_map { |field|
127
127
  next if subfield_value?(field, '2', /penncoi/)
128
128
 
129
129
  term_hash = build_subject_hash(field)
130
130
  next if term_hash.blank? || term_hash[:count]&.zero?
131
131
 
132
132
  format_term type: :display, term: term_hash
133
- end.uniq
133
+ }.uniq
134
134
  end
135
135
 
136
136
  private
@@ -82,7 +82,7 @@ module PennMARC
82
82
  def sort(record)
83
83
  title_field = record.fields('245').first
84
84
  # attempt to get number of non-filing characters present, default to 0
85
- offset = if title_field.indicator2 =~ /^[0-9]$/
85
+ offset = if /^[0-9]$/.match?(title_field.indicator2)
86
86
  title_field.indicator2.to_i
87
87
  else
88
88
  0
@@ -18,7 +18,9 @@ require_relative 'helpers/relation'
18
18
  require_relative 'helpers/production'
19
19
  require_relative 'helpers/edition'
20
20
  require_relative 'helpers/note'
21
+ require_relative 'helpers/series'
21
22
 
23
+ # Top level gem namespace
22
24
  module PennMARC
23
25
  attr_accessor :mappings
24
26
 
@@ -50,105 +52,6 @@ module PennMARC
50
52
  "PennMARC::#{helper.titleize}".constantize.public_send(meth, opts)
51
53
  end
52
54
 
53
- # @todo does this fit in an existing helper?
54
- # @param [MARC::Record] record
55
- # @return [Object]
56
- def cartographic_show(record)
57
- record.fields(%w{255 342}).map do |field|
58
- join_subfields(field, &subfield_not_6_or_8)
59
- end
60
- end
61
-
62
- # @todo move to Identifier helper
63
- # @param [MARC::Record] record
64
- # @return [Object]
65
- def fingerprint_show(record)
66
- record.fields('026').map do |field|
67
- join_subfields(field, &subfield_not_in(%w{2 5 6 8}))
68
- end
69
- end
70
-
71
- # @todo does this fit in an existing helper?
72
- # @param [MARC::Record] record
73
- # @return [Object]
74
- def arrangement_show(record)
75
- get_datafield_and_880(record, '351')
76
- end
77
-
78
- # @param [MARC::Record] record
79
- # @return [Object]
80
- def system_details_show(record)
81
- acc = []
82
- acc += record.fields('538').map do |field|
83
- get_sub3_and_other_subs(field, &subfield_in(%w{a i u}))
84
- end
85
- acc += record.fields('344').map do |field|
86
- get_sub3_and_other_subs(field, &subfield_in(%w{a b c d e f g h}))
87
- end
88
- acc += record.fields(%w{345 346}).map do |field|
89
- get_sub3_and_other_subs(field, &subfield_in(%w{a b}))
90
- end
91
- acc += record.fields('347').map do |field|
92
- get_sub3_and_other_subs(field, &subfield_in(%w{a b c d e f}))
93
- end
94
- acc += record.fields('880')
95
- .select { |f| has_subfield6_value(f, /^538/) }
96
- .map do |field|
97
- get_sub3_and_other_subs(field, &subfield_in(%w{a i u}))
98
- end
99
- acc += record.fields('880')
100
- .select { |f| has_subfield6_value(f, /^344/) }
101
- .map do |field|
102
- get_sub3_and_other_subs(field, &subfield_in(%w{a b c d e f g h}))
103
- end
104
- acc += record.fields('880')
105
- .select { |f| has_subfield6_value(f, /^(345|346)/) }
106
- .map do |field|
107
- get_sub3_and_other_subs(field, &subfield_in(%w{a b}))
108
- end
109
- acc += record.fields('880')
110
- .select { |f| has_subfield6_value(f, /^347/) }
111
- .map do |field|
112
- get_sub3_and_other_subs(field, &subfield_in(%w{a b c d e f}))
113
- end
114
- acc
115
- end
116
-
117
- # @todo the legacy code here is a hot mess for a number of reasons, what do we need this field to do?
118
- # @note port the needed parts from get_offsite_display, don't return HTML
119
- # @param [MARC::Record] record
120
- # @return [Object]
121
- def offsite_show(record); end
122
-
123
- # @todo move this to Creator helper
124
- # @param [MARC::Record] record
125
- # @return [Object]
126
- def contributor_show(record)
127
- acc = []
128
- acc += record.fields(%w{700 710})
129
- .select { |f| ['', ' ', '0'].member?(f.indicator2) }
130
- .select { |f| f.none? { |sf| sf.code == 'i' } }
131
- .map do |field|
132
- contributor = join_subfields(field, &subfield_in(%w{a b c d j q}))
133
- contributor_append = field.select(&subfield_in(%w{e u 3 4})).map do |sf|
134
- if sf.code == '4'
135
- ", #{relator_codes[sf.value]}"
136
- else
137
- " #{sf.value}"
138
- end
139
- end.join
140
- { value: contributor, value_append: contributor_append, link_type: 'author_creator_xfacet2' }
141
- end
142
- acc += record.fields('880')
143
- .select { |f| has_subfield6_value(f, /^(700|710)/) && (f.none? { |sf| sf.code == 'i' }) }
144
- .map do |field|
145
- contributor = join_subfields(field, &subfield_in(%w{a b c d j q}))
146
- contributor_append = join_subfields(field, &subfield_in(%w{e u 3}))
147
- { value: contributor, value_append: contributor_append, link_type: 'author_creator_xfacet2' }
148
- end
149
- acc
150
- end
151
-
152
55
  # Load language map from YAML and memoize in @mappings hash
153
56
  # @return [Hash]
154
57
  def language_map
data/lib/pennmarc/util.rb CHANGED
@@ -9,10 +9,10 @@ module PennMARC
9
9
  # @param [MARC::DataField] field
10
10
  # @param [Proc] selector
11
11
  # @return [String]
12
- def join_subfields(field, &selector)
13
- field.select { |v| selector.call(v) }.filter_map { |sf|
12
+ def join_subfields(field, &)
13
+ field.select(&).filter_map { |sf|
14
14
  value = sf.value&.strip
15
- next unless value.present?
15
+ next if value.blank?
16
16
 
17
17
  value
18
18
  }.join(' ').squish
@@ -88,7 +88,7 @@ module PennMARC
88
88
  field.filter_map do |sf|
89
89
  next unless sf.code == subfield.to_s
90
90
 
91
- next unless sf.value.present?
91
+ next if sf.value.blank?
92
92
 
93
93
  sf.value
94
94
  end
@@ -126,11 +126,11 @@ module PennMARC
126
126
  # @param [String|Array] subfield6_value either a string to look for in sub6 or an array of them
127
127
  # @param selector [Proc] takes a subfield as argument, returns a boolean
128
128
  # @return [Array] array of linked alternates
129
- def linked_alternate(record, subfield6_value, &selector)
129
+ def linked_alternate(record, subfield6_value, &)
130
130
  record.fields('880').filter_map do |field|
131
131
  next unless subfield_value?(field, '6', /^#{Array.wrap(subfield6_value).join('|')}/)
132
132
 
133
- field.select { |sf| selector.call(sf) }.map(&:value).join(' ')
133
+ field.select(&).map(&:value).join(' ')
134
134
  end
135
135
  end
136
136
  alias get_880 linked_alternate
@@ -152,9 +152,9 @@ module PennMARC
152
152
  # @param [String] tag
153
153
  # @return [Array] acc
154
154
  def datafield_and_linked_alternate(record, tag)
155
- record.fields(tag).filter_map do |field|
155
+ record.fields(tag).filter_map { |field|
156
156
  join_subfields(field, &subfield_not_in?(%w[6 8]))
157
- end + linked_alternate_not_6_or_8(record, tag)
157
+ } + linked_alternate_not_6_or_8(record, tag)
158
158
  end
159
159
 
160
160
  # Get the substring of a string up to a given target character
@@ -186,7 +186,7 @@ module PennMARC
186
186
  # @param [MARC::Field] field
187
187
  # @return [String] subfield i without parentheses value
188
188
  def remove_paren_value_from_subfield_i(field)
189
- val = field.filter_map do |sf|
189
+ val = field.filter_map { |sf|
190
190
  next unless sf.code == 'i'
191
191
 
192
192
  match = /\((.+?)\)/.match(sf.value)
@@ -195,7 +195,7 @@ module PennMARC
195
195
  else
196
196
  sf.value
197
197
  end
198
- end.first || ''
198
+ }.first || ''
199
199
  trim_trailing(:colon, trim_trailing(:period, val))
200
200
  end
201
201
 
@@ -205,7 +205,7 @@ module PennMARC
205
205
  # @param [Hash] mapping
206
206
  # @return [String, NilClass] full relator string
207
207
  def translate_relator(relator_code, mapping)
208
- return unless relator_code.present?
208
+ return if relator_code.blank?
209
209
 
210
210
  mapping[relator_code.to_sym]
211
211
  end
data/pennmarc.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'pennmarc'
5
- s.version = '0.0.2'
5
+ s.version = '1.0.0'
6
6
  s.summary = 'Penn Libraries Catalog MARC parsing wisdom for cross-project usage'
7
7
  s.description = 'This gem provides methods for parsing a Penn Libraries MARCXML record into string, array and date
8
8
  objects for use in discovery or preservation applications.'
@@ -19,5 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.add_dependency 'marc', '~> 1.2'
20
20
  s.add_dependency 'nokogiri', '~> 1.15'
21
21
 
22
- s.add_development_dependency 'rspec', '~> 3.12'
22
+ s.metadata['rubygems_mfa_required'] = 'true'
23
23
  end
@@ -17,11 +17,10 @@ describe 'PennMARC::Citation' do
17
17
  end
18
18
 
19
19
  describe '.cite_as_show' do
20
- let(:record) { marc_record fields: [marc_field(tag: '524', subfields: {a: 'Perkins Historical Archive, Box 2'})] }
20
+ let(:record) { marc_record fields: [marc_field(tag: '524', subfields: { a: 'Perkins Historical Archive, Box 2' })] }
21
21
 
22
22
  it 'returns expected citation values' do
23
23
  expect(helper.cite_as_show(record)).to contain_exactly('Perkins Historical Archive, Box 2')
24
24
  end
25
25
  end
26
26
  end
27
-
@@ -9,7 +9,7 @@ describe 'PennMARC::Creator' do
9
9
  describe '.search' do
10
10
  let(:record) { marc_record fields: fields }
11
11
 
12
- context 'for a single author record' do
12
+ context 'with a single author record' do
13
13
  let(:fields) do
14
14
  [marc_field(tag: '100', subfields: { a: 'Surname, Name', '0': 'http://cool.uri/12345',
15
15
  e: 'author', d: '1900-2000' }),
@@ -23,7 +23,7 @@ describe 'PennMARC::Creator' do
23
23
  end
24
24
  end
25
25
 
26
- context 'for a corporate author record' do
26
+ context 'with a corporate author record' do
27
27
  let(:fields) do
28
28
  [marc_field(tag: '110', subfields: { a: 'Group of People', b: 'Annual Meeting', '4': 'aut' }),
29
29
  marc_field(tag: '880', subfields: { '6': '110', a: 'Alt. Group Name', b: 'Alt. Annual Meeting' })]
@@ -39,7 +39,7 @@ describe 'PennMARC::Creator' do
39
39
  describe '.values' do
40
40
  let(:record) { marc_record fields: fields }
41
41
 
42
- context 'for a single author record' do
42
+ context 'with a single author record' do
43
43
  let(:fields) do
44
44
  [marc_field(tag: '100', subfields: { a: 'Author', c: 'Fancy', d: 'active 24th century AD', '4': 'aut' }),
45
45
  marc_field(tag: '880', subfields: { '6': '100', a: 'Alt Author', c: 'Alt Fanciness' })]
@@ -52,7 +52,7 @@ describe 'PennMARC::Creator' do
52
52
  end
53
53
  end
54
54
 
55
- context 'for a corporate author record' do
55
+ context 'with a corporate author record' do
56
56
  let(:fields) do
57
57
  [marc_field(tag: '110', subfields: { a: 'Annual Report', b: 'Leader', e: 'author', '4': 'aut' })]
58
58
  end
@@ -66,12 +66,13 @@ describe 'PennMARC::Creator' do
66
66
  describe '.show' do
67
67
  let(:record) { marc_record fields: fields }
68
68
 
69
- context 'for a single author record' do
69
+ context 'with a single author record' do
70
70
  let(:fields) do
71
71
  [marc_field(tag: '100', subfields: { a: 'Surname, Name', '0': 'http://cool.uri/12345', d: '1900-2000',
72
72
  e: 'author', '4': 'http://cool.uri/vocabulary/relators/aut' }),
73
73
  marc_field(tag: '880', subfields: { a: 'Surname, Alternative', '6': '100' })]
74
74
  end
75
+
75
76
  it 'returns single author values with no URIs anywhere' do
76
77
  values = helper.show(record)
77
78
  expect(values).to contain_exactly 'Surname, Name 1900-2000', 'Surname, Alternative'
@@ -79,11 +80,12 @@ describe 'PennMARC::Creator' do
79
80
  end
80
81
  end
81
82
 
82
- context 'for a corporate author record' do
83
+ context 'with a corporate author record' do
83
84
  let(:fields) do
84
85
  [marc_field(tag: '110', subfields: { a: 'Group of People', b: 'Annual Meeting', '4': 'aut' }),
85
86
  marc_field(tag: '880', subfields: { '6': '110', a: 'Alt. Group Name', b: 'Alt. Annual Meeting' })]
86
87
  end
88
+
87
89
  it 'returns corporate author values with no URIs anywhere' do
88
90
  values = helper.show(record)
89
91
  expect(values).to contain_exactly 'Alt. Group Name Alt. Annual Meeting', 'Group of People Annual Meeting'
@@ -110,7 +112,7 @@ describe 'PennMARC::Creator' do
110
112
  let(:record) { marc_record fields: fields }
111
113
  let(:values) { helper.facet(record) }
112
114
 
113
- context 'for a single author record' do
115
+ context 'with a single author record' do
114
116
  let(:fields) do
115
117
  [marc_field(tag: '100', subfields: { a: 'Author, Great', d: '1900-2000' }),
116
118
  marc_field(tag: '700', subfields: { a: 'Co-Author, Great', d: '1900-2000' }),
@@ -121,7 +123,8 @@ describe 'PennMARC::Creator' do
121
123
  expect(values).to contain_exactly 'Author, Added', 'Author, Great 1900-2000', 'Co-Author, Great 1900-2000'
122
124
  end
123
125
  end
124
- context 'for a corporate author record' do
126
+
127
+ context 'with a corporate author record' do
125
128
  let(:fields) do
126
129
  [marc_field(tag: '110', subfields: { a: 'Group of People', b: 'Annual Meeting' }),
127
130
  marc_field(tag: '710', subfields: { a: 'A Publisher', e: 'publisher' }),
@@ -134,7 +137,8 @@ describe 'PennMARC::Creator' do
134
137
  'Group of People Annual Meeting'
135
138
  end
136
139
  end
137
- context 'for a meeting author record' do
140
+
141
+ context 'with a meeting author record' do
138
142
  let(:fields) do
139
143
  [marc_field(tag: '111', subfields: { a: 'Conference on Things', c: 'Earth' }),
140
144
  marc_field(tag: '711', subfields: { a: 'Thing Institute', j: 'sponsoring body' }),
@@ -178,6 +182,37 @@ describe 'PennMARC::Creator' do
178
182
  end
179
183
  end
180
184
 
181
- xdescribe '.conference_search'
182
- xdescribe '.search_aux'
185
+ describe '.contributor_show' do
186
+ let(:record) do
187
+ marc_record fields: [
188
+ marc_field(tag: '700', subfields: { a: 'Name', b: 'I', c: 'laureate', d: '1968', e: 'author',
189
+ j: 'pseud', q: 'Fuller Name', u: 'affiliation', '3': 'materials',
190
+ '4': 'aut' }),
191
+ marc_field(tag: '700', subfields: { a: 'Ignore' }, indicator2: '1'),
192
+ marc_field(tag: '700', subfields: { i: 'Ignore' }),
193
+ marc_field(tag: '710', subfields: { a: 'Corporation', b: 'A division', c: 'Office', d: '1968', e: 'author',
194
+ u: 'affiliation', '3': 'materials',
195
+ '4': 'aut' }),
196
+ marc_field(tag: '880', subfields: { '6': '700', a: 'Alt Name', b: 'Alt num', c: 'Alt title',
197
+ d: 'Alt date', e: 'Alt relator', j: 'Alt qualifier', q: 'Alt Fuller Name',
198
+ u: 'Alt affiliation', '3': 'Alt materials' }),
199
+ marc_field(tag: '880', subfields: { '6': '710', a: 'Alt Corp Name', b: 'Alt unit', c: 'Alt location',
200
+ d: 'Alt date', e: 'Alt relator', u: 'Alt Affiliation',
201
+ '3': 'Alt materials' }),
202
+ marc_field(tag: '880', subfields: { i: 'Ignore', '6': '700' })
203
+ ]
204
+ end
205
+
206
+ it 'returns expected contributor values' do
207
+ expect(helper.contributor_show(record, mapping)).to contain_exactly(
208
+ 'Name I laureate 1968 pseud Fuller Name author affiliation materials, Author',
209
+ 'Corporation A division Office 1968 author affiliation materials, Author',
210
+ 'Alt Name Alt num Alt title Alt date Alt qualifier Alt Fuller Name Alt relator Alt affiliation Alt materials',
211
+ 'Alt Corp Name Alt unit Alt location Alt date Alt relator Alt Affiliation Alt materials'
212
+ )
213
+ end
214
+ end
215
+
216
+ # describe '.conference_search'
217
+ # describe '.search_aux'
183
218
  end
@@ -27,7 +27,7 @@ describe 'PennMARC::Date' do
27
27
  end
28
28
 
29
29
  describe '.added' do
30
- context "with date formatted '%Y-%m-%d' " do
30
+ context "with date formatted '%Y-%m-%d'" do
31
31
  let(:fields) { [marc_field(tag: 'itm', subfields: { q: '2023-06-28' })] }
32
32
 
33
33
  it 'returns expected value' do
@@ -70,9 +70,9 @@ describe 'PennMARC::Date' do
70
70
  end
71
71
 
72
72
  it 'outputs error message' do
73
- expect do
73
+ expect {
74
74
  helper.added(record)
75
- end.to output("Error parsing date in date added subfield: invalid date - invalid date\n").to_stdout
75
+ }.to output("Error parsing date in date added subfield: invalid date - invalid date\n").to_stdout
76
76
  end
77
77
  end
78
78
  end
@@ -96,9 +96,9 @@ describe 'PennMARC::Date' do
96
96
  end
97
97
 
98
98
  it 'outputs error message' do
99
- expect do
99
+ expect {
100
100
  helper.last_updated(record)
101
- end.to output("Error parsing last updated date: invalid date - invalid date\n").to_stdout
101
+ }.to output("Error parsing last updated date: invalid date - invalid date\n").to_stdout
102
102
  end
103
103
  end
104
104
  end
@@ -10,7 +10,7 @@ describe 'PennMARC::Edition' do
10
10
  marc_field(tag: '880', subfields: { '6': '250', b: 'رمستر' }),
11
11
  marc_field(tag: '775', subfields: { i: 'Other Edition (Remove)',
12
12
  h: 'Cool Book',
13
- t: 'aut'}),
13
+ t: 'aut' }),
14
14
  marc_field(tag: '880', subfields: { '6': '775', i: 'Autre Editione' })]
15
15
  end
16
16
 
@@ -33,6 +33,3 @@ describe 'PennMARC::Edition' do
33
33
  end
34
34
  end
35
35
  end
36
-
37
-
38
-
@@ -9,7 +9,7 @@ describe 'PennMARC::Format' do
9
9
  let(:map) { location_map }
10
10
  let(:formats) { helper.facet(record, map) }
11
11
 
12
- context 'for an "Archive"' do
12
+ context 'with an "Archive"' do
13
13
  let(:map) do
14
14
  { musearch: { specific_location: 'Penn Museum Archives',
15
15
  library: 'Penn Museum Archives',
@@ -19,7 +19,7 @@ describe 'PennMARC::Format' do
19
19
  display: 'Barbara Bates Center for History of Nursing - Fagin Hall 2U' } }
20
20
  end
21
21
 
22
- context 'for a record in "Penn Museum Archives (musearch)"' do
22
+ context 'with a record in "Penn Museum Archives (musearch)"' do
23
23
  let(:record) { marc_record fields: [marc_field(tag: 'hld', subfields: { c: 'musearch' })] }
24
24
 
25
25
  it 'returns format values of "Archive" for a record with holdings located in "musearch"' do
@@ -27,7 +27,7 @@ describe 'PennMARC::Format' do
27
27
  end
28
28
  end
29
29
 
30
- context 'for a record in "Nursing Archives (nursarch)"' do
30
+ context 'with a record in "Nursing Archives (nursarch)"' do
31
31
  let(:record) { marc_record fields: [marc_field(tag: 'hld', subfields: { c: 'nursarch' })] }
32
32
 
33
33
  it 'returns format values of without "Archive" for a record with a holding in "nursarch"' do
@@ -36,7 +36,7 @@ describe 'PennMARC::Format' do
36
36
  end
37
37
  end
38
38
 
39
- context 'for a "Newspaper"' do
39
+ context 'with a "Newspaper"' do
40
40
  let(:record) do
41
41
  marc_record leader: ' as',
42
42
  fields: [marc_control_field(tag: '008', value: ' n')]
@@ -50,7 +50,7 @@ describe 'PennMARC::Format' do
50
50
  # TODO: confirm this as desired functionality
51
51
  # Inspired by https://franklin.library.upenn.edu/catalog/FRANKLIN_999444703503681
52
52
  # which appears to be a thesis on microfilm, but only has microfilm as a format.
53
- context 'for a "Thesis" on "Microfilm"' do
53
+ context 'with a "Thesis" on "Microfilm"' do
54
54
  let(:record) do
55
55
  marc_record leader: ' tm',
56
56
  fields: [
@@ -65,7 +65,7 @@ describe 'PennMARC::Format' do
65
65
  end
66
66
  end
67
67
 
68
- context 'for Microformats as determined by the holding call numbers' do
68
+ context 'with Microformats as determined by the holding call numbers' do
69
69
  let(:record) do
70
70
  marc_record fields: [marc_field(tag: 'hld', subfields: { h: 'AB123', i: '.456 Microfilm' })]
71
71
  end
@@ -75,7 +75,7 @@ describe 'PennMARC::Format' do
75
75
  end
76
76
  end
77
77
 
78
- context 'for a "Book"' do
78
+ context 'with a "Book"' do
79
79
  let(:record) do
80
80
  marc_record leader: ' aa',
81
81
  fields: [marc_field(tag: '245', subfields: { k: 'blah' })]
@@ -86,7 +86,7 @@ describe 'PennMARC::Format' do
86
86
  end
87
87
  end
88
88
 
89
- context 'for a "Projected Graphic"' do
89
+ context 'with a "Projected Graphic"' do
90
90
  let(:record) do
91
91
  marc_record leader: ' gm',
92
92
  fields: [marc_control_field(tag: '007', value: 'go hkaaa ')]
@@ -180,8 +180,28 @@ describe 'PennMARC::Format' do
180
180
  end
181
181
  end
182
182
 
183
+ describe 'cartographic_show' do
184
+ let(:record) do
185
+ marc_record fields: [marc_field(tag: '255', subfields: {
186
+ a: ' Scale 1:2,534,400. 40 mi. to an in.', b: 'polyconic projection',
187
+ c: '(E 74⁰--E 84⁰/N 20⁰--N 12⁰).', d: 'Declination +90° to -90°',
188
+ e: 'equinox 1950, epoch 1949-1958'
189
+ }),
190
+ marc_field(tag: '342', subfields: { a: 'Polyconic', g: '0.9996', h: '0', i: '500,000',
191
+ j: '0' })]
192
+ end
193
+
194
+ it 'returns expected cartographic values' do
195
+ expect(helper.cartographic_show(record)).to contain_exactly(
196
+ 'Polyconic 0.9996 0 500,000 0',
197
+ 'Scale 1:2,534,400. 40 mi. to an in. polyconic projection (E 74⁰--E 84⁰/N 20⁰--N 12⁰). Declination +90° to
198
+ -90° equinox 1950, epoch 1949-1958'.squish
199
+ )
200
+ end
201
+ end
202
+
183
203
  describe '.includes_manuscript?' do
184
- context 'with a manuscript location incldued' do
204
+ context 'with a manuscript location included' do
185
205
  let(:locations) { ['Van Pelt', 'Kislak Center for Special Collections - Manuscripts Storage'] }
186
206
 
187
207
  it 'returns true' do
@@ -49,7 +49,7 @@ describe 'PennMARC::Genre' do
49
49
  vanp: { specific_location: 'Van Pelt' } }
50
50
  end
51
51
 
52
- context 'for a non-video, non-manuscript record' do
52
+ context 'with a non-video, non-manuscript record' do
53
53
  let(:fields) do
54
54
  [marc_control_field(tag: '007', value: 'x'),
55
55
  marc_field(tag: 'hld', subfields: { c: 'vanp' }),
@@ -61,7 +61,7 @@ describe 'PennMARC::Genre' do
61
61
  end
62
62
  end
63
63
 
64
- context 'for a video record' do
64
+ context 'with a video record' do
65
65
  let(:fields) do
66
66
  [marc_control_field(tag: '007', value: 'v'),
67
67
  marc_field(tag: 'hld', subfields: { c: 'vanp' }),
@@ -74,7 +74,7 @@ describe 'PennMARC::Genre' do
74
74
  end
75
75
  end
76
76
 
77
- context 'for a manuscript-located record' do
77
+ context 'with a manuscript-located record' do
78
78
  let(:fields) do
79
79
  [marc_control_field(tag: '007', value: 'x'),
80
80
  marc_field(tag: 'hld', subfields: { c: 'manu' }),
@@ -84,6 +84,7 @@ describe 'PennMARC::Identifier' do
84
84
  marc_field(tag: '880', subfields: { a: '006680200B', b: 'Island', '6': '028' })
85
85
  ]
86
86
  end
87
+
87
88
  it 'returns expected show values' do
88
89
  expect(helper.publisher_number_show(record)).to contain_exactly('602537854325',
89
90
  'B002086600 Island Def Jam Music Group',
@@ -98,8 +99,22 @@ describe 'PennMARC::Identifier' do
98
99
  marc_field(tag: '028', subfields: { a: 'B002086600', b: 'Island Def Jam Music Group' })
99
100
  ]
100
101
  end
102
+
101
103
  it 'returns expected search values' do
102
104
  expect(helper.publisher_number_search(record)).to contain_exactly('602537854325', 'B002086600')
103
105
  end
104
106
  end
107
+
108
+ describe '.fingerprint_show' do
109
+ let(:record) do
110
+ marc_record fields: [
111
+ marc_field(tag: '026', subfields: { a: 'dete nkck', b: 'vess lodo', c: 'Anno Domini MDCXXXVI', d: '3',
112
+ '2': 'fei', '5': 'penn' })
113
+ ]
114
+ end
115
+
116
+ it 'returns expected fingerprint values' do
117
+ expect(helper.fingerprint_show(record)).to contain_exactly('dete nkck vess lodo Anno Domini MDCXXXVI 3')
118
+ end
119
+ end
105
120
  end