stanford-mods 2.5.1 → 2.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '0228a5039c07e8a14dc5b3e3c2ab8406695335ab'
4
- data.tar.gz: 4ab66f765c29758620f0d30d4d94916ec19bd873
3
+ metadata.gz: cee6b06bb95f5c410a2b021f8d2b2d82254e52d5
4
+ data.tar.gz: cb1d846be2f33d5420edeef5705f704fadb9d804
5
5
  SHA512:
6
- metadata.gz: b93ffbd727cb1b2981aecfc859afc3e736186b84fb0e6286b56d297132a2abbba86b8f06251e869b070f54c7b5b74c31a0b32c505008c7f8a7baee12079b6513
7
- data.tar.gz: 74d357cfe005638a9f4292f7340b492aec00b4854562a01bda30b8355b5fa9d94ce08d4c7515a9a4e5b9e91c1ef48493436b97fa7d4f187524fae8baf8c912b4
6
+ metadata.gz: 5b28846bce27f831c74cb88d708691643a24fc1183e593e42068c4b032254dd3ab47094550e45a8c4a2eb43fd02a866e06343506817c22d7f0bdb27dbb5c907a
7
+ data.tar.gz: 54f09f4ec848dfe215bea0559a6e0ae62d17d186e2fa8483aa155495ee27b4b34b3db7de9f0c7e7b102f65dbcd59f4a51ccb7fe97c7eadd640cba1e6c5e4ebcb
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2017-11-16 11:34:11 -0800 using RuboCop version 0.51.0.
3
+ # on 2018-08-08 21:42:13 -0700 using RuboCop version 0.57.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
@@ -9,14 +9,14 @@
9
9
  # Offense count: 2
10
10
  # Cop supports --auto-correct.
11
11
  # Configuration parameters: Include, TreatCommentsAsGroupSeparators.
12
- # Include: **/Gemfile, **/gems.rb
12
+ # Include: **/*.gemfile, **/Gemfile, **/gems.rb
13
13
  Bundler/OrderedGems:
14
14
  Exclude:
15
15
  - 'Gemfile'
16
16
 
17
17
  # Offense count: 1
18
18
  # Cop supports --auto-correct.
19
- # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
19
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
20
20
  # SupportedStyles: outdent, indent
21
21
  Layout/AccessModifierIndentation:
22
22
  Exclude:
@@ -31,7 +31,7 @@ Layout/AlignArray:
31
31
 
32
32
  # Offense count: 4
33
33
  # Cop supports --auto-correct.
34
- # Configuration parameters: EnforcedHashRocketStyle, SupportedHashRocketStyles, EnforcedColonStyle, SupportedColonStyles, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
34
+ # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
35
35
  # SupportedHashRocketStyles: key, separator, table
36
36
  # SupportedColonStyles: key, separator, table
37
37
  # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
@@ -49,7 +49,7 @@ Layout/BlockEndNewline:
49
49
 
50
50
  # Offense count: 20
51
51
  # Cop supports --auto-correct.
52
- # Configuration parameters: EnforcedStyle, SupportedStyles, IndentOneStep, IndentationWidth.
52
+ # Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
53
53
  # SupportedStyles: case, end
54
54
  Layout/CaseIndentation:
55
55
  Exclude:
@@ -78,7 +78,7 @@ Layout/ExtraSpacing:
78
78
 
79
79
  # Offense count: 6
80
80
  # Cop supports --auto-correct.
81
- # Configuration parameters: EnforcedStyle, SupportedStyles.
81
+ # Configuration parameters: EnforcedStyle.
82
82
  # SupportedStyles: symmetrical, new_line, same_line
83
83
  Layout/MultilineArrayBraceLayout:
84
84
  Exclude:
@@ -93,7 +93,7 @@ Layout/MultilineBlockLayout:
93
93
 
94
94
  # Offense count: 5
95
95
  # Cop supports --auto-correct.
96
- # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
96
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
97
97
  # SupportedStyles: aligned, indented, indented_relative_to_receiver
98
98
  Layout/MultilineMethodCallIndentation:
99
99
  Exclude:
@@ -101,7 +101,7 @@ Layout/MultilineMethodCallIndentation:
101
101
 
102
102
  # Offense count: 882
103
103
  # Cop supports --auto-correct.
104
- # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
104
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
105
105
  # SupportedStyles: aligned, indented
106
106
  Layout/MultilineOperationIndentation:
107
107
  Exclude:
@@ -112,6 +112,12 @@ Layout/MultilineOperationIndentation:
112
112
  - 'spec/fixtures/spotlight_pub_date_data.rb'
113
113
  - 'spec/origin_info_spec.rb'
114
114
 
115
+ # Offense count: 1
116
+ # Cop supports --auto-correct.
117
+ Layout/SpaceAfterComma:
118
+ Exclude:
119
+ - 'spec/imprint_spec.rb'
120
+
115
121
  # Offense count: 1
116
122
  # Cop supports --auto-correct.
117
123
  # Configuration parameters: AllowForAlignment.
@@ -121,7 +127,7 @@ Layout/SpaceAroundOperators:
121
127
 
122
128
  # Offense count: 2
123
129
  # Cop supports --auto-correct.
124
- # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters.
130
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
125
131
  # SupportedStyles: space, no_space
126
132
  # SupportedStylesForEmptyBraces: space, no_space
127
133
  Layout/SpaceInsideBlockBraces:
@@ -130,31 +136,27 @@ Layout/SpaceInsideBlockBraces:
130
136
 
131
137
  # Offense count: 11
132
138
  # Cop supports --auto-correct.
139
+ # Configuration parameters: AllowInHeredoc.
133
140
  Layout/TrailingWhitespace:
134
141
  Exclude:
135
142
  - 'lib/stanford-mods/searchworks.rb'
136
143
  - 'spec/searchworks_spec.rb'
137
144
 
138
- # Offense count: 4
139
- Lint/RescueWithoutErrorClass:
140
- Exclude:
141
- - 'lib/stanford-mods/imprint.rb'
142
-
143
- # Offense count: 32
145
+ # Offense count: 33
144
146
  Metrics/AbcSize:
145
- Max: 51
147
+ Max: 56
146
148
 
147
- # Offense count: 101
149
+ # Offense count: 102
148
150
  # Configuration parameters: CountComments, ExcludedMethods.
149
151
  Metrics/BlockLength:
150
- Max: 791
152
+ Max: 795
151
153
 
152
154
  # Offense count: 5
153
155
  # Configuration parameters: CountComments.
154
156
  Metrics/ClassLength:
155
- Max: 344
157
+ Max: 377
156
158
 
157
- # Offense count: 19
159
+ # Offense count: 20
158
160
  Metrics/CyclomaticComplexity:
159
161
  Max: 26
160
162
 
@@ -164,25 +166,18 @@ Metrics/CyclomaticComplexity:
164
166
  Metrics/LineLength:
165
167
  Max: 199
166
168
 
167
- # Offense count: 31
169
+ # Offense count: 32
168
170
  # Configuration parameters: CountComments.
169
171
  Metrics/MethodLength:
170
172
  Max: 52
171
173
 
172
- # Offense count: 15
174
+ # Offense count: 16
173
175
  Metrics/PerceivedComplexity:
