stanford-mods 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1edee19ce68af157f4912685e670abd888bc4353
4
- data.tar.gz: dfed761858e10ec8c4909d28c8f1a245c9a3d8b9
3
+ metadata.gz: 80b7166744ed54bca31cdcbfa1f400d5e05e3e24
4
+ data.tar.gz: 41439aae07f4ab0d35913284f6c5d3ca3db85f1a
5
5
  SHA512:
6
- metadata.gz: 31183275be3ff6bffb919d900cdc7ba7cd7f7831d8beb9148d12c63ff6a7263f769bc7bad2248297ddf767ae17629785ff8ef36fd4bfead5590cc8e3e427843b
7
- data.tar.gz: 113574dfe94ef773584af8006d127c5773e373d73efdf2535748ea690231d4ff2143c24d900ad58fe568c93ebb1c6ae8d517e2bdc63693be3d3f23f10697f1ce
6
+ metadata.gz: 6640e0395f1a500507ea4be9daccb561c85a6f0f02eff01a0e32260efe424cc4bb97a6ece0968a55d0bfbfdad8b45bac0e6ea6362edc6df6d242f32ee2829db2
7
+ data.tar.gz: bf70600680517f261d291d5e377838b6d5b2aad36288bdc238e2b87e9bfbc2d2cf1c70b0c7aa3727f9655d0513cdf30d8290ece7f7e546de43955737777bc7f3
@@ -7,16 +7,13 @@ module Stanford
7
7
  # - we could add methods like my_date.bc?
8
8
  class DateParsing
9
9
 
10
- # get single facet value for date, generally an explicit year or "17th century" or "5 B.C."
11
- # returns '845', not 0845
12
- # @param [String] date_str String containing a date (we hope)
13
- # @return [String, nil] String facet value for year if we could parse one, nil otherwise
14
- def self.facet_string_from_date_str(date_str)
15
- DateParsing.new(date_str).facet_string_from_date_str
10
+ # get display value for year, generally an explicit year or "17th century" or "5 B.C." or "1950s" or '845 A.D.'
11
+ # @return [String, nil] display value for year if we could parse one, nil otherwise
12
+ def self.date_str_for_display(date_str)
13
+ DateParsing.new(date_str).date_str_for_display
16
14
  end
17
15
 
18
16
  # get year as Integer if we can parse date_str to get a year.
19
- # @param [String] date_str String containing a date (we hope)
20
17
  # @return [Integer, nil] Integer year if we could parse one, nil otherwise
21
18
  def self.year_int_from_date_str(date_str)
22
19
  DateParsing.new(date_str).year_int_from_date_str
@@ -25,7 +22,6 @@ module Stanford
25
22
  # get String sortable value year if we can parse date_str to get a year.
26
23
  # SearchWorks currently uses a string field for pub date sorting; thus so does Spotlight.
27
24
  # The values returned must *lexically* sort in chronological order, so the B.C. dates are tricky
28
- # @param [String] date_str String containing a date (we hope)
29
25
  # @return [String, nil] String sortable year if we could parse one, nil otherwise
30
26
  # note that these values must *lexically* sort to create a chronological sort.
31
27
  def self.sortable_year_string_from_date_str(date_str)
@@ -56,25 +52,27 @@ module Stanford
56
52
 
57
53
  BRACKETS_BETWEEN_DIGITS_REXEXP = Regexp.new('\d[' + Regexp.escape('[]') + ']\d')
58
54
 
59
- # get single facet value for date, generally an explicit year or "17th century" or "5 B.C."
60
- # @return [String, nil] String facet value for year if we could parse one, nil otherwise
61
- def facet_string_from_date_str
55
+ # get display value for year, generally an explicit year or "17th century" or "5 B.C." or "1950s" or '845 A.D.'
56
+ # @return [String, nil] String value for year if we could parse one, nil otherwise
57
+ def date_str_for_display
62
58
  return if orig_date_str == '0000-00-00' # shpc collection has these useless dates
63
59
  # B.C. first in case there are 4 digits, e.g. 1600 B.C.
