stanford-mods 0.0.26 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +1 -0
- data/lib/stanford-mods/searchworks.rb +39 -40
- data/lib/stanford-mods/version.rb +1 -1
- data/spec/searchworks_format_spec.rb +94 -58
- data/stanford-mods.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9617b16653a05aef7a4369146c3da872e27ae1fc
|
4
|
+
data.tar.gz: e8b07e17af94b4cfc5e3210cd875c6a217efe86a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec62fd240d006e705d3767bb829c0ef15c18d9135b9acbab5838b4366d536c0e43de293bc53e4722b92cfb42b193c2b106ffdfbc103e3bbcd0802efd99bdfe1c
|
7
|
+
data.tar.gz: 7588c07a0bf04c4cbceb8a291b833c54619529b8d94de5bcc1e6b3245a6daf288a1c5d4c1676684b39b6519e52ed08f1139713efeefa1df69f5869d93a36243b
|
data/README.rdoc
CHANGED
@@ -59,6 +59,7 @@ Example Using SearchWorks Mixins:
|
|
59
59
|
6. Create new Pull Request
|
60
60
|
|
61
61
|
== Releases
|
62
|
+
* <b>0.0.27</b> add genres 'Issue brief', 'Book chapter' and 'Working paper' to map to searchworks format 'Book'
|
62
63
|
* <b>0.0.26</b> map typeOfResource 'sound recording-musical' to searchworks format 'Music - Recording' with spaces
|
63
64
|
* <b>0.0.25</b> map typeOfResource 'text' and genre 'report' to searchworks format 'Book'
|
64
65
|
* <b>0.0.24</b> Largely cosmetic refactoring for easier maintenance.
|
@@ -482,49 +482,48 @@ module Stanford
|
|
482
482
|
# based on the dor_content_type
|
483
483
|
# @return [String] value in the SearchWorks controlled vocabulary
|
484
484
|
def format
|
485
|
-
val=[]
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
case
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
485
|
+
val = []
|
486
|
+
types = self.term_values(:typeOfResource)
|
487
|
+
if types
|
488
|
+
genres = self.term_values(:genre)
|
489
|
+
issuance = self.term_values([:origin_info,:issuance])
|
490
|
+
types.each do |type|
|
491
|
+
case type
|
492
|
+
when 'cartographic'
|
493
|
+
val << 'Map/Globe'
|
494
|
+
when 'mixed material'
|
495
|
+
val << 'Manuscript/Archive'
|
496
|
+
when 'moving image'
|
497
|
+
val << 'Video'
|
498
|
+
when 'notated music'
|
499
|
+
val << 'Music - Score'
|
500
|
+
when 'software, multimedia'
|
501
|
+
val << 'Computer File'
|
502
|
+
when 'sound recording-musical'
|
503
|
+
val << 'Music - Recording'
|
504
|
+
when 'sound recording-nonmusical'
|
505
|
+
val << 'Sound Recording'
|
506
|
+
when 'still image'
|
507
|
+
val << 'Image'
|
508
|
+
when 'text'
|
509
|
+
val << 'Book' if issuance and issuance.include? 'monographic'
|
510
|
+
val << 'Book' if genres and genres.include? 'book chapter'
|
511
|
+
val << 'Book' if genres and genres.include? 'issue brief'
|
512
|
+
val << 'Book' if genres and genres.include? 'libretto'
|
513
|
+
val << 'Book' if genres and genres.include? 'report'
|
514
|
+
val << 'Book' if genres and genres.include? 'technical report'
|
515
|
+
val << 'Book' if genres and genres.include? 'working paper'
|
516
|
+
val << 'Conference Proceedings' if genres and genres.include? 'conference publication'
|
517
|
+
val << 'Journal/Periodical' if issuance and issuance.include? 'continuing'
|
518
|
+
val << 'Journal/Periodical' if genres and genres.include? 'article'
|
519
|
+
val << 'Other' if genres and genres.include? 'student project report'
|
520
|
+
val << 'Thesis' if genres and genres.include? 'thesis'
|
521
|
+
when 'three dimensional object'
|
522
|
+
val << 'Other'
|
519
523
|
end
|
520
524
|
end
|
521
525
|
end
|
522
|
-
|
523
|
-
return val.uniq
|
524
|
-
end
|
525
|
-
if not self.typeOfResource or self.typeOfResource.length == 0
|
526
|
-
[]
|
527
|
-
end
|
526
|
+
val.uniq
|
528
527
|
end
|
529
528
|
|
530
529
|
# @return [String] value with the numeric catkey in it, or nil if none exists
|
@@ -8,88 +8,117 @@ describe "Format field from Searchworks mixin for Stanford::Mods::Record" do
|
|
8
8
|
@ns_decl = "xmlns='#{Mods::MODS_NS}'"
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
context "Book:" do
|
12
|
+
context "typeOfResource text," do
|
13
|
+
it 'originInfo/issuance monographic' do
|
14
|
+
m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><originInfo><issuance>monographic</issuance></originInfo></mods>"
|
15
|
+
@smods_rec.from_str(m)
|
16
|
+
@smods_rec.format.should == ['Book']
|
17
|
+
end
|
18
|
+
context "genre" do
|
19
|
+
it "'book chapter'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
|
20
|
+
m = "<mods #{@ns_decl}><genre>book chapter</genre><typeOfResource>text</typeOfResource></mods>"
|
21
|
+
@smods_rec.from_str(m)
|
22
|
+
@smods_rec.format.should == ['Book']
|
23
|
+
end
|
24
|
+
it "'issue brief'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
|
25
|
+
m = "<mods #{@ns_decl}><genre>issue brief</genre><typeOfResource>text</typeOfResource></mods>"
|
26
|
+
@smods_rec.from_str(m)
|
27
|
+
@smods_rec.format.should == ['Book']
|
28
|
+
end
|
29
|
+
it "'libretto'", :email => 'mods-squad 2014-05-22, Laura Wilsey' do
|
30
|
+
m = "<mods #{@ns_decl}><genre>libretto</genre><typeOfResource>text</typeOfResource></mods>"
|
31
|
+
@smods_rec.from_str(m)
|
32
|
+
@smods_rec.format.should == ['Book']
|
33
|
+
end
|
34
|
+
it "'report'", :jira => 'GRYP-170', :github => 'gdor-indexer/#7' do
|
35
|
+
m = "<mods #{@ns_decl}><genre>report</genre><typeOfResource>text</typeOfResource></mods>"
|
36
|
+
@smods_rec.from_str(m)
|
37
|
+
@smods_rec.format.should == ['Book']
|
38
|
+
end
|
39
|
+
it "'technical report'", :jira => 'GRYPHONDOR-207' do
|
40
|
+
m = "<mods #{@ns_decl}><genre>technical report</genre><typeOfResource>text</typeOfResource></mods>"
|
41
|
+
@smods_rec.from_str(m)
|
42
|
+
@smods_rec.format.should == ['Book']
|
43
|
+
end
|
44
|
+
it "'working paper'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
|
45
|
+
m = "<mods #{@ns_decl}><genre>working paper</genre><typeOfResource>text</typeOfResource></mods>"
|
46
|
+
@smods_rec.from_str(m)
|
47
|
+
@smods_rec.format.should == ['Book']
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end # 'Book'
|
16
52
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
53
|
+
context "Computer File: typeOfResource 'software, multimedia'" do
|
54
|
+
it "no genre (e.g. Dataset)" do
|
55
|
+
m = "<mods #{@ns_decl}><typeOfResource>software, multimedia</typeOfResource></mods>"
|
56
|
+
@smods_rec.from_str(m)
|
57
|
+
@smods_rec.format.should == ['Computer File']
|
58
|
+
end
|
59
|
+
it "genre 'game'", :jira => 'GRYPHONDOR-207' do
|
60
|
+
m = "<mods #{@ns_decl}><genre>game</genre><typeOfResource>software, multimedia</typeOfResource></mods>"
|
61
|
+
@smods_rec.from_str(m)
|
62
|
+
@smods_rec.format.should == ['Computer File']
|
63
|
+
end
|
21
64
|
end
|
22
65
|
|
23
|
-
it '
|
24
|
-
m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource
|
66
|
+
it "Conference Proceedings: typeOfResource 'text', genre 'conference publication'", :jira => 'GRYPHONDOR-207' do
|
67
|
+
m = "<mods #{@ns_decl}><genre>conference publication</genre><typeOfResource>text</typeOfResource></mods>"
|
25
68
|
@smods_rec.from_str(m)
|
26
|
-
@smods_rec.format.should == ['
|
69
|
+
@smods_rec.format.should == ['Conference Proceedings']
|
27
70
|
end
|
28
|
-
|
29
|
-
it "
|
71
|
+
|
72
|
+
it "Journal/Periodical: typeOfResource 'text', genre 'article'" do
|
30
73
|
m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>article</genre></mods>"
|
31
74
|
@smods_rec.from_str(m)
|
32
75
|
@smods_rec.format.should == ['Journal/Periodical']
|
33
76
|
end
|
34
77
|
|
35
|
-
it "
|
78
|
+
it "Image: typeOfResource 'still image'" do
|
36
79
|
m = "<mods #{@ns_decl}><typeOfResource>still image</typeOfResource></mods>"
|
37
80
|
@smods_rec.from_str(m)
|
38
81
|
@smods_rec.format.should == ['Image']
|
39
82
|
end
|
83
|
+
|
84
|
+
it "Music - Recording: typeOfResource 'sound recording-musical'", :jira => 'GRYPHONDOR-207' do
|
85
|
+
m = "<mods #{@ns_decl}><typeOfResource>sound recording-musical</typeOfResource></mods>"
|
86
|
+
@smods_rec.from_str(m)
|
87
|
+
@smods_rec.format.should == ['Music - Recording']
|
88
|
+
end
|
40
89
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
@smods_rec.format.should == ['Computer File']
|
46
|
-
end
|
47
|
-
it "should give a format of Video for <genre>motion picture</genre> and <typeOfResource>moving image</typeOfResource>" do
|
48
|
-
m = "<mods #{@ns_decl}><genre>motion picture</genre><typeOfResource>moving image</typeOfResource></mods>"
|
49
|
-
@smods_rec.from_str(m)
|
50
|
-
@smods_rec.format.should == ['Video']
|
51
|
-
end
|
52
|
-
it "should give a format of Sound Recording for <genre>sound</genre> and <typeOfResource>sound recording-nonmusical</typeOfResource>" do
|
53
|
-
m = "<mods #{@ns_decl}><genre>sound</genre><typeOfResource>sound recording-nonmusical</typeOfResource></mods>"
|
54
|
-
@smods_rec.from_str(m)
|
55
|
-
@smods_rec.format.should == ['Sound Recording']
|
56
|
-
end
|
57
|
-
it "should give a format of Music - Recording for <typeOfResource>sound recording-musical</typeOfResource>" do
|
58
|
-
m = "<mods #{@ns_decl}><typeOfResource>sound recording-musical</typeOfResource></mods>"
|
59
|
-
@smods_rec.from_str(m)
|
60
|
-
@smods_rec.format.should == ['Music - Recording']
|
61
|
-
end
|
62
|
-
it "should give a format of Conference Proceedings for <genre>conference publication</genre> and <typeOfResource>text</typeOfResource>" do
|
63
|
-
m = "<mods #{@ns_decl}><genre>conference publication</genre><typeOfResource>text</typeOfResource></mods>"
|
64
|
-
@smods_rec.from_str(m)
|
65
|
-
@smods_rec.format.should == ['Conference Proceedings']
|
66
|
-
end
|
67
|
-
it "should give a format of Book for <genre>technical report</genre> and <typeOfResource>text</typeOfResource>" do
|
68
|
-
m = "<mods #{@ns_decl}><genre>technical report</genre><typeOfResource>text</typeOfResource></mods>"
|
69
|
-
@smods_rec.from_str(m)
|
70
|
-
@smods_rec.format.should == ['Book']
|
71
|
-
end
|
72
|
-
it "should give a format of Book for <genre>report</genre> and <typeOfResource>text</typeOfResource>", :jira => 'GRYP-170', :github => 'gdor-indexer/#7' do
|
73
|
-
m = "<mods #{@ns_decl}><genre>report</genre><typeOfResource>text</typeOfResource></mods>"
|
74
|
-
@smods_rec.from_str(m)
|
75
|
-
@smods_rec.format.should == ['Book']
|
76
|
-
end
|
90
|
+
it "Music - Score: typeOfResource 'notated music'" do
|
91
|
+
m = "<mods #{@ns_decl}><typeOfResource>notated music</typeOfResource></mods>"
|
92
|
+
@smods_rec.from_str(m)
|
93
|
+
@smods_rec.format.should == ['Music - Score']
|
77
94
|
end
|
78
95
|
|
79
|
-
|
80
|
-
it "should give a format of Other for <genre>student project report</genre> and <typeOfResource>text</typeOfResource>" do
|
96
|
+
it "Other: typeOfResource 'text', genre 'student project report'", :email => 'from Vitus, August 16, 2013' do
|
81
97
|
m = "<mods #{@ns_decl}><genre>student project report</genre><typeOfResource>text</typeOfResource></mods>"
|
82
98
|
@smods_rec.from_str(m)
|
83
99
|
@smods_rec.format.should == ['Other']
|
84
100
|
end
|
85
101
|
|
86
|
-
it "
|
87
|
-
m = "<mods #{@ns_decl}><typeOfResource>
|
102
|
+
it "Sound Recording: typeOfResource 'sound recording-nonmusical', genre 'sound", :jira => 'GRYPHONDOR-207' do
|
103
|
+
m = "<mods #{@ns_decl}><genre>sound</genre><typeOfResource>sound recording-nonmusical</typeOfResource></mods>"
|
88
104
|
@smods_rec.from_str(m)
|
89
|
-
@smods_rec.format.should == ['
|
105
|
+
@smods_rec.format.should == ['Sound Recording']
|
90
106
|
end
|
91
|
-
|
92
|
-
|
107
|
+
|
108
|
+
context "Video: typeOfResource 'moving image'" do
|
109
|
+
it "no genre" do
|
110
|
+
m = "<mods #{@ns_decl}><typeOfResource>moving image</typeOfResource></mods>"
|
111
|
+
@smods_rec.from_str(m)
|
112
|
+
@smods_rec.format.should == ['Video']
|
113
|
+
end
|
114
|
+
it "genre 'motion picture'", :jira => 'GRYPHONDOR-207' do
|
115
|
+
m = "<mods #{@ns_decl}><genre>motion picture</genre><typeOfResource>moving image</typeOfResource></mods>"
|
116
|
+
@smods_rec.from_str(m)
|
117
|
+
@smods_rec.format.should == ['Video']
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
it "empty Array if no typeOfResource field" do
|
93
122
|
m = "<mods #{@ns_decl}><originInfo>
|
94
123
|
<dateCreated>1904</dateCreated>
|
95
124
|
</originInfo></mods>"
|
@@ -97,4 +126,11 @@ describe "Format field from Searchworks mixin for Stanford::Mods::Record" do
|
|
97
126
|
@smods_rec.format.should == []
|
98
127
|
end
|
99
128
|
|
129
|
+
it "empty Array if weird typeOfResource value" do
|
130
|
+
m = "<mods #{@ns_decl}><originInfo>
|
131
|
+
<typeOfResource>foo</typeOfResource>
|
132
|
+
</originInfo></mods>"
|
133
|
+
@smods_rec.from_str(m)
|
134
|
+
@smods_rec.format.should == []
|
135
|
+
end
|
100
136
|
end
|
data/stanford-mods.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |gem|
|
|
30
30
|
gem.add_development_dependency "yard"
|
31
31
|
# tests
|
32
32
|
gem.add_development_dependency 'rspec'
|
33
|
-
# using coveralls now
|
33
|
+
# using coveralls with travis now
|
34
34
|
# gem.add_development_dependency 'simplecov'
|
35
35
|
# gem.add_development_dependency 'simplecov-rcov'
|
36
36
|
# gem.add_development_dependency 'ruby-debug19'
|
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.27
|
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: 2014-05-
|
12
|
+
date: 2014-05-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mods
|