stanford-mods 2.6.0 → 2.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +24 -0
- data/.rubocop.yml +2 -2
- data/.rubocop_todo.yml +126 -79
- data/Gemfile +0 -10
- data/lib/stanford-mods/coordinate.rb +3 -0
- data/lib/stanford-mods/date_parsing.rb +14 -1
- data/lib/stanford-mods/imprint.rb +19 -10
- data/lib/stanford-mods/name.rb +3 -1
- data/lib/stanford-mods/origin_info.rb +14 -0
- data/lib/stanford-mods/searchworks.rb +15 -3
- data/lib/stanford-mods/searchworks_languages.rb +4 -0
- data/lib/stanford-mods/searchworks_subjects.rb +2 -0
- data/lib/stanford-mods/version.rb +1 -1
- data/lib/stanford-mods.rb +1 -0
- data/spec/date_parsing_spec.rb +3 -1
- data/spec/fixtures/searchworks_imprint_data.rb +1 -1
- data/spec/fixtures/searchworks_pub_date_data.rb +1 -1
- data/spec/imprint_spec.rb +2 -0
- data/spec/name_spec.rb +5 -2
- 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
- data/spec/spec_helper.rb +2 -2
- data/stanford-mods.gemspec +3 -0
- metadata +49 -8
- data/.travis.yml +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 922ecb4ab53df951ef735de705037f218347938cac621886b54dc71463c215a6
|
4
|
+
data.tar.gz: 5426c132435bdc34a74df664b4bcbc6797682482689e0843ebdc7527e8df0715
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb12a388c219e4b9f99746d543ecc38cc1a67bc68302dc4255c81a088ffaad2fada7f6387b9525441d199c7ec536f54ba109f38ad92bf2d1d6d771077cdbc6d5
|
7
|
+
data.tar.gz: 2b904ae85c26eef0717a8e1250a7385889b00fe55c2e8ee59c83798f55f46e4e0ee4593f054dc3ab1a02e18095813ba3b16632f77340ddc212a54f36a871931a
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
tests:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby: [jruby-9.2.14.0, 2.7, 3.0]
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- name: Set up Ruby
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
21
|
+
- name: Install dependencies
|
22
|
+
run: bundle install
|
23
|
+
- name: Run tests
|
24
|
+
run: bundle exec rake
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,19 +1,11 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2020-03-13 16:37:30 -0700 using RuboCop version 0.80.1.
|
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: 2
|
10
|
-
# Cop supports --auto-correct.
|
11
|
-
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
|
12
|
-
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
|
13
|
-
Bundler/OrderedGems:
|
14
|
-
Exclude:
|
15
|
-
- 'Gemfile'
|
16
|
-
|
17
9
|
# Offense count: 1
|
18
10
|
# Cop supports --auto-correct.
|
19
11
|
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
@@ -22,32 +14,20 @@ Layout/AccessModifierIndentation:
|
|
22
14
|
Exclude:
|
23
15
|
- 'lib/stanford-mods/origin_info.rb'
|
24
16
|
|
25
|
-
# Offense count:
|
17
|
+
# Offense count: 22
|
26
18
|
# Cop supports --auto-correct.
|
27
|
-
Layout/
|
19
|
+
Layout/ArrayAlignment:
|
28
20
|
Exclude:
|
29
21
|
- 'lib/stanford-mods/searchworks.rb'
|
30
22
|
- 'spec/imprint_spec.rb'
|
31
23
|
|
32
|
-
# Offense count: 4
|
33
|
-
# Cop supports --auto-correct.
|
34
|
-
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
35
|
-
# SupportedHashRocketStyles: key, separator, table
|
36
|
-
# SupportedColonStyles: key, separator, table
|
37
|
-
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
38
|
-
Layout/AlignHash:
|
39
|
-
Exclude:
|
40
|
-
- 'spec/fixtures/searchworks_imprint_data.rb'
|
41
|
-
- 'spec/fixtures/searchworks_pub_date_data.rb'
|
42
|
-
- 'spec/fixtures/spotlight_pub_date_data.rb'
|
43
|
-
|
44
24
|
# Offense count: 12
|
45
25
|
# Cop supports --auto-correct.
|
46
26
|
Layout/BlockEndNewline:
|
47
27
|
Exclude:
|
48
28
|
- 'spec/name_spec.rb'
|
49
29
|
|
50
|
-
# Offense count:
|
30
|
+
# Offense count: 10
|
51
31
|
# Cop supports --auto-correct.
|
52
32
|
# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
|
53
33
|
# SupportedStyles: case, end
|
@@ -71,11 +51,23 @@ Layout/EmptyLineAfterMagicComment:
|
|
71
51
|
|
72
52
|
# Offense count: 1
|
73
53
|
# Cop supports --auto-correct.
|
74
|
-
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
|
54
|
+
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
|
75
55
|
Layout/ExtraSpacing:
|
76
56
|
Exclude:
|
77
57
|
- 'lib/stanford-mods/searchworks.rb'
|
78
58
|
|
59
|
+
# Offense count: 4
|
60
|
+
# Cop supports --auto-correct.
|
61
|
+
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
62
|
+
# SupportedHashRocketStyles: key, separator, table
|
63
|
+
# SupportedColonStyles: key, separator, table
|
64
|
+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
65
|
+
Layout/HashAlignment:
|
66
|
+
Exclude:
|
67
|
+
- 'spec/fixtures/searchworks_imprint_data.rb'
|
68
|
+
- 'spec/fixtures/searchworks_pub_date_data.rb'
|
69
|
+
- 'spec/fixtures/spotlight_pub_date_data.rb'
|
70
|
+
|
79
71
|
# Offense count: 6
|
80
72
|
# Cop supports --auto-correct.
|
81
73
|
# Configuration parameters: EnforcedStyle.
|
@@ -120,7 +112,8 @@ Layout/SpaceAfterComma:
|
|
120
112
|
|
121
113
|
# Offense count: 1
|
122
114
|
# Cop supports --auto-correct.
|
123
|
-
# Configuration parameters: AllowForAlignment.
|
115
|
+
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
|
116
|
+
# SupportedStylesForExponentOperator: space, no_space
|
124
117
|
Layout/SpaceAroundOperators:
|
125
118
|
Exclude:
|
126
119
|
- 'lib/stanford-mods/searchworks.rb'
|
@@ -134,20 +127,20 @@ Layout/SpaceInsideBlockBraces:
|
|
134
127
|
Exclude:
|
135
128
|
- 'lib/stanford-mods/searchworks.rb'
|
136
129
|
|
137
|
-
# Offense count:
|
130
|
+
# Offense count: 6
|
138
131
|
# Cop supports --auto-correct.
|
139
132
|
# Configuration parameters: AllowInHeredoc.
|
140
133
|
Layout/TrailingWhitespace:
|
141
134
|
Exclude:
|
142
|
-
- 'lib/stanford-mods/searchworks.rb'
|
143
135
|
- 'spec/searchworks_spec.rb'
|
144
136
|
|
145
|
-
# Offense count:
|
137
|
+
# Offense count: 31
|
146
138
|
Metrics/AbcSize:
|
147
|
-
Max:
|
139
|
+
Max: 57
|
148
140
|
|
149
|
-
# Offense count:
|
141
|
+
# Offense count: 97
|
150
142
|
# Configuration parameters: CountComments, ExcludedMethods.
|
143
|
+
# ExcludedMethods: refine
|
151
144
|
Metrics/BlockLength:
|
152
145
|
Max: 795
|
153
146
|
|
@@ -156,28 +149,29 @@ Metrics/BlockLength:
|
|
156
149
|
Metrics/ClassLength:
|
157
150
|
Max: 377
|
158
151
|
|
159
|
-
# Offense count:
|
152
|
+
# Offense count: 18
|
160
153
|
Metrics/CyclomaticComplexity:
|
161
|
-
Max:
|
162
|
-
|
163
|
-
# Offense count: 118
|
164
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
165
|
-
# URISchemes: http, https
|
166
|
-
Metrics/LineLength:
|
167
|
-
Max: 199
|
154
|
+
Max: 32
|
168
155
|
|
169
|
-
# Offense count:
|
170
|
-
# Configuration parameters: CountComments.
|
156
|
+
# Offense count: 31
|
157
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
171
158
|
Metrics/MethodLength:
|
172
159
|
Max: 52
|
173
160
|
|
174
|
-
# Offense count:
|
161
|
+
# Offense count: 14
|
175
162
|
Metrics/PerceivedComplexity:
|
176
|
-
Max:
|
163
|
+
Max: 25
|
164
|
+
|
165
|
+
# Offense count: 1
|
166
|
+
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
167
|
+
# 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
|
168
|
+
Naming/FileName:
|
169
|
+
Exclude:
|
170
|
+
- 'lib/stanford-mods.rb'
|
177
171
|
|
178
172
|
# Offense count: 24
|
179
|
-
# Configuration parameters:
|
180
|
-
#
|
173
|
+
# Configuration parameters: ForbiddenDelimiters.
|
174
|
+
# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
|
181
175
|
Naming/HeredocDelimiterNaming:
|
182
176
|
Exclude:
|
183
177
|
- 'spec/geo_spatial_spec.rb'
|
@@ -187,7 +181,7 @@ Naming/HeredocDelimiterNaming:
|
|
187
181
|
- 'spec/searchworks_basic_spec.rb'
|
188
182
|
|
189
183
|
# Offense count: 3
|
190
|
-
# Configuration parameters: EnforcedStyle.
|
184
|
+
# Configuration parameters: EnforcedStyle, IgnoredPatterns.
|
191
185
|
# SupportedStyles: snake_case, camelCase
|
192
186
|
Naming/MethodName:
|
193
187
|
Exclude:
|
@@ -195,24 +189,24 @@ Naming/MethodName:
|
|
195
189
|
- 'lib/stanford-mods/searchworks.rb'
|
196
190
|
|
197
191
|
# Offense count: 2
|
198
|
-
# Configuration parameters:
|
192
|
+
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
193
|
+
# AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp
|
194
|
+
Naming/MethodParameterName:
|
195
|
+
Exclude:
|
196
|
+
- 'lib/stanford-mods/imprint.rb'
|
197
|
+
|
198
|
+
# Offense count: 2
|
199
|
+
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
|
199
200
|
# NamePrefix: is_, has_, have_
|
200
|
-
#
|
201
|
-
#
|
201
|
+
# ForbiddenPrefixes: is_, has_, have_
|
202
|
+
# AllowedMethods: is_a?
|
202
203
|
# MethodDefinitionMacros: define_method, define_singleton_method
|
203
204
|
Naming/PredicateName:
|
204
205
|
Exclude:
|
205
206
|
- 'spec/**/*'
|
206
207
|
- 'lib/stanford-mods/origin_info.rb'
|
207
208
|
|
208
|
-
# Offense count:
|
209
|
-
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
210
|
-
# AllowedNames: io, id, to, by, on, in, at
|
211
|
-
Naming/UncommunicativeMethodParamName:
|
212
|
-
Exclude:
|
213
|
-
- 'lib/stanford-mods/imprint.rb'
|
214
|
-
|
215
|
-
# Offense count: 8
|
209
|
+
# Offense count: 30
|
216
210
|
# Configuration parameters: EnforcedStyle.
|
217
211
|
# SupportedStyles: snake_case, camelCase
|
218
212
|
Naming/VariableName:
|
@@ -221,12 +215,6 @@ Naming/VariableName:
|
|
221
215
|
- 'lib/stanford-mods/origin_info.rb'
|
222
216
|
- 'lib/stanford-mods/searchworks.rb'
|
223
217
|
|
224
|
-
# Offense count: 1
|
225
|
-
# Cop supports --auto-correct.
|
226
|
-
Performance/UnneededSort:
|
227
|
-
Exclude:
|
228
|
-
- 'lib/stanford-mods/origin_info.rb'
|
229
|
-
|
230
218
|
# Offense count: 3
|
231
219
|
RSpec/AnyInstance:
|
232
220
|
Exclude:
|
@@ -245,7 +233,7 @@ RSpec/BeforeAfterAll:
|
|
245
233
|
- 'spec/searchworks_subject_spec.rb'
|
246
234
|
- 'spec/searchworks_title_spec.rb'
|
247
235
|
|
248
|
-
# Offense count:
|
236
|
+
# Offense count: 137
|
249
237
|
# Configuration parameters: Prefixes.
|
250
238
|
# Prefixes: when, with, without
|
251
239
|
RSpec/ContextWording:
|
@@ -283,6 +271,7 @@ RSpec/DescribeClass:
|
|
283
271
|
- 'spec/sw_publication_spec.rb'
|
284
272
|
|
285
273
|
# Offense count: 14
|
274
|
+
# Cop supports --auto-correct.
|
286
275
|
RSpec/EmptyLineAfterFinalLet:
|
287
276
|
Exclude:
|
288
277
|
- 'spec/name_spec.rb'
|
@@ -290,7 +279,7 @@ RSpec/EmptyLineAfterFinalLet:
|
|
290
279
|
- 'spec/physical_location_spec.rb'
|
291
280
|
- 'spec/sw_publication_spec.rb'
|
292
281
|
|
293
|
-
# Offense count:
|
282
|
+
# Offense count: 134
|
294
283
|
# Configuration parameters: Max.
|
295
284
|
RSpec/ExampleLength:
|
296
285
|
Exclude:
|
@@ -305,7 +294,8 @@ RSpec/ExampleLength:
|
|
305
294
|
- 'spec/searchworks_subject_spec.rb'
|
306
295
|
- 'spec/searchworks_title_spec.rb'
|
307
296
|
|
308
|
-
# Offense count:
|
297
|
+
# Offense count: 111
|
298
|
+
# Cop supports --auto-correct.
|
309
299
|
# Configuration parameters: CustomTransform, IgnoredWords.
|
310
300
|
RSpec/ExampleWording:
|
311
301
|
Exclude:
|
@@ -324,12 +314,13 @@ RSpec/FilePath:
|
|
324
314
|
- 'spec/lib/stanford-mods/coordinate_spec.rb'
|
325
315
|
|
326
316
|
# Offense count: 2
|
317
|
+
# Cop supports --auto-correct.
|
327
318
|
# Configuration parameters: .
|
328
319
|
# SupportedStyles: implicit, each, example
|
329
320
|
RSpec/HookArgument:
|
330
321
|
EnforcedStyle: each
|
331
322
|
|
332
|
-
# Offense count:
|
323
|
+
# Offense count: 935
|
333
324
|
# Configuration parameters: AssignmentOnly.
|
334
325
|
RSpec/InstanceVariable:
|
335
326
|
Exclude:
|
@@ -342,6 +333,7 @@ RSpec/InstanceVariable:
|
|
342
333
|
- 'spec/searchworks_title_spec.rb'
|
343
334
|
|
344
335
|
# Offense count: 2
|
336
|
+
# Cop supports --auto-correct.
|
345
337
|
RSpec/LetBeforeExamples:
|
346
338
|
Exclude:
|
347
339
|
- 'spec/origin_info_spec.rb'
|
@@ -357,17 +349,18 @@ RSpec/MultipleDescribes:
|
|
357
349
|
Exclude:
|
358
350
|
- 'spec/geo_spatial_spec.rb'
|
359
351
|
|
360
|
-
# Offense count:
|
352
|
+
# Offense count: 100
|
361
353
|
# Configuration parameters: AggregateFailuresByDefault.
|
362
354
|
RSpec/MultipleExpectations:
|
363
355
|
Max: 9
|
364
356
|
|
365
357
|
# Offense count: 2
|
358
|
+
# Configuration parameters: IgnoreSharedExamples.
|
366
359
|
RSpec/NamedSubject:
|
367
360
|
Exclude:
|
368
361
|
- 'spec/lib/stanford-mods/coordinate_spec.rb'
|
369
362
|
|
370
|
-
# Offense count:
|
363
|
+
# Offense count: 36
|
371
364
|
RSpec/NestedGroups:
|
372
365
|
Max: 5
|
373
366
|
|
@@ -396,8 +389,8 @@ Style/Alias:
|
|
396
389
|
|
397
390
|
# Offense count: 30
|
398
391
|
# Cop supports --auto-correct.
|
399
|
-
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
400
|
-
# SupportedStyles: line_count_based, semantic, braces_for_chaining
|
392
|
+
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
|
393
|
+
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
|
401
394
|
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
402
395
|
# FunctionalMethods: let, let!, subject, watch
|
403
396
|
# IgnoredMethods: lambda, proc, it
|
@@ -409,7 +402,7 @@ Style/BlockDelimiters:
|
|
409
402
|
- 'lib/stanford-mods/searchworks_subjects.rb'
|
410
403
|
- 'spec/name_spec.rb'
|
411
404
|
|
412
|
-
# Offense count:
|
405
|
+
# Offense count: 65
|
413
406
|
Style/CommentedKeyword:
|
414
407
|
Exclude:
|
415
408
|
- 'lib/stanford-mods.rb'
|
@@ -469,6 +462,13 @@ Style/ExpandPathArguments:
|
|
469
462
|
Exclude:
|
470
463
|
- 'stanford-mods.gemspec'
|
471
464
|
|
465
|
+
# Offense count: 36
|
466
|
+
# Cop supports --auto-correct.
|
467
|
+
# Configuration parameters: EnforcedStyle.
|
468
|
+
# SupportedStyles: always, always_true, never
|
469
|
+
Style/FrozenStringLiteralComment:
|
470
|
+
Enabled: false
|
471
|
+
|
472
472
|
# Offense count: 3
|
473
473
|
# Configuration parameters: MinBodyLength.
|
474
474
|
Style/GuardClause:
|
@@ -487,7 +487,7 @@ Style/IfUnlessModifier:
|
|
487
487
|
- 'lib/stanford-mods/date_parsing.rb'
|
488
488
|
- 'lib/stanford-mods/imprint.rb'
|
489
489
|
|
490
|
-
# Offense count:
|
490
|
+
# Offense count: 2
|
491
491
|
# Cop supports --auto-correct.
|
492
492
|
# Configuration parameters: InverseMethods, InverseBlocks.
|
493
493
|
Style/InverseMethods:
|
@@ -509,6 +509,11 @@ Style/MultilineTernaryOperator:
|
|
509
509
|
Exclude:
|
510
510
|
- 'lib/stanford-mods/physical_location.rb'
|
511
511
|
|
512
|
+
# Offense count: 1
|
513
|
+
Style/MultipleComparison:
|
514
|
+
Exclude:
|
515
|
+
- 'lib/stanford-mods/origin_info.rb'
|
516
|
+
|
512
517
|
# Offense count: 1
|
513
518
|
# Cop supports --auto-correct.
|
514
519
|
# Configuration parameters: EnforcedOctalStyle.
|
@@ -517,6 +522,16 @@ Style/NumericLiteralPrefix:
|
|
517
522
|
Exclude:
|
518
523
|
- 'spec/date_parsing_spec.rb'
|
519
524
|
|
525
|
+
# Offense count: 4
|
526
|
+
# Cop supports --auto-correct.
|
527
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
|
528
|
+
# SupportedStyles: predicate, comparison
|
529
|
+
Style/NumericPredicate:
|
530
|
+
Exclude:
|
531
|
+
- 'spec/**/*'
|
532
|
+
- 'lib/stanford-mods/origin_info.rb'
|
533
|
+
- 'lib/stanford-mods/searchworks.rb'
|
534
|
+
|
520
535
|
# Offense count: 8
|
521
536
|
# Cop supports --auto-correct.
|
522
537
|
Style/PerlBackrefs:
|
@@ -531,6 +546,26 @@ Style/PreferredHashMethods:
|
|
531
546
|
Exclude:
|
532
547
|
- 'lib/stanford-mods/searchworks.rb'
|
533
548
|
|
549
|
+
# Offense count: 5
|
550
|
+
# Cop supports --auto-correct.
|
551
|
+
Style/RedundantCondition:
|
552
|
+
Exclude:
|
553
|
+
- 'lib/stanford-mods/origin_info.rb'
|
554
|
+
- 'lib/stanford-mods/searchworks.rb'
|
555
|
+
|
556
|
+
# Offense count: 3
|
557
|
+
# Cop supports --auto-correct.
|
558
|
+
# Configuration parameters: AllowMultipleReturnValues.
|
559
|
+
Style/RedundantReturn:
|
560
|
+
Exclude:
|
561
|
+
- 'lib/stanford-mods/date_parsing.rb'
|
562
|
+
|
563
|
+
# Offense count: 1
|
564
|
+
# Cop supports --auto-correct.
|
565
|
+
Style/RedundantSort:
|
566
|
+
Exclude:
|
567
|
+
- 'lib/stanford-mods/origin_info.rb'
|
568
|
+
|
534
569
|
# Offense count: 6
|
535
570
|
# Cop supports --auto-correct.
|
536
571
|
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
|
@@ -555,6 +590,17 @@ Style/RescueStandardError:
|
|
555
590
|
Exclude:
|
556
591
|
- 'lib/stanford-mods/imprint.rb'
|
557
592
|
|
593
|
+
# Offense count: 18
|
594
|
+
# Cop supports --auto-correct.
|
595
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
|
596
|
+
# AllowedMethods: present?, blank?, presence, try, try!
|
597
|
+
Style/SafeNavigation:
|
598
|
+
Exclude:
|
599
|
+
- 'lib/stanford-mods/date_parsing.rb'
|
600
|
+
- 'lib/stanford-mods/imprint.rb'
|
601
|
+
- 'lib/stanford-mods/searchworks.rb'
|
602
|
+
- 'lib/stanford-mods/searchworks_subjects.rb'
|
603
|
+
|
558
604
|
# Offense count: 1
|
559
605
|
# Cop supports --auto-correct.
|
560
606
|
# Configuration parameters: EnforcedStyle.
|
@@ -576,7 +622,7 @@ Style/StderrPuts:
|
|
576
622
|
Exclude:
|
577
623
|
- 'Rakefile'
|
578
624
|
|
579
|
-
# Offense count:
|
625
|
+
# Offense count: 12
|
580
626
|
# Cop supports --auto-correct.
|
581
627
|
# Configuration parameters: MinSize.
|
582
628
|
# SupportedStyles: percent, brackets
|
@@ -592,12 +638,13 @@ Style/SymbolProc:
|
|
592
638
|
- 'lib/stanford-mods/searchworks.rb'
|
593
639
|
- 'lib/stanford-mods/searchworks_subjects.rb'
|
594
640
|
|
595
|
-
# Offense count:
|
641
|
+
# Offense count: 1
|
596
642
|
# Cop supports --auto-correct.
|
597
|
-
|
643
|
+
# Configuration parameters: EnforcedStyleForMultiline.
|
644
|
+
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
645
|
+
Style/TrailingCommaInArrayLiteral:
|
598
646
|
Exclude:
|
599
|
-
- '
|
600
|
-
- 'lib/stanford-mods/searchworks.rb'
|
647
|
+
- 'spec/date_parsing_spec.rb'
|
601
648
|
|
602
649
|
# Offense count: 125
|
603
650
|
# Cop supports --auto-correct.
|
@@ -609,7 +656,7 @@ Style/WordArray:
|
|
609
656
|
# Offense count: 2
|
610
657
|
# Cop supports --auto-correct.
|
611
658
|
# Configuration parameters: EnforcedStyle.
|
612
|
-
# SupportedStyles:
|
659
|
+
# SupportedStyles: forbid_for_all_comparison_operators, forbid_for_equality_operators_only, require_for_all_comparison_operators, require_for_equality_operators_only
|
613
660
|
Style/YodaCondition:
|
614
661
|
Exclude:
|
615
662
|
- 'lib/stanford-mods/date_parsing.rb'
|
data/Gemfile
CHANGED
@@ -2,13 +2,3 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# See stanford-mods.gemspec for this gem's dependencies
|
4
4
|
gemspec
|
5
|
-
|
6
|
-
group :test, :development do
|
7
|
-
gem 'rubocop', require: false
|
8
|
-
gem 'rubocop-rspec', require: false
|
9
|
-
gem 'pry-byebug', require: false, platform: [:ruby_20, :ruby_21]
|
10
|
-
gem 'coveralls', require: false
|
11
|
-
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 }
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_support/core_ext/integer/inflections'
|
2
|
+
|
1
3
|
module Stanford
|
2
4
|
module Mods
|
3
5
|
# Parsing date strings
|
@@ -32,6 +34,7 @@ module Stanford
|
|
32
34
|
# @return [Boolean] true if the year is between -999 and (current year + 1); false otherwise
|
33
35
|
def self.year_str_valid?(year_str)
|
34
36
|
return false unless year_str && (year_str.match(/^\d{1,4}$/) || year_str.match(/^-\d{1,3}$/))
|
37
|
+
|
35
38
|
(-1000 < year_str.to_i) && (year_str.to_i < Date.today.year + 2)
|
36
39
|
end
|
37
40
|
|
@@ -39,6 +42,7 @@ module Stanford
|
|
39
42
|
# @return [Boolean] true if the year is between -9999 and (current year + 1); false otherwise
|
40
43
|
def self.year_int_valid?(year)
|
41
44
|
return false unless year.is_a? Integer
|
45
|
+
|
42
46
|
(-1000 < year.to_i) && (year < Date.today.year + 2)
|
43
47
|
end
|
44
48
|
|
@@ -59,6 +63,7 @@ module Stanford
|
|
59
63
|
return display_str_for_bc if orig_date_str.match(BC_REGEX)
|
60
64
|
# decade next in case there are 4 digits, e.g. 1950s
|
61
65
|
return display_str_for_decade if orig_date_str.match(DECADE_4CHAR_REGEXP) || orig_date_str.match(DECADE_S_REGEXP)
|
66
|
+
|
62
67
|
result = sortable_year_for_yyyy_or_yy
|
63
68
|
unless result
|
64
69
|
# try removing brackets between digits in case we have 169[5] or [18]91
|
@@ -81,6 +86,7 @@ module Stanford
|
|
81
86
|
return if orig_date_str == '0000-00-00' # shpc collection has these useless dates
|
82
87
|
# B.C. first in case there are 4 digits, e.g. 1600 B.C.
|
83
88
|
return sortable_year_int_for_bc if orig_date_str.match(BC_REGEX)
|
89
|
+
|
84
90
|
result = sortable_year_for_yyyy_or_yy
|
85
91
|
result ||= sortable_year_for_decade # 19xx or 20xx
|
86
92
|
result ||= sortable_year_for_century
|
@@ -102,6 +108,7 @@ module Stanford
|
|
102
108
|
return if orig_date_str == '0000-00-00' # shpc collection has these useless dates
|
103
109
|
# B.C. first in case there are 4 digits, e.g. 1600 B.C.
|
104
110
|
return sortable_year_str_for_bc if orig_date_str.match(BC_REGEX)
|
111
|
+
|
105
112
|
result = sortable_year_for_yyyy_or_yy
|
106
113
|
result ||= sortable_year_for_decade # 19xx or 20xx
|
107
114
|
result ||= sortable_year_for_century
|
@@ -144,6 +151,7 @@ module Stanford
|
|
144
151
|
# @return [String, nil] 4 digit year (e.g. 1865, 0950) if orig_date_str matches pattern, nil otherwise
|
145
152
|
def sortable_year_for_yy
|
146
153
|
return unless orig_date_str
|
154
|
+
|
147
155
|
slash_matches = orig_date_str.match(/\d{1,2}\/\d{1,2}\/\d{2}/)
|
148
156
|
if slash_matches
|
149
157
|
date_obj = Date.strptime(orig_date_str, '%m/%d/%y')
|
@@ -196,6 +204,7 @@ module Stanford
|
|
196
204
|
def sortable_year_for_century
|
197
205
|
return unless orig_date_str
|
198
206
|
return if orig_date_str =~ /B\.C\./
|
207
|
+
|
199
208
|
century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP)
|
200
209
|
if century_matches
|
201
210
|
return $1 + '00' if $1.length == 2
|
@@ -215,12 +224,12 @@ module Stanford
|
|
215
224
|
def display_str_for_century
|
216
225
|
return unless orig_date_str
|
217
226
|
return if orig_date_str =~ /B\.C\./
|
227
|
+
|
218
228
|
century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)
|
219
229
|
return century_str_matches.to_s if century_str_matches
|
220
230
|
|
221
231
|
century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP)
|
222
232
|
if century_matches
|
223
|
-
require 'active_support/core_ext/integer/inflections'
|
224
233
|
return "#{($1.to_i + 1).ordinalize} century"
|
225
234
|
end
|
226
235
|
end
|
@@ -262,6 +271,7 @@ module Stanford
|
|
262
271
|
# @return [String, nil] String sortable -ddd if orig_date_str matches pattern; nil otherwise
|
263
272
|
def sortable_year_str_for_early_numeric
|
264
273
|
return unless orig_date_str.match(EARLY_NUMERIC)
|
274
|
+
|
265
275
|
if orig_date_str =~ /^\-/
|
266
276
|
# negative number becomes x - 1000 for sorting; -005 for -995
|
267
277
|
num = orig_date_str[1..-1].to_i - 1000
|
@@ -275,6 +285,7 @@ module Stanford
|
|
275
285
|
# @return [Integer, nil] Integer sortable -ddd if orig_date_str matches pattern; nil otherwise
|
276
286
|
def sortable_year_int_for_early_numeric
|
277
287
|
return orig_date_str.to_i if orig_date_str.match(EARLY_NUMERIC)
|
288
|
+
|
278
289
|
orig_date_str.to_i if orig_date_str =~ /^-\d{4}$/
|
279
290
|
end
|
280
291
|
|
@@ -290,6 +301,7 @@ module Stanford
|
|
290
301
|
return '1 B.C.' if orig_date_str == '0'
|
291
302
|
# negative number becomes B.C.
|
292
303
|
return "#{orig_date_str[1..-1].to_i + 1} B.C." if orig_date_str =~ /^\-/
|
304
|
+
|
293
305
|
# remove leading 0s from early dates
|
294
306
|
"#{orig_date_str.to_i} A.D."
|
295
307
|
end
|
@@ -304,6 +316,7 @@ module Stanford
|
|
304
316
|
# need more in string than only 2 digits
|
305
317
|
return if orig_date_str.match(/^\d\d$/) || orig_date_str.match(/^\D*\d\d\D*$/)
|
306
318
|
return if orig_date_str =~ /\d\s*B.C./ # skip B.C. dates
|
319
|
+
|
307
320
|
date_obj = Date.parse(orig_date_str)
|
308
321
|
date_obj.year.to_s
|
309
322
|
rescue ArgumentError
|