174
176
  Max: 20
175
177
 
176
- # Offense count: 1
177
- # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
178
- # 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
179
- Naming/FileName:
180
- Exclude:
181
- - 'lib/stanford-mods.rb'
182
-
183
178
  # Offense count: 24
184
179
  # Configuration parameters: Blacklist.
185
- # Blacklist: END, (?-mix:EO[A-Z]{1})
180
+ # Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
186
181
  Naming/HeredocDelimiterNaming:
187
182
  Exclude:
188
183
  - 'spec/geo_spatial_spec.rb'
@@ -192,7 +187,7 @@ Naming/HeredocDelimiterNaming:
192
187
  - 'spec/searchworks_basic_spec.rb'
193
188
 
194
189
  # Offense count: 3
195
- # Configuration parameters: EnforcedStyle, SupportedStyles.
190
+ # Configuration parameters: EnforcedStyle.
196
191
  # SupportedStyles: snake_case, camelCase
197
192
  Naming/MethodName:
198
193
  Exclude:
@@ -210,8 +205,15 @@ Naming/PredicateName:
210
205
  - 'spec/**/*'
211
206
  - 'lib/stanford-mods/origin_info.rb'
212
207
 
208
+ # Offense count: 2
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
+
213
215
  # Offense count: 8
214
- # Configuration parameters: EnforcedStyle, SupportedStyles.
216
+ # Configuration parameters: EnforcedStyle.
215
217
  # SupportedStyles: snake_case, camelCase
216
218
  Naming/VariableName:
217
219
  Exclude:
@@ -219,12 +221,11 @@ Naming/VariableName:
219
221
  - 'lib/stanford-mods/origin_info.rb'
220
222
  - 'lib/stanford-mods/searchworks.rb'
221
223
 
222
- # Offense count: 11
224
+ # Offense count: 1
223
225
  # Cop supports --auto-correct.
224
- # Configuration parameters: AutoCorrect.
225
- Performance/HashEachMethods:
226
+ Performance/UnneededSort:
226
227
  Exclude:
227
- - 'spec/date_parsing_spec.rb'
228
+ - 'lib/stanford-mods/origin_info.rb'
228
229
 
229
230
  # Offense count: 3
230
231
  RSpec/AnyInstance:
@@ -323,7 +324,7 @@ RSpec/FilePath:
323
324
  - 'spec/lib/stanford-mods/coordinate_spec.rb'
324
325
 
325
326
  # Offense count: 2
326
- # Configuration parameters: SupportedStyles.
327
+ # Configuration parameters: .
327
328
  # SupportedStyles: implicit, each, example
328
329
  RSpec/HookArgument:
329
330
  EnforcedStyle: each
@@ -346,7 +347,7 @@ RSpec/LetBeforeExamples:
346
347
  - 'spec/origin_info_spec.rb'
347
348
 
348
349
  # Offense count: 25
349
- # Configuration parameters: SupportedStyles.
350
+ # Configuration parameters: .
350
351
  # SupportedStyles: have_received, receive
351
352
  RSpec/MessageSpies:
352
353
  EnforcedStyle: receive
@@ -357,6 +358,7 @@ RSpec/MultipleDescribes:
357
358
  - 'spec/geo_spatial_spec.rb'
358
359
 
359
360
  # Offense count: 114
361
+ # Configuration parameters: AggregateFailuresByDefault.
360
362
  RSpec/MultipleExpectations:
361
363
  Max: 9
362
364
 
@@ -366,15 +368,8 @@ RSpec/NamedSubject:
366
368
  - 'spec/lib/stanford-mods/coordinate_spec.rb'
367
369
 
368
370
  # Offense count: 38
369
- # Configuration parameters: Max.
370
371
  RSpec/NestedGroups:
371
- Exclude:
372
- - 'spec/origin_info_spec.rb'
373
- - 'spec/physical_location_spec.rb'
374
- - 'spec/searchworks_format_spec.rb'
375
- - 'spec/searchworks_subject_raw_spec.rb'
376
- - 'spec/searchworks_subject_spec.rb'
377
- - 'spec/searchworks_title_spec.rb'
372
+ Max: 5
378
373
 
379
374
  # Offense count: 7
380
375
  RSpec/RepeatedExample:
@@ -393,7 +388,7 @@ RSpec/VoidExpect:
393
388
 
394
389
  # Offense count: 1
395
390
  # Cop supports --auto-correct.
396
- # Configuration parameters: EnforcedStyle, SupportedStyles.
391
+ # Configuration parameters: EnforcedStyle.
397
392
  # SupportedStyles: prefer_alias, prefer_alias_method
398
393
  Style/Alias:
399
394
  Exclude:
@@ -401,7 +396,7 @@ Style/Alias:
401
396
 
402
397
  # Offense count: 30
403
398
  # Cop supports --auto-correct.
404
- # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
399
+ # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.
405
400
  # SupportedStyles: line_count_based, semantic, braces_for_chaining
406
401
  # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
407
402
  # FunctionalMethods: let, let!, subject, watch
@@ -434,7 +429,7 @@ Style/CommentedKeyword:
434
429
 
435
430
  # Offense count: 2
436
431
  # Cop supports --auto-correct.
437
- # Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions.
432
+ # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
438
433
  # SupportedStyles: assign_to_condition, assign_inside_condition
439
434
  Style/ConditionalAssignment:
440
435
  Exclude:
@@ -468,6 +463,12 @@ Style/EmptyCaseCondition:
468
463
  Style/Encoding:
469
464
  Enabled: false
470
465
 
466
+ # Offense count: 1
467
+ # Cop supports --auto-correct.
468
+ Style/ExpandPathArguments:
469
+ Exclude:
470
+ - 'stanford-mods.gemspec'
471
+
471
472
  # Offense count: 3
472
473
  # Configuration parameters: MinBodyLength.
473
474
  Style/GuardClause:
@@ -479,6 +480,13 @@ Style/IdenticalConditionalBranches:
479
480
  Exclude:
480
481
  - 'lib/stanford-mods/searchworks.rb'
481
482
 
483
+ # Offense count: 2
484
+ # Cop supports --auto-correct.
485
+ Style/IfUnlessModifier:
486
+ Exclude:
487
+ - 'lib/stanford-mods/date_parsing.rb'
488
+ - 'lib/stanford-mods/imprint.rb'
489
+
482
490
  # Offense count: 3
483
491
  # Cop supports --auto-correct.
484
492
  # Configuration parameters: InverseMethods, InverseBlocks.
@@ -503,7 +511,7 @@ Style/MultilineTernaryOperator:
503
511
 
504
512
  # Offense count: 1
505
513
  # Cop supports --auto-correct.
506
- # Configuration parameters: EnforcedOctalStyle, SupportedOctalStyles.
514
+ # Configuration parameters: EnforcedOctalStyle.
507
515
  # SupportedOctalStyles: zero_with_o, zero_only
508
516
  Style/NumericLiteralPrefix:
509
517
  Exclude:
@@ -517,7 +525,7 @@ Style/PerlBackrefs:
517
525
 
518
526
  # Offense count: 3
519
527
  # Cop supports --auto-correct.
