mods 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,6 +37,7 @@ TODO: Write usage instructions here
37
37
 
38
38
  == Releases
39
39
 
40
+ 0.0.6 implement recordInfo, fix to work under jruby
40
41
  0.0.5 implement subject, change a few constants
41
42
  0.0.4 implement language, location, origin_info, physical_description
42
43
  0.0.3 use nom-xml gem and make this more nokogiri-ish; implement name, title, and simple top level elements with no subelements
@@ -7,7 +7,7 @@ module Mods
7
7
  LINKING_ATTRIBS = ['xlink', 'ID']
8
8
 
9
9
  DATE_ATTRIBS = ['encoding', 'point', 'keyDate', 'qualifier']
10
- ENCODING_ATTRIB_VALUES = ['w3cdtf', 'iso8601', 'marc']
10
+ ENCODING_ATTRIB_VALUES = ['w3cdtf', 'iso8601', 'marc', 'edtf', 'temper']
11
11
  POINT_ATTRIB_VALUES = ['start', 'end']
12
12
  KEY_DATE_ATTRIB_VALUEs = ['yes']
13
13
  QUALIFIER_ATTRIB_VALUES = ['approximate', 'inferred', 'questionable']
@@ -114,16 +114,18 @@ module Mods
114
114
  t.conference_name :path => '/mods/name[@type="conference"]'
115
115
 
116
116
  # LANGUAGE -------------------------------------------------------------------------------
117
-
118
117
  t.language :path => '/mods/language' do |n|
119
- n.languageTerm :path => 'languageTerm' do |lt|
120
- lt.type_at :path => '@type', :accessor => lambda { |a| a.text }
121
- lt.authority :path => '@authority', :accessor => lambda { |a| a.text }
122
- end
118
+ n.languageTerm :path => 'languageTerm'
123
119
  n.code_term :path => 'languageTerm[@type="code"]'
124
120
  n.text_term :path => 'languageTerm[@type="text"]'
125
121
  n.scriptTerm :path => 'scriptTerm'
126
122
  end
123
+ t._languageTerm :path => '//languageTerm' do |lt|
124
+ lt.type_at :path => '@type', :accessor => lambda { |a| a.text }
125
+ Mods::AUTHORITY_ATTRIBS.each { |attr_name|
126
+ lt.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
127
+ }
128
+ end
127
129
 
128
130
  # PHYSICAL_DESCRIPTION -------------------------------------------------------------------
129
131
  t.physical_description :path => '/mods/physicalDescription' do |n|
@@ -257,6 +259,49 @@ module Mods
257
259
  end
258
260
  end
259
261
 
262
+ # RECORD_INFO --------------------------------------------------------------------------
263
+ t.record_info :path => '/mods/recordInfo'
264
+ t._record_info :path => '//recordInfo' do |n|
265
+ # attributes
266
+ n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
267
+ Mods::LANG_ATTRIBS.each { |attr_name|
268
+ n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
269
+ }
270
+ # child elements
271
+ n.recordContentSource :path => 'recordContentSource' do |r|
272
+ Mods::AUTHORITY_ATTRIBS.each { |attr_name|
273
+ r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
274
+ }
275
+ end
276
+ n.recordCreationDate :path => 'recordCreationDate' do |r|
277
+ Mods::DATE_ATTRIBS.each { |attr_name|
278
+ r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
279
+ }
280
+ end
281
+ n.recordChangeDate :path => 'recordChangeDate' do |r|
282
+ Mods::DATE_ATTRIBS.each { |attr_name|
283
+ r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
284
+ }
285
+ end
286
+ n.recordIdentifier :path => 'recordIdentifier' do |r|
287
+ r.source :path => '@source', :accessor => lambda { |a| a.text }
288
+ end
289
+ n.recordOrigin :path => 'recordOrigin'
290
+ n.languageOfCataloging :path => 'languageOfCataloging' do |r|
291
+ Mods::AUTHORITY_ATTRIBS.each { |attr_name|
292
+ r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
293
+ }
294
+ r.languageTerm :path => 'languageTerm'
295
+ r.scriptTerm :path => 'scriptTerm'
296
+ end
297
+ n.descriptionStandard :path => 'descriptionStandard' do |r|
298
+ Mods::AUTHORITY_ATTRIBS.each { |attr_name|
299
+ r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
300
+ }
301
+ end
302
+ end
303
+
304
+
260
305
  end # terminology