64
- return facet_string_for_bc if orig_date_str.match(BC_REGEX)
65
- result = sortable_year_for_yyyy_yy_or_decade
60
+ return display_str_for_bc if orig_date_str.match(BC_REGEX)
61
+ # decade next in case there are 4 digits, e.g. 1950s
62
+ return display_str_for_decade if orig_date_str.match(DECADE_4CHAR_REGEXP) || orig_date_str.match(DECADE_S_REGEXP)
63
+ result = sortable_year_for_yyyy_or_yy
66
64
  unless result
67
65
  # try removing brackets between digits in case we have 169[5] or [18]91
68
66
  no_brackets = remove_brackets
69
- return DateParsing.new(no_brackets).facet_string_from_date_str if no_brackets
67
+ return DateParsing.new(no_brackets).date_str_for_display if no_brackets
70
68
  end
71
69
  # parsing below this line gives string inapprop for year_str_valid?
72
70
  unless self.class.year_str_valid?(result)
73
- result = facet_string_for_century
74
- result ||= facet_string_for_early_numeric
71
+ result = display_str_for_century
72
+ result ||= display_str_for_early_numeric
75
73
  end
76
74
  # remove leading 0s from early dates
77
- result = result.to_i.to_s if result && result.match(/^\d+$/)
75
+ result = "#{result.to_i} A.D." if result && result.match(/^0\d+$/)
78
76
  result
79
77
  end
80
78
 
@@ -84,7 +82,8 @@ module Stanford
84
82
  return if orig_date_str == '0000-00-00' # shpc collection has these useless dates
85
83
  # B.C. first in case there are 4 digits, e.g. 1600 B.C.
86
84
  return sortable_year_int_for_bc if orig_date_str.match(BC_REGEX)
87
- result = sortable_year_for_yyyy_yy_or_decade
85
+ result = sortable_year_for_yyyy_or_yy
86
+ result ||= sortable_year_for_decade # 19xx or 20xx
88
87
  result ||= sortable_year_for_century
89
88
  result ||= sortable_year_int_for_early_numeric
90
89
  unless result
@@ -104,7 +103,8 @@ module Stanford
104
103
  return if orig_date_str == '0000-00-00' # shpc collection has these useless dates
105
104
  # B.C. first in case there are 4 digits, e.g. 1600 B.C.
106
105
  return sortable_year_str_for_bc if orig_date_str.match(BC_REGEX)
107
- result = sortable_year_for_yyyy_yy_or_decade
106
+ result = sortable_year_for_yyyy_or_yy
107
+ result ||= sortable_year_for_decade # 19xx or 20xx
108
108
  result ||= sortable_year_for_century
109
109
  result ||= sortable_year_str_for_early_numeric
110
110
  unless result
@@ -118,11 +118,10 @@ module Stanford
118
118
  # get String sortable value year if we can parse date_str to get a year.
119
119
  # @return [String, nil] String sortable year if we could parse one, nil otherwise
120
120
  # note that these values must *lexically* sort to create a chronological sort.
121
- def sortable_year_for_yyyy_yy_or_decade
121
+ def sortable_year_for_yyyy_or_yy
122
122
  # most date strings have a four digit year
123
123
  result = sortable_year_for_yyyy
124
124
  result ||= sortable_year_for_yy # 19xx or 20xx
125
- result ||= sortable_year_for_decade # 19xx or 20xx
126
125
  result
127
126
  end
128
127
 
@@ -161,15 +160,34 @@ module Stanford
161
160
  nil # explicitly want nil if date won't parse
162
161
  end
163
162
 
163
+ DECADE_4CHAR_REGEXP = Regexp.new('(^|\D)\d{3}[u\-?x]')
164
+
164
165
  # get first year of decade (as String) if we have: yyyu, yyy-, yyy? or yyyx pattern
165
166
  # note that these are the only decade patterns found in our actual date strings in MODS records
166
167
  # @return [String, nil] 4 digit year (e.g. 1860, 1950) if orig_date_str matches pattern, nil otherwise
