mods 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -0
- data/lib/mods/nom_terminology.rb +290 -208
- data/lib/mods/version.rb +1 -1
- data/spec/name_spec.rb +1 -1
- data/spec/related_item_spec.rb +154 -0
- data/spec/subject_spec.rb +17 -16
- data/spec/top_level_elmnts_simple_spec.rb +156 -5
- metadata +6 -4
data/README.rdoc
CHANGED
@@ -37,6 +37,7 @@ TODO: Write usage instructions here
|
|
37
37
|
|
38
38
|
== Releases
|
39
39
|
|
40
|
+
0.0.8 implement relatedItem and attributes on all simple top level elements
|
40
41
|
0.0.7 implement part
|
41
42
|
0.0.6 implement recordInfo, fix to work under jruby
|
42
43
|
0.0.5 implement subject, change a few constants
|
data/lib/mods/nom_terminology.rb
CHANGED
@@ -27,94 +27,53 @@ module Mods
|
|
27
27
|
Mods::TOP_LEVEL_ELEMENTS_SIMPLE.each { |elname|
|
28
28
|
t.send elname, :path => "/mods/#{elname}"
|
29
29
|
}
|
30
|
-
|
31
|
-
# TITLE_INFO ----------------------------------------------------------------------------
|
32
|
-
# note - titleInfo can be a top level element or a sub-element of relatedItem
|
33
|
-
# (<titleInfo> as subelement of <subject> is not part of the MODS namespace)
|
34
30
|
|
35
|
-
|
31
|
+
# ABSTRACT -------------------------------------------------------------------------------
|
32
|
+
t._abstract :path => '//abstract' do |n|
|
33
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
34
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
n.
|
46
|
-
n.
|
47
|
-
|
48
|
-
|
49
|
-
n.partName :path => 'partName'
|
50
|
-
n.sort_title :path => '.', :accessor => lambda { |node|
|
51
|
-
if node.type_at != "alternative" || (node.type_at == "alternative" && mods_ng_xml.xpath('/mods/titleInfo').size == 1)
|
52
|
-
node.title.text + (!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
|
53
|
-
end
|
54
|
-
}
|
55
|
-
n.full_title :path => '.', :accessor => lambda { |node|
|
56
|
-
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
57
|
-
node.title.text +
|
58
|
-
(!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
|
59
|
-
}
|
60
|
-
n.short_title :path => '.', :accessor => lambda { |node|
|
61
|
-
if node.type_at != "alternative"
|
62
|
-
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
63
|
-
node.title.text
|
64
|
-
end
|
65
|
-
}
|
66
|
-
n.alternative_title :path => '.', :accessor => lambda { |node|
|
67
|
-
if node.type_at == "alternative"
|
68
|
-
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
69
|
-
node.title.text
|
70
|
-
end
|
37
|
+
# ACCESS_CONDITION -----------------------------------------------------------------------
|
38
|
+
t._accessCondition :path => '//accessCondition' do |n|
|
39
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
40
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
41
|
+
end
|
42
|
+
|
43
|
+
# CLASSIFICATION -------------------------------------------------------------------------
|
44
|
+
t._classification :path => '//classification' do |n|
|
45
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
46
|
+
n.edition :path => '@edition', :accessor => lambda { |a| a.text }
|
47
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
48
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
71
49
|
}
|
50
|
+
end
|
51
|
+
|
52
|
+
# EXTENSION ------------------------------------------------------------------------------
|
53
|
+
t._extension :path => '//extension' do |n|
|
54
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
72
55
|
end
|
73
56
|
|
74
|
-
#
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
# NAME ------------------------------------------------------------------------------------
|
82
|
-
t.plain_name :path => '/mods/name'
|
83
|
-
|
84
|
-
t._plain_name :path => '//name' do |n|
|
85
|
-
|
86
|
-
Mods::Name::ATTRIBUTES.each { |attr_name|
|
87
|
-
if attr_name != 'type'
|
88
|
-
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
89
|
-
else
|
90
|
-
n.type_at :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
91
|
-
end
|
57
|
+
# GENRE ----------------------------------------------------------------------------------
|
58
|
+
t._genre :path => '//genre' do |n|
|
59
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
60
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
61
|
+
n.usage :path => '@usage', :accessor => lambda { |a| a.text }
|
62
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
63
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
92
64
|
}
|
93
|
-
|
94
|
-
n.namePart :path => 'namePart' do |np|
|
95
|
-
np.type_at :path => '@type'
|
96
|
-
end
|
97
|
-
n.displayForm :path => 'displayForm'
|
98
|
-
n.affiliation :path => 'affiliation'
|
99
|
-
n.description_el :path => 'description' # description is used by Nokogiri
|
100
|
-
n.role :path => 'role/roleTerm' do |r|
|
101
|
-
r.type_at :path => "@type", :accessor => lambda { |a| a.text }
|
102
|
-
r.authority :path => "@authority", :accessor => lambda { |a| a.text }
|
103
|
-
end
|
104
65
|
end
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
n.
|
109
|
-
n.
|
110
|
-
n.
|
66
|
+
|
67
|
+
# IDENTIIER ------------------------------------------------------------------------------
|
68
|
+
t._identifier :path => '//identifier' do |n|
|
69
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
70
|
+
n.invalid :path => '@invalid', :accessor => lambda { |a| a.text }
|
71
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
111
72
|
end
|
112
73
|
|
113
|
-
t.corporate_name :path => '/mods/name[@type="corporate"]'
|
114
|
-
t.conference_name :path => '/mods/name[@type="conference"]'
|
115
|
-
|
116
74
|
# LANGUAGE -------------------------------------------------------------------------------
|
117
|
-
t.language :path => '/mods/language'
|
75
|
+
t.language :path => '/mods/language'
|
76
|
+
t._language :path => '//language' do |n|
|
118
77
|
n.languageTerm :path => 'languageTerm'
|
119
78
|
n.code_term :path => 'languageTerm[@type="code"]'
|
120
79
|
n.text_term :path => 'languageTerm[@type="text"]'
|
@@ -125,29 +84,16 @@ module Mods
|
|
125
84
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
126
85
|
lt.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
127
86
|
}
|
128
|
-
end
|
87
|
+
end # t.language
|
129
88
|
|
130
|
-
# PHYSICAL_DESCRIPTION -------------------------------------------------------------------
|
131
|
-
t.physical_description :path => '/mods/physicalDescription' do |n|
|
132
|
-
n.digitalOrigin :path => 'digitalOrigin'
|
133
|
-
n.extent :path => 'extent'
|
134
|
-
n.form :path => 'form' do |f|
|
135
|
-
f.authority :path => '@authority', :accessor => lambda { |a| a.text }
|
136
|
-
f.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
137
|
-
end
|
138
|
-
n.internetMediaType :path => 'internetMediaType'
|
139
|
-
n.note :path => 'note' do |nn|
|
140
|
-
nn.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
141
|
-
nn.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
142
|
-
end
|
143
|
-
n.reformattingQuality :path => 'reformattingQuality'
|
144
|
-
end
|
145
|
-
|
146
89
|
# LOCATION -------------------------------------------------------------------------------
|
147
|
-
t.location :path => '/mods/location'
|
90
|
+
t.location :path => '/mods/location'
|
91
|
+
t._location :path => '//location' do |n|
|
148
92
|
n.physicalLocation :path => 'physicalLocation' do |e|
|
149
|
-
e.authority :path => '@authority', :accessor => lambda { |a| a.text }
|
150
93
|
e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
94
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
95
|
+
e.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
96
|
+
}
|
151
97
|
end
|
152
98
|
n.shelfLocator :path => 'shelfLocator'
|
153
99
|
n.url :path => 'url' do |e|
|
@@ -159,23 +105,70 @@ module Mods
|
|
159
105
|
end
|
160
106
|
n.holdingSimple :path => 'holdingSimple'
|
161
107
|
n.holdingExternal :path => 'holdingExternal'
|
108
|
+
end # t.location
|
109
|
+
|
110
|
+
# NAME ------------------------------------------------------------------------------------
|
111
|
+
t.plain_name :path => '/mods/name'
|
112
|
+
t._plain_name :path => '//name' do |n|
|
113
|
+
Mods::Name::ATTRIBUTES.each { |attr_name|
|
114
|
+
if attr_name != 'type'
|
115
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
116
|
+
else
|
117
|
+
n.type_at :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
118
|
+
end
|
119
|
+
}
|
120
|
+
# elements
|
121
|
+
n.namePart :path => 'namePart' do |np|
|
122
|
+
np.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
123
|
+
end
|
124
|
+
n.displayForm :path => 'displayForm'
|
125
|
+
n.affiliation :path => 'affiliation'
|
126
|
+
n.description_el :path => 'description' # description is used by Nokogiri
|
127
|
+
n.role :path => 'role/roleTerm' do |r|
|
128
|
+
r.type_at :path => "@type", :accessor => lambda { |a| a.text }
|
129
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
130
|
+
r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
131
|
+
}
|
132
|
+
end
|
133
|
+
end # t._plain_name
|
134
|
+
|
135
|
+
t.personal_name :path => '/mods/name[@type="personal"]'
|
136
|
+
t._personal_name :path => '//name[@type="personal"]' do |n|
|
137
|
+
n.family_name :path => 'namePart[@type="family"]'
|
138
|
+
n.given_name :path => 'namePart[@type="given"]'
|
139
|
+
n.termsOfAddress :path => 'namePart[@type="termsOfAddress"]'
|
140
|
+
n.date :path => 'namePart[@type="date"]'
|
141
|
+
end
|
142
|
+
|
143
|
+
t.corporate_name :path => '/mods/name[@type="corporate"]'
|
144
|
+
t._corporate_name :path => '//name[@type="corporate"]'
|
145
|
+
t.conference_name :path => '/mods/name[@type="conference"]'
|
146
|
+
t._conference_name :path => '//name[@type="conference"]'
|
147
|
+
|
148
|
+
# NOTE ---------------------------------------------------------------------------------
|
149
|
+
t._note :path => '//note' do |n|
|
150
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
151
|
+
n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
|
152
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
162
153
|
end
|
163
154
|
|
164
155
|
# ORIGIN_INFO --------------------------------------------------------------------------
|
165
|
-
t.origin_info :path => '/mods/originInfo'
|
156
|
+
t.origin_info :path => '/mods/originInfo'
|
157
|
+
t._origin_info :path => '//originInfo' do |n|
|
166
158
|
n.place :path => 'place' do |e|
|
167
159
|
e.placeTerm :path => 'placeTerm' do |ee|
|
168
160
|
ee.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
169
|
-
|
161
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
162
|
+
ee.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
163
|
+
}
|
170
164
|
end
|
171
165
|
end
|
172
166
|
n.publisher :path => 'publisher'
|
173
167
|
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |date_el|
|
174
168
|
n.send date_el, :path => "#{date_el}" do |d|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
d.qualifier :path => '@qualifier', :accessor => lambda { |a| a.text }
|
169
|
+
Mods::DATE_ATTRIBS.each { |attr_name|
|
170
|
+
d.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
171
|
+
}
|
179
172
|
if date_el == 'dateOther'
|
180
173
|
d.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
181
174
|
end
|
@@ -184,83 +177,15 @@ module Mods
|
|
184
177
|
n.edition :path => 'edition'
|
185
178
|
n.issuance :path => 'issuance'
|
186
179
|
n.frequency :path => 'frequency' do |f|
|
187
|
-
f.authority :path => '@authority', :accessor => lambda { |a| a.text }
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
# SUBJECT -----------------------------------------------------------------------------
|
192
|
-
t.subject :path => '/mods/subject' do |n|
|
193
|
-
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
194
|
-
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
195
|
-
}
|
196
|
-
n.topic :path => 'topic' do |n|
|
197
180
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
198
|
-
|
199
|
-
}
|
200
|
-
end
|
201
|
-
n.geographic :path => 'geographic' do |n|
|
202
|
-
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
203
|
-
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
204
|
-
}
|
205
|
-
end
|
206
|
-
n.temporal :path => 'temporal' do |n|
|
207
|
-
n.encoding :path => 'encoding'
|
208
|
-
n.point :path => 'point'
|
209
|
-
n.keyDate :path => 'keyDate'
|
210
|
-
n.qualifier :path => 'qualifier'
|
211
|
-
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
212
|
-
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
213
|
-
}
|
214
|
-
Mods::DATE_ATTRIBS.each { |attr_name|
|
215
|
-
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
216
|
-
}
|
217
|
-
end
|
218
|
-
n.titleInfo :path => 'titleInfo' do |t|
|
219
|
-
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
220
|
-
t.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
221
|
-
}
|
222
|
-
end
|
223
|
-
# Note: 'name' is used by Nokogiri
|
224
|
-
n.name_ :path => 'name' do |t|
|
225
|
-
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
226
|
-
t.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
227
|
-
}
|
228
|
-
end
|
229
|
-
n.geographicCode :path => 'geographicCode' do |g|
|
230
|
-
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
231
|
-
g.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
181
|
+
f.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
232
182
|
}
|
233
183
|
end
|
234
|
-
|
235
|
-
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
236
|
-
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
237
|
-
}
|
238
|
-
end
|
239
|
-
n.hierarchicalGeographic :path => 'hierarchicalGeographic' do |n|
|
240
|
-
Mods::Subject::HIER_GEO_CHILD_ELEMENTS.each { |elname|
|
241
|
-
n.send elname, :path => "#{elname}"
|
242
|
-
}
|
243
|
-
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
244
|
-
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
245
|
-
}
|
246
|
-
end
|
247
|
-
n.cartographics :path => 'cartographics' do |n|
|
248
|
-
n.scale :path => 'scale'
|
249
|
-
n.projection :path => 'projection'
|
250
|
-
n.coordinates :path => 'coordinates'
|
251
|
-
Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.each { |elname|
|
252
|
-
n.send elname, :path => "#{elname}"
|
253
|
-
}
|
254
|
-
end
|
255
|
-
n.occupation :path => 'occupation' do |n|
|
256
|
-
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
257
|
-
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
258
|
-
}
|
259
|
-
end
|
260
|
-
end
|
184
|
+
end # t.origin_info
|
261
185
|
|
262
186
|
# PART -----------------------------------------------------------------------------------
|
263
|
-
t.part :path => '/mods/part'
|
187
|
+
t.part :path => '/mods/part'
|
188
|
+
t._part :path => '//part' do |n|
|
264
189
|
# attributes
|
265
190
|
n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
|
266
191
|
n.order :path => '@order', :accessor => lambda { |a| a.text }
|
@@ -284,7 +209,7 @@ module Mods
|
|
284
209
|
e.total :path => 'total'
|
285
210
|
e.list :path => 'list'
|
286
211
|
end
|
287
|
-
n.date :path => 'date' do |e|
|
212
|
+
n.date :path => 'date' do |e|
|
288
213
|
Mods::DATE_ATTRIBS.reject { |a| a == 'keyDate' }.each { |attr_name|
|
289
214
|
e.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
290
215
|
}
|
@@ -293,6 +218,25 @@ module Mods
|
|
293
218
|
e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
294
219
|
e.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
295
220
|
end
|
221
|
+
end # t._part
|
222
|
+
|
223
|
+
# PHYSICAL_DESCRIPTION -------------------------------------------------------------------
|
224
|
+
t.physical_description :path => '/mods/physicalDescription'
|
225
|
+
t._physical_description :path => '//physicalDescription' do |n|
|
226
|
+
n.digitalOrigin :path => 'digitalOrigin'
|
227
|
+
n.extent :path => 'extent'
|
228
|
+
n.form :path => 'form' do |f|
|
229
|
+
f.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
230
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
231
|
+
f.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
232
|
+
}
|
233
|
+
end
|
234
|
+
n.internetMediaType :path => 'internetMediaType'
|
235
|
+
n.note :path => 'note' do |nn|
|
236
|
+
nn.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
237
|
+
nn.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
238
|
+
end
|
239
|
+
n.reformattingQuality :path => 'reformattingQuality'
|
296
240
|
end
|
297
241
|
|
298
242
|
# RECORD_INFO --------------------------------------------------------------------------
|
@@ -335,8 +279,176 @@ module Mods
|
|
335
279
|
r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
336
280
|
}
|
337
281
|
end
|
282
|
+
end # t._record_info
|
283
|
+
|
284
|
+
# RELATED_ITEM-------------------------------------------------------------------------
|
285
|
+
t.related_item :path => '/mods/relatedItem' do |n|
|
286
|
+
# attributes
|
287
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
288
|
+
n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
|
289
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
290
|
+
# elements
|
291
|
+
n.abstract :path => 'abstract'
|
292
|
+
n.accessCondition :path => 'accessCondition'
|
293
|
+
n.classification :path => 'classification'
|
294
|
+
n.extension :path => 'extension'
|
295
|
+
n.genre :path => 'genre'
|
296
|
+
n.identifier :path => 'identifier'
|
297
|
+
n.language :path => 'language'
|
298
|
+
n.location :path => 'location'
|
299
|
+
n.name_el :path => 'name' # Note: 'name' is used by Nokogiri
|
300
|
+
n.personal_name :path => 'name[@type="personal"]'
|
301
|
+
n.corporate_name :path => 'name[@type="corporate"]'
|
302
|
+
n.conference_name :path => 'name[@type="conference"]'
|
303
|
+
n.note :path => 'note'
|
304
|
+
n.originInfo :path => 'originInfo'
|
305
|
+
n.part :path => 'part'
|
306
|
+
n.physicalDescription :path => 'physicalDescription'
|
307
|
+
n.recordInfo :path => 'recordInfo'
|
308
|
+
n.subject :path => 'subject'
|
309
|
+
n.tableOfContents :path => 'tableOfContents'
|
310
|
+
n.targetAudience :path => 'targetAudience'
|
311
|
+
n.titleInfo :path => 'titleInfo'
|
312
|
+
n.typeOfResource :path => 'typeOfResource'
|
338
313
|
end
|
314
|
+
|
315
|
+
# SUBJECT -----------------------------------------------------------------------------
|
316
|
+
t.subject :path => '/mods/subject'
|
317
|
+
t._subject :path => '//subject' do |n|
|
318
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
319
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
320
|
+
}
|
321
|
+
n.topic :path => 'topic' do |n|
|
322
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
323
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
324
|
+
}
|
325
|
+
end
|
326
|
+
n.geographic :path => 'geographic' do |n|
|
327
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
328
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
329
|
+
}
|
330
|
+
end
|
331
|
+
n.temporal :path => 'temporal' do |n|
|
332
|
+
# date attributes as elements
|
333
|
+
Mods::DATE_ATTRIBS.each { |attr_name|
|
334
|
+
n.send attr_name, :path => "#{attr_name}"
|
335
|
+
}
|
336
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
337
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
338
|
+
}
|
339
|
+
# date attributes as attributes
|
340
|
+
Mods::DATE_ATTRIBS.each { |attr_name|
|
341
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
342
|
+
}
|
343
|
+
end
|
344
|
+
n.titleInfo :path => 'titleInfo' do |t|
|
345
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
346
|
+
t.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
347
|
+
}
|
348
|
+
end
|
349
|
+
# Note: 'name' is used by Nokogiri
|
350
|
+
n.name_el :path => 'name' do |t|
|
351
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
352
|
+
t.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
353
|
+
}
|
354
|
+
end
|
355
|
+
n.personal_name :path => 'name[@type="personal"]'
|
356
|
+
n.corporate_name :path => 'name[@type="corporate"]'
|
357
|
+
n.conference_name :path => 'name[@type="conference"]'
|
358
|
+
n.geographicCode :path => 'geographicCode' do |g|
|
359
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
360
|
+
g.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
361
|
+
}
|
362
|
+
end
|
363
|
+
n.genre :path => 'genre' do |n|
|
364
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
365
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
366
|
+
}
|
367
|
+
end
|
368
|
+
n.hierarchicalGeographic :path => 'hierarchicalGeographic' do |n|
|
369
|
+
Mods::Subject::HIER_GEO_CHILD_ELEMENTS.each { |elname|
|
370
|
+
n.send elname, :path => "#{elname}"
|
371
|
+
}
|
372
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
373
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
374
|
+
}
|
375
|
+
end
|
376
|
+
n.cartographics :path => 'cartographics' do |n|
|
377
|
+
n.scale :path => 'scale'
|
378
|
+
n.projection :path => 'projection'
|
379
|
+
n.coordinates :path => 'coordinates'
|
380
|
+
Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.each { |elname|
|
381
|
+
n.send elname, :path => "#{elname}"
|
382
|
+
}
|
383
|
+
end
|
384
|
+
n.occupation :path => 'occupation' do |n|
|
385
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
386
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
387
|
+
}
|
388
|
+
end
|
389
|
+
end # t.subject
|
390
|
+
|
391
|
+
# TABLE_OF_CONTENTS ---------------------------------------------------------------------
|
392
|
+
t._tableOfContents :path => '//tableOfContents' do |n|
|
393
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
394
|
+
n.shareable :path => '@shareable', :accessor => lambda { |a| a.text }
|
395
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
396
|
+
end
|
397
|
+
|
398
|
+
# TARGET_AUDIENCE -----------------------------------------------------------------------
|
399
|
+
t._targetAudience :path => '//targetAudience' do |n|
|
400
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
401
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
402
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
403
|
+
}
|
404
|
+
end
|
405
|
+
|
406
|
+
# TITLE_INFO ----------------------------------------------------------------------------
|
407
|
+
t.title_info :path => '/mods/titleInfo'
|
408
|
+
t._title_info :path => '//titleInfo' do |n|
|
409
|
+
Mods::TitleInfo::ATTRIBUTES.each { |attr_name|
|
410
|
+
if attr_name != 'type'
|
411
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
412
|
+
else
|
413
|
+
n.type_at :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
414
|
+
end
|
415
|
+
}
|
416
|
+
n.title :path => 'title'
|
417
|
+
n.subTitle :path => 'subTitle'
|
418
|
+
n.nonSort :path => 'nonSort'
|
419
|
+
n.partNumber :path => 'partNumber'
|
420
|
+
n.partName :path => 'partName'
|
421
|
+
n.sort_title :path => '.', :accessor => lambda { |node|
|
422
|
+
if node.type_at != "alternative" || (node.type_at == "alternative" && mods_ng_xml.xpath('/mods/titleInfo').size == 1)
|
423
|
+
node.title.text + (!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
|
424
|
+
end
|
425
|
+
}
|
426
|
+
n.full_title :path => '.', :accessor => lambda { |node|
|
427
|
+
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
428
|
+
node.title.text +
|
429
|
+
(!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
|
430
|
+
}
|
431
|
+
n.short_title :path => '.', :accessor => lambda { |node|
|
432
|
+
if node.type_at != "alternative"
|
433
|
+
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
434
|
+
node.title.text
|
435
|
+
end
|
436
|
+
}
|
437
|
+
n.alternative_title :path => '.', :accessor => lambda { |node|
|
438
|
+
if node.type_at == "alternative"
|
439
|
+
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
440
|
+
node.title.text
|
441
|
+
end
|
442
|
+
}
|
443
|
+
end # t._title_info
|
339
444
|
|
445
|
+
# TYPE_OF_RESOURCE --------------------------------------------------------------------
|
446
|
+
t._typeOfResource :path => '//typeOfResource' do |n|
|
447
|
+
n.collection :path => '@collection', :accessor => lambda { |a| a.text }
|
448
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
449
|
+
n.manuscript :path => '@manuscript', :accessor => lambda { |a| a.text }
|
450
|
+
n.usage :path => '@usage', :accessor => lambda { |a| a.text }
|
451
|
+
end
|
340
452
|
|
341
453
|
end # terminology
|
342
454
|
|
@@ -345,43 +457,13 @@ module Mods
|
|
345
457
|
mods_ng_xml
|
346
458
|
end # set_terminology_no_ns
|
347
459
|
|
348
|
-
|
349
|
-
# authority, authorityURI, valueURI
|
350
|
-
# displayLabel, usage altRepGroup
|
351
|
-
# type
|
352
|
-
# TODO: common subelement attributes: lang, xml:lang, script, transliteration
|
353
|
-
# TODO: other common attribute: supplied
|
354
|
-
|
355
|
-
|
460
|
+
|
356
461
|
# set the NOM terminology, with namespaces
|
357
462
|
# @param mods_ng_xml a Nokogiri::Xml::Document object containing MODS (with namespaces)
|
358
463
|
def set_terminology_ns(mods_ng_xml)
|
359
464
|
mods_ng_xml.set_terminology(:namespaces => { 'm' => Mods::MODS_NS}) do |t|
|
360
465
|
|
361
|
-
#
|
362
|
-
t.title_info :path => '//m:titleInfo' do |n|
|
363
|
-
n.title :path => 'm:title'
|
364
|
-
n.subTitle :path => 'm:subTitle'
|
365
|
-
n.nonSort :path => 'm:nonSort'
|
366
|
-
n.partNumber :path => 'm:partNumber'
|
367
|
-
n.partName :path => 'm:partName'
|
368
|
-
n.type_at :path => '@type'
|
369
|
-
end
|
370
|
-
|
371
|
-
t.author :path => '//m:name' do |n|
|
372
|
-
n.valueURI :path => '@valueURI'
|
373
|
-
n.namePart :path => 'm:namePart', :single => true
|
374
|
-
end
|
375
|
-
|
376
|
-
t.corporate_authors :path => '//m:name[@type="corporate"]'
|
377
|
-
t.personal_authors :path => 'm:name[@type="personal"]' do |n|
|
378
|
-
n.roleTerm :path => 'm:role/m:roleTerm'
|
379
|
-
n.name_role_pair :path => '.', :accessor => lambda { |node| node.roleTerm.text + ": " + node.namePart.text }
|
380
|
-
end
|
381
|
-
|
382
|
-
t.language :path => 'm:language' do |n|
|
383
|
-
n.value :path => 'm:languageTerm', :accessor => :text
|
384
|
-
end
|
466
|
+
# TODO implement terminology with namespace
|
385
467
|
|
386
468
|
end
|
387
469
|
|
data/lib/mods/version.rb
CHANGED
data/spec/name_spec.rb
CHANGED
@@ -229,7 +229,7 @@ describe "Mods <name> Element" do
|
|
229
229
|
it "should recognize type attribute on namePart element" do
|
230
230
|
Mods::Name::NAME_PART_TYPES.each { |t|
|
231
231
|
@mods_rec.from_str("<mods><name><namePart type='#{t}'>hi</namePart></name></mods>")
|
232
|
-
@mods_rec.plain_name.namePart.type_at.
|
232
|
+
@mods_rec.plain_name.namePart.type_at.should == [t]
|
233
233
|
}
|
234
234
|
end
|
235
235
|
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Mods <relatedItem> Element" do
|
4
|
+
before(:all) do
|
5
|
+
@mods_rec = Mods::Record.new
|
6
|
+
@rel_it1 = @mods_rec.from_str('<mods><relatedItem displayLabel="Bibliography" type="host">
|
7
|
+
<titleInfo>
|
8
|
+
<title/>
|
9
|
+
</titleInfo>
|
10
|
+
<recordInfo>
|
11
|
+
<recordIdentifier source="Gallica ARK"/>
|
12
|
+
</recordInfo>
|
13
|
+
<typeOfResource>text</typeOfResource>
|
14
|
+
</relatedItem></mods>').related_item
|
15
|
+
@rel_it_mult = @mods_rec.from_str('<mods><relatedItem>
|
16
|
+
<titleInfo>
|
17
|
+
<title>Complete atlas, or, Distinct view of the known world</title>
|
18
|
+
</titleInfo>
|
19
|
+
<name type="personal">
|
20
|
+
<namePart>Bowen, Emanuel,</namePart>
|
21
|
+
<namePart type="date">d. 1767</namePart>
|
22
|
+
</name>
|
23
|
+
</relatedItem>
|
24
|
+
<relatedItem type="host" displayLabel="From:">
|
25
|
+
<titleInfo>
|
26
|
+
<title>Complete atlas, or, Distinct view of the known world</title>
|
27
|
+
</titleInfo>
|
28
|
+
<name>
|
29
|
+
<namePart>Bowen, Emanuel, d. 1767.</namePart>
|
30
|
+
</name>
|
31
|
+
<identifier type="local">(AuCNL)1669726</identifier>
|
32
|
+
</relatedItem></mods>').related_item
|
33
|
+
@rel_it2 = @mods_rec.from_str('<mods><relatedItem type="constituent" ID="MODSMD_ARTICLE1">
|
34
|
+
<titleInfo>
|
35
|
+
<title>Nuppineula.</title>
|
36
|
+
</titleInfo>
|
37
|
+
<genre>article</genre>
|
38
|
+
<part ID="DIVL15" type="paragraph" order="1"/>
|
39
|
+
<part ID="DIVL17" type="paragraph" order="2"/>
|
40
|
+
<part ID="DIVL19" type="paragraph" order="3"/>
|
41
|
+
</relatedItem></mods>').related_item
|
42
|
+
@coll_ex = @mods_rec.from_str('<mods><relatedItem type="host">
|
43
|
+
<titleInfo>
|
44
|
+
<title>The Collier Collection of the Revs Institute for Automotive Research</title>
|
45
|
+
</titleInfo>
|
46
|
+
<typeOfResource collection="yes"/>
|
47
|
+
</relatedItem></mods>').related_item
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should associate the right pieces with the right <relatedItem> elements" do
|
51
|
+
pending "to be implemented (Mods::RelatedItem object)"
|
52
|
+
end
|
53
|
+
|
54
|
+
context "basic <related_item> terminology pieces" do
|
55
|
+
|
56
|
+
it ".relatedItem should be a NodeSet" do
|
57
|
+
[@rel_it1, @rel_it_mult, @rel_it2, @coll_ex].each { |ri| ri.should be_an_instance_of(Nokogiri::XML::NodeSet) }
|
58
|
+
end
|
59
|
+
it ".relatedItem should have as many members as there are <recordInfo> elements in the xml" do
|
60
|
+
[@rel_it1, @rel_it2, @coll_ex].each { |ri| ri.size.should == 1 }
|
61
|
+
@rel_it_mult.size.should == 2
|
62
|
+
end
|
63
|
+
it "relatedItem.type_at should match type attribute" do
|
64
|
+
[@rel_it1, @rel_it_mult, @coll_ex].each { |ri| ri.type_at.should == ['host'] }
|
65
|
+
@rel_it2.type_at.should == ['constituent']
|
66
|
+
end
|
67
|
+
it "relatedItem.id_at should match ID attribute" do
|
68
|
+
@rel_it2.id_at.should == ['MODSMD_ARTICLE1']
|
69
|
+
[@rel_it1, @rel_it_mult, @coll_ex].each { |ri| ri.id_at.size.should == 0 }
|
70
|
+
end
|
71
|
+
it "relatedItem.displayLabel should match displayLabel attribute" do
|
72
|
+
@rel_it1.displayLabel.should == ['Bibliography']
|
73
|
+
@rel_it_mult.displayLabel.should == ['From:']
|
74
|
+
[@rel_it2, @coll_ex].each { |ri| ri.displayLabel.size.should == 0 }
|
75
|
+
end
|
76
|
+
|
77
|
+
context "<genre> child element" do
|
78
|
+
it "relatedItem.genre should match <relatedItem><genre>" do
|
79
|
+
@rel_it2.genre.map { |ri| ri.text }.should == ['article']
|
80
|
+
end
|
81
|
+
end # <genre> child element
|
82
|
+
|
83
|
+
context "<identifier> child element" do
|
84
|
+
it "relatedItem.identifier.type_at should match <relatedItem><identifier type=''> attribute" do
|
85
|
+
@rel_it_mult.identifier.type_at.should == ['local']
|
86
|
+
end
|
87
|
+
it "relatedItem.identifier should match <relatedItem><identifier>" do
|
88
|
+
@rel_it_mult.identifier.map { |n| n.text }.should == ['(AuCNL)1669726']
|
89
|
+
end
|
90
|
+
end # <identifier> child element
|
91
|
+
|
92
|
+
context "<name> child element" do
|
93
|
+
it "relatedItem.personal_name.namePart should match <relatedItem><name type='personal'><namePart>" do
|
94
|
+
@rel_it_mult.personal_name.namePart.map { |n| n.text }.size.should == 2
|
95
|
+
@rel_it_mult.personal_name.namePart.map { |n| n.text }.should include('Bowen, Emanuel,')
|
96
|
+
@rel_it_mult.personal_name.namePart.map { |n| n.text }.should include('d. 1767')
|
97
|
+
@rel_it_mult.personal_name.namePart.map { |n| n.text }.should_not include('Bowen, Emanuel, d. 1767.')
|
98
|
+
end
|
99
|
+
it "relatedItem.personal_name.date should match <relatedItem><name type='personal'><namePart type='date'>" do
|
100
|
+
@rel_it_mult.personal_name.date.map { |n| n.text }.should == ['d. 1767']
|
101
|
+
end
|
102
|
+
it "relatedItem.name_el.namePart should match <relatedItem><name><namePart>" do
|
103
|
+
@rel_it_mult.name_el.namePart.map { |n| n.text }.size.should == 3
|
104
|
+
@rel_it_mult.name_el.namePart.map { |n| n.text }.should include('Bowen, Emanuel,')
|
105
|
+
@rel_it_mult.name_el.namePart.map { |n| n.text }.should include('d. 1767')
|
106
|
+
@rel_it_mult.name_el.namePart.map { |n| n.text }.should include('Bowen, Emanuel, d. 1767.')
|
107
|
+
end
|
108
|
+
end # <name> child element
|
109
|
+
|
110
|
+
context "<part> child element" do
|
111
|
+
it "relatedItem.part.type_at should match <relatedItem><part type=''> attribute" do
|
112
|
+
@rel_it2.part.type_at.should == ['paragraph', 'paragraph', 'paragraph']
|
113
|
+
end
|
114
|
+
it "relatedItem.part.id_at should match <relatedItem><part ID=''> attribute" do
|
115
|
+
@rel_it2.part.id_at.size.should == 3
|
116
|
+
@rel_it2.part.id_at.should include('DIVL15')
|
117
|
+
@rel_it2.part.id_at.should include('DIVL17')
|
118
|
+
@rel_it2.part.id_at.should include('DIVL19')
|
119
|
+
end
|
120
|
+
it "relatedItem.part.order should match <relatedItem><part order=''> attribute" do
|
121
|
+
@rel_it2.part.order.size.should == 3
|
122
|
+
@rel_it2.part.order.should include('1')
|
123
|
+
@rel_it2.part.order.should include('2')
|
124
|
+
@rel_it2.part.order.should include('3')
|
125
|
+
end
|
126
|
+
end # <part> child element
|
127
|
+
|
128
|
+
context "<recordInfo> child element" do
|
129
|
+
it "relatedItem.recordInfo.recordIdentifier.source should match <relatedItem><recordInfo><recordIdentifier source> attribute" do
|
130
|
+
@rel_it1.recordInfo.recordIdentifier.source.should == ['Gallica ARK']
|
131
|
+
end
|
132
|
+
end # <recordInfo> child element
|
133
|
+
|
134
|
+
context "<titleInfo> child element" do
|
135
|
+
it "relatedItem.titleInfo.title should access <relatedItem><titleInfo><title>" do
|
136
|
+
@rel_it1.titleInfo.title.map { |n| n.text }.should == ['']
|
137
|
+
@rel_it_mult.titleInfo.title.map { |n| n.text }.should == ['Complete atlas, or, Distinct view of the known world', 'Complete atlas, or, Distinct view of the known world']
|
138
|
+
@rel_it2.titleInfo.title.map { |n| n.text }.should == ['Nuppineula.']
|
139
|
+
@coll_ex.titleInfo.title.map { |n| n.text }.should == ['The Collier Collection of the Revs Institute for Automotive Research']
|
140
|
+
end
|
141
|
+
end # <titleInfo> child element
|
142
|
+
|
143
|
+
context "<typeOfResource> child element" do
|
144
|
+
it "relatedItem.typeOfResource should access <relatedItem><typeOfResource>" do
|
145
|
+
@rel_it1.typeOfResource.map { |n| n.text }.should == ['text']
|
146
|
+
end
|
147
|
+
it "relatedItem.typeOfResource.collection should access <relatedItem><typeOfResource collection='yes'> attribute" do
|
148
|
+
@coll_ex.typeOfResource.collection.should == ['yes']
|
149
|
+
end
|
150
|
+
end # <typeOfResource> child element
|
151
|
+
|
152
|
+
end # basic <related_item> terminology pieces
|
153
|
+
|
154
|
+
end
|
data/spec/subject_spec.rb
CHANGED
@@ -25,9 +25,9 @@ describe "Mods <subject> Element" do
|
|
25
25
|
pending "to be implemented"
|
26
26
|
end
|
27
27
|
|
28
|
-
context "
|
28
|
+
context "subterms for <name> child elements of <subject> element" do
|
29
29
|
before(:all) do
|
30
|
-
@
|
30
|
+
@both_types_sub = @mods_rec.from_str('<mods><subject>
|
31
31
|
<name type="personal">
|
32
32
|
<namePart>Bridgens, R.P</namePart>
|
33
33
|
</name>
|
@@ -35,13 +35,13 @@ describe "Mods <subject> Element" do
|
|
35
35
|
<name type="corporate">
|
36
36
|
<namePart>Britton & Rey.</namePart>
|
37
37
|
</name>
|
38
|
-
</subject></mods>').subject
|
39
|
-
@
|
38
|
+
</subject></mods>').subject
|
39
|
+
@pers_name_sub = @mods_rec.from_str('<mods><subject>
|
40
40
|
<name type="personal" authority="ingest">
|
41
41
|
<namePart type="family">Edward VI , king of England, </namePart>
|
42
42
|
<displayForm>Edward VI , king of England, 1537-1553</displayForm>
|
43
|
-
</name></subject></mods>').subject
|
44
|
-
@
|
43
|
+
</name></subject></mods>').subject
|
44
|
+
@mult_pers_name_sub = @mods_rec.from_str('<mods><subject authority="lcsh">
|
45
45
|
<name type="personal">
|
46
46
|
<namePart>Baker, George H</namePart>
|
47
47
|
<role>
|
@@ -77,8 +77,8 @@ describe "Mods <subject> Element" do
|
|
77
77
|
</subject><subject authority="lcsh">
|
78
78
|
<name type="personal">
|
79
79
|
<namePart>Swasey, W. F. (William F.)</namePart>
|
80
|
-
</name></subject></mods>').subject
|
81
|
-
@
|
80
|
+
</name></subject></mods>').subject
|
81
|
+
@mult_corp_name_sub = @mods_rec.from_str('<mods><subject authority="lcsh">
|
82
82
|
<name type="corporate">
|
83
83
|
<namePart>Britton & Rey.</namePart>
|
84
84
|
</name>
|
@@ -88,19 +88,20 @@ describe "Mods <subject> Element" do
|
|
88
88
|
<role>
|
89
89
|
<roleTerm type="text">lithographers.</roleTerm>
|
90
90
|
</role>
|
91
|
-
</name></subject></mods>').subject
|
91
|
+
</name></subject></mods>').subject
|
92
92
|
end
|
93
93
|
it "should be able to identify corporate names" do
|
94
|
-
|
94
|
+
@both_types_sub.corporate_name.namePart.map { |e| e.text }.should == ['Britton & Rey.']
|
95
95
|
end
|
96
96
|
it "should be able to identify personal names" do
|
97
|
-
|
97
|
+
@both_types_sub.personal_name.namePart.map { |e| e.text }.should == ['Bridgens, R.P']
|
98
|
+
@pers_name_sub.personal_name.displayForm.map { |e| e.text }.should == ['Edward VI , king of England, 1537-1553']
|
98
99
|
end
|
99
100
|
it "should be able to identify roles associated with a name" do
|
100
|
-
|
101
|
+
@mult_corp_name_sub.corporate_name.role.map { |e| e.text }.should == ['lithographers.']
|
101
102
|
end
|
102
103
|
it "should be able to identify dates associated with a name" do
|
103
|
-
|
104
|
+
@mult_pers_name_sub.personal_name.date.map { |e| e.text }.should include("1818-1878")
|
104
105
|
end
|
105
106
|
it "should do the appropriate thing with the role for the value of a name" do
|
106
107
|
pending "to be implemented"
|
@@ -313,7 +314,7 @@ describe "Mods <subject> Element" do
|
|
313
314
|
context "<name> child element" do
|
314
315
|
it "should understand all attributes allowed on a <name> element" do
|
315
316
|
Mods::Name::ATTRIBUTES.each { |a|
|
316
|
-
name = @mods_rec.from_str("<mods><subject><name #{a}='attr_val'>Obadiah</name></subject></mods>").subject.
|
317
|
+
name = @mods_rec.from_str("<mods><subject><name #{a}='attr_val'>Obadiah</name></subject></mods>").subject.name_el
|
317
318
|
if (a == 'type')
|
318
319
|
name.type_at.should == ['attr_val']
|
319
320
|
else
|
@@ -323,7 +324,7 @@ describe "Mods <subject> Element" do
|
|
323
324
|
end
|
324
325
|
it "should understand all immediate child elements allowed on a <name> element" do
|
325
326
|
Mods::Name::CHILD_ELEMENTS.each { |e|
|
326
|
-
name = @mods_rec.from_str("<mods><subject><name><#{e}>el_val</#{e}></name></subject></mods>").subject.
|
327
|
+
name = @mods_rec.from_str("<mods><subject><name><#{e}>el_val</#{e}></name></subject></mods>").subject.name_el
|
327
328
|
if (e == 'description')
|
328
329
|
name.description_el.text.should == 'el_val'
|
329
330
|
elsif (e != 'role')
|
@@ -336,7 +337,7 @@ describe "Mods <subject> Element" do
|
|
336
337
|
<name type="personal" authority="lcsh">
|
337
338
|
<namePart>Nahl, Charles Christian</namePart>
|
338
339
|
<namePart type="date">1818-1878</namePart>
|
339
|
-
</name></mods>').subject.
|
340
|
+
</name></mods>').subject.name_el.authority.should == ["lcsh"]
|
340
341
|
end
|
341
342
|
end # <name>
|
342
343
|
|
@@ -29,11 +29,162 @@ describe "Mods Top Level Elements that do not have Child Elements" do
|
|
29
29
|
pending "need to implement ruby style version of (element/attribute) method names"
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
@mods_rec.
|
36
|
-
|
32
|
+
context "<abstract> child element" do
|
33
|
+
it ".abstract.displayLabel should be an accessor for displayLabel attribute on abstract element: <abstract displayLabel='foo'>" do
|
34
|
+
@mods_rec.from_str('<mods><abstract displayLabel="Summary">blah blah blah</abstract></mods>')
|
35
|
+
@mods_rec.abstract.displayLabel.should == ['Summary']
|
36
|
+
end
|
37
|
+
it ".abstract.type_at should be an accessor for type attribute on abstract element: <abstract type='foo'>" do
|
38
|
+
@mods_rec.from_str('<mods><abstract type="Scope and Contents note">blah blah blah</abstract></mods>')
|
39
|
+
@mods_rec.abstract.type_at.should == ['Scope and Contents note']
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "<accessCondition> child element" do
|
44
|
+
before(:all) do
|
45
|
+
@acc_cond = @mods_rec.from_str('<mods><accessCondition displayLabel="meh" type="useAndReproduction">blah blah blah</accessCondition></mods>').accessCondition
|
46
|
+
@acc_cond2 = @mods_rec.from_str('<mods><accessCondition type="useAndReproduction">All rights reserved.</accessCondition></mods>').accessCondition
|
47
|
+
end
|
48
|
+
it ".accessCondition.displayLabel should be an accessor for displayLabel attribute on accessCondition element: <accessCondition displayLabel='foo'>" do
|
49
|
+
@acc_cond.displayLabel.should == ['meh']
|
50
|
+
end
|
51
|
+
it ".accessCondition.type_at should be an accessor for type attribute on accessCondition element: <accessCondition type='foo'>" do
|
52
|
+
[@acc_cond, @acc_cond2].each { |ac| ac.type_at.should == ['useAndReproduction'] }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "<classification> child element" do
|
57
|
+
before(:all) do
|
58
|
+
@class1 = @mods_rec.from_str('<mods><classification authority="ddc" edition="11">683</classification></mods>').classification
|
59
|
+
@class2 = @mods_rec.from_str('<mods><classification authority="lcc">JK609.M2</classification></mods>').classification
|
60
|
+
end
|
61
|
+
it ".classification.authority should be an accessor for authority attribute on classification element: <classification authority='foo'>" do
|
62
|
+
@class1.authority.should == ['ddc']
|
63
|
+
@class2.authority.should == ['lcc']
|
64
|
+
end
|
65
|
+
it ".classification.edition should be an accessor for edition attribute on classification element: <classification edition='foo'>" do
|
66
|
+
@class1.edition.should == ['11']
|
67
|
+
end
|
68
|
+
it "should recognize all authority attributes" do
|
69
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
70
|
+
@mods_rec.from_str("<mods><classification #{a}='attr_val'>zzz</classification></mods>")
|
71
|
+
@mods_rec.classification.send(a.to_sym).should == ['attr_val']
|
72
|
+
}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "<extension> child element" do
|
77
|
+
before(:all) do
|
78
|
+
@ext = @mods_rec.from_str('<mods><extension xmlns:dcterms="http://purl.org/dc/terms/" >
|
79
|
+
<dcterms:modified>2003-03-24</dcterms:modified>
|
80
|
+
</extension></mods>').extension
|
81
|
+
end
|
82
|
+
it ".extension.displayLabel should be an accessor for displayLabel attribute on extension element: <extension displayLabel='foo'>" do
|
83
|
+
@mods_rec.from_str('<mods><extension displayLabel="something">blah blah blah</extension></mods>')
|
84
|
+
@mods_rec.extension.displayLabel.should == ['something']
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "<genre> child element" do
|
89
|
+
it ".genre.displayLabel should be an accessor for displayLabel attribute on genre element: <genre displayLabel='foo'>" do
|
90
|
+
@mods_rec.from_str('<mods><genre displayLabel="something">blah blah blah</genre></mods>')
|
91
|
+
@mods_rec.genre.displayLabel.should == ['something']
|
92
|
+
end
|
93
|
+
it ".genre.type_at should be an accessor for type attribute on genre element: <genre type='foo'>" do
|
94
|
+
@mods_rec.from_str('<mods><genre type="maybe">blah blah blah</genre></mods>')
|
95
|
+
@mods_rec.genre.type_at.should == ['maybe']
|
96
|
+
end
|
97
|
+
it ".genre.usage should be an accessor for usage attribute on genre element: <genre usage='foo'>" do
|
98
|
+
@mods_rec.from_str('<mods><genre usage="fer sure">blah blah blah</genre></mods>')
|
99
|
+
@mods_rec.genre.usage.should == ['fer sure']
|
100
|
+
end
|
101
|
+
it "should recognize all authority attributes" do
|
102
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
103
|
+
@mods_rec.from_str("<mods><genre #{a}='attr_val'>zzz</genre></mods>")
|
104
|
+
@mods_rec.genre.send(a.to_sym).should == ['attr_val']
|
105
|
+
}
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "<identifier> child element" do
|
110
|
+
before(:all) do
|
111
|
+
@id = @mods_rec.from_str('<mods><identifier displayLabel="book_number" type="local">70</identifier></mods>').identifier
|
112
|
+
end
|
113
|
+
it ".identifier.displayLabel should be an accessor for displayLabel attribute on identifier element: <identifier displayLabel='foo'>" do
|
114
|
+
@id.displayLabel.should == ['book_number']
|
115
|
+
end
|
116
|
+
it ".identifier.invalid should be an accessor for invalid attribute on identifier element: <identifier invalid='foo'>" do
|
117
|
+
@mods_rec.from_str('<mods> <identifier type="isbn" invalid="yes">0877780116</identifier></mods>')
|
118
|
+
@mods_rec.identifier.invalid.should == ['yes']
|
119
|
+
end
|
120
|
+
it ".identifier.type_at should be an accessor for type attribute on identifier element: <identifier type='foo'>" do
|
121
|
+
@id.type_at.should == ['local']
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context "<note> child element" do
|
126
|
+
it ".note.displayLabel should be an accessor for displayLabel attribute on note element: <note displayLabel='foo'>" do
|
127
|
+
@mods_rec.from_str('<mods><note displayLabel="state_note">blah</note></mods>')
|
128
|
+
@mods_rec.note.displayLabel.should == ['state_note']
|
129
|
+
end
|
130
|
+
it ".note.id_at should be an accessor for ID attribute on note element: <note ID='foo'>" do
|
131
|
+
@mods_rec.from_str('<mods><note ID="foo">blah blah blah</note></mods>')
|
132
|
+
@mods_rec.note.id_at.should == ['foo']
|
133
|
+
end
|
134
|
+
it ".note.type_at should be an accessor for type attribute on note element: <note type='foo'>" do
|
135
|
+
@mods_rec.from_str('<mods><note type="content">blah</note></mods>')
|
136
|
+
@mods_rec.note.type_at.should == ['content']
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context "<tableOfContents> child element" do
|
141
|
+
it ".tableOfContents.displayLabel should be an accessor for displayLabel attribute on tableOfContents element: <tableOfContents displayLabel='foo'>" do
|
142
|
+
@mods_rec.from_str('<mods><tableOfContents displayLabel="Chapters included in book">blah blah</tableOfContents></mods>')
|
143
|
+
@mods_rec.tableOfContents.displayLabel.should == ['Chapters included in book']
|
144
|
+
end
|
145
|
+
it ".tableOfContents.shareable should be an accessor for shareable attribute on tableOfContents element: <tableOfContents shareable='foo'>" do
|
146
|
+
@mods_rec.from_str('<mods><tableOfContents shareable="no">blah blah blah</tableOfContents></mods>')
|
147
|
+
@mods_rec.tableOfContents.shareable.should == ['no']
|
148
|
+
end
|
149
|
+
it ".tableOfContents.type_at should be an accessor for type attribute on tableOfContents element: <tableOfContents type='foo'>" do
|
150
|
+
@mods_rec.from_str('<mods><tableOfContents type="partial contents">blah blah</tableOfContents></mods>')
|
151
|
+
@mods_rec.tableOfContents.type_at.should == ['partial contents']
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context "<targetAudience> child element" do
|
156
|
+
it ".targetAudience.displayLabel should be an accessor for displayLabel attribute on targetAudience element: <targetAudience displayLabel='foo'>" do
|
157
|
+
@mods_rec.from_str('<mods><targetAudience displayLabel="ta da">blah blah</targetAudience></mods>')
|
158
|
+
@mods_rec.targetAudience.displayLabel.should == ['ta da']
|
159
|
+
end
|
160
|
+
it "should recognize all authority attributes" do
|
161
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
162
|
+
@mods_rec.from_str("<mods><targetAudience #{a}='attr_val'>zzz</targetAudience></mods>")
|
163
|
+
@mods_rec.targetAudience.send(a.to_sym).should == ['attr_val']
|
164
|
+
}
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
context "<typeOfResource> child element" do
|
169
|
+
before(:all) do
|
170
|
+
'<typeOfResource manuscript="yes">mixed material</typeOfResource>'
|
171
|
+
end
|
172
|
+
it ".typeOfResource.collection should be an accessor for collection attribute on typeOfResource element: <typeOfResource collection='foo'>" do
|
173
|
+
@mods_rec.from_str('<mods><typeOfResource collection="yes">blah blah blah</typeOfResource></mods>')
|
174
|
+
@mods_rec.typeOfResource.collection.should == ['yes']
|
175
|
+
end
|
176
|
+
it ".typeOfResource.displayLabel should be an accessor for displayLabel attribute on typeOfResource element: <typeOfResource displayLabel='foo'>" do
|
177
|
+
@mods_rec.from_str('<mods><typeOfResource displayLabel="Summary">blah blah blah</typeOfResource></mods>')
|
178
|
+
@mods_rec.typeOfResource.displayLabel.should == ['Summary']
|
179
|
+
end
|
180
|
+
it ".typeOfResource.manuscript should be an accessor for manuscript attribute on typeOfResource element: <typeOfResource manuscript='foo'>" do
|
181
|
+
@mods_rec.from_str('<mods><typeOfResource manuscript="yes">blah blah blah</typeOfResource></mods>')
|
182
|
+
@mods_rec.typeOfResource.manuscript.should == ['yes']
|
183
|
+
end
|
184
|
+
it ".typeOfResource.usage should be an accessor for usage attribute on typeOfResource element: <typeOfResource usage='foo'>" do
|
185
|
+
@mods_rec.from_str('<mods><typeOfResource usage="fer sure">blah blah blah</typeOfResource></mods>')
|
186
|
+
@mods_rec.typeOfResource.usage.should == ['fer sure']
|
187
|
+
end
|
37
188
|
end
|
38
189
|
|
39
190
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
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: 2012-11-
|
13
|
+
date: 2012-11-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- spec/physical_description_spec.rb
|
195
195
|
- spec/reader_spec.rb
|
196
196
|
- spec/record_info_spec.rb
|
197
|
+
- spec/related_item_spec.rb
|
197
198
|
- spec/spec_helper.rb
|
198
199
|
- spec/subject_spec.rb
|
199
200
|
- spec/title_spec.rb
|
@@ -212,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
213
|
version: '0'
|
213
214
|
segments:
|
214
215
|
- 0
|
215
|
-
hash:
|
216
|
+
hash: -1659531354165299453
|
216
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
218
|
none: false
|
218
219
|
requirements:
|
@@ -221,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
222
|
version: '0'
|
222
223
|
segments:
|
223
224
|
- 0
|
224
|
-
hash:
|
225
|
+
hash: -1659531354165299453
|
225
226
|
requirements: []
|
226
227
|
rubyforge_project:
|
227
228
|
rubygems_version: 1.8.24
|
@@ -237,6 +238,7 @@ test_files:
|
|
237
238
|
- spec/physical_description_spec.rb
|
238
239
|
- spec/reader_spec.rb
|
239
240
|
- spec/record_info_spec.rb
|
241
|
+
- spec/related_item_spec.rb
|
240
242
|
- spec/spec_helper.rb
|
241
243
|
- spec/subject_spec.rb
|
242
244
|
- spec/title_spec.rb
|