stanford-mods 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -1
- data/lib/stanford-mods/kolb.rb +16 -0
- data/lib/stanford-mods/searchworks.rb +6 -6
- data/lib/stanford-mods/version.rb +1 -1
- data/spec/kolb_spec.rb +236 -0
- data/spec/values_for_req_sw_spec.rb +12 -19
- metadata +6 -3
data/README.rdoc
CHANGED
@@ -60,6 +60,7 @@ Example Using SearchWorks Mixins:
|
|
60
60
|
|
61
61
|
== Releases
|
62
62
|
|
63
|
-
0.0.
|
63
|
+
0.0.4 KolbRecord started
|
64
|
+
0.0.3 began SearchWorks mixins with sw_access_facet and sw_language_facet
|
64
65
|
0.0.2 add usage instructions to readme
|
65
66
|
0.0.1 Initial commit - grab name
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Kolb Collection specific wranglings of MODS metadata as an extension of the Mods::Record object
|
2
|
+
module Stanford
|
3
|
+
module Mods
|
4
|
+
|
5
|
+
class KolbRecord < Record
|
6
|
+
|
7
|
+
require 'stanford-mods/searchworks'
|
8
|
+
|
9
|
+
# NAOMI_MUST_COMMENT_THIS_METHOD
|
10
|
+
def publish_date
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -7,12 +7,12 @@ module Stanford
|
|
7
7
|
class Record < ::Mods::Record
|
8
8
|
|
9
9
|
# if it's coming from DOR, then it is available online
|
10
|
-
def
|
10
|
+
def sw_access_facet
|
11
11
|
['Online']
|
12
12
|
end
|
13
13
|
|
14
14
|
# include langagues known to SearchWorks; try to error correct when possible (e.g. when ISO-639 disagrees with MARC standard)
|
15
|
-
def
|
15
|
+
def sw_language_facet
|
16
16
|
result = []
|
17
17
|
@mods_ng_xml.language.each { |n|
|
18
18
|
# get languageTerm codes and add their translations to the result
|
@@ -48,8 +48,8 @@ module Stanford
|
|
48
48
|
end
|
49
49
|
}
|
50
50
|
result.uniq
|
51
|
-
end
|
51
|
+
end # language_facet
|
52
52
|
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
53
|
+
end # class Record
|
54
|
+
end # Module Mods
|
55
|
+
end # Module Stanford
|
data/spec/kolb_spec.rb
ADDED
@@ -0,0 +1,236 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stanford-mods/kolb'
|
3
|
+
|
4
|
+
describe "Kolb Collection Mods Record" do
|
5
|
+
before(:all) do
|
6
|
+
@krec = Stanford::Mods::KolbRecord.new
|
7
|
+
@krec.from_str('<?xml version="1.0"?>
|
8
|
+
<ns3:mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="http://www.loc.gov/mods/v3" xmlns:ns2="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
|
9
|
+
<ns3:titleInfo>
|
10
|
+
<ns3:title>Edward VI, king of England,</ns3:title>
|
11
|
+
</ns3:titleInfo>
|
12
|
+
<ns3:language>
|
13
|
+
<ns3:languageTerm type="code" authority="iso639-2b">eng</ns3:languageTerm>
|
14
|
+
<ns3:languageTerm type="text">English</ns3:languageTerm>
|
15
|
+
</ns3:language>
|
16
|
+
<ns3:typeOfResource>still image</ns3:typeOfResource>
|
17
|
+
<ns3:originInfo>
|
18
|
+
<ns3:dateCreated>1537-1553.</ns3:dateCreated>
|
19
|
+
<ns3:dateCreated point="start">1537</ns3:dateCreated>
|
20
|
+
<ns3:dateCreated point="end">1553</ns3:dateCreated>
|
21
|
+
</ns3:originInfo>
|
22
|
+
<ns3:subject>
|
23
|
+
<ns3:name type="personal" authority="ingest">
|
24
|
+
<ns3:namePart type="family">Edward VI , king of England, </ns3:namePart>
|
25
|
+
<ns3:displayForm>Edward VI , king of England, 1537-1553</ns3:displayForm>
|
26
|
+
</ns3:name>
|
27
|
+
</ns3:subject>
|
28
|
+
<ns3:name type="personal" authority="ingest">
|
29
|
+
<ns3:role>
|
30
|
+
<ns3:roleTerm type="text" authority="marcrelator">creator</ns3:roleTerm>
|
31
|
+
<ns3:roleTerm type="code" authority="marcrelator">cre</ns3:roleTerm>
|
32
|
+
</ns3:role>
|
33
|
+
<ns3:namePart type="family">Holbein, Han, 1497-1543</ns3:namePart>
|
34
|
+
<ns3:displayForm>Holbein, Han, 1497-1543</ns3:displayForm>
|
35
|
+
</ns3:name>
|
36
|
+
<ns3:name type="personal" authority="ingest">
|
37
|
+
<ns3:role>
|
38
|
+
<ns3:roleTerm type="text" authority="marcrelator">creator</ns3:roleTerm>
|
39
|
+
<ns3:roleTerm type="code" authority="marcrelator">cre</ns3:roleTerm>
|
40
|
+
</ns3:role>
|
41
|
+
<ns3:namePart type="family">Sheppard, Robert, 1732-1737</ns3:namePart>
|
42
|
+
<ns3:displayForm>Sheppard, Robert, 1732-1737</ns3:displayForm>
|
43
|
+
</ns3:name>
|
44
|
+
<ns3:subject authority="ingest">
|
45
|
+
<ns3:topic>Ruler, English.Ruler, English.</ns3:topic>
|
46
|
+
</ns3:subject>
|
47
|
+
<ns3:abstract displayLabel="Scope and Contents note"/>
|
48
|
+
<ns3:physicalDescription>
|
49
|
+
<ns3:note displayLabel="Material Specific Details note">0395</ns3:note>
|
50
|
+
</ns3:physicalDescription>
|
51
|
+
</ns3:mods>')
|
52
|
+
end
|
53
|
+
|
54
|
+
context "for SearchWorks Solr" do
|
55
|
+
# from https://consul.stanford.edu/display/NGDE/Required+and+Recommended+Solr+Fields+for+SearchWorks+documents
|
56
|
+
|
57
|
+
context "required values" do
|
58
|
+
|
59
|
+
it "catch all text field" do
|
60
|
+
pending "to be implemented"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "format" do
|
64
|
+
# sometimes from contentMetadata, o.w. see mods_mapper.is_a_map/image?
|
65
|
+
pending "to be implemented"
|
66
|
+
|
67
|
+
#<ns3:typeOfResource>still image</ns3:typeOfResource>
|
68
|
+
end
|
69
|
+
|
70
|
+
# FIXME: update per gryphDOR code / searcworks code / new schema
|
71
|
+
|
72
|
+
it "collection" do
|
73
|
+
pending "to be implemented"
|
74
|
+
# from solr_mapper.rb
|
75
|
+
# # Special treatment for collection objects
|
76
|
+
#if is_a_collection?
|
77
|
+
# solr_doc[:display_type] = "Collection"
|
78
|
+
# solr_doc[:collection_type] = "Digital Collection"
|
79
|
+
#else
|
80
|
+
# solr_doc[:display_type] = display_type
|
81
|
+
#end
|
82
|
+
|
83
|
+
#if collections # An array of the druids of any collections this object is part of
|
84
|
+
# solr_doc[:collection] = collections
|
85
|
+
# solr_doc[:collection_with_title] = collections_with_titles
|
86
|
+
#end
|
87
|
+
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
it "display_type" do
|
92
|
+
pending "to be implemented"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context "strongly recommended" do
|
97
|
+
it "access_facet" do
|
98
|
+
@krec.sw_access_facet.should == ['Online']
|
99
|
+
end
|
100
|
+
context "title" do
|
101
|
+
context "for display and searching" do
|
102
|
+
it "short title" do
|
103
|
+
@krec.short_titles.should == ['Edward VI, king of England,']
|
104
|
+
end
|
105
|
+
it "full title" do
|
106
|
+
@krec.full_titles.should == ['Edward VI, king of England,']
|
107
|
+
end
|
108
|
+
it "alternative titles" do
|
109
|
+
@krec.alternative_titles.size.should == 0
|
110
|
+
end
|
111
|
+
end
|
112
|
+
it "sortable title" do
|
113
|
+
@krec.sort_title.should == 'Edward VI, king of England,'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context "recommended" do
|
119
|
+
context "publication date" do
|
120
|
+
it "for searching and facet" do
|
121
|
+
pending "to be implemented"
|
122
|
+
@krec.pub_date.should include('1537')
|
123
|
+
@krec.pub_date.should include('1545')
|
124
|
+
@krec.pub_date.should include('1553')
|
125
|
+
@krec.pub_date.should_not include('1554')
|
126
|
+
@krec.pub_date.should_not include('1536')
|
127
|
+
end
|
128
|
+
it "for sorting should be dateCreated start date" do
|
129
|
+
pending "to be implemented"
|
130
|
+
@krec.pub_date_sort.should == '1537'
|
131
|
+
end
|
132
|
+
it "for pub date grouping (hierarchical / date slider?)" do
|
133
|
+
pending "to be implemented"
|
134
|
+
@krec.pub_date_group_facet.should == 'More than 50 years ago'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
context "language" do
|
138
|
+
it "facet should have a text value" do
|
139
|
+
@krec.sw_language_facet.should == ['English']
|
140
|
+
end
|
141
|
+
end
|
142
|
+
context "authors" do
|
143
|
+
it "personal_names" do
|
144
|
+
@krec.personal_names.size.should == 2
|
145
|
+
@krec.personal_names.should include('Holbein, Han, 1497-1543')
|
146
|
+
@krec.personal_names.should include('Sheppard, Robert, 1732-1737')
|
147
|
+
end
|
148
|
+
it "name object showing creator role" do
|
149
|
+
pending "to be implemented"
|
150
|
+
end
|
151
|
+
it "author sort" do
|
152
|
+
pending "to be implemented"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
end # for SearchWorks Solr
|
158
|
+
|
159
|
+
context "abstract" do
|
160
|
+
# FIXME: move to stanford_mods, not kolb specific
|
161
|
+
it "should not include empty elements" do
|
162
|
+
pending "to be implemented"
|
163
|
+
# <ns3:abstract displayLabel="Scope and Contents note"/>
|
164
|
+
@krec.abstract.size.should == 0
|
165
|
+
@krec.scope_and_contents_note.size.should == 0
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
context "physicalDescription" do
|
170
|
+
# <ns3:physicalDescription>
|
171
|
+
# <ns3:note displayLabel="Material Specific Details note">0395</ns3:note>
|
172
|
+
# </ns3:physicalDescription>
|
173
|
+
it "should be included in catch all text" do
|
174
|
+
pending "to be implemented"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context "subject" do
|
179
|
+
it "topic" do
|
180
|
+
@krec.subject.topic.map { |e| e.text }.should == ['Ruler, English.Ruler, English.']
|
181
|
+
end
|
182
|
+
it "name" do
|
183
|
+
pending "to be implemented"
|
184
|
+
@krec.subject.name.map { |e| e.text }.should == ['Edward VI , king of England, 1537-1553']
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
context "kolb record title issue" do
|
189
|
+
before(:all) do
|
190
|
+
@krec.from_str('<?xml version="1.0" encoding="UTF-8"?>
|
191
|
+
<ns3:mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="http://www.loc.gov/mods/v3" xmlns:ns2="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
|
192
|
+
<ns3:titleInfo>
|
193
|
+
<ns3:title>Elizabeth I, queen of England,</ns3:title>
|
194
|
+
</ns3:titleInfo>
|
195
|
+
<ns3:language>
|
196
|
+
<ns3:languageTerm type="code" authority="iso639-2b">eng</ns3:languageTerm>
|
197
|
+
<ns3:languageTerm type="text">English</ns3:languageTerm>
|
198
|
+
</ns3:language>
|
199
|
+
<ns3:typeOfResource>still image</ns3:typeOfResource>
|
200
|
+
<ns3:originInfo>
|
201
|
+
<ns3:dateCreated>1533-1603.</ns3:dateCreated>
|
202
|
+
<ns3:dateCreated point="start">1533</ns3:dateCreated>
|
203
|
+
<ns3:dateCreated point="end">1603</ns3:dateCreated>
|
204
|
+
</ns3:originInfo>
|
205
|
+
<ns3:subject>
|
206
|
+
<ns3:name type="personal" authority="ingest">
|
207
|
+
<ns3:namePart type="family">Elizabeth I, Queen of England</ns3:namePart>
|
208
|
+
<ns3:displayForm>Elizabeth I, Queen of England, 1533-1603</ns3:displayForm>
|
209
|
+
</ns3:name>
|
210
|
+
</ns3:subject>
|
211
|
+
<ns3:name type="personal" authority="ingest">
|
212
|
+
<ns3:role>
|
213
|
+
<ns3:roleTerm type="text" authority="marcrelator">creator</ns3:roleTerm>
|
214
|
+
<ns3:roleTerm type="code" authority="marcrelator">cre</ns3:roleTerm>
|
215
|
+
</ns3:role>
|
216
|
+
<ns3:namePart type="family">Houston, Richard, 1721?-1775</ns3:namePart>
|
217
|
+
<ns3:displayForm>Houston, Richard, 1721?-1775</ns3:displayForm>
|
218
|
+
</ns3:name>
|
219
|
+
<ns3:subject authority="ingest">
|
220
|
+
<ns3:topic>Ruler, English. W</ns3:topic>
|
221
|
+
</ns3:subject>
|
222
|
+
<ns3:abstract displayLabel="Scope and Contents note">Elisabetha D.G./Angliae,Franciae & Hiberniae,
|
223
|
+
Regina,./Printed for E.Bakewell & H.Parker; opposite Birchin Lane
|
224
|
+
in Cornhill.</ns3:abstract>
|
225
|
+
<ns3:physicalDescription>
|
226
|
+
<ns3:note displayLabel="Material Specific Details note">0411</ns3:note>
|
227
|
+
</ns3:physicalDescription>
|
228
|
+
</ns3:mods>')
|
229
|
+
end
|
230
|
+
it "should get full title" do
|
231
|
+
@krec.title_info.full_title.should == ['Elizabeth I, queen of England,']
|
232
|
+
@krec.full_titles.should == ['Elizabeth I, queen of England,']
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
@@ -6,22 +6,14 @@ describe "Values for SearchWorks Solr" do
|
|
6
6
|
|
7
7
|
context "required fields" do
|
8
8
|
context "DOR specific" do
|
9
|
-
|
10
|
-
|
11
|
-
end
|
9
|
+
# in harvestdor code: druid, parent_coll_ckey, id, collection
|
10
|
+
|
12
11
|
it "url_fulltext" do
|
13
12
|
pending "to be implemented"
|
14
13
|
end
|
15
14
|
it "mods_xml" do
|
16
15
|
pending "to be implemented"
|
17
16
|
end
|
18
|
-
it "parent_coll_ckey if item object" do
|
19
|
-
pending "to be implemented in harvestdor"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
it "id" do
|
24
|
-
pending "to be implemented in harvestdor"
|
25
17
|
end
|
26
18
|
|
27
19
|
it "all_search" do
|
@@ -33,7 +25,6 @@ describe "Values for SearchWorks Solr" do
|
|
33
25
|
end
|
34
26
|
|
35
27
|
# FIXME: update per gryphDOR code / searcworks code / new schema
|
36
|
-
|
37
28
|
it "collection" do
|
38
29
|
pending "to be implemented, using controlled vocab, in harvestdor"
|
39
30
|
end
|
@@ -46,7 +37,7 @@ describe "Values for SearchWorks Solr" do
|
|
46
37
|
|
47
38
|
context "strongly recommended fields" do
|
48
39
|
it "access_facet" do
|
49
|
-
Stanford::Mods::Record.new.
|
40
|
+
Stanford::Mods::Record.new.sw_access_facet.should == ['Online']
|
50
41
|
end
|
51
42
|
context "title fields" do
|
52
43
|
context "for display" do
|
@@ -88,18 +79,20 @@ describe "Values for SearchWorks Solr" do
|
|
88
79
|
m = '<mods><language><languageTerm authority="iso639-2b" type="code">per ara, dut</languageTerm></language></mods>'
|
89
80
|
r = Stanford::Mods::Record.new
|
90
81
|
r.from_str(m)
|
91
|
-
r.
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
82
|
+
langs = r.sw_language_facet
|
83
|
+
langs.size.should == 3
|
84
|
+
langs.should include("Persian")
|
85
|
+
langs.should include("Arabic")
|
86
|
+
langs.should include("Dutch")
|
87
|
+
langs.should_not include("Dutch; Flemish")
|
96
88
|
end
|
97
89
|
it "should not have duplicates" do
|
98
90
|
m = '<mods><language><languageTerm type="code" authority="iso639-2b">eng</languageTerm><languageTerm type="text">English</languageTerm></language></mods>'
|
99
91
|
r = Stanford::Mods::Record.new
|
100
92
|
r.from_str(m)
|
101
|
-
r.
|
102
|
-
|
93
|
+
langs = r.sw_language_facet
|
94
|
+
langs.size.should == 1
|
95
|
+
langs.should include("English")
|
103
96
|
end
|
104
97
|
|
105
98
|
end
|
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.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -145,10 +145,12 @@ files:
|
|
145
145
|
- Rakefile
|
146
146
|
- config/mappings_hash.rb
|
147
147
|
- lib/stanford-mods.rb
|
148
|
+
- lib/stanford-mods/kolb.rb
|
148
149
|
- lib/stanford-mods/mappings.rb
|
149
150
|
- lib/stanford-mods/searchworks.rb
|
150
151
|
- lib/stanford-mods/searchworks_languages.rb
|
151
152
|
- lib/stanford-mods/version.rb
|
153
|
+
- spec/kolb_spec.rb
|
152
154
|
- spec/spec_helper.rb
|
153
155
|
- spec/values_for_req_sw_spec.rb
|
154
156
|
- stanford-mods.gemspec
|
@@ -166,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
166
168
|
version: '0'
|
167
169
|
segments:
|
168
170
|
- 0
|
169
|
-
hash:
|
171
|
+
hash: 3798331701017040481
|
170
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
173
|
none: false
|
172
174
|
requirements:
|
@@ -175,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
177
|
version: '0'
|
176
178
|
segments:
|
177
179
|
- 0
|
178
|
-
hash:
|
180
|
+
hash: 3798331701017040481
|
179
181
|
requirements: []
|
180
182
|
rubyforge_project:
|
181
183
|
rubygems_version: 1.8.24
|
@@ -183,6 +185,7 @@ signing_key:
|
|
183
185
|
specification_version: 3
|
184
186
|
summary: Stanford specific wrangling of MODS metadata
|
185
187
|
test_files:
|
188
|
+
- spec/kolb_spec.rb
|
186
189
|
- spec/spec_helper.rb
|
187
190
|
- spec/values_for_req_sw_spec.rb
|
188
191
|
has_rdoc:
|