stanford-mods 2.6.0 → 2.6.1
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 +5 -5
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +53 -28
- data/.travis.yml +3 -3
- data/Gemfile +1 -5
- data/lib/stanford-mods/coordinate.rb +3 -0
- data/lib/stanford-mods/date_parsing.rb +12 -0
- data/lib/stanford-mods/imprint.rb +16 -8
- data/lib/stanford-mods/name.rb +2 -0
- data/lib/stanford-mods/origin_info.rb +14 -0
- data/lib/stanford-mods/searchworks.rb +15 -3
- data/lib/stanford-mods/searchworks_subjects.rb +2 -0
- data/lib/stanford-mods/version.rb +1 -1
- data/spec/date_parsing_spec.rb +2 -0
- data/spec/imprint_spec.rb +1 -0
- data/spec/name_spec.rb +3 -0
- data/spec/origin_info_spec.rb +3 -0
- data/spec/physical_location_spec.rb +6 -0
- data/spec/searchworks_pub_dates_spec.rb +1 -0
- data/spec/searchworks_spec.rb +1 -0
- data/spec/searchworks_subject_raw_spec.rb +6 -0
- data/spec/searchworks_subject_spec.rb +2 -0
- data/spec/searchworks_title_spec.rb +36 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e9d2af555e2d1c5bf5e6bf11b0e41486999b9ccf5131551e1754b58cdcbd35d9
|
|
4
|
+
data.tar.gz: 88e8d8489fd5b10054511cf9e035ff8fb8082b17c1b19c77383056dd64408f19
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c634a77d490c3be26ee52467a0143a684d6c419662c80a746fc8fe790df46600065347636938359bfa9ed4c4afea5094c30b817ae9501c48aad928ad22895e8
|
|
7
|
+
data.tar.gz: 1e208cd646215f96d8a999a4fc8b636f1839433ae71c3b24356b5ba2d84cabe1fc7865bbb7bcbb8565c567e4bc56201c966b0a7813d52d787a8c1bbb1407f331
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2018-
|
|
3
|
+
# on 2018-11-14 11:35:35 -0800 using RuboCop version 0.60.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:
|
|
9
|
+
# Offense count: 1
|
|
10
10
|
# Cop supports --auto-correct.
|
|
11
|
-
# Configuration parameters:
|
|
11
|
+
# Configuration parameters: TreatCommentsAsGroupSeparators, Include.
|
|
12
12
|
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
|
|
13
13
|
Bundler/OrderedGems:
|
|
14
14
|
Exclude:
|
|
@@ -22,7 +22,7 @@ Layout/AccessModifierIndentation:
|
|
|
22
22
|
Exclude:
|
|
23
23
|
- 'lib/stanford-mods/origin_info.rb'
|
|
24
24
|
|
|
25
|
-
# Offense count:
|
|
25
|
+
# Offense count: 22
|
|
26
26
|
# Cop supports --auto-correct.
|
|
27
27
|
Layout/AlignArray:
|
|
28
28
|
Exclude:
|
|
@@ -47,7 +47,7 @@ Layout/BlockEndNewline:
|
|
|
47
47
|
Exclude:
|
|
48
48
|
- 'spec/name_spec.rb'
|
|
49
49
|
|
|
50
|
-
# Offense count:
|
|
50
|
+
# Offense count: 10
|
|
51
51
|
# Cop supports --auto-correct.
|
|
52
52
|
# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
|
|
53
53
|
# SupportedStyles: case, end
|
|
@@ -134,20 +134,20 @@ Layout/SpaceInsideBlockBraces:
|
|
|
134
134
|
Exclude:
|
|
135
135
|
- 'lib/stanford-mods/searchworks.rb'
|
|
136
136
|
|
|
137
|
-
# Offense count:
|
|
137
|
+
# Offense count: 6
|
|
138
138
|
# Cop supports --auto-correct.
|
|
139
139
|
# Configuration parameters: AllowInHeredoc.
|
|
140
140
|
Layout/TrailingWhitespace:
|
|
141
141
|
Exclude:
|
|
142
|
-
- 'lib/stanford-mods/searchworks.rb'
|
|
143
142
|
- 'spec/searchworks_spec.rb'
|
|
144
143
|
|
|
145
|
-
# Offense count:
|
|
144
|
+
# Offense count: 32
|
|
146
145
|
Metrics/AbcSize:
|
|
147
|
-
Max:
|
|
146
|
+
Max: 58
|
|
148
147
|
|
|
149
|
-
# Offense count:
|
|
148
|
+
# Offense count: 97
|
|
150
149
|
# Configuration parameters: CountComments, ExcludedMethods.
|
|
150
|
+
# ExcludedMethods: refine
|
|
151
151
|
Metrics/BlockLength:
|
|
152
152
|
Max: 795
|
|
153
153
|
|
|
@@ -156,24 +156,31 @@ Metrics/BlockLength:
|
|
|
156
156
|
Metrics/ClassLength:
|
|
157
157
|
Max: 377
|
|
158
158
|
|
|
159
|
-
# Offense count:
|
|
159
|
+
# Offense count: 18
|
|
160
160
|
Metrics/CyclomaticComplexity:
|
|
161
|
-
Max:
|
|
161
|
+
Max: 32
|
|
162
162
|
|
|
163
|
-
# Offense count:
|
|
163
|
+
# Offense count: 116
|
|
164
164
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
|
165
165
|
# URISchemes: http, https
|
|
166
166
|
Metrics/LineLength:
|
|
167
167
|
Max: 199
|
|
168
168
|
|
|
169
|
-
# Offense count:
|
|
170
|
-
# Configuration parameters: CountComments.
|
|
169
|
+
# Offense count: 31
|
|
170
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
|
171
171
|
Metrics/MethodLength:
|
|
172
172
|
Max: 52
|
|
173
173
|
|
|
174
|
-
# Offense count:
|
|
174
|
+
# Offense count: 14
|
|
175
175
|
Metrics/PerceivedComplexity:
|
|
176
|
-
Max:
|
|
176
|
+
Max: 25
|
|
177
|
+
|
|
178
|
+
# Offense count: 1
|
|
179
|
+
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
|
180
|
+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
|
181
|
+
Naming/FileName:
|
|
182
|
+
Exclude:
|
|
183
|
+
- 'lib/stanford-mods.rb'
|
|
177
184
|
|
|
178
185
|
# Offense count: 24
|
|
179
186
|
# Configuration parameters: Blacklist.
|
|
@@ -207,7 +214,7 @@ Naming/PredicateName:
|
|
|
207
214
|
|
|
208
215
|
# Offense count: 2
|
|
209
216
|
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
|
210
|
-
# AllowedNames: io, id, to, by, on, in, at
|
|
217
|
+
# AllowedNames: io, id, to, by, on, in, at, ip, db
|
|
211
218
|
Naming/UncommunicativeMethodParamName:
|
|
212
219
|
Exclude:
|
|
213
220
|
- 'lib/stanford-mods/imprint.rb'
|
|
@@ -245,7 +252,7 @@ RSpec/BeforeAfterAll:
|
|
|
245
252
|
- 'spec/searchworks_subject_spec.rb'
|
|
246
253
|
- 'spec/searchworks_title_spec.rb'
|
|
247
254
|
|
|
248
|
-
# Offense count:
|
|
255
|
+
# Offense count: 134
|
|
249
256
|
# Configuration parameters: Prefixes.
|
|
250
257
|
# Prefixes: when, with, without
|
|
251
258
|
RSpec/ContextWording:
|
|
@@ -283,6 +290,7 @@ RSpec/DescribeClass:
|
|
|
283
290
|
- 'spec/sw_publication_spec.rb'
|
|
284
291
|
|
|
285
292
|
# Offense count: 14
|
|
293
|
+
# Cop supports --auto-correct.
|
|
286
294
|
RSpec/EmptyLineAfterFinalLet:
|
|
287
295
|
Exclude:
|
|
288
296
|
- 'spec/name_spec.rb'
|
|
@@ -290,7 +298,7 @@ RSpec/EmptyLineAfterFinalLet:
|
|
|
290
298
|
- 'spec/physical_location_spec.rb'
|
|
291
299
|
- 'spec/sw_publication_spec.rb'
|
|
292
300
|
|
|
293
|
-
# Offense count:
|
|
301
|
+
# Offense count: 133
|
|
294
302
|
# Configuration parameters: Max.
|
|
295
303
|
RSpec/ExampleLength:
|
|
296
304
|
Exclude:
|
|
@@ -305,7 +313,8 @@ RSpec/ExampleLength:
|
|
|
305
313
|
- 'spec/searchworks_subject_spec.rb'
|
|
306
314
|
- 'spec/searchworks_title_spec.rb'
|
|
307
315
|
|
|
308
|
-
# Offense count:
|
|
316
|
+
# Offense count: 111
|
|
317
|
+
# Cop supports --auto-correct.
|
|
309
318
|
# Configuration parameters: CustomTransform, IgnoredWords.
|
|
310
319
|
RSpec/ExampleWording:
|
|
311
320
|
Exclude:
|
|
@@ -324,12 +333,13 @@ RSpec/FilePath:
|
|
|
324
333
|
- 'spec/lib/stanford-mods/coordinate_spec.rb'
|
|
325
334
|
|
|
326
335
|
# Offense count: 2
|
|
336
|
+
# Cop supports --auto-correct.
|
|
327
337
|
# Configuration parameters: .
|
|
328
338
|
# SupportedStyles: implicit, each, example
|
|
329
339
|
RSpec/HookArgument:
|
|
330
340
|
EnforcedStyle: each
|
|
331
341
|
|
|
332
|
-
# Offense count:
|
|
342
|
+
# Offense count: 931
|
|
333
343
|
# Configuration parameters: AssignmentOnly.
|
|
334
344
|
RSpec/InstanceVariable:
|
|
335
345
|
Exclude:
|
|
@@ -342,6 +352,7 @@ RSpec/InstanceVariable:
|
|
|
342
352
|
- 'spec/searchworks_title_spec.rb'
|
|
343
353
|
|
|
344
354
|
# Offense count: 2
|
|
355
|
+
# Cop supports --auto-correct.
|
|
345
356
|
RSpec/LetBeforeExamples:
|
|
346
357
|
Exclude:
|
|
347
358
|
- 'spec/origin_info_spec.rb'
|
|
@@ -357,7 +368,7 @@ RSpec/MultipleDescribes:
|
|
|
357
368
|
Exclude:
|
|
358
369
|
- 'spec/geo_spatial_spec.rb'
|
|
359
370
|
|
|
360
|
-
# Offense count:
|
|
371
|
+
# Offense count: 100
|
|
361
372
|
# Configuration parameters: AggregateFailuresByDefault.
|
|
362
373
|
RSpec/MultipleExpectations:
|
|
363
374
|
Max: 9
|
|
@@ -367,7 +378,7 @@ RSpec/NamedSubject:
|
|
|
367
378
|
Exclude:
|
|
368
379
|
- 'spec/lib/stanford-mods/coordinate_spec.rb'
|
|
369
380
|
|
|
370
|
-
# Offense count:
|
|
381
|
+
# Offense count: 36
|
|
371
382
|
RSpec/NestedGroups:
|
|
372
383
|
Max: 5
|
|
373
384
|
|
|
@@ -409,7 +420,7 @@ Style/BlockDelimiters:
|
|
|
409
420
|
- 'lib/stanford-mods/searchworks_subjects.rb'
|
|
410
421
|
- 'spec/name_spec.rb'
|
|
411
422
|
|
|
412
|
-
# Offense count:
|
|
423
|
+
# Offense count: 65
|
|
413
424
|
Style/CommentedKeyword:
|
|
414
425
|
Exclude:
|
|
415
426
|
- 'lib/stanford-mods.rb'
|
|
@@ -487,7 +498,7 @@ Style/IfUnlessModifier:
|
|
|
487
498
|
- 'lib/stanford-mods/date_parsing.rb'
|
|
488
499
|
- 'lib/stanford-mods/imprint.rb'
|
|
489
500
|
|
|
490
|
-
# Offense count:
|
|
501
|
+
# Offense count: 2
|
|
491
502
|
# Cop supports --auto-correct.
|
|
492
503
|
# Configuration parameters: InverseMethods, InverseBlocks.
|
|
493
504
|
Style/InverseMethods:
|
|
@@ -509,6 +520,11 @@ Style/MultilineTernaryOperator:
|
|
|
509
520
|
Exclude:
|
|
510
521
|
- 'lib/stanford-mods/physical_location.rb'
|
|
511
522
|
|
|
523
|
+
# Offense count: 1
|
|
524
|
+
Style/MultipleComparison:
|
|
525
|
+
Exclude:
|
|
526
|
+
- 'lib/stanford-mods/origin_info.rb'
|
|
527
|
+
|
|
512
528
|
# Offense count: 1
|
|
513
529
|
# Cop supports --auto-correct.
|
|
514
530
|
# Configuration parameters: EnforcedOctalStyle.
|
|
@@ -517,6 +533,15 @@ Style/NumericLiteralPrefix:
|
|
|
517
533
|
Exclude:
|
|
518
534
|
- 'spec/date_parsing_spec.rb'
|
|
519
535
|
|
|
536
|
+
# Offense count: 1
|
|
537
|
+
# Cop supports --auto-correct.
|
|
538
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
|
|
539
|
+
# SupportedStyles: predicate, comparison
|
|
540
|
+
Style/NumericPredicate:
|
|
541
|
+
Exclude:
|
|
542
|
+
- 'spec/**/*'
|
|
543
|
+
- 'lib/stanford-mods/searchworks.rb'
|
|
544
|
+
|
|
520
545
|
# Offense count: 8
|
|
521
546
|
# Cop supports --auto-correct.
|
|
522
547
|
Style/PerlBackrefs:
|
|
@@ -576,7 +601,7 @@ Style/StderrPuts:
|
|
|
576
601
|
Exclude:
|
|
577
602
|
- 'Rakefile'
|
|
578
603
|
|
|
579
|
-
# Offense count:
|
|
604
|
+
# Offense count: 12
|
|
580
605
|
# Cop supports --auto-correct.
|
|
581
606
|
# Configuration parameters: MinSize.
|
|
582
607
|
# SupportedStyles: percent, brackets
|
|
@@ -599,7 +624,7 @@ Style/UnneededCondition:
|
|
|
599
624
|
- 'lib/stanford-mods/origin_info.rb'
|
|
600
625
|
- 'lib/stanford-mods/searchworks.rb'
|
|
601
626
|
|
|
602
|
-
# Offense count:
|
|
627
|
+
# Offense count: 124
|
|
603
628
|
# Cop supports --auto-correct.
|
|
604
629
|
# Configuration parameters: MinSize, WordRegex.
|
|
605
630
|
# SupportedStyles: percent, brackets
|
data/.travis.yml
CHANGED
|
@@ -2,11 +2,11 @@ language: ruby
|
|
|
2
2
|
script: rake
|
|
3
3
|
rvm:
|
|
4
4
|
- 2.4.4
|
|
5
|
-
- 2.3.
|
|
5
|
+
- 2.3.7
|
|
6
6
|
# we used to use jruby for merged DOR + MARC records, but no more ...
|
|
7
|
-
- jruby-9.2.
|
|
7
|
+
- jruby-9.2.4.0
|
|
8
8
|
matrix:
|
|
9
9
|
allow_failures:
|
|
10
|
-
- rvm: jruby-9.2.
|
|
10
|
+
- rvm: jruby-9.2.4.0
|
|
11
11
|
notifications: false
|
|
12
12
|
sudo: false
|
data/Gemfile
CHANGED
|
@@ -4,11 +4,7 @@ source 'https://rubygems.org'
|
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
6
|
group :test, :development do
|
|
7
|
-
gem 'rubocop', require: false
|
|
7
|
+
gem 'rubocop', '~> 0.60.0', require: false
|
|
8
8
|
gem 'rubocop-rspec', require: false
|
|
9
|
-
gem 'pry-byebug', require: false, platform: [:ruby_20, :ruby_21]
|
|
10
9
|
gem 'coveralls', require: false
|
|
11
10
|
end
|
|
12
|
-
|
|
13
|
-
# Pin to activesupport 4.x for older versions of ruby
|
|
14
|
-
gem 'activesupport', '~> 4.2' if RUBY_VERSION < '2.2.2'
|
|
@@ -16,12 +16,14 @@ module Stanford
|
|
|
16
16
|
# @return [String] the coordinate in WKT/CQL ENVELOPE representation
|
|
17
17
|
def as_envelope
|
|
18
18
|
return unless valid?
|
|
19
|
+
|
|
19
20
|
"ENVELOPE(#{bounds[:min_x]}, #{bounds[:max_x]}, #{bounds[:max_y]}, #{bounds[:min_y]})"
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
# @return [String] the coordinate in Solr 4.x+ bbox-format representation
|
|
23
24
|
def as_bbox
|
|
24
25
|
return unless valid?
|
|
26
|
+
|
|
25
27
|
"#{bounds[:min_x]} #{bounds[:min_y]} #{bounds[:max_x]} #{bounds[:max_y]}"
|
|
26
28
|
end
|
|
27
29
|
|
|
@@ -44,6 +46,7 @@ module Stanford
|
|
|
44
46
|
@bounds ||= begin
|
|
45
47
|
matches = cleaner_coordinate(value).match %r{\A(?<lat>[EW].+-+.+)\s*/\s*(?<lng>[NS].+-+.+)\Z}
|
|
46
48
|
return {} unless matches
|
|
49
|
+
|
|
47
50
|
min_x, max_x = matches['lat'].split(/-+/).map { |x| coord_to_decimal(x) }.minmax
|
|
48
51
|
min_y, max_y = matches['lng'].split(/-+/).map { |y| coord_to_decimal(y) }.minmax
|
|
49
52
|
{ min_x: min_x, min_y: min_y, max_x: max_x, max_y: max_y }
|
|
@@ -32,6 +32,7 @@ module Stanford
|
|
|
32
32
|
# @return [Boolean] true if the year is between -999 and (current year + 1); false otherwise
|
|
33
33
|
def self.year_str_valid?(year_str)
|
|
34
34
|
return false unless year_str && (year_str.match(/^\d{1,4}$/) || year_str.match(/^-\d{1,3}$/))
|
|
35
|
+
|
|
35
36
|
(-1000 < year_str.to_i) && (year_str.to_i < Date.today.year + 2)
|
|
36
37
|
end
|
|
37
38
|
|
|
@@ -39,6 +40,7 @@ module Stanford
|
|
|
39
40
|
# @return [Boolean] true if the year is between -9999 and (current year + 1); false otherwise
|
|
40
41
|
def self.year_int_valid?(year)
|
|
41
42
|
return false unless year.is_a? Integer
|
|
43
|
+
|
|
42
44
|
(-1000 < year.to_i) && (year < Date.today.year + 2)
|
|
43
45
|
end
|
|
44
46
|
|
|
@@ -59,6 +61,7 @@ module Stanford
|
|
|
59
61
|
return display_str_for_bc if orig_date_str.match(BC_REGEX)
|
|
60
62
|
# decade next in case there are 4 digits, e.g. 1950s
|
|
61
63
|
return display_str_for_decade if orig_date_str.match(DECADE_4CHAR_REGEXP) || orig_date_str.match(DECADE_S_REGEXP)
|
|
64
|
+
|
|
62
65
|
result = sortable_year_for_yyyy_or_yy
|
|
63
66
|
unless result
|
|
64
67
|
# try removing brackets between digits in case we have 169[5] or [18]91
|
|
@@ -81,6 +84,7 @@ module Stanford
|
|
|
81
84
|
return if orig_date_str == '0000-00-00' # shpc collection has these useless dates
|
|
82
85
|
# B.C. first in case there are 4 digits, e.g. 1600 B.C.
|
|
83
86
|
return sortable_year_int_for_bc if orig_date_str.match(BC_REGEX)
|
|
87
|
+
|
|
84
88
|
result = sortable_year_for_yyyy_or_yy
|
|
85
89
|
result ||= sortable_year_for_decade # 19xx or 20xx
|
|
86
90
|
result ||= sortable_year_for_century
|
|
@@ -102,6 +106,7 @@ module Stanford
|
|
|
102
106
|
return if orig_date_str == '0000-00-00' # shpc collection has these useless dates
|
|
103
107
|
# B.C. first in case there are 4 digits, e.g. 1600 B.C.
|
|
104
108
|
return sortable_year_str_for_bc if orig_date_str.match(BC_REGEX)
|
|
109
|
+
|
|
105
110
|
result = sortable_year_for_yyyy_or_yy
|
|
106
111
|
result ||= sortable_year_for_decade # 19xx or 20xx
|
|
107
112
|
result ||= sortable_year_for_century
|
|
@@ -144,6 +149,7 @@ module Stanford
|
|
|
144
149
|
# @return [String, nil] 4 digit year (e.g. 1865, 0950) if orig_date_str matches pattern, nil otherwise
|
|
145
150
|
def sortable_year_for_yy
|
|
146
151
|
return unless orig_date_str
|
|
152
|
+
|
|
147
153
|
slash_matches = orig_date_str.match(/\d{1,2}\/\d{1,2}\/\d{2}/)
|
|
148
154
|
if slash_matches
|
|
149
155
|
date_obj = Date.strptime(orig_date_str, '%m/%d/%y')
|
|
@@ -196,6 +202,7 @@ module Stanford
|
|
|
196
202
|
def sortable_year_for_century
|
|
197
203
|
return unless orig_date_str
|
|
198
204
|
return if orig_date_str =~ /B\.C\./
|
|
205
|
+
|
|
199
206
|
century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP)
|
|
200
207
|
if century_matches
|
|
201
208
|
return $1 + '00' if $1.length == 2
|
|
@@ -215,6 +222,7 @@ module Stanford
|
|
|
215
222
|
def display_str_for_century
|
|
216
223
|
return unless orig_date_str
|
|
217
224
|
return if orig_date_str =~ /B\.C\./
|
|
225
|
+
|
|
218
226
|
century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)
|
|
219
227
|
return century_str_matches.to_s if century_str_matches
|
|
220
228
|
|
|
@@ -262,6 +270,7 @@ module Stanford
|
|
|
262
270
|
# @return [String, nil] String sortable -ddd if orig_date_str matches pattern; nil otherwise
|
|
263
271
|
def sortable_year_str_for_early_numeric
|
|
264
272
|
return unless orig_date_str.match(EARLY_NUMERIC)
|
|
273
|
+
|
|
265
274
|
if orig_date_str =~ /^\-/
|
|
266
275
|
# negative number becomes x - 1000 for sorting; -005 for -995
|
|
267
276
|
num = orig_date_str[1..-1].to_i - 1000
|
|
@@ -275,6 +284,7 @@ module Stanford
|
|
|
275
284
|
# @return [Integer, nil] Integer sortable -ddd if orig_date_str matches pattern; nil otherwise
|
|
276
285
|
def sortable_year_int_for_early_numeric
|
|
277
286
|
return orig_date_str.to_i if orig_date_str.match(EARLY_NUMERIC)
|
|
287
|
+
|
|
278
288
|
orig_date_str.to_i if orig_date_str =~ /^-\d{4}$/
|
|
279
289
|
end
|
|
280
290
|
|
|
@@ -290,6 +300,7 @@ module Stanford
|
|
|
290
300
|
return '1 B.C.' if orig_date_str == '0'
|
|
291
301
|
# negative number becomes B.C.
|
|
292
302
|
return "#{orig_date_str[1..-1].to_i + 1} B.C." if orig_date_str =~ /^\-/
|
|
303
|
+
|
|
293
304
|
# remove leading 0s from early dates
|
|
294
305
|
"#{orig_date_str.to_i} A.D."
|
|
295
306
|
end
|
|
@@ -304,6 +315,7 @@ module Stanford
|
|
|
304
315
|
# need more in string than only 2 digits
|
|
305
316
|
return if orig_date_str.match(/^\d\d$/) || orig_date_str.match(/^\D*\d\d\D*$/)
|
|
306
317
|
return if orig_date_str =~ /\d\s*B.C./ # skip B.C. dates
|
|
318
|
+
|
|
307
319
|
date_obj = Date.parse(orig_date_str)
|
|
308
320
|
date_obj.year.to_s
|
|
309
321
|
rescue ArgumentError
|
|
@@ -45,6 +45,7 @@ module Stanford
|
|
|
45
45
|
else
|
|
46
46
|
date_field_keys.map do |date_field|
|
|
47
47
|
next unless origin_info_node.respond_to?(date_field)
|
|
48
|
+
|
|
48
49
|
date_elements = origin_info_node.send(date_field)
|
|
49
50
|
date_elements.map(&:as_object).map(&:first) if date_elements.any?
|
|
50
51
|
end.first
|
|
@@ -82,6 +83,7 @@ module Stanford
|
|
|
82
83
|
compact_values = values.compact.reject { |v| v.strip.empty? }
|
|
83
84
|
return compact_values.join(delimiter) if compact_values.length == 1 ||
|
|
84
85
|
!ends_in_terminating_punctuation?(delimiter)
|
|
86
|
+
|
|
85
87
|
compact_values.each_with_index.map do |value, i|
|
|
86
88
|
if (compact_values.length - 1) == i || # last item?
|
|
87
89
|
ends_in_terminating_punctuation?(value)
|
|
@@ -104,6 +106,7 @@ module Stanford
|
|
|
104
106
|
|
|
105
107
|
def publisher_vals_str(origin_info_node)
|
|
106
108
|
return if origin_info_node.publisher.text.strip.empty?
|
|
109
|
+
|
|
107
110
|
publishers = origin_info_node.publisher.reject do |p|
|
|
108
111
|
p.text.strip.empty?
|
|
109
112
|
end.map(&:text)
|
|
@@ -114,6 +117,7 @@ module Stanford
|
|
|
114
117
|
|
|
115
118
|
def place_vals_str(origin_info_node)
|
|
116
119
|
return if origin_info_node.place.text.strip.empty?
|
|
120
|
+
|
|
117
121
|
places = place_terms(origin_info_node).reject do |p|
|
|
118
122
|
p.text.strip.empty?
|
|
119
123
|
end.map(&:text)
|
|
@@ -130,6 +134,7 @@ module Stanford
|
|
|
130
134
|
def place_terms(origin_info_element)
|
|
131
135
|
return [] unless origin_info_element.respond_to?(:place) &&
|
|
132
136
|
origin_info_element.place.respond_to?(:placeTerm)
|
|
137
|
+
|
|
133
138
|
if unencoded_place_terms?(origin_info_element)
|
|
134
139
|
origin_info_element.place.placeTerm.select do |term|
|
|
135
140
|
!term.attributes['type'].respond_to?(:value) ||
|
|
@@ -142,6 +147,7 @@ module Stanford
|
|
|
142
147
|
term.attributes['authority'].respond_to?(:value) &&
|
|
143
148
|
term.attributes['authority'].value == 'marccountry' &&
|
|
144
149
|
MARC_COUNTRIES.include?(term.text.strip)
|
|
150
|
+
|
|
145
151
|
term = term.clone
|
|
146
152
|
term.content = MARC_COUNTRIES[term.text.strip]
|
|
147
153
|
term
|
|
@@ -154,12 +160,14 @@ module Stanford
|
|
|
154
160
|
def date_str(origin_info_node)
|
|
155
161
|
date_vals = origin_info_date_vals(origin_info_node)
|
|
156
162
|
return if date_vals.empty?
|
|
163
|
+
|
|
157
164
|
date_vals.map(&:strip).join(' ')
|
|
158
165
|
end
|
|
159
166
|
|
|
160
167
|
def origin_info_date_vals(origin_info_node)
|
|
161
168
|
date_field_keys.map do |date_field|
|
|
162
169
|
next unless origin_info_node.respond_to?(date_field)
|
|
170
|
+
|
|
163
171
|
date_elements = origin_info_node.send(date_field)
|
|
164
172
|
date_elements_display_vals(date_elements) if date_elements.present?
|
|
165
173
|
end.compact.flatten
|
|
@@ -338,8 +346,8 @@ module Stanford
|
|
|
338
346
|
else
|
|
339
347
|
ng_date_element.content
|
|
340
348
|
end
|
|
341
|
-
|
|
342
|
-
|
|
349
|
+
rescue
|
|
350
|
+
ng_date_element.content
|
|
343
351
|
end
|
|
344
352
|
ng_date_element
|
|
345
353
|
end
|
|
@@ -352,8 +360,8 @@ module Stanford
|
|
|
352
360
|
else
|
|
353
361
|
ng_date_element.content
|
|
354
362
|
end
|
|
355
|
-
|
|
356
|
-
|
|
363
|
+
rescue
|
|
364
|
+
ng_date_element.content
|
|
357
365
|
end
|
|
358
366
|
ng_date_element
|
|
359
367
|
end
|
|
@@ -376,8 +384,8 @@ module Stanford
|
|
|
376
384
|
else
|
|
377
385
|
my_ng_date_element.content
|
|
378
386
|
end
|
|
379
|
-
|
|
380
|
-
|
|
387
|
+
rescue
|
|
388
|
+
my_ng_date_element.content
|
|
381
389
|
end
|
|
382
390
|
my_ng_date_element
|
|
383
391
|
end
|
|
@@ -398,8 +406,8 @@ module Stanford
|
|
|
398
406
|
else
|
|
399
407
|
my_ng_date_element.content
|
|
400
408
|
end
|
|
401
|
-
|
|
402
|
-
|
|
409
|
+
rescue
|
|
410
|
+
my_ng_date_element.content
|
|
403
411
|
end
|
|
404
412
|
my_ng_date_element
|
|
405
413
|
end
|
data/lib/stanford-mods/name.rb
CHANGED
|
@@ -45,6 +45,7 @@ module Stanford
|
|
|
45
45
|
result = []
|
|
46
46
|
mods_ng_xml.personal_name.map do |n|
|
|
47
47
|
next if n.role.size.zero?
|
|
48
|
+
|
|
48
49
|
n.role.each { |r|
|
|
49
50
|
result << n.display_value_w_date unless includes_marc_relator_collector_role?(r)
|
|
50
51
|
}
|
|
@@ -58,6 +59,7 @@ module Stanford
|
|
|
58
59
|
result = []
|
|
59
60
|
mods_ng_xml.personal_name.each do |n|
|
|
60
61
|
next if n.role.size.zero?
|
|
62
|
+
|
|
61
63
|
n.role.each { |r|
|
|
62
64
|
result << n.display_value_w_date if includes_marc_relator_collector_role?(r)
|
|
63
65
|
}
|
|
@@ -82,6 +82,7 @@ module Stanford
|
|
|
82
82
|
def year_display_str(date_el_array)
|
|
83
83
|
result = date_parsing_result(date_el_array, :date_str_for_display)
|
|
84
84
|
return result if result
|
|
85
|
+
|
|
85
86
|
_ignore, orig_str_to_parse = self.class.earliest_year_str(date_el_array)
|
|
86
87
|
DateParsing.date_str_for_display(orig_str_to_parse) if orig_str_to_parse
|
|
87
88
|
end
|
|
@@ -93,6 +94,7 @@ module Stanford
|
|
|
93
94
|
def year_int(date_el_array)
|
|
94
95
|
result = date_parsing_result(date_el_array, :year_int_from_date_str)
|
|
95
96
|
return result if result
|
|
97
|
+
|
|
96
98
|
year_int, _ignore = self.class.earliest_year_int(date_el_array)
|
|
97
99
|
year_int if year_int
|
|
98
100
|
end
|
|
@@ -104,6 +106,7 @@ module Stanford
|
|
|
104
106
|
def year_sort_str(date_el_array)
|
|
105
107
|
result = date_parsing_result(date_el_array, :sortable_year_string_from_date_str)
|
|
106
108
|
return result if result
|
|
109
|
+
|
|
107
110
|
sortable_str, _ignore = self.class.earliest_year_str(date_el_array)
|
|
108
111
|
sortable_str if sortable_str
|
|
109
112
|
end
|
|
@@ -115,6 +118,7 @@ module Stanford
|
|
|
115
118
|
def date_created_elements(ignore_approximate = false)
|
|
116
119
|
date_created_nodeset = mods_ng_xml.origin_info.dateCreated
|
|
117
120
|
return self.class.remove_approximate(date_created_nodeset) if ignore_approximate
|
|
121
|
+
|
|
118
122
|
date_created_nodeset.to_a
|
|
119
123
|
end
|
|
120
124
|
|
|
@@ -125,6 +129,7 @@ module Stanford
|
|
|
125
129
|
def date_issued_elements(ignore_approximate = false)
|
|
126
130
|
date_issued_nodeset = mods_ng_xml.origin_info.dateIssued
|
|
127
131
|
return self.class.remove_approximate(date_issued_nodeset) if ignore_approximate
|
|
132
|
+
|
|
128
133
|
date_issued_nodeset.to_a
|
|
129
134
|
end
|
|
130
135
|
|
|
@@ -194,6 +199,7 @@ module Stanford
|
|
|
194
199
|
# @return [Integer, String] year as a String or Integer, depending on method_sym
|
|
195
200
|
def date_parsing_result(date_el_array, method_sym)
|
|
196
201
|
return if date_el_array.empty?
|
|
202
|
+
|
|
197
203
|
# prefer keyDate
|
|
198
204
|
key_date_el = self.class.keyDate(date_el_array)
|
|
199
205
|
DateParsing.send(method_sym, key_date_el.content) if key_date_el
|
|
@@ -239,6 +245,7 @@ module Stanford
|
|
|
239
245
|
return nil unless pub_date
|
|
240
246
|
return "#{pub_date.to_i + 1000} B.C." if pub_date.start_with?('-')
|
|
241
247
|
return pub_date unless pub_date.include? '--'
|
|
248
|
+
|
|
242
249
|
"#{pub_date[0, 2].to_i + 1}th century"
|
|
243
250
|
end
|
|
244
251
|
|
|
@@ -251,6 +258,7 @@ module Stanford
|
|
|
251
258
|
pd = pd.gsub('--', '00')
|
|
252
259
|
end
|
|
253
260
|
fail "pub_date_sort was about to return a non 4 digit value #{pd}!" if pd && pd.length != 4
|
|
261
|
+
|
|
254
262
|
pd
|
|
255
263
|
end
|
|
256
264
|
|
|
@@ -261,6 +269,7 @@ module Stanford
|
|
|
261
269
|
def pub_date_display
|
|
262
270
|
return dates_no_marc_encoding.first unless dates_no_marc_encoding.empty?
|
|
263
271
|
return dates_marc_encoding.first unless dates_marc_encoding.empty?
|
|
272
|
+
|
|
264
273
|
nil
|
|
265
274
|
end
|
|
266
275
|
|
|
@@ -274,6 +283,7 @@ module Stanford
|
|
|
274
283
|
# use the cached year if there is one
|
|
275
284
|
if @pub_year
|
|
276
285
|
return nil if @pub_year == ''
|
|
286
|
+
|
|
277
287
|
return @pub_year
|
|
278
288
|
end
|
|
279
289
|
|
|
@@ -307,6 +317,7 @@ module Stanford
|
|
|
307
317
|
def pub_dates
|
|
308
318
|
return dates_marc_encoding unless dates_marc_encoding.empty?
|
|
309
319
|
return dates_no_marc_encoding unless dates_no_marc_encoding.empty?
|
|
320
|
+
|
|
310
321
|
nil
|
|
311
322
|
end
|
|
312
323
|
|
|
@@ -410,6 +421,7 @@ module Stanford
|
|
|
410
421
|
dates.each do |f_date|
|
|
411
422
|
matches = f_date.scan(/\d{1}th/)
|
|
412
423
|
next if matches.empty?
|
|
424
|
+
|
|
413
425
|
if matches.length == 1
|
|
414
426
|
@pub_year = (matches.first[0, 2].to_i - 1).to_s + '--'
|
|
415
427
|
return @pub_year
|
|
@@ -436,6 +448,7 @@ module Stanford
|
|
|
436
448
|
dates.each do |f_date|
|
|
437
449
|
matches = f_date.scan(/\d{2}th/)
|
|
438
450
|
next if matches.empty?
|
|
451
|
+
|
|
439
452
|
if matches.length == 1
|
|
440
453
|
@pub_year = (matches.first[0, 2].to_i - 1).to_s + '--'
|
|
441
454
|
return @pub_year
|
|
@@ -464,6 +477,7 @@ module Stanford
|
|
|
464
477
|
# Single digit u notation
|
|
465
478
|
matches = f_date.scan(/\d{3}u/)
|
|
466
479
|
return matches.first.tr('u', '0') if matches.length == 1
|
|
480
|
+
|
|
467
481
|
# Double digit u notation
|
|
468
482
|
matches = f_date.scan(/\d{2}u{2}/)
|
|
469
483
|
return matches.first.tr('u', '-') if matches.length == 1
|
|
@@ -153,12 +153,13 @@ module Stanford
|
|
|
153
153
|
first_title_info_node.title.text.strip.empty? ? nil : first_title_info_node.title.text.strip
|
|
154
154
|
end
|
|
155
155
|
|
|
156
|
+
# Searchworks requires that the MODS has a '//titleInfo/title'
|
|
156
157
|
# @return [String] value for title_245_search, title_full_display
|
|
157
158
|
def sw_full_title
|
|
159
|
+
return nil if !first_title_info_node || !title
|
|
158
160
|
|
|
159
|
-
return nil unless first_title_info_node
|
|
160
161
|
preSubTitle = nonSort_title ? [nonSort_title, title].compact.join(" ") : title
|
|
161
|
-
preSubTitle.sub!(/:$/, '')
|
|
162
|
+
preSubTitle.sub!(/:$/, '')
|
|
162
163
|
|
|
163
164
|
subTitle = first_title_info_node.subTitle.text.strip
|
|
164
165
|
preParts = subTitle.empty? ? preSubTitle : preSubTitle + " : " + subTitle
|
|
@@ -178,6 +179,7 @@ module Stanford
|
|
|
178
179
|
|
|
179
180
|
result = parts ? preParts + ". " + parts : preParts
|
|
180
181
|
return nil unless result
|
|
182
|
+
|
|
181
183
|
result += "." unless result =~ /[[:punct:]]$/
|
|
182
184
|
result.strip!
|
|
183
185
|
result = nil if result.empty?
|
|
@@ -191,13 +193,20 @@ module Stanford
|
|
|
191
193
|
def sw_title_display
|
|
192
194
|
result = sw_full_title
|
|
193
195
|
return nil unless result
|
|
196
|
+
|
|
194
197
|
result.sub(/[\.,;:\/\\]+$/, '').strip
|
|
195
198
|
end
|
|
196
199
|
|
|
197
200
|
# this includes all titles except
|
|
198
201
|
# @return [Array<String>] values for title_variant_search
|
|
199
202
|
def sw_addl_titles
|
|
200
|
-
|
|
203
|
+
excluded_title = sw_short_title || sw_title_display
|
|
204
|
+
if excluded_title.present?
|
|
205
|
+
title_regex = Regexp.new(Regexp.escape(excluded_title))
|
|
206
|
+
full_titles.reject { |s| s =~ title_regex }.reject(&:blank?)
|
|
207
|
+
else
|
|
208
|
+
full_titles.reject(&:blank?)
|
|
209
|
+
end
|
|
201
210
|
end
|
|
202
211
|
|
|
203
212
|
# Returns a sortable version of the main title
|
|
@@ -235,6 +244,7 @@ module Stanford
|
|
|
235
244
|
def format_main
|
|
236
245
|
types = typeOfResource
|
|
237
246
|
return [] unless types
|
|
247
|
+
|
|
238
248
|
article_genres = ['article', 'Article',
|
|
239
249
|
'book chapter', 'Book chapter', 'Book Chapter',
|
|
240
250
|
'issue brief', 'Issue brief', 'Issue Brief',
|
|
@@ -295,6 +305,7 @@ module Stanford
|
|
|
295
305
|
def sw_genre
|
|
296
306
|
genres = term_values(:genre)
|
|
297
307
|
return [] unless genres
|
|
308
|
+
|
|
298
309
|
val = genres.map(&:to_s)
|
|
299
310
|
thesis_pub = ['thesis', 'Thesis']
|
|
300
311
|
val << 'Thesis/Dissertation' if (genres & thesis_pub).any?
|
|
@@ -314,6 +325,7 @@ module Stanford
|
|
|
314
325
|
def catkey
|
|
315
326
|
catkey = term_values([:record_info, :recordIdentifier])
|
|
316
327
|
return nil unless catkey && !catkey.empty?
|
|
328
|
+
|
|
317
329
|
catkey.first.tr('a', '') # ensure catkey is numeric only
|
|
318
330
|
end
|
|
319
331
|
end # class Record
|
|
@@ -109,12 +109,14 @@ module Stanford
|
|
|
109
109
|
if codes && codes.size > xvals.size
|
|
110
110
|
subject.geographicCode.each { |n|
|
|
111
111
|
next unless n.authority != 'marcgac' && n.authority != 'marccountry'
|
|
112
|
+
|
|
112
113
|
sw_logger.info("#{druid} has subject geographicCode element with untranslated encoding (#{n.authority}): #{n.to_xml}")
|
|
113
114
|
}
|
|
114
115
|
end
|
|
115
116
|
|
|
116
117
|
# FIXME: stanford-mods should be returning [], not nil ...
|
|
117
118
|
return nil if !result || result.empty?
|
|
119
|
+
|
|
118
120
|
result
|
|
119
121
|
end
|
|
120
122
|
end
|
data/spec/date_parsing_spec.rb
CHANGED
|
@@ -394,12 +394,14 @@ describe "date parsing methods" do
|
|
|
394
394
|
Stanford::Mods::DateParsing.date_str_for_display('1666')
|
|
395
395
|
end
|
|
396
396
|
end
|
|
397
|
+
|
|
397
398
|
context '*sortable_year_string_from_date_str' do
|
|
398
399
|
it 'calls instance method sortable_year_string_from_date_str' do
|
|
399
400
|
expect_any_instance_of(Stanford::Mods::DateParsing).to receive(:sortable_year_string_from_date_str)
|
|
400
401
|
Stanford::Mods::DateParsing.sortable_year_string_from_date_str('1666')
|
|
401
402
|
end
|
|
402
403
|
end
|
|
404
|
+
|
|
403
405
|
context '*year_int_from_date_str' do
|
|
404
406
|
it 'calls instance method year_int_from_date_str' do
|
|
405
407
|
expect_any_instance_of(Stanford::Mods::DateParsing).to receive(:year_int_from_date_str)
|
data/spec/imprint_spec.rb
CHANGED
data/spec/name_spec.rb
CHANGED
|
@@ -284,6 +284,7 @@ describe "name/author concepts" do
|
|
|
284
284
|
expect(smods_rec.non_collector_person_authors).to eq [name]
|
|
285
285
|
end
|
|
286
286
|
end
|
|
287
|
+
|
|
287
288
|
it 'nil if only collectors' do
|
|
288
289
|
name_snippet =
|
|
289
290
|
<<-EOF
|
|
@@ -345,6 +346,7 @@ describe "name/author concepts" do
|
|
|
345
346
|
expect(smods_rec.collectors_w_dates).to eq [collector_name]
|
|
346
347
|
end
|
|
347
348
|
end
|
|
349
|
+
|
|
348
350
|
context 'no valueURI for roleTerm' do
|
|
349
351
|
it 'collector marc relator code' do
|
|
350
352
|
name_snippet =
|
|
@@ -373,6 +375,7 @@ describe "name/author concepts" do
|
|
|
373
375
|
expect(smods_rec.collectors_w_dates).to eq [collector_name]
|
|
374
376
|
end
|
|
375
377
|
end
|
|
378
|
+
|
|
376
379
|
it 'does not include non-collectors' do
|
|
377
380
|
name_snippet =
|
|
378
381
|
<<-EOF
|
data/spec/origin_info_spec.rb
CHANGED
|
@@ -66,6 +66,7 @@ describe "computations from /originInfo field" do
|
|
|
66
66
|
SPOTLIGHT_PUB_DATE_DATA.each_pair.each do |coll_name, coll_data|
|
|
67
67
|
# papyri - the only Spotlight data with BC dates
|
|
68
68
|
next if coll_name == 'papyri' && method_sym == :pub_year_int
|
|
69
|
+
|
|
69
70
|
coll_data.each_pair do |mods_str, exp_vals|
|
|
70
71
|
expected = exp_vals[exp_val_position]
|
|
71
72
|
it "#{expected} for rec in #{coll_name}" do
|
|
@@ -303,6 +304,7 @@ describe "computations from /originInfo field" do
|
|
|
303
304
|
end
|
|
304
305
|
end
|
|
305
306
|
end
|
|
307
|
+
|
|
306
308
|
context "retains element when attribute qualifer=" do
|
|
307
309
|
['inferred', 'invalid_attr_val'].each do |attr_val|
|
|
308
310
|
let(:qual_attr_val) { attr_val }
|
|
@@ -372,6 +374,7 @@ describe "computations from /originInfo field" do
|
|
|
372
374
|
end
|
|
373
375
|
end
|
|
374
376
|
end
|
|
377
|
+
|
|
375
378
|
context "retains element when attribute qualifer=" do
|
|
376
379
|
['inferred', 'invalid_attr_val'].each do |attr_val|
|
|
377
380
|
let(:qual_attr_val) { attr_val }
|
|
@@ -74,6 +74,7 @@ describe "Physical Location for series, box, folder" do
|
|
|
74
74
|
expect(@smods_rec.box).to eq expected
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
|
+
|
|
77
78
|
context 'in /relatedItem/location/physicalLocation' do
|
|
78
79
|
it "has the expected box label '#{expected}'" do
|
|
79
80
|
@smods_rec.from_str(mods_rel_item_loc_phys_loc)
|
|
@@ -131,6 +132,7 @@ describe "Physical Location for series, box, folder" do
|
|
|
131
132
|
expect(@smods_rec.folder).to eq expected
|
|
132
133
|
end
|
|
133
134
|
end
|
|
135
|
+
|
|
134
136
|
context 'in /relatedItem/location/physicalLocation' do
|
|
135
137
|
it "has the expected folder label '#{expected}'" do
|
|
136
138
|
@smods_rec.from_str(mods_rel_item_loc_phys_loc)
|
|
@@ -179,12 +181,14 @@ describe "Physical Location for series, box, folder" do
|
|
|
179
181
|
expect(@smods_rec.physical_location_str).to eq expected
|
|
180
182
|
end
|
|
181
183
|
end
|
|
184
|
+
|
|
182
185
|
context 'in /relatedItem/location/physicalLocation' do
|
|
183
186
|
it "has the expected location '#{expected}'" do
|
|
184
187
|
@smods_rec.from_str(mods_rel_item_loc_phys_loc)
|
|
185
188
|
expect(@smods_rec.physical_location_str).to eq expected
|
|
186
189
|
end
|
|
187
190
|
end
|
|
191
|
+
|
|
188
192
|
context 'with multiple physicalLocation elements' do
|
|
189
193
|
it "has the expected location '#{expected}'" do
|
|
190
194
|
@smods_rec.from_str(mods_loc_multiple_phys_loc)
|
|
@@ -233,12 +237,14 @@ describe "Physical Location for series, box, folder" do
|
|
|
233
237
|
expect(@smods_rec.series).to eq expected
|
|
234
238
|
end
|
|
235
239
|
end
|
|
240
|
+
|
|
236
241
|
context 'in /relatedItem/location/physicalLocation' do
|
|
237
242
|
it "has the expected series name '#{expected}'" do
|
|
238
243
|
@smods_rec.from_str(mods_rel_item_loc_phys_loc)
|
|
239
244
|
expect(@smods_rec.series).to eq expected
|
|
240
245
|
end
|
|
241
246
|
end
|
|
247
|
+
|
|
242
248
|
context 'with multiple physicalLocation elements' do
|
|
243
249
|
it "has the expected series name '#{expected}'" do
|
|
244
250
|
@smods_rec.from_str(mods_loc_multiple_phys_loc)
|
|
@@ -212,6 +212,7 @@ describe "Date methods (searchworks.rb)" do
|
|
|
212
212
|
expect(smods_rec.send(:pub_date)).to eq('8--')
|
|
213
213
|
end
|
|
214
214
|
end # pub_date
|
|
215
|
+
|
|
215
216
|
context "pub_dates (protected)" do
|
|
216
217
|
it "puts dateIssued values before dateCreated values" do
|
|
217
218
|
m = "<mods #{ns_decl}><originInfo>
|
data/spec/searchworks_spec.rb
CHANGED
|
@@ -97,6 +97,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
|
97
97
|
</mods>"
|
|
98
98
|
@smods_rec.from_str(m)
|
|
99
99
|
end
|
|
100
|
+
|
|
100
101
|
it "main author (for author_1xx_search)" do
|
|
101
102
|
expect(@smods_rec).to receive(:main_author_w_date) # in stanford-mods.rb
|
|
102
103
|
@smods_rec.sw_main_author
|
|
@@ -128,6 +128,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
|
128
128
|
</mods>"
|
|
129
129
|
@smods_rec.from_str m
|
|
130
130
|
end
|
|
131
|
+
|
|
131
132
|
it "uses a ', ' as the separator by default" do
|
|
132
133
|
expect(@smods_rec.sw_subject_names).to eq ['first, second']
|
|
133
134
|
end
|
|
@@ -192,6 +193,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
|
192
193
|
</mods>"
|
|
193
194
|
@smods_rec.from_str m
|
|
194
195
|
end
|
|
196
|
+
|
|
195
197
|
it "uses a ' ' as the separator by default" do
|
|
196
198
|
expect(@smods_rec.sw_subject_titles).to eq ['first second']
|
|
197
199
|
end
|
|
@@ -276,6 +278,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
|
276
278
|
expect(@smods_rec.sw_geographic_search).to eq([])
|
|
277
279
|
end
|
|
278
280
|
end
|
|
281
|
+
|
|
279
282
|
context "hierarchicalGeographic subelement" do
|
|
280
283
|
it "should have a separate value for each hierarchicalGeographic element" do
|
|
281
284
|
m = "<mods #{@ns_decl}>
|
|
@@ -305,6 +308,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
|
305
308
|
</subject></mods>"
|
|
306
309
|
@smods_rec.from_str m
|
|
307
310
|
end
|
|
311
|
+
|
|
308
312
|
it "uses a space as the separator by default" do
|
|
309
313
|
expect(@smods_rec.sw_geographic_search).to eq ['Canada British Columbia Vancouver']
|
|
310
314
|
end
|
|
@@ -313,6 +317,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
|
313
317
|
end
|
|
314
318
|
end
|
|
315
319
|
end # hierarchicalGeographic
|
|
320
|
+
|
|
316
321
|
context "geographicCode subelement" do
|
|
317
322
|
before(:all) do
|
|
318
323
|
m = "<mods #{@ns_decl}>
|
|
@@ -324,6 +329,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
|
324
329
|
@smods_rec.from_str m
|
|
325
330
|
@geo_search_from_codes = @smods_rec.sw_geographic_search
|
|
326
331
|
end
|
|
332
|
+
|
|
327
333
|
it "should not add untranslated values" do
|
|
328
334
|
expect(@geo_search_from_codes).not_to include('n-us-md')
|
|
329
335
|
expect(@geo_search_from_codes).not_to include('e-er')
|
|
@@ -240,6 +240,7 @@ describe "Subject fields (searchworks.rb)" do
|
|
|
240
240
|
expect(@smods_rec.subject_other_subvy_search).to be_nil
|
|
241
241
|
end
|
|
242
242
|
end
|
|
243
|
+
|
|
243
244
|
context "genre subelement" do
|
|
244
245
|
it "should have a separate value for each genre element" do
|
|
245
246
|
m = "<mods #{@ns_decl}>
|
|
@@ -266,6 +267,7 @@ describe "Subject fields (searchworks.rb)" do
|
|
|
266
267
|
before :each do
|
|
267
268
|
allow(@smods_rec.sw_logger).to receive(:info).with(/ has subject geographicCode element with untranslated encoding \(iso3166\): <geographicCode authority=.*>us<\/geographicCode>/)
|
|
268
269
|
end
|
|
270
|
+
|
|
269
271
|
it "should be nil if there are no values in the MODS" do
|
|
270
272
|
@smods_rec = Stanford::Mods::Record.new
|
|
271
273
|
@smods_rec.from_str(@ng_mods_no_subject.to_s)
|
|
@@ -27,6 +27,19 @@ describe 'title fields (searchworks.rb)' do
|
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
context 'when titleInfo contains a subTitle but no title' do
|
|
31
|
+
let(:record) do
|
|
32
|
+
m = "<mods #{@ns_decl}><titleInfo><subTitle>An overview from 1942-1950</subTitle></titleInfo></mods>"
|
|
33
|
+
rec = Stanford::Mods::Record.new
|
|
34
|
+
rec.from_str m
|
|
35
|
+
rec
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'returns nil' do
|
|
39
|
+
expect(record.sw_full_title).to be_nil
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
30
43
|
context 'missing title node' do
|
|
31
44
|
it 'deals with missing titleInfo node' do
|
|
32
45
|
m = "<mods #{@ns_decl}></mods>"
|
|
@@ -80,6 +93,7 @@ describe 'title fields (searchworks.rb)' do
|
|
|
80
93
|
expect(@smods_rec.sw_full_title).to eq 'The Olympics!'
|
|
81
94
|
end
|
|
82
95
|
end # no subtitle
|
|
96
|
+
|
|
83
97
|
context 'subtitle' do
|
|
84
98
|
it 'end title with a colon' do
|
|
85
99
|
m = "<mods #{@ns_decl}>
|
|
@@ -123,6 +137,7 @@ describe 'title fields (searchworks.rb)' do
|
|
|
123
137
|
expect(@smods_rec.sw_full_title).to eq 'The Olympics : a history?'
|
|
124
138
|
end
|
|
125
139
|
end # subtitle
|
|
140
|
+
|
|
126
141
|
context 'partName' do
|
|
127
142
|
context 'no partNumber' do
|
|
128
143
|
it 'end partName with period' do
|
|
@@ -162,6 +177,7 @@ describe 'title fields (searchworks.rb)' do
|
|
|
162
177
|
expect(@smods_rec.sw_full_title).to eq 'cfb. Appendix.'
|
|
163
178
|
end
|
|
164
179
|
end # no partNumber
|
|
180
|
+
|
|
165
181
|
context 'partNumber' do
|
|
166
182
|
it 'end partNumber with comma' do
|
|
167
183
|
m = "<mods #{@ns_decl}>
|
|
@@ -205,6 +221,7 @@ describe 'title fields (searchworks.rb)' do
|
|
|
205
221
|
end
|
|
206
222
|
end
|
|
207
223
|
end # partName
|
|
224
|
+
|
|
208
225
|
context 'no partName, but partNumber' do
|
|
209
226
|
it 'end partNumber with period' do
|
|
210
227
|
m = "<mods #{@ns_decl}>
|
|
@@ -322,6 +339,7 @@ describe 'title fields (searchworks.rb)' do
|
|
|
322
339
|
expect(@smods_rec.sw_title_display).to eq 'The Jerk'
|
|
323
340
|
end
|
|
324
341
|
end
|
|
342
|
+
|
|
325
343
|
context 'no subtitle' do
|
|
326
344
|
it 'end title with a period' do
|
|
327
345
|
m = "<mods #{@ns_decl}>
|
|
@@ -351,6 +369,7 @@ describe 'title fields (searchworks.rb)' do
|
|
|
351
369
|
expect(@smods_rec.sw_title_display).to eq 'The Olympics!'
|
|
352
370
|
end
|
|
353
371
|
end # no subtitle
|
|
372
|
+
|
|
354
373
|
context 'subtitle' do
|
|
355
374
|
it 'end title with a colon' do
|
|
356
375
|
m = "<mods #{@ns_decl}>
|
|
@@ -394,6 +413,7 @@ describe 'title fields (searchworks.rb)' do
|
|
|
394
413
|
expect(@smods_rec.sw_title_display).to eq 'The Olympics : a history?'
|
|
395
414
|
end
|
|
396
415
|
end # subtitle
|
|
416
|
+
|
|
397
417
|
context 'partName' do
|
|
398
418
|
context 'no partNumber' do
|
|
399
419
|
it 'end partName with period' do
|
|
@@ -433,6 +453,7 @@ describe 'title fields (searchworks.rb)' do
|
|
|
433
453
|
expect(@smods_rec.sw_title_display).to eq 'cfb. Appendix'
|
|
434
454
|
end
|
|
435
455
|
end # no partNumber
|
|
456
|
+
|
|
436
457
|
context 'partNumber' do
|
|
437
458
|
it 'end partNumber with comma' do
|
|
438
459
|
m = "<mods #{@ns_decl}>
|
|
@@ -476,6 +497,7 @@ describe 'title fields (searchworks.rb)' do
|
|
|
476
497
|
end
|
|
477
498
|
end
|
|
478
499
|
end # partName
|
|
500
|
+
|
|
479
501
|
context 'no partName, but partNumber' do
|
|
480
502
|
it 'end partNumber with period' do
|
|
481
503
|
m = "<mods #{@ns_decl}>
|
|
@@ -544,6 +566,7 @@ describe 'title fields (searchworks.rb)' do
|
|
|
544
566
|
@smods_rec.from_str(m)
|
|
545
567
|
@addl_titles = @smods_rec.sw_addl_titles
|
|
546
568
|
end
|
|
569
|
+
|
|
547
570
|
it 'should not include the main title' do
|
|
548
571
|
expect(@addl_titles.size).to eq 2
|
|
549
572
|
expect(@addl_titles).not_to include(@smods_rec.sw_full_title)
|
|
@@ -563,6 +586,18 @@ describe 'title fields (searchworks.rb)' do
|
|
|
563
586
|
@smods_rec.from_str(m)
|
|
564
587
|
expect(@smods_rec.sw_addl_titles).to eq ['Alternative', 'Joke]']
|
|
565
588
|
end
|
|
589
|
+
it 'excludes weird cases where there is no short title' do
|
|
590
|
+
m = <<-EOXML
|
|
591
|
+
<mods #{@ns_decl}>
|
|
592
|
+
<titleInfo></titleInfo>
|
|
593
|
+
<titleInfo type="alternative">
|
|
594
|
+
<title>Sponsored projects report for the year ended</title>
|
|
595
|
+
</titleInfo>
|
|
596
|
+
</mods>
|
|
597
|
+
EOXML
|
|
598
|
+
@smods_rec.from_str(m)
|
|
599
|
+
expect(@smods_rec.sw_addl_titles).to be_empty
|
|
600
|
+
end
|
|
566
601
|
end
|
|
567
602
|
|
|
568
603
|
context 'sort title' do
|
|
@@ -630,6 +665,7 @@ describe 'title fields (searchworks.rb)' do
|
|
|
630
665
|
</titleInfo></mods>"
|
|
631
666
|
@all_smods_rec.from_str(all)
|
|
632
667
|
end
|
|
668
|
+
|
|
633
669
|
it 'short titles' do
|
|
634
670
|
expect(@mccarthy_smods_rec.sw_short_title).to eql 'McCarthy, John'
|
|
635
671
|
expect(@insp_general_smods_rec.sw_short_title).to eql 'Semiannual report to Congress'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stanford-mods
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.6.
|
|
4
|
+
version: 2.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Naomi Dushay
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2018-
|
|
12
|
+
date: 2018-11-15 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: mods
|
|
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
171
171
|
version: '0'
|
|
172
172
|
requirements: []
|
|
173
173
|
rubyforge_project:
|
|
174
|
-
rubygems_version: 2.6
|
|
174
|
+
rubygems_version: 2.7.6
|
|
175
175
|
signing_key:
|
|
176
176
|
specification_version: 4
|
|
177
177
|
summary: Stanford specific wrangling of MODS metadata
|