stanford-mods 0.0.22 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +9 -9
- data/.travis.yml +1 -1
- data/README.rdoc +1 -1
- data/lib/stanford-mods/searchworks.rb +24 -1
- data/lib/stanford-mods/version.rb +1 -1
- data/spec/searchworks_gdor_spec.rb +53 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWYzOWJkOWZiZmE1YmIzZDQzY2UwM2ZmYjFkM2ZjM2QzMTQ1NjFhYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
7
|
-
|
6
|
+
ODhmMTJhNzAwMmIwNjhhYmM0ODk2OGIzNzMwZjM4NGQ1NTg4MTI5Yg==
|
7
|
+
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjA1YWI5ZGM2MzE4NjU2YmQ1YzYwYjhjZDcyMzg3Njk3YmVhMTRiMmI0ZTll
|
10
|
+
MDdmMjU1ZDU2MGU3ZDg4NmMyN2I0MThlNDI1YTRjOGUzNmY0YWFjNWE4Zjg1
|
11
|
+
MjViOTYzYTI2ZTBhZDE4OGJjNmZhOTAwNTMxZmIyNmYzNTBkNGI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZmIyMjljNzEyMDZiZmE4Y2Q3NDM3NGExNDM1YTVmZGM1MzAzODcyZGEyNjNk
|
14
|
+
NjdmMzJhYTQ4ZDNjNTJmNmNlOGM4ZWQ4MjE5ZDRjYjYxMTZiZWE5OTNlY2Fi
|
15
|
+
ZGViMTgwNjhjZDE2ODY2NjY2M2VjODcyMmNlYWI3NzRhNzg4ZTU=
|
data/.travis.yml
CHANGED
data/README.rdoc
CHANGED
@@ -59,7 +59,7 @@ Example Using SearchWorks Mixins:
|
|
59
59
|
6. Create new Pull Request
|
60
60
|
|
61
61
|
== Releases
|
62
|
-
|
62
|
+
* <b>0.0.23</b> Added logic for dealing with "u-notation" approximate dates, e.g., 198u
|
63
63
|
* <b>0.0.20</b> Added mapping for typeOfResource notated music
|
64
64
|
* <b>0.0.19</b> Additional mappings, including Hydrus formats (GRYPHONDOR-207)
|
65
65
|
* <b>0.0.11</b> escape regex special characters when using short title in a regex
|
@@ -389,6 +389,7 @@ module Stanford
|
|
389
389
|
end
|
390
390
|
vals and vals.empty? ? nil : vals
|
391
391
|
end
|
392
|
+
|
392
393
|
def is_number?(object)
|
393
394
|
true if Integer(object) rescue false
|
394
395
|
end
|
@@ -397,7 +398,7 @@ module Stanford
|
|
397
398
|
end
|
398
399
|
|
399
400
|
# Get the publish year from mods
|
400
|
-
|
401
|
+
# @return [String] 4 character year or nil if no valid date was found
|
401
402
|
def pub_year
|
402
403
|
#use the cached year if there is one
|
403
404
|
if @pub_year
|
@@ -417,6 +418,9 @@ module Stanford
|
|
417
418
|
#try to find a date starting with the most normal date formats and progressing to more wonky ones
|
418
419
|
@pub_year=get_plain_four_digit_year pruned_dates
|
419
420
|
return @pub_year if @pub_year
|
421
|
+
# Check for years in u notation, e.g., 198u
|
422
|
+
@pub_year=get_u_year pruned_dates
|
423
|
+
return @pub_year if @pub_year
|
420
424
|
@pub_year=get_double_digit_century pruned_dates
|
421
425
|
return @pub_year if @pub_year
|
422
426
|
@pub_year=get_bc_year pruned_dates
|
@@ -567,6 +571,25 @@ module Stanford
|
|
567
571
|
end
|
568
572
|
return nil
|
569
573
|
end
|
574
|
+
|
575
|
+
# If a year has a "u" in it, replace instances of u with 0
|
576
|
+
# @param [String]
|
577
|
+
# @return String
|
578
|
+
def get_u_year dates
|
579
|
+
dates.each do |f_date|
|
580
|
+
# Single digit u notation
|
581
|
+
matches=f_date.scan(/\d{3}u/)
|
582
|
+
if matches.length == 1
|
583
|
+
return matches.first.gsub('u','0')
|
584
|
+
end
|
585
|
+
# Double digit u notation
|
586
|
+
matches=f_date.scan(/\d{2}u{2}/)
|
587
|
+
if matches.length == 1
|
588
|
+
return matches.first.gsub('u','-')
|
589
|
+
end
|
590
|
+
end
|
591
|
+
return nil
|
592
|
+
end
|
570
593
|
|
571
594
|
#get a double digit century like '12th century' from the date array
|
572
595
|
def get_double_digit_century dates
|
@@ -571,6 +571,59 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
571
571
|
@smods_rec.pub_date_facet.should == '9th century'
|
572
572
|
end
|
573
573
|
|
574
|
+
context "dates with u notation (e.g., 198u)" do
|
575
|
+
context "single digit u notation (e.g., 198u)" do
|
576
|
+
before(:each) do
|
577
|
+
m = "<mods #{@ns_decl}>
|
578
|
+
<originInfo>
|
579
|
+
<dateIssued encoding=\"marc\" point=\"start\" keyDate=\"yes\">198u</dateIssued>
|
580
|
+
<dateIssued encoding=\"marc\" point=\"end\">9999</dateIssued>
|
581
|
+
</originInfo></mods>"
|
582
|
+
@smods_rec = Stanford::Mods::Record.new
|
583
|
+
@smods_rec.from_str(m)
|
584
|
+
end
|
585
|
+
it "recognizes single digit u notation" do
|
586
|
+
dates = ["198u", "9999"]
|
587
|
+
uDate = @smods_rec.get_u_year dates
|
588
|
+
uDate.should eql("1980")
|
589
|
+
end
|
590
|
+
it 'pub_date: 198u = 1980' do
|
591
|
+
@smods_rec.pub_date.should == '1980'
|
592
|
+
end
|
593
|
+
it "pub_date_sort: 198u = 1980" do
|
594
|
+
@smods_rec.pub_date_sort.should =='1980'
|
595
|
+
end
|
596
|
+
it "pub_date_facet: 198u = 1980" do
|
597
|
+
@smods_rec.pub_date_facet.should == '1980'
|
598
|
+
end
|
599
|
+
end
|
600
|
+
context "double digit u notation (e.g., 19uu)" do
|
601
|
+
before(:each) do
|
602
|
+
m = "<mods #{@ns_decl}>
|
603
|
+
<originInfo>
|
604
|
+
<dateIssued encoding=\"marc\" point=\"start\" keyDate=\"yes\">19uu</dateIssued>
|
605
|
+
<dateIssued encoding=\"marc\" point=\"end\">9999</dateIssued>
|
606
|
+
</originInfo></mods>"
|
607
|
+
@smods_rec = Stanford::Mods::Record.new
|
608
|
+
@smods_rec.from_str(m)
|
609
|
+
end
|
610
|
+
it "recognizes double digit u notation" do
|
611
|
+
dates = ["19uu", "9999"]
|
612
|
+
uDate = @smods_rec.get_u_year dates
|
613
|
+
uDate.should eql("19--")
|
614
|
+
end
|
615
|
+
it 'pub_date: 19uu = 19--' do
|
616
|
+
@smods_rec.pub_date.should == '19--'
|
617
|
+
end
|
618
|
+
it "pub_date_sort: 19uu = 1900" do
|
619
|
+
@smods_rec.pub_date_sort.should =='1900'
|
620
|
+
end
|
621
|
+
it "pub_date_facet: 19uu = 20th century" do
|
622
|
+
@smods_rec.pub_date_facet.should == '20th century'
|
623
|
+
end
|
624
|
+
end
|
625
|
+
end
|
626
|
+
|
574
627
|
|
575
628
|
|
576
629
|
|
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.
|
4
|
+
version: 0.0.23
|
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:
|
12
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mods
|
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
162
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.
|
163
|
+
rubygems_version: 2.0.7
|
164
164
|
signing_key:
|
165
165
|
specification_version: 4
|
166
166
|
summary: Stanford specific wrangling of MODS metadata
|