520
- # Configuration parameters: EnforcedStyle, SupportedStyles.
528
+ # Configuration parameters: EnforcedStyle.
521
529
  # SupportedStyles: short, verbose
522
530
  Style/PreferredHashMethods:
523
531
  Exclude:
@@ -525,7 +533,7 @@ Style/PreferredHashMethods:
525
533
 
526
534
  # Offense count: 6
527
535
  # Cop supports --auto-correct.
528
- # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
536
+ # Configuration parameters: EnforcedStyle, AllowInnerSlashes.
529
537
  # SupportedStyles: slashes, percent_r, mixed
530
538
  Style/RegexpLiteral:
531
539
  Exclude:
@@ -539,9 +547,17 @@ Style/RescueModifier:
539
547
  Exclude:
540
548
  - 'lib/stanford-mods/origin_info.rb'
541
549
 
550
+ # Offense count: 4
551
+ # Cop supports --auto-correct.
552
+ # Configuration parameters: EnforcedStyle.
553
+ # SupportedStyles: implicit, explicit
554
+ Style/RescueStandardError:
555
+ Exclude:
556
+ - 'lib/stanford-mods/imprint.rb'
557
+
542
558
  # Offense count: 1
543
559
  # Cop supports --auto-correct.
544
- # Configuration parameters: EnforcedStyle, SupportedStyles.
560
+ # Configuration parameters: EnforcedStyle.
545
561
  # SupportedStyles: only_raise, only_fail, semantic
546
562
  Style/SignalException:
547
563
  Exclude:
@@ -549,7 +565,7 @@ Style/SignalException:
549
565
 
550
566
  # Offense count: 1
551
567
  # Cop supports --auto-correct.
552
- # Configuration parameters: SupportedStyles.
568
+ # Configuration parameters: .
553
569
  # SupportedStyles: use_perl_names, use_english_names
554
570
  Style/SpecialGlobalVars:
555
571
  EnforcedStyle: use_perl_names
@@ -562,7 +578,7 @@ Style/StderrPuts:
562
578
 
563
579
  # Offense count: 13
564
580
  # Cop supports --auto-correct.
565
- # Configuration parameters: MinSize, SupportedStyles.
581
+ # Configuration parameters: MinSize.
566
582
  # SupportedStyles: percent, brackets
567
583
  Style/SymbolArray:
568
584
  EnforcedStyle: brackets
@@ -576,16 +592,23 @@ Style/SymbolProc:
576
592
  - 'lib/stanford-mods/searchworks.rb'
577
593
  - 'lib/stanford-mods/searchworks_subjects.rb'
578
594
 
595
+ # Offense count: 5
596
+ # Cop supports --auto-correct.
597
+ Style/UnneededCondition:
598
+ Exclude:
599
+ - 'lib/stanford-mods/origin_info.rb'
600
+ - 'lib/stanford-mods/searchworks.rb'
601
+
579
602
  # Offense count: 125
580
603
  # Cop supports --auto-correct.
581
- # Configuration parameters: SupportedStyles, MinSize, WordRegex.
604
+ # Configuration parameters: MinSize, WordRegex.
582
605
  # SupportedStyles: percent, brackets
583
606
  Style/WordArray:
584
607
  EnforcedStyle: brackets
585
608
 
586
609
  # Offense count: 2
587
610
  # Cop supports --auto-correct.
588
- # Configuration parameters: EnforcedStyle, SupportedStyles.
611
+ # Configuration parameters: EnforcedStyle.
589
612
  # SupportedStyles: all_comparison_operators, equality_operators_only
590
613
  Style/YodaCondition:
591
614
  Exclude:
data/.travis.yml CHANGED
@@ -1,16 +1,12 @@
1
1
  language: ruby
2
2
  script: rake
3
3
  rvm:
4
+ - 2.4.4
4
5
  - 2.3.1
5
- - 2.2.3 # spotlight
6
- - 2.2.0
7
6
  # we used to use jruby for merged DOR + MARC records, but no more ...
8
- - jruby-head
9
- # we also test against ruby-head, which may be unstable.
10
- - ruby-head
7
+ - jruby-9.2.0.0
11
8
  matrix:
12
9
  allow_failures:
13
- - rvm: jruby-head
14
- - rvm: ruby-head
10
+ - rvm: jruby-9.2.0.0
15
11
  notifications: false
16
12
  sudo: false
@@ -139,24 +139,24 @@ module Stanford
139
139
  present_title_info_nodes ? present_title_info_nodes.first : nil
140
140
  end
141
141
 
142
- # @return [String] the nonSort text portion of the titleInfo node as a string (if non-empty, else nil)
142
+ # @return [String] the nonSort text portion of the titleInfo node as a string (if non-empty, else nil)
143
143
  def nonSort_title
144
144
  return unless first_title_info_node && first_title_info_node.nonSort
145
145
 
146
146
  first_title_info_node.nonSort.text.strip.empty? ? nil : first_title_info_node.nonSort.text.strip
147
147
  end
148
-
148
+
149
149
  # @return [String] the text of the titleInfo node as a string (if non-empty, else nil)
150
150
  def title
151
151
  return unless first_title_info_node && first_title_info_node.title
152
152
 
153
153
  first_title_info_node.title.text.strip.empty? ? nil : first_title_info_node.title.text.strip
154
154
  end
155
-
155
+
156
156
  # @return [String] value for title_245_search, title_full_display
157
157
  def sw_full_title
158
-
159
- return nil unless first_title_info_node
158
+
159
+ return nil unless first_title_info_node
160
160
  preSubTitle = nonSort_title ? [nonSort_title, title].compact.join(" ") : title
161
161
  preSubTitle.sub!(/:$/, '') if preSubTitle # remove trailing colon
162
162
 
@@ -227,67 +227,13 @@ module Stanford
227
227
  # see origin_info.rb (as all this information comes from top level originInfo element)
228
228
  # ---- end PUBLICATION (place, year) ----
229
229
 