261
306
 
262
307
  mods_ng_xml.nom!
@@ -34,6 +34,8 @@ module Mods
34
34
  def normalize_mods
35
35
  if !@namespace_aware
36
36
  @mods_ng_xml.remove_namespaces!
37
+ # doing weird re-reading of xml for jruby, which gets confused by its own cache
38
+ @mods_ng_xml = Nokogiri::XML(@mods_ng_xml.to_s)
37
39
  end
38
40
  end
39
41
 
@@ -1,4 +1,4 @@
1
1
  module Mods
2
2
  # this is the Ruby Gem version
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
@@ -4,42 +4,64 @@ describe "Mods <language> Element" do
4
4
  before(:all) do
5
5
  @mods_rec = Mods::Record.new
6
6
  @simple = '<mods><language>Greek</language></mods>'
7
+ @simple_ln = @mods_rec.from_str(@simple).language
7
8
  @iso639_2b_code = '<mods><language><languageTerm authority="iso639-2b" type="code">fre</languageTerm></language></mods>'
9
+ @iso639_2b_code_ln = @mods_rec.from_str(@iso639_2b_code).language
8
10
  @iso639_2b_text = '<mods><language><languageTerm authority="iso639-2b" type="text">English</languageTerm></language></mods>'
11
+ @iso639_2b_text_ln = @mods_rec.from_str(@iso639_2b_text).language
9
12
  @mult_codes = '<mods><language><languageTerm authority="iso639-2b" type="code">per ara, dut</languageTerm></language></mods>'
10
- @mult_code_terms = '<mods><language><languageTerm authority="iso639-2b" type="code">spa</languageTerm><languageTerm authority="iso639-2b" type="code">dut</languageTerm></language></mods>'
11
- @mult_text_terms = '<mods><language><languageTerm authority="iso639-2b" type="text">Chinese</languageTerm><languageTerm authority="iso639-2b" type="text">Spanish</languageTerm></language></mods>'
13
+ @mult_codes_ln = @mods_rec.from_str(@mult_codes).language
14
+ mult_code_terms = '<mods><language><languageTerm authority="iso639-2b" type="code">spa</languageTerm><languageTerm authority="iso639-2b" type="code">dut</languageTerm></language></mods>'
15
+ @mult_code_terms = @mods_rec.from_str(mult_code_terms).language
16
+ mult_text_terms = '<mods><language><languageTerm authority="iso639-2b" type="text">Chinese</languageTerm><languageTerm authority="iso639-2b" type="text">Spanish</languageTerm></language></mods>'
17
+ @mult_text_terms = @mods_rec.from_str(mult_text_terms).language
18
+ @ex_array = [@simple_ln, @iso639_2b_code_ln, @iso639_2b_text_ln, @mult_codes_ln, @mult_code_terms, @mult_text_terms]
12
19
  end
13
20
 
14
- context "basic language terminology pieces" do
21
+ context "basic <language> terminology pieces" do
15
22
  before(:all) do
16
23
  @mods_rec.from_str(@iso639_2b_code)
17
24
  end
18
- it "should understand languageTerm.type_at attribute" do
19
- @mods_rec.language.languageTerm.type_at.should == ["code"]
25
+ it "should be a NodeSet" do
26
+ @ex_array.each { |t| t.should be_an_instance_of(Nokogiri::XML::NodeSet) }
20
27
  end