167
168
  def sortable_year_for_decade
168
- decade_matches = orig_date_str.match(/\d{3}[u\-?x]/) if orig_date_str
169
+ decade_matches = orig_date_str.match(DECADE_4CHAR_REGEXP) if orig_date_str
169
170
  changed_to_zero = decade_matches.to_s.tr('u\-?x', '0') if decade_matches
170
171
  DateParsing.new(changed_to_zero).sortable_year_for_yyyy if changed_to_zero
171
172
  end
172
173
 
174
+ DECADE_S_REGEXP = Regexp.new('\d{3}0\'?s')
175
+
176
+ # get, e.g. 1950s, if we have: yyyu, yyy-, yyy? or yyyx pattern or yyy0s or yyy0's
177
+ # note that these are the only decade patterns found in our actual date strings in MODS records
178
+ # @return [String, nil] 4 digit year with s (e.g. 1860s, 1950s) if orig_date_str matches pattern, nil otherwise
179
+ def display_str_for_decade
180
+ decade_matches = orig_date_str.match(DECADE_4CHAR_REGEXP) if orig_date_str
181
+ if decade_matches
182
+ changed_to_zero = decade_matches.to_s.tr('u\-?x', '0') if decade_matches
183
+ zeroth_year = DateParsing.new(changed_to_zero).sortable_year_for_yyyy if changed_to_zero
184
+ return "#{zeroth_year}s" if zeroth_year
185
+ else
186
+ decade_matches = orig_date_str.match(DECADE_S_REGEXP) if orig_date_str
187
+ return decade_matches.to_s.tr("'", '') if decade_matches
188
+ end
189
+ end
190
+
173
191
  CENTURY_WORD_REGEXP = Regexp.new('(\d{1,2}).*century')
174
192
  CENTURY_4CHAR_REGEXP = Regexp.new('(\d{1,2})[u\-]{2}')
175
193
 
@@ -192,10 +210,10 @@ module Stanford
192
210
  end
193
211
  end
194
212
 
195
- # get single facet value for century (17th century) if we have: yyuu, yy--, yy--? or xxth century pattern
213
+ # get display value for century (17th century) if we have: yyuu, yy--, yy--? or xxth century pattern
196
214
  # note that these are the only century patterns found in our actual date strings in MODS records
197
215
  # @return [String, nil] yy(th) Century if orig_date_str matches pattern, nil otherwise; also nil if B.C. in pattern
198
- def facet_string_for_century
216
+ def display_str_for_century
199
217
  return unless orig_date_str
200
218
  return if orig_date_str.match(/B\.C\./)
201
219
  century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)
@@ -228,9 +246,9 @@ module Stanford
228
246
  "-#{$1}".to_i if bc_matches
229
247
  end
230
248
 
231
- # get single facet value for B.C. if we have B.C. pattern
249
+ # get display value for B.C. if we have B.C. pattern
232
250
  # @return [String, nil] ddd B.C. if ddd B.C. in pattern; nil otherwise
233
- def facet_string_for_bc
251
+ def display_str_for_bc
234
252
  bc_matches = orig_date_str.match(BC_REGEX) if orig_date_str
235
253
  bc_matches.to_s if bc_matches
236
254
  end
@@ -261,14 +279,14 @@ module Stanford
261
279
  orig_date_str.to_i if orig_date_str.match(/^-\d{4}$/)
262
280
  end
263
281
 
264
- # get single facet value for date String containing yyy, yy, y, -y, -yy, -yyy
282
+ # get display value for date String containing yyy, yy, y, -y, -yy, -yyy
265
283
  # negative number strings will be changed to B.C. strings
266
- def facet_string_for_early_numeric
284
+ def display_str_for_early_numeric
267
285
  return unless orig_date_str.match(EARLY_NUMERIC)
268
286
  # negative number becomes B.C.
269
- return orig_date_str[1..-1] + " B.C." if orig_date_str.match(/^\-/)
287
+ return "#{orig_date_str[1..-1]} B.C." if orig_date_str.match(/^\-/)
270
288
  # remove leading 0s from early dates
271
- orig_date_str.to_i.to_s
289
+ "#{orig_date_str.to_i} A.D."
272
290
  end
273
291
 
274
292
  # NOTE: while Date.parse() works for many dates, the *sortable_year_for_yyyy
@@ -4,7 +4,7 @@ require 'mods'
4
4
  # Parsing MODS /originInfo for Publication/Imprint data:
5
5
  # * pub year for date slider facet
6
6
  # * pub year for sorting
7
- # * pub year for single facet value
7
+ # * pub year for single display value
8
8
  # * imprint info for display
9
9
  # *
10
10
  # These methods may be used by searchworks.rb file or by downstream apps
@@ -12,16 +12,6 @@ module Stanford
12
12
  module Mods
13
13
  class Record < ::Mods::Record
14
14
 
15
- # return a single string intended for facet use for pub date
16
- # prefer dateIssued (any) before dateCreated (any) before dateCaptured (any)
17
- # look for a keyDate and use it if there is one; otherwise pick earliest date
18
- # @param [Boolean] ignore_approximate true if approximate dates (per qualifier attribute)
19
- # should be ignored; false if approximate dates should be included
20
- # @return [String] single String containing publication year for facet use
21
- def pub_date_facet_single_value(ignore_approximate = false)
22
- single_pub_year(ignore_approximate, :year_facet_str)
23
- end
24
-
25
15
  # return pub year as an Integer
26
16
  # prefer dateIssued (any) before dateCreated (any) before dateCaptured (any)
27
17
  # look for a keyDate and use it if there is one; otherwise pick earliest date
@@ -45,15 +35,53 @@ module Stanford
45
35
  single_pub_year(ignore_approximate, :year_sort_str)
46
36
  end
47
37
 
38
+ # return a single string intended for display of pub year
39
+ # 0 < year < 1000: add A.D. suffix
40
+ # year < 0: add B.C. suffix. ('-5' => '5 B.C.', '700 B.C.' => '700 B.C.')
41
+ # 195u => 195x
42
+ # 19uu => 19xx
43
+ # '-5' => '5 B.C.'
44
+ # '700 B.C.' => '700 B.C.'
45
+ # '7th century' => '7th century'
46
+ # date ranges?
47
+ # prefer dateIssued (any) before dateCreated (any) before dateCaptured (any)
48
+ # look for a keyDate and use it if there is one; otherwise pick earliest date
49
+ # @param [Boolean] ignore_approximate true if approximate dates (per qualifier attribute)
50
+ # should be ignored; false if approximate dates should be included
51
+ def pub_year_display_str(ignore_approximate = false)
52
+ single_pub_year(ignore_approximate, :year_display_str)
53
+
54
+ # TODO: want range displayed when start and end points
55
+ # TODO: also want best year in year_isi fields
56
+ # get_main_title_date
57
+ # https://github.com/sul-dlss/SearchWorks/blob/7d4d870a9d450fed8b081c38dc3dbd590f0b706e/app/helpers/results_document_helper.rb#L8-L46
58
+
59
+ #"publication_year_isi" => "Publication date", <-- do it already
60
+ #"beginning_year_isi" => "Beginning date",
61
+ #"earliest_year_isi" => "Earliest date",
62
+ #"earliest_poss_year_isi" => "Earliest possible date",
63
+ #"ending_year_isi" => "Ending date",
64
+ #"latest_year_isi" => "Latest date",
65
+ #"latest_poss_year_isi" => "Latest possible date",
66
+ #"production_year_isi" => "Production date",
67
+ #"original_year_isi" => "Original date",
68
+ #"copyright_year_isi" => "Copyright date"} %>
69
+
70
+ #"creation_year_isi" => "Creation date", <-- do it already
71
+ #{}"release_year_isi" => "Release date",
72
+ #{}"reprint_year_isi" => "Reprint/reissue date",
73
+ #{}"other_year_isi" => "Date",
74
+ end
75
+
48
76
  # given the passed date elements, look for a single keyDate and use it if there is one;
49
77
  # otherwise pick earliest parseable date
50
78
  # @param [Array<Nokogiri::XML::Element>] date_el_array the elements from which to select a pub date
51
- # @return [String] single String containing publication year for facet use
52
- def year_facet_str(date_el_array)
53
- result = date_parsing_result(date_el_array, :facet_string_from_date_str)
79
+ # @return [String] single String containing publication year for display
80
+ def year_display_str(date_el_array)
81
+ result = date_parsing_result(date_el_array, :date_str_for_display)
54
82
  return result if result
55
83
  _ignore, orig_str_to_parse = self.class.earliest_year_str(date_el_array)
56
- DateParsing.facet_string_from_date_str(orig_str_to_parse) if orig_str_to_parse
84
+ DateParsing.date_str_for_display(orig_str_to_parse) if orig_str_to_parse
57
85
  end
58
86
 
59
87
  # given the passed date elements, look for a single keyDate and use it if there is one;
@@ -205,8 +233,8 @@ module Stanford
205
233
  # Spotlight: pub_date field should be replaced by pub_year_w_approx_isi and pub_year_no_approx_isi
206
234
  # SearchWorks: pub_date field used for display in search results and show view; for sorting nearby-on-shelf
207
235
  # these could be done with more approp fields/methods (pub_year_int for sorting; new pub year methods to populate field)
208
- # TODO: prob should deprecated this in favor of pub_date_facet_single_value;
209
- # need head-to-head testing with pub_date_facet_single_value
236
+ # TODO: prob should deprecate this in favor of pub_year_display_str;
237
+ # need head-to-head testing with pub_year_display_str
210
238
  # @return <Array[String]> with values for the pub date facet
211
239
  def pub_date_facet
212
240
  if pub_date
@@ -366,6 +366,10 @@ module Stanford
366
366
  end
367
367
  end
368
368
  end
369
+ # Archived website is in the MODS genre tag but it is considered a
370
+ # Resource type for Searchworks, so it needs to be removed from the
371
+ # applicable genre values
372
+ val.delete 'Archived website'
369
373
  val.uniq
370
374
  end
371
375
 
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = "1.5.2"
4
+ VERSION = "1.5.3"
5
5
  end
6
6
  end
@@ -388,10 +388,10 @@ describe "date parsing methods" do
388
388
  '8 B.C.' => -8
389
389
  }
390
390
 
391
- context '*facet_string_from_date_str' do
392
- it 'calls instance method facet_string_from_date_str' do
393
- expect_any_instance_of(Stanford::Mods::DateParsing).to receive(:facet_string_from_date_str)
394
- Stanford::Mods::DateParsing.facet_string_from_date_str('1666')
391
+ context '*date_str_for_display' do
392
+ it 'calls instance method date_str_for_display' do
393
+ expect_any_instance_of(Stanford::Mods::DateParsing).to receive(:date_str_for_display)
394
+ Stanford::Mods::DateParsing.date_str_for_display('1666')
395
395
  end
396
396
  end
397
397
  context '*sortable_year_string_from_date_str' do
@@ -407,7 +407,7 @@ describe "date parsing methods" do
407
407
  end
408
408
  end
409
409
 
410
- context '#facet_string_from_date_str' do
410
+ context '#date_str_for_display' do
411
411
  single_year
412
412
  .merge(specific_month)
413
413
  .merge(specific_day)
@@ -417,41 +417,48 @@ describe "date parsing methods" do
417
417
  .merge(brackets_in_middle_of_year)
418
418
  .merge(invalid_but_can_get_year).each do |example, expected|
419
419
  expected = expected.to_i.to_s if expected.match(/^\d+$/)
420
+ expected = "#{expected} A.D." if expected.match(/^\d{1,3}$/)
420
421
  it "#{expected} for single value #{example}" do
421
- expect(Stanford::Mods::DateParsing.new(example).facet_string_from_date_str).to eq expected
422
+ expect(Stanford::Mods::DateParsing.new(example).date_str_for_display).to eq expected
422
423
  end
423
424
  end
424
425
 
425
- multiple_years
426
- .merge(multiple_years_4_digits_once)
427
- .merge(decade_only)
426
+ decade_only
428
427
  .merge(decade_only_4_digits).each do |example, expected|
428
+ expected = "#{expected.first.to_i}s" if expected.first.match(/^\d+$/)
429
+ it "#{expected} for decade #{example}" do
430
+ expect(Stanford::Mods::DateParsing.new(example).date_str_for_display).to eq expected
431
+ end
432
+ end
433
+
434
+ multiple_years
435
+ .merge(multiple_years_4_digits_once).each do |example, expected|
429
436
  it "#{expected.first} for multi-value #{example}" do
430
- expect(Stanford::Mods::DateParsing.new(example).facet_string_from_date_str).to eq expected.first
437
+ expect(Stanford::Mods::DateParsing.new(example).date_str_for_display).to eq expected.first
431
438
  end
432
439
  end
433
440
 
434
441
  early_numeric_dates.each do |example, expected|
435
442
  if example.start_with?('-')
436
- exp = example[1..-1] + " B.C."
443
+ exp = "#{example[1..-1]} B.C."
437
444
  it "#{exp} for #{example}" do
438
- expect(Stanford::Mods::DateParsing.new(example).facet_string_from_date_str).to eq exp
445
+ expect(Stanford::Mods::DateParsing.new(example).date_str_for_display).to eq exp
439
446
  end
440
447
  else
441
- expected = expected.to_i.to_s if expected.match(/^\d+$/)
448
+ expected = "#{expected.to_i} A.D." if expected.match(/^\d+$/)
442
449
  it "#{expected} for #{example}" do
443
- expect(Stanford::Mods::DateParsing.new(example).facet_string_from_date_str).to eq expected
450
+ expect(Stanford::Mods::DateParsing.new(example).date_str_for_display).to eq expected
444
451
  end
445
452
  end
446
453
  end
447
454
 
448
455
  bc_dates.keys.each do |example|
449
456
  it "#{example} for #{example}" do
450
- expect(Stanford::Mods::DateParsing.new(example).facet_string_from_date_str).to eq example
457
+ expect(Stanford::Mods::DateParsing.new(example).date_str_for_display).to eq example
451
458
  end
452
459
  end
453
460
  it '1600 B.C. for 1600 B.C.' do
454
- expect(Stanford::Mods::DateParsing.new('1600 B.C.').facet_string_from_date_str).to eq '1600 B.C.'
461
+ expect(Stanford::Mods::DateParsing.new('1600 B.C.').date_str_for_display).to eq '1600 B.C.'
455
462
  end
456
463
 
457
464
  [ # bad dates
@@ -461,7 +468,7 @@ describe "date parsing methods" do
461
468
  'uuuu'
462
469
  ].each do |example|
463
470
  it "nil for #{example}" do
464
- expect(Stanford::Mods::DateParsing.new(example).facet_string_from_date_str).to eq nil
471
+ expect(Stanford::Mods::DateParsing.new(example).date_str_for_display).to eq nil
465
472
  end
466
473
  end
467
474
  end
@@ -701,6 +708,34 @@ describe "date parsing methods" do
701
708
  end
702
709
  end
703
710
 
711
+ context '#display_str_for_decade' do
712
+ decade_only.each do |example, expected|
713
+ it "#{expected.first} for #{example}" do
714
+ expect(Stanford::Mods::DateParsing.new(example).display_str_for_decade).to eq "#{expected.first}s"
715
+ end
716
+ end
717
+ { # example string as key, expected result as value
718
+ '199u' => '1990s',
719
+ '200-' => '2000s',
720
+ '201?' => '2010s',
721
+ '202x' => '2020s',
722
+ 'early 1890s' => '1890s',
723
+ '1950s' => '1950s',
724
+ "1950's" => '1950s'
725
+ }.each do |example, expected|
726
+ it "#{expected} for #{example}" do
727
+ expect(Stanford::Mods::DateParsing.new(example).display_str_for_decade).to eq expected
728
+ end
729
+ end
730
+
731
+ # some of the strings this method cannot handle (so must be parsed with other instance methods)
732
+ specific_day_2_digit_year.keys.each do |example|
733
+ it "nil for #{example}" do
734
+ expect(Stanford::Mods::DateParsing.new(example).display_str_for_decade).to eq nil
735
+ end
736
+ end
737
+ end
738
+
704
739
  context '#sortable_year_for_century' do
705
740
  century_only.keys.each do |example|
706
741
  it "1700 from #{example}" do
@@ -715,10 +750,10 @@ describe "date parsing methods" do
715
750
  end
716
751
  end
717
752
 
718
- context '#facet_string_for_century' do
753
+ context '#display_str_for_century' do
719
754
  century_only.each do |example, expected|
720
755
  it "#{expected} for #{example}" do
721
- expect(Stanford::Mods::DateParsing.new(example).facet_string_for_century).to eq expected
756
+ expect(Stanford::Mods::DateParsing.new(example).display_str_for_century).to eq expected
722
757
  end
723
758
  end
724
759
  { # example string as key, expected result as value
@@ -730,12 +765,12 @@ describe "date parsing methods" do
730
765
  '2--' => '3rd century'
731
766
  }.each do |example, expected|
732
767
  it "#{expected} for #{example}" do
733
- expect(Stanford::Mods::DateParsing.new(example).facet_string_for_century).to eq expected
768
+ expect(Stanford::Mods::DateParsing.new(example).display_str_for_century).to eq expected
734
769
  end
735
770
  end
736
771
 
737
772
  it 'nil for 7th century B.C. (to be handled in different method)' do
738
- expect(Stanford::Mods::DateParsing.new('7th century B.C.').facet_string_for_century).to eq nil
773
+ expect(Stanford::Mods::DateParsing.new('7th century B.C.').display_str_for_century).to eq nil
739
774
  end
740
775
  end
741
776
 
@@ -755,17 +790,18 @@ describe "date parsing methods" do
755
790
  end
756
791
  end
757
792
 
758
- context '#facet_string_for_early_numeric' do
793
+ context '#display_str_for_early_numeric' do
759
794
  early_numeric_dates.each do |example, expected|
760
795
  expected = expected.to_i.to_s if expected.match(/^\d+$/)
761
796
  if example.start_with?('-')
762
- exp = example[1..-1] + " B.C."
797
+ exp = "#{example[1..-1]} B.C."
763
798
  it "#{exp} for #{example}" do
764
- expect(Stanford::Mods::DateParsing.new(example).facet_string_for_early_numeric).to eq exp
799
+ expect(Stanford::Mods::DateParsing.new(example).display_str_for_early_numeric).to eq exp
765
800
  end
766
801
  else
802
+ exp = "#{expected} A.D."
767
803
  it "#{expected} for #{example}" do
768
- expect(Stanford::Mods::DateParsing.new(example).facet_string_for_early_numeric).to eq expected
804
+ expect(Stanford::Mods::DateParsing.new(example).display_str_for_early_numeric).to eq exp
769
805
  end
770
806
  end
771
807
  end
@@ -787,14 +823,14 @@ describe "date parsing methods" do
787
823
  end
788
824
  end
789
825
 
790
- context '#facet_string_for_bc' do
826
+ context '#display_str_for_bc' do
791
827
  bc_dates.keys.each do |example|
792
828
  it "#{example} for #{example}" do
793
- expect(Stanford::Mods::DateParsing.new(example).facet_string_for_bc).to eq example
829
+ expect(Stanford::Mods::DateParsing.new(example).display_str_for_bc).to eq example
794
830
  end
795
831
  end
796
832
  it '1600 B.C. for 1600 B.C.' do
797
- expect(Stanford::Mods::DateParsing.new('1600 B.C.').facet_string_for_bc).to eq '1600 B.C.'
833
+ expect(Stanford::Mods::DateParsing.new('1600 B.C.').display_str_for_bc).to eq '1600 B.C.'
798
834
  end
799
835
  end
800
836