230
- # select one or more format values from the controlled vocabulary here:
231
- # http://searchworks-solr-lb.stanford.edu:8983/solr/select?facet.field=format&rows=0&facet.sort=index
232
- # @return <Array[String]> value in the SearchWorks controlled vocabulary
233
- # @deprecated - kept for backwards compatibility but not part of SW UI redesign work Summer 2014
234
- # @deprecated: this is no longer used in SW, Revs or Spotlight Jan 2016
235
- def format
236
- types = term_values(:typeOfResource)
237
- return [] unless types
238
- genres = term_values(:genre)
239
- issuance = term_values([:origin_info, :issuance])
240
- val = []
241
- types.each do |type|
242
- case type
243
- when 'cartographic'
244
- val << 'Map/Globe'
245
- when 'mixed material'
246
- val << 'Manuscript/Archive'
247
- when 'moving image'
248
- val << 'Video'
249
- when 'notated music'
250
- val << 'Music - Score'
251
- when 'software, multimedia'
252
- val << 'Computer File'
253
- when 'sound recording-musical'
254
- val << 'Music - Recording'
255
- when 'sound recording-nonmusical', 'sound recording'
256
- val << 'Sound Recording'
257
- when 'still image'
258
- val << 'Image'
259
- when 'text'
260
- val << 'Book' if issuance && issuance.include?('monographic')
261
- book_genres = ['book chapter', 'Book chapter', 'Book Chapter',
262
- 'issue brief', 'Issue brief', 'Issue Brief',
263
- 'librettos', 'Librettos',
264
- 'project report', 'Project report', 'Project Report',
265
- 'technical report', 'Technical report', 'Technical Report',
266
- 'working paper', 'Working paper', 'Working Paper']
267
- val << 'Book' if genres && !(genres & book_genres).empty?
268
- conf_pub = ['conference publication', 'Conference publication', 'Conference Publication']
269
- val << 'Conference Proceedings' if genres && !(genres & conf_pub).empty?
270
- val << 'Journal/Periodical' if issuance && issuance.include?('continuing')
271
- article = ['article', 'Article']
272
- val << 'Journal/Periodical' if genres && !(genres & article).empty?
273
- stu_proj_rpt = ['student project report', 'Student project report', 'Student Project report', 'Student Project Report']
274
- val << 'Other' if genres && !(genres & stu_proj_rpt).empty?
275
- thesis = ['thesis', 'Thesis']
276
- val << 'Thesis' if genres && !(genres & thesis).empty?
277
- when 'three dimensional object'
278
- val << 'Other'
279
- end
280
- end
281
- val.uniq
282
- end
283
-
284
230
  # select one or more format values from the controlled vocabulary per JVine Summer 2014
285
231
  # http://searchworks-solr-lb.stanford.edu:8983/solr/select?facet.field=format_main_ssim&rows=0&facet.sort=index
286
232
  # https://github.com/sul-dlss/stanford-mods/issues/66 - For geodata, the
287
233
  # resource type should be only Map and not include Software, multimedia.
288
234
  # @return <Array[String]> value in the SearchWorks controlled vocabulary
289
235
  def format_main
290
- types = term_values(:typeOfResource)
236
+ types = typeOfResource
291
237
  return [] unless types
292
238
  article_genres = ['article', 'Article',
293
239
  'book chapter', 'Book chapter', 'Book Chapter',
@@ -303,13 +249,18 @@ module Stanford
303
249
  'thesis', 'Thesis'
304
250
  ]
305
251
  val = []
306
- genres = term_values(:genre)
307
- issuance = term_values([:origin_info, :issuance])
252
+ genres = term_values(:genre) || []
253
+ issuance = term_values([:origin_info, :issuance]) || []
254
+ frequency = term_values([:origin_info, :frequency]) || []
255
+
256
+ val << 'Dataset' if genres.include?('dataset') || genres.include?('Dataset')
257
+
308
258
  types.each do |type|
309
- case type
259
+ val << 'Archive/Manuscript' if type.manuscript == 'yes'
260
+
261
+ case type.text
310
262
  when 'cartographic'
311
263
  val << 'Map'
312
- val.delete 'Software/Multimedia'
313
264
  when 'mixed material'
314
265
  val << 'Archive/Manuscript'
315
266
  when 'moving image'
@@ -317,11 +268,7 @@ module Stanford
317
268
  when 'notated music'
318
269
  val << 'Music score'
319
270
  when 'software, multimedia'
320
- if genres && (genres.include?('dataset') || genres.include?('Dataset'))
321
- val << 'Dataset'
322
- elsif !val.include?('Map')
323
- val << 'Software/Multimedia'
324
- end
271
+ val << 'Software/Multimedia' unless types.map(&:text).include?('cartographic') || (genres.include?('dataset') || genres.include?('Dataset'))
325
272
  when 'sound recording-musical'
326
273
  val << 'Music recording'
327
274
  when 'sound recording-nonmusical', 'sound recording'
@@ -329,11 +276,14 @@ module Stanford
329
276
  when 'still image'
330
277
  val << 'Image'
331
278
  when 'text'
332
- val << 'Book' if genres && !(genres & article_genres).empty?
333
- val << 'Book' if issuance && issuance.include?('monographic')
334
- val << 'Book' if genres && !(genres & book_genres).empty?
335
- val << 'Journal/Periodical' if issuance && issuance.include?('continuing')
336
- val << 'Archived website' if genres && genres.include?('archived website')
279
+ is_explicitly_a_book = type.manuscript != 'yes' && (issuance.include?('monographic') || !(genres & article_genres).empty? || !(genres & book_genres).empty?)
280
+ is_periodical = issuance.include?('continuing') || issuance.include?('serial') || frequency.any? { |x| !x.empty? }
281
+ is_archived_website = genres.any? { |x| x.casecmp('archived website') == 0 }
282
+
283
+ val << 'Book' if is_explicitly_a_book
284
+ val << 'Journal/Periodical' if is_periodical
285
+ val << 'Archived website' if is_archived_website
286
+ val << 'Book' unless is_explicitly_a_book || is_periodical || is_archived_website
337
287
  when 'three dimensional object'
338
288
  val << 'Object'
339
289
  end
@@ -341,24 +291,22 @@ module Stanford
341
291
  val.uniq
342
292
  end
343
293
 
344
- # https://github.com/sul-dlss/stanford-mods/issues/66
345
- # Limit genre values to Government document, Conference proceedings,
346
- # Technical report and Thesis/Dissertation
347
294
  # @return <Array[String]> values for the genre facet in SearchWorks
348
295
  def sw_genre
349
296
  genres = term_values(:genre)
350
297
  return [] unless genres
351
- types = term_values(:typeOfResource)
352
- val = []
353
- val << 'Thesis/Dissertation' if genres.include?('thesis') || genres.include?('Thesis')
354
- if genres && types && types.include?('text')
355
- conf_pub = ['conference publication', 'Conference publication', 'Conference Publication']
356
- gov_pub = ['government publication', 'Government publication', 'Government Publication']
357
- tech_rpt = ['technical report', 'Technical report', 'Technical Report']
358
- val << 'Conference proceedings' unless (genres & conf_pub).empty?
359
- val << 'Government document' unless (genres & gov_pub).empty?
360
- val << 'Technical report' unless (genres & tech_rpt).empty?
361
- end
298
+ val = genres.map(&:to_s)
299
+ thesis_pub = ['thesis', 'Thesis']
300
+ val << 'Thesis/Dissertation' if (genres & thesis_pub).any?
301
+
302
+ conf_pub = ['conference publication', 'Conference publication', 'Conference Publication']
303
+ gov_pub = ['government publication', 'Government publication', 'Government Publication']
304
+ tech_rpt = ['technical report', 'Technical report', 'Technical Report']
305
+
306
+ val << 'Conference proceedings' if (genres & conf_pub).any?
307
+ val << 'Government document' if (genres & gov_pub).any?
308
+ val << 'Technical report' if (genres & tech_rpt).any?
309
+
362
310
  val.uniq
363
311
  end
364
312
 
@@ -55,12 +55,11 @@ module Stanford
55
55
  end
56
56
 
57
57
  # Values are the contents of:
58
- # mods/genre
59
58
  # mods/subject/topic
60
59
  # @return [Array<String>] values for the topic_search Solr field for this document or nil if none
61
60
  def topic_search
62
61
  @topic_search ||= begin