21
- it "should understand languageTerm.authority attribute" do
22
- @mods_rec.language.languageTerm.authority.should == ["iso639-2b"]
23
- end
24
- it "should understand languageTerm value" do
25
- @mods_rec.language.languageTerm.text.should == "fre"
26
- @mods_rec.language.languageTerm.size.should == 1
28
+ it "should have as many members as there are <language> elements in the xml" do
29
+ @ex_array.each { |t| t.size.should == 1 }
27
30
  end
31
+
32
+ context "<languageTerm> child element" do
33
+ it "should understand languageTerm.type_at attribute" do
34
+ @iso639_2b_code_ln.languageTerm.type_at.should == ["code"]
35
+ end
36
+ it "should understand languageTerm.authority attribute" do
37
+ @iso639_2b_code_ln.languageTerm.authority.should == ["iso639-2b"]
38
+ end
39
+ it "should understand languageTerm value" do
40
+ @iso639_2b_code_ln.languageTerm.text.should == "fre"
41
+ @iso639_2b_code_ln.languageTerm.size.should == 1
42
+ end
43
+
44
+ it "should recognize all authority attributes" do
45
+ Mods::AUTHORITY_ATTRIBS.each { |a|
46
+ @mods_rec.from_str("<mods><language><languageTerm #{a}='attr_val'>zzz</languageTerm></language></mods>")
47
+ @mods_rec.language.languageTerm.send(a.to_sym).should == ['attr_val']
48
+ }
49
+ end
50
+ end # <languageTerm>
51
+
28
52
  it "should get one language.code_term for each languageTerm element with a type attribute of 'code'" do
29
- @mods_rec.language.code_term.size.should == 1
30
- @mods_rec.language.code_term.text.should == "fre"
31
- @mods_rec.from_str(@mult_code_terms)
32
- @mods_rec.language.code_term.size.should == 2
33
- @mods_rec.language.code_term.first.text.should include("spa")
34
- @mods_rec.language.code_term[1].text.should == "dut"
53
+ @iso639_2b_code_ln.code_term.size.should == 1
54
+ @iso639_2b_code_ln.code_term.text.should == "fre"
55
+ @mult_code_terms.code_term.size.should == 2
56
+ @mult_code_terms.code_term.first.text.should include("spa")
57
+ @mult_code_terms.code_term[1].text.should == "dut"
35
58
  end
36
59
  it "should get one language.text_term for each languageTerm element with a type attribute of 'text'" do
37
- @mods_rec.from_str(@mult_text_terms)
38
- @mods_rec.language.text_term.size.should == 2
39
- @mods_rec.language.text_term.first.text.should include("Chinese")
40
- @mods_rec.language.text_term[1].text.should == "Spanish"
60
+ @mult_text_terms.text_term.size.should == 2
61
+ @mult_text_terms.text_term.first.text.should include("Chinese")
62
+ @mult_text_terms.text_term[1].text.should == "Spanish"
41
63
  end
42
- end
64
+ end # basic <language> terminology pieces
43
65
 
44
66
  context "Mods::Record.languages convenience method" do
45
67
 
