stanford-mods 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -418,6 +418,8 @@ module Stanford
418
418
  return @pub_year if @pub_year
419
419
  @pub_year=get_double_digit_century pruned_dates
420
420
  return @pub_year if @pub_year
421
+ @pub_year=get_bc_year pruned_dates
422
+ return @pub_year if @pub_year
421
423
  @pub_year=get_three_digit_year pruned_dates
422
424
  return @pub_year if @pub_year
423
425
  @pub_year=get_single_digit_century pruned_dates
@@ -453,18 +455,22 @@ module Stanford
453
455
  #@return <Array[String]> with values for the pub date facet
454
456
  def pub_date_facet
455
457
  if pub_date
458
+ if pub_date.start_with?('-')
459
+ return (pub_date.to_i + 1000).to_s + ' B.C.'
460
+ end
456
461
  if pub_date.include? '--'
457
462
  cent=pub_date[0,2].to_i
458
463
  cent+=1
459
464
  cent=cent.to_s+'th century'
460
- cent
465
+ return cent
461
466
  else
462
- pub_date
467
+ return pub_date
463
468
  end
464
469
  else
465
470
  nil
466
471
  end
467
472
  end
473
+
468
474
 
469
475
  # Values are the contents of:
470
476
  # subject/topic
@@ -595,6 +601,17 @@ module Stanford
595
601
  end
596
602
  return nil
597
603
  end
604
+ #get the 3 digit BC year, return it as a negative, so -700 for 300 BC. Other methods will translate it to proper display, this is good for sorting.
605
+ def get_bc_year dates
606
+ dates.each do |f_date|
607
+ matches=f_date.scan(/\d{3} B.C./)
608
+ if matches.length > 0
609
+ bc_year=matches.first[0..2]
610
+ return (bc_year.to_i-1000).to_s
611
+ end
612
+ end
613
+ return nil
614
+ end
598
615
 
599
616
  #get a single digit century like '9th century' from the date array
600
617
  def get_single_digit_century dates
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = "0.0.16"
4
+ VERSION = "0.0.17"
5
5
  end
6
6
  end
@@ -514,6 +514,15 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
514
514
  @smods_rec.from_str(m)
515
515
  @smods_rec.pub_date.should == '1865'
516
516
  end
517
+ it 'should work on 3 digit BC dates' do
518
+ m = "<mods #{@ns_decl}><originInfo><dateCreated>300 B.C.</dateCreated></originInfo>"
519
+ @smods_rec = Stanford::Mods::Record.new
520
+ @smods_rec.from_str(m)
521
+ @smods_rec.pub_year.should == '-700'
522
+ @smods_rec.pub_date.should == '-700'
523
+ @smods_rec.pub_date_sort.should =='-700'
524
+ @smods_rec.pub_date_facet.should == '300 B.C.'
525
+ end
517
526
  it 'should handle century based dates' do
518
527
  m = "<mods #{@ns_decl}><originInfo><dateIssued>13th century AH / 19th CE</dateIssued><issuance>monographic</issuance></originInfo>"
519
528
  @smods_rec = Stanford::Mods::Record.new
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: 0.0.16
4
+ version: 0.0.17
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-07-11 00:00:00.000000000 Z
13
+ date: 2013-07-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mods
@@ -170,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
170
  version: '0'
171
171
  segments:
172
172
  - 0
173
- hash: -3033686945404462688
173
+ hash: 3651735380351841710
174
174
  required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  none: false
176
176
  requirements:
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  version: '0'
180
180
  segments:
181
181
  - 0
182
- hash: -3033686945404462688
182
+ hash: 3651735380351841710
183
183
  requirements: []
184
184
  rubyforge_project:
185
185
  rubygems_version: 1.8.25