63
- vals = term_values(:genre) || []
62
+ vals = []
64
63
  vals.concat(subject_topics) if subject_topics
65
64
  vals.empty? ? nil : vals
66
65
  end
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = "2.5.1".freeze
4
+ VERSION = "2.6.0".freeze
5
5
  end
6
6
  end
data/spec/imprint_spec.rb CHANGED
@@ -18,7 +18,8 @@ describe Stanford::Mods::Imprint do
18
18
  '<dateCreated keyDate="yes">1964</dateCreated><dateIssued>195u</dateIssued>' => [1964],
19
19
  '<dateIssued>1964</dateIssued><dateCreated>195u</dateCreated>' => [1964],
20
20
  '<dateIssued point="start">195u</dateIssued><dateIssued point="end">1964</dateIssued>' => (1950..1964).to_a,
21
- '<dateIssued>1964</dateIssued><dateIssued>195u</dateIssued>' => [1964] + (1950..1959).to_a
21
+ '<dateIssued>1964</dateIssued><dateIssued>195u</dateIssued>' => [1964] + (1950..1959).to_a,
22
+ '<dateCreated keyDate="yes" encoding="w3cdtf" point="start">1966</dateCreated><dateCreated encoding="w3cdtf" point="end">1967</dateCreated>' => [1966,1967]
22
23
  }.each do |example, expected|
23
24
  it 'works' do
24
25
  smods_rec.from_str("#{mods_origin_info_start_str}
@@ -5,269 +5,6 @@ describe "Format fields (searchworks.rb)" do
5
5
  @ns_decl = "xmlns='#{Mods::MODS_NS}'"
6
6
  end
7
7
 
8
- # @deprecated: this is no longer used in SW, Revs or Spotlight Jan 2016
9
- context "format" do
10
- context "Book:" do
11
- context "typeOfResource text," do
12
- it 'originInfo/issuance monographic' do
13
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><originInfo><issuance>monographic</issuance></originInfo></mods>"
14
- @smods_rec.from_str(m)
15
- expect(@smods_rec.format).to eq ['Book']
16
- end
17
- context "genre" do
18
- it "'book chapter'", email: 'mods-squad 2014-05-22, Joanna Dyla' do
19
- m = "<mods #{@ns_decl}><genre>book chapter</genre><typeOfResource>text</typeOfResource></mods>"
20
- @smods_rec.from_str(m)
21
- expect(@smods_rec.format).to eq ['Book']
22
- m = "<mods #{@ns_decl}><genre>Book chapter</genre><typeOfResource>text</typeOfResource></mods>"
23
- @smods_rec.from_str(m)
24
- expect(@smods_rec.format).to eq ['Book']
25
- m = "<mods #{@ns_decl}><genre>Book Chapter</genre><typeOfResource>text</typeOfResource></mods>"
26
- @smods_rec.from_str(m)
27
- expect(@smods_rec.format).to eq ['Book']
28
- end
29
- it "'issue brief'", email: 'mods-squad 2014-05-22, Joanna Dyla' do
30
- m = "<mods #{@ns_decl}><genre>issue brief</genre><typeOfResource>text</typeOfResource></mods>"
31
- @smods_rec.from_str(m)
32
- expect(@smods_rec.format).to eq ['Book']
33
- m = "<mods #{@ns_decl}><genre>Issue brief</genre><typeOfResource>text</typeOfResource></mods>"
34
- @smods_rec.from_str(m)
35
- expect(@smods_rec.format).to eq ['Book']
36
- m = "<mods #{@ns_decl}><genre>Issue Brief</genre><typeOfResource>text</typeOfResource></mods>"
37
- @smods_rec.from_str(m)
38
- expect(@smods_rec.format).to eq ['Book']
39
- end
40
- it "'librettos'", jira: 'INDEX-98' do
41
- m = "<mods #{@ns_decl}><genre>librettos</genre><typeOfResource>text</typeOfResource></mods>"
42
- @smods_rec.from_str(m)
43
- expect(@smods_rec.format).to eq ['Book']
44
- m = "<mods #{@ns_decl}><genre>Librettos</genre><typeOfResource>text</typeOfResource></mods>"
45
- @smods_rec.from_str(m)
46
- expect(@smods_rec.format).to eq ['Book']
47
- end
48
- it "'libretto' isn't valid", jira: 'INDEX-98' do
49
- m = "<mods #{@ns_decl}><genre>libretto</genre><typeOfResource>text</typeOfResource></mods>"
50
- @smods_rec.from_str(m)
51
- expect(@smods_rec.format).to eq []
52
- end
53
- it "'project report'", jira: 'GRYP-170', github: 'gdor-indexer/#7' do
54
- m = "<mods #{@ns_decl}><genre>project report</genre><typeOfResource>text</typeOfResource></mods>"
55
- @smods_rec.from_str(m)
56
- expect(@smods_rec.format).to eq ['Book']
57
- m = "<mods #{@ns_decl}><genre>Project report</genre><typeOfResource>text</typeOfResource></mods>"
58
- @smods_rec.from_str(m)
59
- expect(@smods_rec.format).to eq ['Book']
60
- m = "<mods #{@ns_decl}><genre>Project Report</genre><typeOfResource>text</typeOfResource></mods>"
61
- @smods_rec.from_str(m)
62
- expect(@smods_rec.format).to eq ['Book']
63
- end
64
- it "'report' isn't valid", jira: 'GRYP-170', github: 'gdor-indexer/#7' do
65
- m = "<mods #{@ns_decl}><genre>report</genre><typeOfResource>text</typeOfResource></mods>"
66
- @smods_rec.from_str(m)
67
- expect(@smods_rec.format).to eq []
68
- end
69
- it "'technical report'", jira: 'GRYPHONDOR-207' do
70
- m = "<mods #{@ns_decl}><genre>technical report</genre><typeOfResource>text</typeOfResource></mods>"
71
- @smods_rec.from_str(m)
72
- expect(@smods_rec.format).to eq ['Book']
73
- m = "<mods #{@ns_decl}><genre>Technical report</genre><typeOfResource>text</typeOfResource></mods>"
74
- @smods_rec.from_str(m)
75
- expect(@smods_rec.format).to eq ['Book']
76
- m = "<mods #{@ns_decl}><genre>Technical Report</genre><typeOfResource>text</typeOfResource></mods>"
77
- @smods_rec.from_str(m)
78
- expect(@smods_rec.format).to eq ['Book']
79
- end
80
- it "'working paper'", email: 'mods-squad 2014-05-22, Joanna Dyla' do
81
- m = "<mods #{@ns_decl}><genre>working paper</genre><typeOfResource>text</typeOfResource></mods>"
82
- @smods_rec.from_str(m)
83
- expect(@smods_rec.format).to eq ['Book']
84
- m = "<mods #{@ns_decl}><genre>Working paper</genre><typeOfResource>text</typeOfResource></mods>"
85
- @smods_rec.from_str(m)
86
- expect(@smods_rec.format).to eq ['Book']
87
- m = "<mods #{@ns_decl}><genre>Working Paper</genre><typeOfResource>text</typeOfResource></mods>"
88
- @smods_rec.from_str(m)
89
- expect(@smods_rec.format).to eq ['Book']
90
- end
91
- end
92
- end
93
- end # 'Book'
94
-
95
- context "Computer File: typeOfResource 'software, multimedia'" do
96
- it "no genre (e.g. Dataset)" do
97
- m = "<mods #{@ns_decl}><typeOfResource>software, multimedia</typeOfResource></mods>"
98
- @smods_rec.from_str(m)
99
- expect(@smods_rec.format).to eq ['Computer File']
100
- end
101
- it "genre 'game'", jira: 'GRYPHONDOR-207' do
102
- m = "<mods #{@ns_decl}><genre>game</genre><typeOfResource>software, multimedia</typeOfResource></mods>"
103
- @smods_rec.from_str(m)
104
- expect(@smods_rec.format).to eq ['Computer File']
105
- m = "<mods #{@ns_decl}><genre>Game</genre><typeOfResource>software, multimedia</typeOfResource></mods>"
106
- @smods_rec.from_str(m)
107
- expect(@smods_rec.format).to eq ['Computer File']
108
- end
109
- end
110
-
111
- it "Conference Proceedings: typeOfResource 'text', genre 'conference publication'", jira: 'GRYPHONDOR-207' do
112
- m = "<mods #{@ns_decl}><genre>conference publication</genre><typeOfResource>text</typeOfResource></mods>"
113
- @smods_rec.from_str(m)
114
- expect(@smods_rec.format).to eq ['Conference Proceedings']
115
- m = "<mods #{@ns_decl}><genre>Conference publication</genre><typeOfResource>text</typeOfResource></mods>"
116
- @smods_rec.from_str(m)
117
- expect(@smods_rec.format).to eq ['Conference Proceedings']
118
- m = "<mods #{@ns_decl}><genre>Conference Publication</genre><typeOfResource>text</typeOfResource></mods>"
119
- @smods_rec.from_str(m)
120
- expect(@smods_rec.format).to eq ['Conference Proceedings']
121
- end
122
-
123
- context "Journal/Periodical: typeOfResource 'text'," do
124
- it "genre 'article" do
125
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>article</genre></mods>"
126
- @smods_rec.from_str(m)
127
- expect(@smods_rec.format).to eq ['Journal/Periodical']
128
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>Article</genre></mods>"
129
- @smods_rec.from_str(m)
130
- expect(@smods_rec.format).to eq ['Journal/Periodical']
131
- end
132
- it "originInfo/issuance 'continuing'" do
133
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><originInfo><issuance>continuing</issuance></originInfo></mods>"
134
- @smods_rec.from_str(m)
135
- expect(@smods_rec.format).to eq ['Journal/Periodical']
136
- end
137
- end
138
-
139
- it "Image: typeOfResource 'still image'" do
140
- m = "<mods #{@ns_decl}><typeOfResource>still image</typeOfResource></mods>"
141
- @smods_rec.from_str(m)
142
- expect(@smods_rec.format).to eq ['Image']
143
- end
144
-
145
- it "Manuscript/Archive: typeOfResource 'mixed material'" do
146
- m = "<mods #{@ns_decl}><typeOfResource>mixed material</typeOfResource></mods>"
147
- @smods_rec.from_str(m)
148
- expect(@smods_rec.format).to eq ['Manuscript/Archive']
149
- end
150
-
151
- it "Map/Globe: typeOfResource 'cartographic'" do
152
- m = "<mods #{@ns_decl}><typeOfResource>cartographic</typeOfResource></mods>"
153
- @smods_rec.from_str(m)
154
- expect(@smods_rec.format).to eq ['Map/Globe']
155
- end
156
-
157
- it "Music - Recording: typeOfResource 'sound recording-musical'", jira: 'GRYPHONDOR-207' do
158
- m = "<mods #{@ns_decl}><typeOfResource>sound recording-musical</typeOfResource></mods>"
159
- @smods_rec.from_str(m)
160
- expect(@smods_rec.format).to eq ['Music - Recording']
161
- end
162
-
163
- it "Music - Score: typeOfResource 'notated music'" do
164
- m = "<mods #{@ns_decl}><typeOfResource>notated music</typeOfResource></mods>"
165
- @smods_rec.from_str(m)
166
- expect(@smods_rec.format).to eq ['Music - Score']
167
- end
168
-
169
- it "Other: typeOfResource 'text', genre 'student project report'", email: 'from Vitus, August 16, 2013' do
170
- m = "<mods #{@ns_decl}><genre>student project report</genre><typeOfResource>text</typeOfResource></mods>"
171
- @smods_rec.from_str(m)
172
- expect(@smods_rec.format).to eq ['Other']
173
- m = "<mods #{@ns_decl}><genre>Student project report</genre><typeOfResource>text</typeOfResource></mods>"
174
- @smods_rec.from_str(m)
175
- expect(@smods_rec.format).to eq ['Other']
176
- m = "<mods #{@ns_decl}><genre>Student Project report</genre><typeOfResource>text</typeOfResource></mods>"
177
- @smods_rec.from_str(m)
178
- expect(@smods_rec.format).to eq ['Other']
179
- m = "<mods #{@ns_decl}><genre>Student Project Report</genre><typeOfResource>text</typeOfResource></mods>"
180
- @smods_rec.from_str(m)
181
- expect(@smods_rec.format).to eq ['Other']
182
- end
183
-
184
- context "Sound Recording:" do
185
- it "typeOfResource 'sound recording-nonmusical', genre 'sound", jira: 'GRYPHONDOR-207' do
186
- m = "<mods #{@ns_decl}><genre>sound</genre><typeOfResource>sound recording-nonmusical</typeOfResource></mods>"
187
- @smods_rec.from_str(m)
188
- expect(@smods_rec.format).to eq ['Sound Recording']
189
- m = "<mods #{@ns_decl}><genre>Sound</genre><typeOfResource>sound recording-nonmusical</typeOfResource></mods>"
190
- @smods_rec.from_str(m)
191
- expect(@smods_rec.format).to eq ['Sound Recording']
192
- end
193
- it "typeOfResource 'sound recording', genre 'sound", jira: 'INDEX-94' do
194
- m = "<mods #{@ns_decl}><genre>sound</genre><typeOfResource>sound recording</typeOfResource></mods>"
195
- @smods_rec.from_str(m)
196
- expect(@smods_rec.format).to eq ['Sound Recording']
197
- m = "<mods #{@ns_decl}><genre>Sound</genre><typeOfResource>sound recording</typeOfResource></mods>"
198
- @smods_rec.from_str(m)
199
- expect(@smods_rec.format).to eq ['Sound Recording']
200
- end
201
- end
202
-
203
- it "Thesis: typeOfResource 'text', genre 'thesis'" do
204
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>thesis</genre></mods>"
205
- @smods_rec.from_str(m)
206
- expect(@smods_rec.format).to eq ['Thesis']
207
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>Thesis</genre></mods>"
208
- @smods_rec.from_str(m)
209
- expect(@smods_rec.format).to eq ['Thesis']
210
- end
211
-
212
- context "Video: typeOfResource 'moving image'" do
213
- it "no genre" do
214
- m = "<mods #{@ns_decl}><typeOfResource>moving image</typeOfResource></mods>"
215
- @smods_rec.from_str(m)
216
- expect(@smods_rec.format).to eq ['Video']
217
- end
218
- it "genre 'motion picture'", jira: 'GRYPHONDOR-207' do
219
- m = "<mods #{@ns_decl}><genre>motion picture</genre><typeOfResource>moving image</typeOfResource></mods>"
220
- @smods_rec.from_str(m)
221
- expect(@smods_rec.format).to eq ['Video']
222
- m = "<mods #{@ns_decl}><genre>Motion Picture</genre><typeOfResource>moving image</typeOfResource></mods>"
223
- @smods_rec.from_str(m)
224
- expect(@smods_rec.format).to eq ['Video']
225
- m = "<mods #{@ns_decl}><genre>Motion Picture</genre><typeOfResource>moving image</typeOfResource></mods>"
226
- @smods_rec.from_str(m)
227
- expect(@smods_rec.format).to eq ['Video']
228
- end
229
- end
230
-
231
- context "multiple format values", jira: 'INDEX-32' do
232
- it "multiple typeOfResource elements" do
233
- m = "<mods #{@ns_decl}><typeOfResource>moving image</typeOfResource><typeOfResource>sound recording</typeOfResource></mods>"
234
- @smods_rec.from_str(m)
235
- expect(@smods_rec.format).to eq ['Video', 'Sound Recording']
236
- end
237
- it "multiple genre elements, single typeOfResource" do
238
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>librettos</genre><genre>article</genre></mods>"
239
- @smods_rec.from_str(m)
240
- expect(@smods_rec.format).to eq ['Book', 'Journal/Periodical']
241
- end
242
- it "mish mash" do
243
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><typeOfResource>still image</typeOfResource><genre>librettos</genre><genre>article</genre></mods>"
244
- @smods_rec.from_str(m)
245
- expect(@smods_rec.format).to eq ['Book', 'Journal/Periodical', 'Image']
246
- end
247
- it "doesn't give duplicate values" do
248
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>librettos</genre><genre>issue brief</genre></mods>"
249
- @smods_rec.from_str(m)
250
- expect(@smods_rec.format).to eq ['Book']
251
- end
252
- end
253
-
254
- it "empty Array if no typeOfResource field" do
255
- m = "<mods #{@ns_decl}><originInfo>
256
- <dateCreated>1904</dateCreated>
257
- </originInfo></mods>"
258
- @smods_rec.from_str(m)
259
- expect(@smods_rec.format).to eq []
260
- end
261
-
262
- it "empty Array if weird typeOfResource value" do
263
- m = "<mods #{@ns_decl}>
264
- <typeOfResource>foo</typeOfResource>
265
- </mods>"
266
- @smods_rec.from_str(m)
267
- expect(@smods_rec.format).to eq []
268
- end
269
- end # format
270
-
271
8
  context "format_main" do
272
9
  it "3D object: typeOfResource 'three dimensional object'" do
273
10
  m = "<mods #{@ns_decl}><typeOfResource>three dimensional object</typeOfResource></mods>"
@@ -329,10 +66,10 @@ describe "Format fields (searchworks.rb)" do
329
66
  @smods_rec.from_str(m)
330
67
  expect(@smods_rec.format_main).to eq ['Book']
331
68
  end
332
- it "'report' isn't valid", jira: 'GRYP-170', github: 'gdor-indexer/#7' do
69
+ it "'report' isn't valid, so defaults to book", jira: 'GRYP-170', github: 'gdor-indexer/#7' do
333
70
  m = "<mods #{@ns_decl}><genre>report</genre><typeOfResource>text</typeOfResource></mods>"
334
71
  @smods_rec.from_str(m)
335
- expect(@smods_rec.format_main).to eq []
72
+ expect(@smods_rec.format_main).to eq ['Book']
336
73
  end
337
74
  it "'student project report'", consul: '/NGDE/Format 2014-05-28' do
338
75
  m = "<mods #{@ns_decl}><genre authority=\"local\">student project report</genre><typeOfResource>text</typeOfResource></mods>"
@@ -400,10 +137,10 @@ describe "Format fields (searchworks.rb)" do
400
137
  @smods_rec.from_str(m)
401
138
  expect(@smods_rec.format_main).to eq ['Book']
402
139
  end
403
- it "'libretto' isn't valid", jira: 'INDEX-98' do
140
+ it "'libretto' isn't valid, so it defaults to book", jira: 'INDEX-98' do
404
141
  m = "<mods #{@ns_decl}><genre>libretto</genre><typeOfResource>text</typeOfResource></mods>"
405
142
  @smods_rec.from_str(m)
406
- expect(@smods_rec.format_main).to eq []
143
+ expect(@smods_rec.format_main).to eq ['Book']
407
144
  end
408
145
  it "'librettos'", jira: 'INDEX-98' do
409
146
  m = "<mods #{@ns_decl}><genre>librettos</genre><typeOfResource>text</typeOfResource></mods>"
@@ -578,57 +315,57 @@ describe "Format fields (searchworks.rb)" do
578
315
  end # format_main
579
316
 
580
317
  context "sw_genre" do
581
- it "ignores values that are not in the prescribed list" do
318
+ it "includes values that are not in the prescribed list" do
582
319
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Not on the list</genre><typeOfResource>text</typeOfResource></mods>"
583
320
  @smods_rec.from_str(m)
584
- expect(@smods_rec.sw_genre).to eq []
321
+ expect(@smods_rec.sw_genre).to eq ['Not on the list']
585
322
  end
586
323
  it "Conference proceedings: typeOfResource 'text', genre 'conference publication'" do
587
324
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">conference publication</genre><typeOfResource>text</typeOfResource></mods>"
588
325
  @smods_rec.from_str(m)
589
- expect(@smods_rec.sw_genre).to eq ['Conference proceedings']
326
+ expect(@smods_rec.sw_genre).to eq ['conference publication', 'Conference proceedings']
590
327
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Conference publication</genre><typeOfResource>text</typeOfResource></mods>"
591
328
  @smods_rec.from_str(m)
592
- expect(@smods_rec.sw_genre).to eq ['Conference proceedings']
329
+ expect(@smods_rec.sw_genre).to eq ['Conference publication', 'Conference proceedings']
593
330
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Conference Publication</genre><typeOfResource>text</typeOfResource></mods>"
594
331
  @smods_rec.from_str(m)
595
- expect(@smods_rec.sw_genre).to eq ['Conference proceedings']
332
+ expect(@smods_rec.sw_genre).to eq ['Conference Publication', 'Conference proceedings']
596
333
  end
597
334
  it "Thesis/Dissertation: typeOfResource 'text', genre 'thesis'" do
598
335
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">thesis</genre><typeOfResource>text</typeOfResource></mods>"
599
336
  @smods_rec.from_str(m)
600
- expect(@smods_rec.sw_genre).to eq ['Thesis/Dissertation']
337
+ expect(@smods_rec.sw_genre).to eq ['thesis', 'Thesis/Dissertation']
601
338
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Thesis</genre><typeOfResource>text</typeOfResource></mods>"
602
339
  @smods_rec.from_str(m)
603
- expect(@smods_rec.sw_genre).to eq ['Thesis/Dissertation']
340
+ expect(@smods_rec.sw_genre).to eq ['Thesis', 'Thesis/Dissertation']
604
341
  end
605
342
  it "Government Document: typeOfResource 'text', genre 'government publication'" do
606
343
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">government publication</genre><typeOfResource>text</typeOfResource></mods>"
607
344
  @smods_rec.from_str(m)
608
- expect(@smods_rec.sw_genre).to eq ['Government document']
345
+ expect(@smods_rec.sw_genre).to eq ['government publication', 'Government document']
609
346
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Government publication</genre><typeOfResource>text</typeOfResource></mods>"
610
347
  @smods_rec.from_str(m)
611
- expect(@smods_rec.sw_genre).to eq ['Government document']
348
+ expect(@smods_rec.sw_genre).to eq ['Government publication', 'Government document']
612
349
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Government Publication</genre><typeOfResource>text</typeOfResource></mods>"
613
350
  @smods_rec.from_str(m)
614
- expect(@smods_rec.sw_genre).to eq ['Government document']
351
+ expect(@smods_rec.sw_genre).to eq ['Government Publication', 'Government document']
615
352
  m = "<mods #{@ns_decl}><genre>government publication</genre><typeOfResource>text</typeOfResource></mods>"
616
353
  @smods_rec.from_str(m)
617
- expect(@smods_rec.sw_genre).to eq ['Government document']
354
+ expect(@smods_rec.sw_genre).to eq ['government publication', 'Government document']
618
355
  end
619
356
  it "Technical Report: typeOfResource 'text', genre 'technical report'" do
620
357
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">technical report</genre><typeOfResource>text</typeOfResource></mods>"
621
358
  @smods_rec.from_str(m)
622
- expect(@smods_rec.sw_genre).to eq ['Technical report']
359
+ expect(@smods_rec.sw_genre).to eq ['technical report', 'Technical report']
623
360
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Technical report</genre><typeOfResource>text</typeOfResource></mods>"
624
361
  @smods_rec.from_str(m)
625
362
  expect(@smods_rec.sw_genre).to eq ['Technical report']
626
363
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Technical Report</genre><typeOfResource>text</typeOfResource></mods>"
627
364
  @smods_rec.from_str(m)
628
- expect(@smods_rec.sw_genre).to eq ['Technical report']
365
+ expect(@smods_rec.sw_genre).to eq ['Technical Report', 'Technical report']
629
366
  m = "<mods #{@ns_decl}><genre>technical report</genre><typeOfResource>text</typeOfResource></mods>"
630
367
  @smods_rec.from_str(m)
631
- expect(@smods_rec.sw_genre).to eq ['Technical report']
368
+ expect(@smods_rec.sw_genre).to eq ['technical report', 'Technical report']
632
369
  end
633
370
  it "it does not include Archived website: typeOfResource 'text', genre 'archived website'" do
634
371
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">archived website</genre><typeOfResource>text</typeOfResource></mods>"
@@ -638,13 +375,13 @@ describe "Format fields (searchworks.rb)" do
638
375
  it "capitalizes the first letter of a genre value" do
639
376
  m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre authority=\"marcgt\">technical report</genre></mods>"
640
377
  @smods_rec.from_str(m)
641
- expect(@smods_rec.sw_genre).to eq ['Technical report']
378
+ expect(@smods_rec.sw_genre).to eq ['technical report', 'Technical report']
642
379
  m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre authority=\"marcgt\">Technical report</genre></mods>"
643
380
  @smods_rec.from_str(m)
644
381
  expect(@smods_rec.sw_genre).to eq ['Technical report']
645
382
  m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre authority=\"marcgt\">Technical Report</genre></mods>"
646
383
  @smods_rec.from_str(m)
647
- expect(@smods_rec.sw_genre).to eq ['Technical report']
384
+ expect(@smods_rec.sw_genre).to eq ['Technical Report', 'Technical report']
648
385
  end
649
386
  # NOTE: may need to remove plurals and/or trailing punctuation in future
650
387
  it "returns all genre values" do
@@ -655,7 +392,7 @@ describe "Format fields (searchworks.rb)" do
655
392
  <genre>thesis</genre>
656
393
  </mods>"
657
394
  @smods_rec.from_str(m)
658
- expect(@smods_rec.sw_genre).to eq ['Thesis/Dissertation', 'Conference proceedings', 'Government document']
395
+ expect(@smods_rec.sw_genre).to eq ['government publication', 'conference publication', 'thesis', 'Thesis/Dissertation', 'Conference proceedings', 'Government document']
659
396
  end
660
397
  it "doesn't have duplicates" do
661
398
  m = "<mods #{@ns_decl}>
@@ -665,7 +402,7 @@ describe "Format fields (searchworks.rb)" do
665
402
  <genre>Conference publication</genre>
666
403
  </mods>"
667
404
  @smods_rec.from_str(m)
668
- expect(@smods_rec.sw_genre).to eq ['Conference proceedings', 'Technical report']
405
+ expect(@smods_rec.sw_genre).to eq ['conference publication', 'technical report', 'Conference publication', 'Conference proceedings', 'Technical report']
669
406
  end
670
407
  it "empty Array if no genre values" do
671
408
  m = "<mods #{@ns_decl}>
@@ -44,9 +44,6 @@ describe "Subject fields (searchworks.rb)" do
44
44
  it "should contain subject <topic> subelement data" do
45
45
  expect(@smods_rec.topic_search).to include(@topic)
46
46
  end
47
- it "should contain top level <genre> element data" do
48
- expect(@smods_rec.topic_search).to include(@genre)
49
- end
50
47
  it "should not contain other subject element data" do
51
48
  expect(@smods_rec.topic_search).not_to include(@cart_coord)
52
49
  expect(@smods_rec.topic_search).not_to include(@s_genre)
@@ -64,12 +61,6 @@ describe "Subject fields (searchworks.rb)" do
64
61
  @smods_rec.from_str(m)
65
62
  expect(@smods_rec.topic_search).to eq([@topic])
66
63
  end
67
- it "should not be nil if there are only <genre> elements (no subject/topic elements)" do
68
- m = "<mods #{@ns_decl}><genre>#{@genre}</genre></mods>"
69
- @smods_rec = Stanford::Mods::Record.new
70
- @smods_rec.from_str(m)
71
- expect(@smods_rec.topic_search).to eq([@genre])
72
- end
73
64
  context "topic subelement" do
74
65
  it "should have a separate value for each topic element" do
75
66
  m = "<mods #{@ns_decl}>
@@ -280,9 +271,6 @@ describe "Subject fields (searchworks.rb)" do
280
271
  @smods_rec.from_str(@ng_mods_no_subject.to_s)
281
272
  expect(@smods_rec.subject_all_search).to be_nil
282
273
  end
283
- it "should contain top level <genre> element data" do
284
- expect(@smods_rec.subject_all_search).to include(@genre)
285
- end
286
274
  it "should not contain cartographic sub element" do
287
275
  expect(@smods_rec.subject_all_search).not_to include(@cart_coord)
288
276
  end
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.5.1
4
+ version: 2.6.0
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: 2017-12-05 00:00:00.000000000 Z
12
+ date: 2018-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mods