@@ -0,0 +1,251 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Mods <recordInfo> Element" do
4
+ before(:all) do
5
+ @mods_rec = Mods::Record.new
6
+ end
7
+
8
+ it "should translate language codes" do
9
+ pending "to be implemented"
10
+ end
11
+
12
+ it "should normalize dates" do
13
+ pending "to be implemented"
14
+ end
15
+
16
+ context "basic <record_info> terminology pieces" do
17
+ before(:all) do
18
+ @rec_info = @mods_rec.from_str('<mods><recordInfo>
19
+ <recordContentSource authority="marcorg">RQE</recordContentSource>
20
+ <recordCreationDate encoding="marc">890517</recordCreationDate>
21
+ <recordIdentifier source="SIRSI">a9079953</recordIdentifier>
22
+ </recordInfo></mods>').record_info
23
+ @rec_info2 = @mods_rec.from_str('<mods><recordInfo>
24
+ <descriptionStandard>aacr2</descriptionStandard>
25
+ <recordContentSource authority="marcorg">AU@</recordContentSource>
26
+ <recordCreationDate encoding="marc">050921</recordCreationDate>
27
+ <recordIdentifier source="SIRSI">a8837534</recordIdentifier>
28
+ <languageOfCataloging>
29
+ <languageTerm authority="iso639-2b" type="code">eng</languageTerm>
30
+ </languageOfCataloging>
31
+ </recordInfo></mods>').record_info
32
+ @bnf = @mods_rec.from_str('<mods><recordInfo>
33
+ <recordContentSource>TEI Description</recordContentSource>
34
+ <recordCreationDate encoding="w3cdtf">2011-12-07</recordCreationDate>
35
+ <recordIdentifier source="BNF 2166"/>
36
+ <recordOrigin/>
37
+ <languageOfCataloging>
38
+ <languageTerm authority="iso639-2b">fra</languageTerm>
39
+ </languageOfCataloging>
40
+ </recordInfo></mods>').record_info
41
+ @rlin = @mods_rec.from_str('<mods><recordInfo>
42
+ <descriptionStandard>appm</descriptionStandard>
43
+ <recordContentSource authority="marcorg">CSt</recordContentSource>
44
+ <recordCreationDate encoding="marc">850416</recordCreationDate>
45
+ <recordChangeDate encoding="iso8601">19991012150824.0</recordChangeDate>
46
+ <recordIdentifier source="CStRLIN">a4083219</recordIdentifier>
47
+ </recordInfo></mods>').record_info
48
+ end
49
+
50
+ it "should be a NodeSet" do
51
+ [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.should be_an_instance_of(Nokogiri::XML::NodeSet) }
52
+ end
53
+ it "should have as many members as there are <recordInfo> elements in the xml" do
54
+ [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.size.should == 1 }
55
+ end
56
+ it "should recognize language attributes on <recordInfo> element" do
57
+ pending "problem with xml:lang"
58
+ Mods::LANG_ATTRIBS.each { |a|
59
+ @mods_rec.from_str("<mods><recordInfo #{a}='val'><recordOrigin>nowhere</recordOrigin></recordInfo></mods>")
60
+ @mods_rec.record_info.send(a.to_sym).should == ['val']
61
+ }
62
+ end
63
+ it "should recognize displayLabel attribute on <recordInfo> element" do
64
+ @mods_rec.from_str("<mods><recordInfo displayLabel='val'><recordOrigin>nowhere</recordOrigin></recordInfo></mods>")
65
+ @mods_rec.record_info.displayLabel.should == ['val']
66
+ end
67
+
68
+ context "<recordContentSource> child element" do
69
+ it "should be a NodeSet" do
70
+ [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordContentSource.should be_an_instance_of(Nokogiri::XML::NodeSet) }
71
+ end
72
+ it "recordContentSource NodeSet should have as many Nodes as there are <recordContentSource> elements in the xml" do
73
+ [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordContentSource.size.should == 1 }
74
+ end
75
+ it "text should get element value" do
76
+ @rec_info.recordContentSource.map { |n| n.text }.should == ["RQE"]
77
+ @rec_info2.recordContentSource.map { |n| n.text }.should == ["AU@"]
78
+ @bnf.recordContentSource.map { |n| n.text }.should == ["TEI Description"]
79
+ @rlin.recordContentSource.map { |n| n.text }.should == ["CSt"]
80
+ end
81
+ it "should recognize authority attribute" do
82
+ [@rec_info, @rec_info2, @rlin].each { |ri| ri.recordContentSource.authority.should == ['marcorg'] }
83
+ @bnf.recordContentSource.authority.size.should == 0
84
+ end
85
+ it "should recognize all authority attributes" do
86
+ Mods::AUTHORITY_ATTRIBS.each { |a|
87
+ @mods_rec.from_str("<mods><recordInfo><recordContentSource #{a}='attr_val'>zzz</recordContentSource></recordInfo></mods>")
88
+ @mods_rec.record_info.recordContentSource.send(a.to_sym).should == ['attr_val']
89
+ }
90
+ end
91
+ end # <recordContentSource>
92
+
93
+ context "<recordCreationDate> child element" do
94
+ it "should be a NodeSet" do
95
+ [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordCreationDate.should be_an_instance_of(Nokogiri::XML::NodeSet) }
96
+ end
97
+ it "recordCreationDate NodeSet should have as many Nodes as there are <recordCreationDate> elements in the xml" do
98
+ [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordCreationDate.size.should == 1 }
99
+ end
100
+ it "text should get element value" do
101
+ @rec_info.recordCreationDate.map { |n| n.text }.should == ['890517']
102
+ @rec_info2.recordCreationDate.map { |n| n.text }.should == ['050921']
103
+ @bnf.recordCreationDate.map { |n| n.text }.should == ['2011-12-07']
104
+ @rlin.recordCreationDate.map { |n| n.text }.should == ['850416']
105
+ end
106
+ it "should recognize encoding attribute" do
107
+ [@rec_info, @rec_info2, @rlin].each { |ri| ri.recordCreationDate.encoding.should == ['marc'] }
108
+ @bnf.recordCreationDate.encoding.should == ['w3cdtf']
109
+ end
110
+ it "should recognize all date attributes" do
111
+ Mods::DATE_ATTRIBS.each { |a|
112
+ @mods_rec.from_str("<mods><recordInfo><recordCreationDate #{a}='attr_val'>zzz</recordCreationDate></recordInfo></mods>")
113
+ @mods_rec.record_info.recordCreationDate.send(a.to_sym).should == ['attr_val']
114
+ }
115
+ end
116
+ end # <recordCreationDate>
117
+
118
+ context "<recordChangeDate> child element" do
119
+ it "should be a NodeSet" do
120
+ [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordChangeDate.should be_an_instance_of(Nokogiri::XML::NodeSet) }
121
+ end
122
+ it "recordChangeDate NodeSet should have as many Nodes as there are <recordChangeDate> elements in the xml" do
123
+ [@rec_info, @rec_info2, @bnf].each { |ri| ri.recordChangeDate.size.should == 0 }
124
+ @rlin.recordChangeDate.size.should == 1
125
+ end
126
+ it "text should get element value" do
127
+ @rlin.recordChangeDate.map { |n| n.text }.should == ['19991012150824.0']
128
+ end
129
+ it "should recognize encoding attribute" do
130
+ @rlin.recordChangeDate.encoding.should == ['iso8601']
131
+ end
132
+ it "should recognize all date attributes" do
133
+ Mods::DATE_ATTRIBS.each { |a|
134
+ @mods_rec.from_str("<mods><recordInfo><recordChangeDate #{a}='attr_val'>zzz</recordChangeDate></recordInfo></mods>")
135
+ @mods_rec.record_info.recordChangeDate.send(a.to_sym).should == ['attr_val']
136
+ }
137
+ end
138
+ end # <recordChangeDate>
139
+
140
+ context "<recordIdentifier> child element" do
141
+ it "should be a NodeSet" do
142
+ [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordIdentifier.should be_an_instance_of(Nokogiri::XML::NodeSet) }
143
+ end
144
+ it "recordIdentifier NodeSet should have as many Nodes as there are <recordIdentifier> elements in the xml" do
145
+ [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordIdentifier.size.should == 1 }
146
+ end
147
+ it "text should get element value" do
148
+ @rec_info.recordIdentifier.map { |n| n.text }.should == ['a9079953']
149
+ @rec_info2.recordIdentifier.map { |n| n.text }.should == ['a8837534']
150
+ @bnf.recordIdentifier.map { |n| n.text }.should == ['']
151
+ @rlin.recordIdentifier.map { |n| n.text }.should == ['a4083219']
152
+ end
153
+ it "should recognize source attribute" do
154
+ [@rec_info, @rec_info2].each { |ri| ri.recordIdentifier.source.should == ['SIRSI'] }
155
+ @bnf.recordIdentifier.source.should == ['BNF 2166']
156
+ @rlin.recordIdentifier.source.should == ['CStRLIN']
157
+ end
158
+ it "should allow a source attribute without element content" do
159
+ @bnf.recordIdentifier.source.should == ['BNF 2166']
160
+ @bnf.recordIdentifier.map { |n| n.text }.should == ['']
161
+ end
162
+ end # <recordIdentifier>
163
+
164
+ context "<recordOrigin> child element" do
165
+ it "should be a NodeSet" do
166
+ [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordOrigin.should be_an_instance_of(Nokogiri::XML::NodeSet) }
167
+ end
168
+ it "recordOrigin NodeSet should have as many Nodes as there are <recordOrigin> elements in the xml" do
169
+ [@rec_info, @rec_info2, @rlin].each { |ri| ri.recordOrigin.size.should == 0 }
170
+ @bnf.recordOrigin.size.should == 1
171
+ end
172
+ it "text should get element value" do
173
+ @mods_rec.from_str("<mods><recordInfo><recordOrigin>human prepared</recordOrigin></recordInfo></mods>")
174
+ @mods_rec.record_info.recordOrigin.map {|n| n.text }.should == ['human prepared']
175
+ @bnf.recordOrigin.map { |n| n.text }.should == ['']
176
+ end
177
+ end # <recordOrigin>
178
+
179
+ context "<languageOfCataloging> child element" do
180
+ it "should be a NodeSet" do
181
+ [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.languageOfCataloging.should be_an_instance_of(Nokogiri::XML::NodeSet) }
182
+ end
183
+ it "languageOfCataloging NodeSet should have as many Nodes as there are <languageOfCataloging> elements in the xml" do
184
+ [@rec_info2, @bnf].each { |ri| ri.languageOfCataloging.size.should == 1 }
185
+ [@rec_info, @rlin].each { |ri| ri.languageOfCataloging.size.should == 0 }
186
+ end
187
+ it "text should get element value" do
188
+ # this example is from http://www.loc.gov/standards/mods/v3/mods-userguide-elements.html
189
+ # though it doesn't match the doc at http://www.loc.gov/standards/mods/mods-outline.html#recordInfo
190
+ @mods_rec.from_str("<mods><recordInfo><languageOfCataloging authority='iso639-2b'>fre</languageOfCataloging></recordInfo></mods>")
191
+ @mods_rec.record_info.languageOfCataloging.map { |n| n.text }.should == ['fre']
192
+ end
193
+ it "authority should get attribute value" do
194
+ # this example is from http://www.loc.gov/standards/mods/v3/mods-userguide-elements.html
195
+ # though it doesn't match the doc at http://www.loc.gov/standards/mods/mods-outline.html#recordInfo
196
+ @mods_rec.from_str("<mods><recordInfo><languageOfCataloging authority='iso639-2b'>fre</languageOfCataloging></recordInfo></mods>")
197
+ @mods_rec.record_info.languageOfCataloging.authority.should == ['iso639-2b']
198
+ end
199
+
200
+ # from http://www.loc.gov/standards/mods/userguide/recordinfo.html#languageofcataloging
201
+ # objectPart attribute defined for consistency with <language> . Unlikely to be used with <languageOfCataloging>
202
+ it "objectType should get attribute value" do
203
+ pending "<languageOfCataloging objectType=''> to be implemented ... maybe ..."
204
+ end
205
+
206
+ context "<languageTerm> child element" do
207
+ it "text should get element value" do
208
+ @rec_info2.languageOfCataloging.languageTerm.map { |n| n.text }.should == ['eng']
209
+ @bnf.languageOfCataloging.languageTerm.map { |n| n.text }.should == ['fra']
210
+ end
211
+ it "should recognize all authority attributes" do
212
+ Mods::AUTHORITY_ATTRIBS.each { |a|
213
+ @mods_rec.from_str("<mods><recordInfo><languageOfCataloging><languageTerm #{a}='attr_val'>zzz</languageTerm></languageOfCataloging></recordInfo></mods>")
214
+ @mods_rec.record_info.languageOfCataloging.languageTerm.send(a.to_sym).should == ['attr_val']
215
+ }
216
+ end
217
+ it "should recognize the type attribute with type_at term" do
218
+ @rec_info2.languageOfCataloging.languageTerm.type_at.should == ['code']
219
+ end
220
+ end # <languageTerm>
221
+
222
+ context "<scriptTerm> child element" do
223
+ it "should do something" do
224
+ pending "<recordInfo><languageOfCataloging><scriptTerm> to be implemented"
225
+ end
226
+ end
227
+ end # <languageOfCataloging>
228
+
229
+ context "<descriptionStandard> child element" do
230
+ it "should be a NodeSet" do
231
+ [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.descriptionStandard.should be_an_instance_of(Nokogiri::XML::NodeSet) }
232
+ end
233
+ it "descriptionStandard NodeSet should have as many Nodes as there are <descriptionStandard> elements in the xml" do
234
+ [@rec_info, @bnf].each { |ri| ri.descriptionStandard.size.should == 0 }
235
+ [@rec_info2, @rlin].each { |ri| ri.descriptionStandard.size.should == 1 }
236
+ end
237
+ it "text should get element value" do
238
+ @rec_info2.descriptionStandard.map { |n| n.text }.should == ['aacr2']
239
+ @rlin.descriptionStandard.map { |n| n.text }.should == ['appm']
240
+ @bnf.descriptionStandard.map { |n| n.text }.should == []
241
+ end
242
+ it "should recognize all authority attributes" do
243
+ Mods::AUTHORITY_ATTRIBS.each { |a|
244
+ @mods_rec.from_str("<mods><recordInfo><descriptionStandard #{a}='attr_val'>zzz</descriptionStandard></recordInfo></mods>")
245
+ @mods_rec.record_info.descriptionStandard.send(a.to_sym).should == ['attr_val']
246
+ }
247
+ end
248
+ end # <descriptionStandard>
249
+
250
+ end # basic <record_info> terminology pieces
251
+ end
@@ -434,7 +434,6 @@ describe "Mods <subject> Element" do
434
434
 
435
435
  end # <occupation>
436
436
 
437
-
438
437
  end # basic subject terminology
439
438
 
440
439
  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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -192,6 +192,7 @@ files:
192
192
  - spec/origin_info_spec.rb
193
193
  - spec/physical_description_spec.rb
194
194
  - spec/reader_spec.rb
195
+ - spec/record_info_spec.rb
195
196
  - spec/spec_helper.rb
196
197
  - spec/subject_spec.rb
197
198
  - spec/title_spec.rb
@@ -210,7 +211,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
210
211
  version: '0'
211
212
  segments:
212
213
  - 0
213
- hash: -2903168770934676746
214
+ hash: 400692064805909387
214
215
  required_rubygems_version: !ruby/object:Gem::Requirement
215
216
  none: false
216
217
  requirements:
@@ -219,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
220
  version: '0'
220
221
  segments:
221
222
  - 0
222
- hash: -2903168770934676746
223
+ hash: 400692064805909387
223
224
  requirements: []
224
225
  rubyforge_project:
225
226
  rubygems_version: 1.8.24
@@ -233,6 +234,7 @@ test_files:
233
234
  - spec/origin_info_spec.rb
234
235
  - spec/physical_description_spec.rb
235
236
  - spec/reader_spec.rb
237
+ - spec/record_info_spec.rb
236
238
  - spec/spec_helper.rb
237
239
  - spec/subject_spec.rb
238
240
  - spec/title_spec.rb