stanford-mods 1.3.4 → 1.4.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 +4 -4
- data/lib/stanford-mods/date_parsing.rb +80 -34
- data/lib/stanford-mods/origin_info.rb +143 -88
- data/lib/stanford-mods/searchworks.rb +1 -0
- data/lib/stanford-mods/version.rb +1 -1
- data/spec/date_parsing_spec.rb +121 -6
- data/spec/origin_info_spec.rb +80 -35
- data/spec/searchworks_format_spec.rb +1 -0
- data/spec/searchworks_pub_dates_spec.rb +154 -137
- metadata +2 -2
@@ -223,6 +223,7 @@ module Stanford
|
|
223
223
|
# http://searchworks-solr-lb.stanford.edu:8983/solr/select?facet.field=format&rows=0&facet.sort=index
|
224
224
|
# @return <Array[String]> value in the SearchWorks controlled vocabulary
|
225
225
|
# @deprecated - kept for backwards compatibility but not part of SW UI redesign work Summer 2014
|
226
|
+
# @deprecated: this is no longer used in SW, Revs or Spotlight Jan 2016
|
226
227
|
def format
|
227
228
|
val = []
|
228
229
|
types = self.term_values(:typeOfResource)
|
data/spec/date_parsing_spec.rb
CHANGED
@@ -378,6 +378,15 @@ describe "date parsing methods" do
|
|
378
378
|
'75 B.C.' => '-925',
|
379
379
|
'8 B.C.' => '-992'
|
380
380
|
}
|
381
|
+
bc_dates_to_int = {
|
382
|
+
'801 B.C.' => -801,
|
383
|
+
'800 B.C.' => -800,
|
384
|
+
'750 B.C.' => -750,
|
385
|
+
'700 B.C.' => -700,
|
386
|
+
'699 B.C.' => -699,
|
387
|
+
'75 B.C.' => -75,
|
388
|
+
'8 B.C.' => -8
|
389
|
+
}
|
381
390
|
|
382
391
|
context '*facet_string_from_date_str' do
|
383
392
|
it 'calls instance method facet_string_from_date_str' do
|
@@ -391,6 +400,12 @@ describe "date parsing methods" do
|
|
391
400
|
Stanford::Mods::DateParsing.sortable_year_string_from_date_str('1666')
|
392
401
|
end
|
393
402
|
end
|
403
|
+
context '*year_int_from_date_str' do
|
404
|
+
it 'calls instance method year_int_from_date_str' do
|
405
|
+
expect_any_instance_of(Stanford::Mods::DateParsing).to receive(:year_int_from_date_str)
|
406
|
+
Stanford::Mods::DateParsing.year_int_from_date_str('1666')
|
407
|
+
end
|
408
|
+
end
|
394
409
|
|
395
410
|
context '#facet_string_from_date_str' do
|
396
411
|
single_year
|
@@ -442,7 +457,8 @@ describe "date parsing methods" do
|
|
442
457
|
[ # bad dates
|
443
458
|
'9999',
|
444
459
|
'2035',
|
445
|
-
'0000-00-00'
|
460
|
+
'0000-00-00',
|
461
|
+
'uuuu'
|
446
462
|
].each do |example|
|
447
463
|
it "nil for #{example}" do
|
448
464
|
expect(Stanford::Mods::DateParsing.new(example).facet_string_from_date_str).to eq nil
|
@@ -450,6 +466,61 @@ describe "date parsing methods" do
|
|
450
466
|
end
|
451
467
|
end
|
452
468
|
|
469
|
+
context '#year_int_from_date_str' do
|
470
|
+
single_year
|
471
|
+
.merge(specific_month)
|
472
|
+
.merge(specific_day)
|
473
|
+
.merge(specific_day_2_digit_year)
|
474
|
+
.merge(bc_dates_to_int)
|
475
|
+
.merge(specific_day_ruby_parse_fail)
|
476
|
+
.merge(brackets_in_middle_of_year)
|
477
|
+
.merge(invalid_but_can_get_year).each do |example, expected|
|
478
|
+
it "#{expected} for single value #{example}" do
|
479
|
+
expect(Stanford::Mods::DateParsing.new(example).year_int_from_date_str).to eq expected.to_i
|
480
|
+
end
|
481
|
+
end
|
482
|
+
|
483
|
+
multiple_years
|
484
|
+
.merge(multiple_years_4_digits_once)
|
485
|
+
.merge(decade_only)
|
486
|
+
.merge(decade_only_4_digits).each do |example, expected|
|
487
|
+
it "#{expected.first} for multi-value #{example}" do
|
488
|
+
expect(Stanford::Mods::DateParsing.new(example).year_int_from_date_str).to eq expected.first.to_i
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
century_only.keys.each do |example|
|
493
|
+
it "1700 from #{example}" do
|
494
|
+
expect(Stanford::Mods::DateParsing.new(example).year_int_from_date_str).to eq 1700
|
495
|
+
end
|
496
|
+
end
|
497
|
+
|
498
|
+
early_numeric_dates.each do |example, _expected|
|
499
|
+
it "#{example} for #{example}" do
|
500
|
+
expect(Stanford::Mods::DateParsing.new(example).year_int_from_date_str).to eq example.to_i
|
501
|
+
end
|
502
|
+
end
|
503
|
+
|
504
|
+
it 'nil for -1666' do
|
505
|
+
skip("code broken for -yyyy dates but no existing data for this yet")
|
506
|
+
expect(Stanford::Mods::DateParsing.new('-1666').year_int_from_date_str).to eq nil
|
507
|
+
end
|
508
|
+
it '-1666 for 1666 B.C.' do
|
509
|
+
expect(Stanford::Mods::DateParsing.new('1666 B.C.').year_int_from_date_str).to eq(-1666)
|
510
|
+
end
|
511
|
+
|
512
|
+
[ # bad dates
|
513
|
+
'9999',
|
514
|
+
'2035',
|
515
|
+
'0000-00-00',
|
516
|
+
'uuuu'
|
517
|
+
].each do |example|
|
518
|
+
it "nil for #{example}" do
|
519
|
+
expect(Stanford::Mods::DateParsing.new(example).year_int_from_date_str).to eq nil
|
520
|
+
end
|
521
|
+
end
|
522
|
+
end
|
523
|
+
|
453
524
|
context '#sortable_year_string_from_date_str' do
|
454
525
|
single_year
|
455
526
|
.merge(specific_month)
|
@@ -491,7 +562,8 @@ describe "date parsing methods" do
|
|
491
562
|
[ # bad dates
|
492
563
|
'9999',
|
493
564
|
'2035',
|
494
|
-
'0000-00-00'
|
565
|
+
'0000-00-00',
|
566
|
+
'uuuu'
|
495
567
|
].each do |example|
|
496
568
|
it "nil for #{example}" do
|
497
569
|
expect(Stanford::Mods::DateParsing.new(example).sortable_year_string_from_date_str).to eq nil
|
@@ -524,6 +596,33 @@ describe "date parsing methods" do
|
|
524
596
|
end
|
525
597
|
end
|
526
598
|
|
599
|
+
context '*year_int_valid?' do
|
600
|
+
{ # example int as key, expected result as value
|
601
|
+
-1666 => false,
|
602
|
+
-999 => true,
|
603
|
+
-35 => true,
|
604
|
+
-3 => true,
|
605
|
+
0 => true,
|
606
|
+
5 => true,
|
607
|
+
33 => true,
|
608
|
+
150 => true,
|
609
|
+
(Date.today.year + 1) => true, # current year + 1
|
610
|
+
(Date.today.year + 2) => false, # current year + 2
|
611
|
+
9999 => false,
|
612
|
+
'165x' => false,
|
613
|
+
'198-' => false,
|
614
|
+
'random text' => false,
|
615
|
+
nil => false
|
616
|
+
}.each do |example, expected|
|
617
|
+
it "#{expected} for #{example}" do
|
618
|
+
expect(Stanford::Mods::DateParsing.year_int_valid?(example)).to eq expected
|
619
|
+
end
|
620
|
+
end
|
621
|
+
it 'true for 0000' do
|
622
|
+
expect(Stanford::Mods::DateParsing.year_int_valid?(0000)).to eq true
|
623
|
+
end
|
624
|
+
end
|
625
|
+
|
527
626
|
context '#sortable_year_for_yyyy' do
|
528
627
|
single_year
|
529
628
|
.merge(specific_month)
|
@@ -640,10 +739,18 @@ describe "date parsing methods" do
|
|
640
739
|
end
|
641
740
|
end
|
642
741
|
|
643
|
-
context '#
|
742
|
+
context '#sortable_year_int_for_early_numeric' do
|
743
|
+
early_numeric_dates.each do |example, _expected|
|
744
|
+
it "#{example} for #{example}" do
|
745
|
+
expect(Stanford::Mods::DateParsing.new(example).sortable_year_int_for_early_numeric).to eq example.to_i
|
746
|
+
end
|
747
|
+
end
|
748
|
+
end
|
749
|
+
|
750
|
+
context '#sortable_year_str_for_early_numeric' do
|
644
751
|
early_numeric_dates.each do |example, expected|
|
645
752
|
it "#{expected} for #{example}" do
|
646
|
-
expect(Stanford::Mods::DateParsing.new(example).
|
753
|
+
expect(Stanford::Mods::DateParsing.new(example).sortable_year_str_for_early_numeric).to eq expected
|
647
754
|
end
|
648
755
|
end
|
649
756
|
end
|
@@ -664,10 +771,18 @@ describe "date parsing methods" do
|
|
664
771
|
end
|
665
772
|
end
|
666
773
|
|
667
|
-
context '#
|
774
|
+
context '#sortable_year_int_for_bc' do
|
775
|
+
bc_dates_to_int.each do |example, expected|
|
776
|
+
it "#{expected} for #{example}" do
|
777
|
+
expect(Stanford::Mods::DateParsing.new(example).sortable_year_int_for_bc).to eq expected
|
778
|
+
end
|
779
|
+
end
|
780
|
+
end
|
781
|
+
|
782
|
+
context '#sortable_year_str_for_bc' do
|
668
783
|
bc_dates.each do |example, expected|
|
669
784
|
it "#{expected} for #{example}" do
|
670
|
-
expect(Stanford::Mods::DateParsing.new(example).
|
785
|
+
expect(Stanford::Mods::DateParsing.new(example).sortable_year_str_for_bc).to eq expected
|
671
786
|
end
|
672
787
|
end
|
673
788
|
end
|
data/spec/origin_info_spec.rb
CHANGED
@@ -24,7 +24,7 @@ describe "computations from /originInfo field" do
|
|
24
24
|
<dateCreated>1999</dateCreated>' +
|
25
25
|
mods_origin_info_end_str
|
26
26
|
smods_rec.from_str(mods_str)
|
27
|
-
expect(smods_rec.send(method_sym)).to eq '2005'
|
27
|
+
expect(smods_rec.send(method_sym)).to eq method_sym.to_s.match(/int/) ? 2005 : '2005'
|
28
28
|
end
|
29
29
|
it 'respects ignore_approximate param' do
|
30
30
|
mods_str = mods_origin_info_start_str +
|
@@ -32,8 +32,8 @@ describe "computations from /originInfo field" do
|
|
32
32
|
'<dateCreated point="end">1599</dateCreated>' +
|
33
33
|
mods_origin_info_end_str
|
34
34
|
smods_rec.from_str(mods_str)
|
35
|
-
expect(smods_rec.send(method_sym, true)).to eq '1599'
|
36
|
-
expect(smods_rec.send(method_sym, false)).to eq '1000'
|
35
|
+
expect(smods_rec.send(method_sym, true)).to eq method_sym.to_s.match(/int/) ? 1599 : '1599'
|
36
|
+
expect(smods_rec.send(method_sym, false)).to eq method_sym.to_s.match(/int/) ? 1000 : '1000'
|
37
37
|
end
|
38
38
|
it 'nil if ignore_approximate and all dates are approximate' do
|
39
39
|
mods_str = mods_origin_info_start_str +
|
@@ -42,7 +42,7 @@ describe "computations from /originInfo field" do
|
|
42
42
|
mods_origin_info_end_str
|
43
43
|
smods_rec.from_str(mods_str)
|
44
44
|
expect(smods_rec.send(method_sym, true)).to eq nil
|
45
|
-
expect(smods_rec.send(method_sym, false)).to eq '1000'
|
45
|
+
expect(smods_rec.send(method_sym, false)).to eq method_sym.to_s.match(/int/) ? 1000 : '1000'
|
46
46
|
end
|
47
47
|
it 'respects ignore_approximate even for keyDate' do
|
48
48
|
mods_str = mods_origin_info_start_str +
|
@@ -50,8 +50,8 @@ describe "computations from /originInfo field" do
|
|
50
50
|
'<dateCreated point="end">1599</dateCreated>' +
|
51
51
|
mods_origin_info_end_str
|
52
52
|
smods_rec.from_str(mods_str)
|
53
|
-
expect(smods_rec.send(method_sym, true)).to eq '1599'
|
54
|
-
expect(smods_rec.send(method_sym, false)).to eq '1000'
|
53
|
+
expect(smods_rec.send(method_sym, true)).to eq method_sym.to_s.match(/int/) ? 1599 : '1599'
|
54
|
+
expect(smods_rec.send(method_sym, false)).to eq method_sym.to_s.match(/int/) ? 1000 : '1000'
|
55
55
|
end
|
56
56
|
it 'uses dateCaptured if no dateIssued or dateCreated' do
|
57
57
|
# for web archive seed files
|
@@ -60,16 +60,19 @@ describe "computations from /originInfo field" do
|
|
60
60
|
'<dateCaptured encoding="w3cdtf" point="end">20151218111111</dateCaptured>' +
|
61
61
|
mods_origin_info_end_str
|
62
62
|
smods_rec.from_str(mods_str)
|
63
|
-
expect(smods_rec.send(method_sym)).to eq '2015'
|
63
|
+
expect(smods_rec.send(method_sym)).to eq method_sym.to_s.match(/int/) ? 2015 : '2015'
|
64
64
|
end
|
65
65
|
context 'spotlight actual data' do
|
66
66
|
require 'fixtures/spotlight_pub_date_data'
|
67
67
|
SPOTLIGHT_PUB_DATE_DATA.each_pair.each do |coll_name, coll_data|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
# papyri - the only Spotlight data with BC dates
|
69
|
+
unless coll_name == 'papyri' && method_sym == :pub_year_int
|
70
|
+
coll_data.each_pair do |mods_str, exp_vals|
|
71
|
+
expected = exp_vals[exp_val_position]
|
72
|
+
it "#{expected} for rec in #{coll_name}" do
|
73
|
+
smods_rec.from_str(mods_str)
|
74
|
+
expect(smods_rec.send(method_sym)).to eq((method_sym.to_s.match(/int/) ? expected.to_i : expected)) if expected
|
75
|
+
end
|
73
76
|
end
|
74
77
|
end
|
75
78
|
end
|
@@ -80,11 +83,34 @@ describe "computations from /originInfo field" do
|
|
80
83
|
it_behaves_like "single pub date value", :pub_date_facet_single_value, 1
|
81
84
|
end
|
82
85
|
|
83
|
-
context '#
|
84
|
-
it_behaves_like "single pub date value", :
|
86
|
+
context '#pub_year_sort_str' do
|
87
|
+
it_behaves_like "single pub date value", :pub_year_sort_str, 0
|
85
88
|
end
|
86
89
|
|
87
|
-
context '
|
90
|
+
context '#pub_year_int' do
|
91
|
+
it_behaves_like "single pub date value", :pub_year_int, 0
|
92
|
+
# papyri - the only Spotlight data with BC dates
|
93
|
+
it '-200 for 200 B.C.' do
|
94
|
+
# hd778hw9236
|
95
|
+
mods_str = mods_origin_info_start_str +
|
96
|
+
'<dateCreated encoding="w3cdtf" keyDate="yes" point="start" qualifier="approximate">200 B.C.</dateCreated>' +
|
97
|
+
'<dateCreated encoding="w3cdtf" keyDate="yes" point="end" qualifier="approximate">180 B.C.</dateCreated>' +
|
98
|
+
mods_origin_info_end_str
|
99
|
+
smods_rec.from_str(mods_str)
|
100
|
+
expect(smods_rec.pub_year_int).to eq(-200)
|
101
|
+
end
|
102
|
+
it '-211 for 211 B.C.' do
|
103
|
+
# ww728rz0477
|
104
|
+
mods_str = mods_origin_info_start_str +
|
105
|
+
'<dateCreated encoding="w3cdtf" keyDate="yes" point="start" qualifier="approximate">211 B.C.</dateCreated>' +
|
106
|
+
'<dateCreated encoding="w3cdtf" keyDate="yes" point="end" qualifier="approximate">150 B.C.</dateCreated>' +
|
107
|
+
mods_origin_info_end_str
|
108
|
+
smods_rec.from_str(mods_str)
|
109
|
+
expect(smods_rec.pub_year_int).to eq(-211)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context '*earliest_year_str' do
|
88
114
|
it 'selects earliest (valid) parseable date from multiple options' do
|
89
115
|
mods_str = mods_origin_info_start_str +
|
90
116
|
'<dateIssued point="start" qualifier="questionable">1758</dateIssued>' +
|
@@ -92,7 +118,7 @@ describe "computations from /originInfo field" do
|
|
92
118
|
'<dateIssued>1753]</dateIssued>' +
|
93
119
|
mods_origin_info_end_str
|
94
120
|
smods_rec.from_str(mods_str)
|
95
|
-
expect(Stanford::Mods::Record.
|
121
|
+
expect(Stanford::Mods::Record.earliest_year_str(smods_rec.date_issued_elements)).to eq ['1753', '1753]']
|
96
122
|
end
|
97
123
|
it 'ignores encoding' do
|
98
124
|
# encoding matters for choosing display, not for parsing year
|
@@ -102,21 +128,21 @@ describe "computations from /originInfo field" do
|
|
102
128
|
'<dateIssued encoding="w3cdtf">1300</dateIssued>' +
|
103
129
|
mods_origin_info_end_str
|
104
130
|
smods_rec.from_str(mods_str)
|
105
|
-
expect(Stanford::Mods::Record.
|
131
|
+
expect(Stanford::Mods::Record.earliest_year_str(smods_rec.date_issued_elements)).to eq ['1100', '1100']
|
106
132
|
mods_str = mods_origin_info_start_str +
|
107
133
|
'<dateIssued>1200</dateIssued>' +
|
108
134
|
'<dateIssued encoding="marc">1300</dateIssued>' +
|
109
135
|
'<dateIssued encoding="w3cdtf">1100</dateIssued>' +
|
110
136
|
mods_origin_info_end_str
|
111
137
|
smods_rec.from_str(mods_str)
|
112
|
-
expect(Stanford::Mods::Record.
|
138
|
+
expect(Stanford::Mods::Record.earliest_year_str(smods_rec.date_issued_elements)).to eq ['1100', '1100']
|
113
139
|
mods_str = mods_origin_info_start_str +
|
114
140
|
'<dateIssued>1300</dateIssued>' +
|
115
141
|
'<dateIssued encoding="marc">1100</dateIssued>' +
|
116
142
|
'<dateIssued encoding="w3cdtf">1200</dateIssued>' +
|
117
143
|
mods_origin_info_end_str
|
118
144
|
smods_rec.from_str(mods_str)
|
119
|
-
expect(Stanford::Mods::Record.
|
145
|
+
expect(Stanford::Mods::Record.earliest_year_str(smods_rec.date_issued_elements)).to eq ['1100', '1100']
|
120
146
|
end
|
121
147
|
it 'calls DateParsing.sortable_year_string_from_date_str for each element value' do
|
122
148
|
mods_str = mods_origin_info_start_str +
|
@@ -126,7 +152,7 @@ describe "computations from /originInfo field" do
|
|
126
152
|
mods_origin_info_end_str
|
127
153
|
smods_rec.from_str(mods_str)
|
128
154
|
expect(Stanford::Mods::DateParsing).to receive(:sortable_year_string_from_date_str).exactly(3).times
|
129
|
-
Stanford::Mods::Record.
|
155
|
+
Stanford::Mods::Record.earliest_year_str(smods_rec.date_issued_elements)
|
130
156
|
end
|
131
157
|
end
|
132
158
|
|
@@ -137,7 +163,7 @@ describe "computations from /originInfo field" do
|
|
137
163
|
'<dateIssued keyDate="yes">2014</dateIssued>' +
|
138
164
|
mods_origin_info_end_str
|
139
165
|
smods_rec.from_str(mods_str)
|
140
|
-
expect(smods_rec.send(method_sym, smods_rec.date_issued_elements)).to eq '2014'
|
166
|
+
expect(smods_rec.send(method_sym, smods_rec.date_issued_elements)).to eq method_sym.to_s.match(/int/) ? 2014 : '2014'
|
141
167
|
end
|
142
168
|
it 'ignores invalid keyDate value' do
|
143
169
|
mods_str = mods_origin_info_start_str +
|
@@ -145,25 +171,33 @@ describe "computations from /originInfo field" do
|
|
145
171
|
'<dateIssued>1499</dateIssued>' +
|
146
172
|
mods_origin_info_end_str
|
147
173
|
smods_rec.from_str(mods_str)
|
148
|
-
expect(smods_rec.send(method_sym, smods_rec.date_issued_elements)).to eq '1499'
|
174
|
+
expect(smods_rec.send(method_sym, smods_rec.date_issued_elements)).to eq method_sym.to_s.match(/int/) ? 1499 : '1499'
|
149
175
|
end
|
150
|
-
it 'calls
|
176
|
+
it 'calls earliest_year_str if multiple keyDates present' do
|
151
177
|
mods_str = mods_origin_info_start_str +
|
152
178
|
'<dateCreated keyDate="yes">2003</dateCreated>' +
|
153
179
|
'<dateCreated keyDate="yes">2001</dateCreated>' +
|
154
180
|
mods_origin_info_end_str
|
155
181
|
smods_rec.from_str(mods_str)
|
156
|
-
|
182
|
+
if method_sym.to_s.match(/int/)
|
183
|
+
expect(Stanford::Mods::Record).to receive(:earliest_year_int).with(smods_rec.date_created_elements)
|
184
|
+
else
|
185
|
+
expect(Stanford::Mods::Record).to receive(:earliest_year_str).with(smods_rec.date_created_elements)
|
186
|
+
end
|
157
187
|
expect(smods_rec.send(method_sym, smods_rec.date_created_elements))
|
158
188
|
end
|
159
|
-
it 'calls
|
189
|
+
it 'calls earliest_year_str if no keyDate' do
|
160
190
|
mods_str = mods_origin_info_start_str +
|
161
191
|
'<dateIssued>1753]</dateIssued>' +
|
162
192
|
'<dateIssued point="start" qualifier="questionable">1758</dateIssued>' +
|
163
193
|
'<dateIssued point="end" qualifier="questionable">uuuu</dateIssued>' +
|
164
194
|
mods_origin_info_end_str
|
165
195
|
smods_rec.from_str(mods_str)
|
166
|
-
|
196
|
+
if method_sym.to_s.match(/int/)
|
197
|
+
expect(Stanford::Mods::Record).to receive(:earliest_year_int).with(smods_rec.date_issued_elements)
|
198
|
+
else
|
199
|
+
expect(Stanford::Mods::Record).to receive(:earliest_year_str).with(smods_rec.date_issued_elements)
|
200
|
+
end
|
167
201
|
smods_rec.send(method_sym, smods_rec.date_issued_elements)
|
168
202
|
end
|
169
203
|
it 'ignores encoding' do
|
@@ -174,43 +208,54 @@ describe "computations from /originInfo field" do
|
|
174
208
|
'<dateIssued encoding="w3cdtf">1300</dateIssued>' +
|
175
209
|
mods_origin_info_end_str
|
176
210
|
smods_rec.from_str(mods_str)
|
177
|
-
expect(smods_rec.send(method_sym, smods_rec.date_issued_elements)).to eq '1100'
|
211
|
+
expect(smods_rec.send(method_sym, smods_rec.date_issued_elements)).to eq method_sym.to_s.match(/int/) ? 1100 : '1100'
|
178
212
|
mods_str = mods_origin_info_start_str +
|
179
213
|
'<dateIssued>1200</dateIssued>' +
|
180
214
|
'<dateIssued encoding="marc">1300</dateIssued>' +
|
181
215
|
'<dateIssued encoding="w3cdtf" keyDate="yes">1100</dateIssued>' +
|
182
216
|
mods_origin_info_end_str
|
183
217
|
smods_rec.from_str(mods_str)
|
184
|
-
expect(smods_rec.send(method_sym, smods_rec.date_issued_elements)).to eq '1100'
|
218
|
+
expect(smods_rec.send(method_sym, smods_rec.date_issued_elements)).to eq method_sym.to_s.match(/int/) ? 1100 : '1100'
|
185
219
|
mods_str = mods_origin_info_start_str +
|
186
220
|
'<dateIssued>1300</dateIssued>' +
|
187
221
|
'<dateIssued encoding="marc" keyDate="yes">1100</dateIssued>' +
|
188
222
|
'<dateIssued encoding="w3cdtf">1200</dateIssued>' +
|
189
223
|
mods_origin_info_end_str
|
190
224
|
smods_rec.from_str(mods_str)
|
191
|
-
expect(smods_rec.send(method_sym, smods_rec.date_issued_elements)).to eq '1100'
|
225
|
+
expect(smods_rec.send(method_sym, smods_rec.date_issued_elements)).to eq method_sym.to_s.match(/int/) ? 1100 : '1100'
|
192
226
|
end
|
193
227
|
end
|
194
228
|
|
195
|
-
context '#
|
196
|
-
it_behaves_like "pub date best single value", :
|
229
|
+
context '#year_facet_str' do
|
230
|
+
it_behaves_like "pub date best single value", :year_facet_str
|
197
231
|
it 'uses facet value, not sorting value' do
|
198
232
|
mods_str = mods_origin_info_start_str +
|
199
233
|
'<dateCreated keyDate="yes">180 B.C.</dateCreated>' +
|
200
234
|
mods_origin_info_end_str
|
201
235
|
smods_rec.from_str(mods_str)
|
202
|
-
expect(smods_rec.
|
236
|
+
expect(smods_rec.year_facet_str(smods_rec.date_created_elements)).to eq '180 B.C.'
|
203
237
|
end
|
204
238
|
end
|
205
239
|
|
206
|
-
context '#
|
207
|
-
it_behaves_like "pub date best single value", :
|
240
|
+
context '#year_sort_str' do
|
241
|
+
it_behaves_like "pub date best single value", :year_sort_str
|
208
242
|
it 'uses string sorting value, not facet value' do
|
209
243
|
mods_str = mods_origin_info_start_str +
|
210
244
|
'<dateCreated keyDate="yes">180 B.C.</dateCreated>' +
|
211
245
|
mods_origin_info_end_str
|
212
246
|
smods_rec.from_str(mods_str)
|
213
|
-
expect(smods_rec.
|
247
|
+
expect(smods_rec.year_sort_str(smods_rec.date_created_elements)).to eq '-820'
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
context '#year_int' do
|
252
|
+
it_behaves_like "pub date best single value", :year_int
|
253
|
+
it 'uses integer sorting value, not string or facet value' do
|
254
|
+
mods_str = mods_origin_info_start_str +
|
255
|
+
'<dateCreated keyDate="yes">180 B.C.</dateCreated>' +
|
256
|
+
mods_origin_info_end_str
|
257
|
+
smods_rec.from_str(mods_str)
|
258
|
+
expect(smods_rec.year_int(smods_rec.date_created_elements)).to eq(-180)
|
214
259
|
end
|
215
260
|
end
|
216
261
|
|