pennmarc 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9003d5a58efd2cbef83a220bd0d609edfdc2bfb883378c003d0bafa2d85e520e
4
- data.tar.gz: d8f841dbba9e412848b31a7a11284b14e2bbb772fbb98762b827ab9e2baf6355
3
+ metadata.gz: 2b87c66becc36828ec6331d7261d0b71472a74f4af26f2b7a145ed54316ed11a
4
+ data.tar.gz: 0de62b7492b92ebe0902081aee1da5e5bcabac9e8d9042bab88db7887adda62e
5
5
  SHA512:
6
- metadata.gz: a45d1e909a7a9efad1aec8047d79f3358b1ee3b523958661459c27b397f3a0f33c00deffeae2bdd30fad14156b8f348171639375677e6f600086e1b592fe2c51
7
- data.tar.gz: ba609fef49f12f9341328fc292cc510fab6ab298174791afc99ec802ecd1c62448c9ccc009a7f01c6aefef7be2c56d794cc5f2e0bddf01c72fc4e9db11ce6961
6
+ metadata.gz: 0ffced7042a0c00a09c1a2b465e0d17506e55bf0a77255e8f1bce1acabdfabe8faa819864cb0376d7ac6a10285c1a810bd1ede17210829326d342998ed908aa4
7
+ data.tar.gz: 7aac0315dda59416fdd5b5ed6409b1ddc9a3f881bc75a5aa08c07d299d9824ed9c12a6f6cbe7cacc39a45980f36bcfb97e9ed6b42c379a3aa6364b56f397a244
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 10000`
3
- # on 2024-08-20 20:46:53 UTC using RuboCop version 1.51.0.
3
+ # on 2024-08-30 16:12:14 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
@@ -138,7 +138,7 @@ RSpec/FilePath:
138
138
  Exclude:
139
139
  - 'spec/lib/pennmarc/parser_spec.rb'
140
140
 
141
- # Offense count: 26
141
+ # Offense count: 27
142
142
  # Configuration parameters: Max, AllowedGroups.
143
143
  RSpec/NestedGroups:
144
144
  Exclude:
@@ -35,6 +35,23 @@ module PennMARC
35
35
  series_values.uniq
36
36
  end
37
37
 
38
+ # Hash that associates {https://www.loc.gov/marc/bibliographic/bd830.html 830} and
39
+ # {https://www.loc.gov/marc/bibliographic/bd440.html 440} show values to query values to make building fielded
40
+ # search links easier in the downstream app.
41
+ # @param record [MARC::Record]
42
+ # @return [Hash]
43
+ def show_query_map(record)
44
+ record.fields(%w[830 440]).each_with_object({}) do |field, hash|
45
+ show_values = title_show_entries(record, field.tag) + [remaining_show_value(field)]
46
+
47
+ query_value = trim_punctuation(join_subfields(field, &subfield_in?(%w[a n p])))
48
+
49
+ show_values.each do |show_value|
50
+ hash[show_value] = query_value
51
+ end
52
+ end
53
+ end
54
+
38
55
  # Values from series fields for display.
39
56
  # @param record [MARC::Record]
40
57
  # @param relator_map [Hash]
@@ -141,10 +158,10 @@ module PennMARC
141
158
  # @note added 2017/04/10: filter out 0 (authority record numbers) added by Alma
142
159
  # @param record [MARC::Record]
143
160
  # @param tags_present [Array<String>]
144
- # @return [Array<Hash>] array of remaining show entry hashes
161
+ # @return [Array<String>] array of remaining show entry hashes
145
162
  def remaining_show_entries(record, tags_present)
146
163
  record.fields(tags_present.drop(1)).map do |field|
147
- join_subfields(field, &subfield_not_in?(%w[0 5 6 8]))
164
+ remaining_show_value(field)
148
165
  end || []
149
166
  end
150
167
 
@@ -200,6 +217,13 @@ module PennMARC
200
217
  join_subfields(field, &subfield_in?(%w[i a s t n d]))
201
218
  end
202
219
  end
220
+
221
+ # Parse the value for a given remaining show field
222
+ # @param field [MARC::Field]
223
+ # @return [String]
224
+ def remaining_show_value(field)
225
+ join_subfields(field, &subfield_not_in?(%w[0 5 6 8]))
226
+ end
203
227
  end
204
228
  end
205
229
  end
@@ -88,7 +88,6 @@ module PennMARC
88
88
  # Single-valued Title, for use in headings. Takes the first {https://www.oclc.org/bibformats/en/2xx/245.html 245}
89
89
  # value. Special consideration for
90
90
  # {https://www.oclc.org/bibformats/en/2xx/245.html#punctuation punctuation practices}.
91
- # @todo still consider ǂh? medium, which OCLC doc says DO NOT USE...but that is OCLC...
92
91
  # @todo is punctuation handling still as desired? treatment here is described in spreadsheet from 2011
93
92
  # @param record [MARC::Record]
94
93
  # @return [String] single title for display
@@ -98,15 +97,14 @@ module PennMARC
98
97
  [format_title(values[:title_or_form]), values[:punctuation], values[:other_info]].compact_blank.join(' ')
99
98
  end
100
99
 
101
- # Same as show, but with inclusive dates appended. For use on show page.
100
+ # Same as show, but with all subfields included as found - except for subfield c.
102
101
  # @param record [MARC::Record]
103
102
  # @return [String] detailed title for display
104
103
  def detailed_show(record)
105
104
  field = record.fields('245')&.first
106
- values = title_values(field)
107
- title = [format_title(values[:title_or_form]), values[:punctuation],
108
- trim_trailing(:period, values[:other_info])].compact_blank.join(' ')
109
- values[:inclusive_dates].present? ? [title, values[:inclusive_dates]].compact_blank.join(', ') : title
105
+ return unless field
106
+
107
+ join_subfields(field, &subfield_not_in?(%w[6 8]))
110
108
  end
111
109
 
112
110
  # Same structure as show, but linked alternate title.
@@ -124,17 +122,6 @@ module PennMARC
124
122
  [format_title(values[:title_or_form]), values[:punctuation], values[:other_info]].compact_blank.join(' ')
125
123
  end
126
124
 
127
- # Title statement of responsibility (field 245, subfield c) and linked alternate for display.
128
- # See https://www.oclc.org/bibformats/en/2xx/245.html#subfieldc for examples
129
- # @param [MARC::Record] record
130
- # @return [Array<String>] statement of responsibility and linked alternate
131
- def statement_of_responsibility_show(record)
132
- field = record.fields('245').first
133
- statement = field&.find { |sf| sf.code == 'c' }&.value
134
- alternate_statement = linked_alternate(record, '245', &subfield_in?(%w[c]))&.first
135
- [statement, alternate_statement].compact_blank
136
- end
137
-
138
125
  # Canonical title with non-filing characters relocated to the end.
139
126
  #
140
127
  # @note Currently we index two "title sort" fields: title_nssort (ssort type - regex token filter applied) and
@@ -269,7 +256,6 @@ module PennMARC
269
256
  title_or_form = field.find_all(&subfield_in?(%w[a k]))
270
257
  .map { |sf| trim_trailing(:comma, trim_trailing(:slash, sf.value).rstrip) }
271
258
  .first || ''
272
- inclusive_dates = field.find { |sf| sf.code == 'f' }&.value
273
259
  other_info = field.find_all(&subfield_in?(%w[b n p]))
274
260
  .map { |sf| trim_trailing(:slash, sf.value) }
275
261
  .join(' ')
@@ -283,7 +269,6 @@ module PennMARC
283
269
  [title_punctuation, medium_punctuation].include?(':') ? ':' : nil
284
270
  end
285
271
  { title_or_form: title_or_form,
286
- inclusive_dates: inclusive_dates,
287
272
  other_info: other_info,
288
273
  punctuation: punctuation }
289
274
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PennMARC
4
- VERSION = '1.1.1'
4
+ VERSION = '1.2.0'
5
5
  end
@@ -15,6 +15,24 @@ describe 'PennMARC::Series' do
15
15
  marc_record fields: [marc_field(tag: '666', subfields: { a: 'test' })]
16
16
  end
17
17
 
18
+ describe '.show_query_map' do
19
+ let(:record) do
20
+ marc_record fields: [
21
+ marc_field(tag: '440', subfields: { a: 'Teachings of the feathered pillow', n: 'number', p: 'section' }),
22
+ marc_field(tag: '490', subfields: { a: 'Ignored' }),
23
+ marc_field(tag: '830', subfields: { a: 'International litigation in practice', v: 'volume 13.' })
24
+ ]
25
+ end
26
+
27
+ it 'returns expected hash' do
28
+ expect(helper.show_query_map(record)).to eq(
29
+ { 'Teachings of the feathered pillow number section' => 'Teachings of the feathered pillow number section',
30
+ 'Teachings of the feathered pillow section number' => 'Teachings of the feathered pillow number section',
31
+ 'International litigation in practice volume 13.' => 'International litigation in practice' }
32
+ )
33
+ end
34
+ end
35
+
18
36
  describe '.show' do
19
37
  it 'returns the series values for display' do
20
38
  expect(helper.show(record, relator_map: mapping)).to contain_exactly(
@@ -139,15 +139,44 @@ describe 'PennMARC::Title' do
139
139
  end
140
140
 
141
141
  describe '.detailed_show' do
142
- let(:record) do
143
- marc_record fields: [
144
- marc_field(tag: '245', subfields: { k: 'Letters', f: '1972-1982', b: 'to Lewis Mumford.' })
145
- ]
146
- end
147
-
148
142
  context 'with subfields ǂk, ǂf and ǂc' do
143
+ let(:record) do
144
+ marc_record fields: [
145
+ marc_field(tag: '245', subfields: { k: 'Letters,', f: '1972-1982,', b: 'to Lewis Mumford.' })
146
+ ]
147
+ end
148
+
149
149
  it 'returns detailed title values' do
150
- expect(helper.detailed_show(record)).to eq 'Letters to Lewis Mumford, 1972-1982'
150
+ expect(helper.detailed_show(record)).to eq 'Letters, 1972-1982, to Lewis Mumford.'
151
+ end
152
+ end
153
+
154
+ context 'with subfields ǂk and ǂb' do
155
+ let(:record) do
156
+ marc_record fields: [
157
+ marc_field(tag: '245', subfields: { k: 'Letters', b: 'to Lewis Mumford.' })
158
+ ]
159
+ end
160
+
161
+ it 'returns title value without dates' do
162
+ expect(helper.detailed_show(record)).to eq 'Letters to Lewis Mumford.'
163
+ end
164
+ end
165
+
166
+ # e.g., 9977704838303681
167
+ context 'with ǂa containing an " : " as well as inclusive dates' do
168
+ let(:record) do
169
+ marc_record fields: [
170
+ marc_field(tag: '245', subfields: { a: 'The frugal housewife : ',
171
+ b: 'dedicated to those who are not ashamed of economy, ',
172
+ f: '1830 / ', c: 'by the author of Hobomok.' })
173
+ ]
174
+ end
175
+
176
+ it 'returns single title value with text from ǂa and ǂn' do
177
+ expect(helper.detailed_show(record)).to eq(
178
+ 'The frugal housewife : dedicated to those who are not ashamed of economy, 1830 / by the author of Hobomok.'
179
+ )
151
180
  end
152
181
  end
153
182
  end
@@ -179,25 +208,6 @@ describe 'PennMARC::Title' do
179
208
  end
180
209
  end
181
210
 
182
- describe '.statement_of_responsibility_show' do
183
- let(:record) do
184
- marc_record fields: [marc_field(tag: '245', subfields: { c: 'statement of responsibility' }),
185
- marc_field(tag: '880', subfields: { '6': '245', c: 'déclaration de responsabilité' })]
186
- end
187
-
188
- context 'with ǂc defined' do
189
- it 'returns statement of responsibility' do
190
- expect(helper.statement_of_responsibility_show(record)).to include 'statement of responsibility'
191
- end
192
- end
193
-
194
- context 'with linked alternate of 245 ǂc defined' do
195
- it 'returns alternate statement of responsibility' do
196
- expect(helper.statement_of_responsibility_show(record)).to include 'déclaration de responsabilité'
197
- end
198
- end
199
- end
200
-
201
211
  describe '.sort' do
202
212
  context 'with a record with a valid indicator2 value' do
203
213
  let(:record) 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.1.1
4
+ version: 1.2.0
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: 2024-08-23 00:00:00.000000000 Z
15
+ date: 2024-08-30 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport