eadcodec 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +460 -0
- data/README +21 -0
- data/Rakefile +57 -0
- data/lib/EAD.rb +150 -0
- data/lib/EADBiogHist.rb +10 -0
- data/lib/EADDate.rb +24 -0
- data/lib/EADDescription.rb +21 -0
- data/lib/EADDocument.rb +98 -0
- data/lib/EADHeader.rb +70 -0
- data/lib/EADLevel.rb +72 -0
- data/lib/EADNote.rb +24 -0
- data/lib/EADPhysTech.rb +16 -0
- data/lib/EADProfileDesc.rb +17 -0
- data/lib/EADRelatedMaterial.rb +21 -0
- data/lib/EADScopeContent.rb +21 -0
- data/lib/EADStreamParser.rb +40 -0
- data/lib/EADSubordinates.rb +29 -0
- data/lib/EADSubtitle.rb +8 -0
- data/lib/eadcodec.rb +1 -0
- data/test/TestEAD.rb +50 -0
- data/test/TestEADDescription.rb +73 -0
- data/test/TestEADDocument.rb +32 -0
- data/test/TestEADLevel.rb +76 -0
- data/test/TestEADNote.rb +36 -0
- data/test/TestEADPhysTech.rb +44 -0
- data/test/TestEADScopeContent.rb +43 -0
- data/test/TestEADStreamParser.rb +109 -0
- data/test/TestEADSubordinates.rb +33 -0
- data/test/TestEADSubtitle.rb +40 -0
- data/test/TestPartialExport.rb +53 -0
- data/test/TestXMLStreamObjectParser.rb +126 -0
- data/test/examples/example1.xml +454 -0
- data/test/examples/example2.xml +313 -0
- data/test/examples/example2_exported.xml +512 -0
- metadata +86 -0
@@ -0,0 +1,76 @@
|
|
1
|
+
require "TestEAD"
|
2
|
+
require "EADSubordinates"
|
3
|
+
require "EADLevel"
|
4
|
+
|
5
|
+
class TestEADLevel < TestEAD
|
6
|
+
def initialize(*args)
|
7
|
+
super(*args)
|
8
|
+
|
9
|
+
@test_file = "test_ead_level.xml"
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_attrs
|
13
|
+
dsc = EAD::EADSubordinates.new
|
14
|
+
@ead.add_descelem(dsc)
|
15
|
+
|
16
|
+
c01 = EAD::EADLevel.new
|
17
|
+
c01.did = EAD::EADDescription.new
|
18
|
+
c01.phystech = EAD::EADPhysTech.new
|
19
|
+
dsc.add_level(c01)
|
20
|
+
|
21
|
+
c02 = EAD::EADLevel.new
|
22
|
+
c01.add_level(c02)
|
23
|
+
|
24
|
+
c03 = EAD::EADLevel.new
|
25
|
+
c02.add_level(c03)
|
26
|
+
|
27
|
+
export
|
28
|
+
element_exists("/ead/archdesc/dsc/c01", "Check that the level was added")
|
29
|
+
element_exists("/ead/archdesc/dsc/c01/did", "Check that the description was added")
|
30
|
+
element_exists("/ead/archdesc/dsc/c01/phystech", "Check that the phystech was added")
|
31
|
+
element_exists("/ead/archdesc/dsc/c01/c02", "Check that the second level was added")
|
32
|
+
element_exists("/ead/archdesc/dsc/c01/c02/c03", "Check that the third level was added")
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_import
|
36
|
+
import
|
37
|
+
dsc = @ead.descelems[0]
|
38
|
+
assert(dsc.levels[0], "Check that the level was imported")
|
39
|
+
assert(dsc.levels[0].did, "Check that the description was imported")
|
40
|
+
assert(dsc.levels[0].levels[0], "Check that the second level was imported")
|
41
|
+
assert(dsc.levels[0].levels[0].levels[0], "Check that the third level was imported")
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_attrs_unnumbered
|
45
|
+
dsc = EAD::EADSubordinates.new
|
46
|
+
@ead.add_descelem(dsc)
|
47
|
+
|
48
|
+
c01 = EAD::EADLevel.new
|
49
|
+
c01.set_unnumbered
|
50
|
+
c01.did = EAD::EADDescription.new
|
51
|
+
c01.phystech = EAD::EADPhysTech.new
|
52
|
+
dsc.add_level(c01)
|
53
|
+
|
54
|
+
c02 = EAD::EADLevel.new
|
55
|
+
c01.add_level(c02)
|
56
|
+
|
57
|
+
c03 = EAD::EADLevel.new
|
58
|
+
c02.add_level(c03)
|
59
|
+
|
60
|
+
export
|
61
|
+
element_exists("/ead/archdesc/dsc/c", "Check that the level was added")
|
62
|
+
element_exists("/ead/archdesc/dsc/c/did", "Check that the description was added")
|
63
|
+
element_exists("/ead/archdesc/dsc/c/phystech", "Check that the phystech was added")
|
64
|
+
element_exists("/ead/archdesc/dsc/c/c", "Check that the second level was added")
|
65
|
+
element_exists("/ead/archdesc/dsc/c/c/c", "Check that the third level was added")
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_import_unnumbered
|
69
|
+
import
|
70
|
+
dsc = @ead.descelems[0]
|
71
|
+
assert(dsc.levels[0], "Check that the level was imported")
|
72
|
+
assert(dsc.levels[0].did, "Check that the description was imported")
|
73
|
+
assert(dsc.levels[0].levels[0], "Check that the second level was imported")
|
74
|
+
assert(dsc.levels[0].levels[0].levels[0], "Check that the third level was imported")
|
75
|
+
end
|
76
|
+
end
|
data/test/TestEADNote.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require "TestEAD"
|
2
|
+
require "EADNote"
|
3
|
+
|
4
|
+
class TestEADNote < TestEAD
|
5
|
+
def initialize(*args)
|
6
|
+
super(*args)
|
7
|
+
|
8
|
+
@test_file = "test_ead_note.xml"
|
9
|
+
@p = "Test p"
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_attrs
|
13
|
+
dsc = EAD::EADSubordinates.new
|
14
|
+
@ead.add_descelem(dsc)
|
15
|
+
|
16
|
+
c01 = EAD::EADLevel.new
|
17
|
+
dsc.add_level(c01)
|
18
|
+
|
19
|
+
sc = EAD::EADNote.new
|
20
|
+
sc.p << EAD::EADP.new(@p)
|
21
|
+
sc.p << EAD::EADP.new(@p)
|
22
|
+
c01.note = sc
|
23
|
+
|
24
|
+
export
|
25
|
+
element_exists("/ead/archdesc/dsc/c01/note", "Check that the scopecontent was added")
|
26
|
+
compare_xpath(@p, "/ead/archdesc/dsc/c01/note/p")
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def test_import
|
31
|
+
import
|
32
|
+
note = @ead.descelems[0].levels[0].note
|
33
|
+
assert_equal(@p, note.p[0].value)
|
34
|
+
assert_equal(@p, note.p[1].value)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "TestEAD"
|
2
|
+
|
3
|
+
class TestEADPhysTech < TestEAD
|
4
|
+
def initialize(*args)
|
5
|
+
super(*args)
|
6
|
+
@test_file = "test_ead_phystech.xml"
|
7
|
+
@head = "HEADTest"
|
8
|
+
@ptext = "Some Text "
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_export
|
12
|
+
phystech = EAD::EADPhysTech.new
|
13
|
+
phystech.head = @head
|
14
|
+
(1..4).each {|i| phystech.p << EAD::EADP.new(@ptext+i.to_s)}
|
15
|
+
|
16
|
+
did = EAD::EADDescription.new
|
17
|
+
did.head = "head"
|
18
|
+
did.unitid = "id"
|
19
|
+
|
20
|
+
@ead.archdesc.phystech = phystech
|
21
|
+
@ead.archdesc.did = did
|
22
|
+
export
|
23
|
+
|
24
|
+
# Since we've added content it is now valid EAD
|
25
|
+
validate_dtd
|
26
|
+
|
27
|
+
element_exists("/ead/archdesc/phystech", "Test did exists")
|
28
|
+
compare_xpath(@head, "/ead/archdesc/phystech/head")
|
29
|
+
(1..4).each do |i|
|
30
|
+
compare_xpath(@ptext+i.to_s, "/ead/archdesc/phystech/p["+i.to_s+"]")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def test_import
|
36
|
+
import
|
37
|
+
phystech = @ead.archdesc.phystech
|
38
|
+
|
39
|
+
assert_equal(@head, phystech.head.value)
|
40
|
+
(1..4).each do |i|
|
41
|
+
assert_equal(@ptext+i.to_s, phystech.p[i-1].value)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "TestEAD"
|
2
|
+
require "EADSubordinates"
|
3
|
+
require "EADLevel"
|
4
|
+
require "EADScopeContent"
|
5
|
+
|
6
|
+
class TestEADScopeContent < TestEAD
|
7
|
+
def initialize(*args)
|
8
|
+
super(*args)
|
9
|
+
|
10
|
+
@test_file = "test_ead_scopecontent.xml"
|
11
|
+
@head = "Test Head"
|
12
|
+
@p = "Test p"
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_attrs
|
16
|
+
dsc = EAD::EADSubordinates.new
|
17
|
+
@ead.add_descelem(dsc)
|
18
|
+
|
19
|
+
c01 = EAD::EADLevel.new
|
20
|
+
dsc.add_level(c01)
|
21
|
+
|
22
|
+
sc = EAD::EADScopeContent.new
|
23
|
+
sc.head = @head
|
24
|
+
sc.p << EAD::EADP.new(@p)
|
25
|
+
sc.p << EAD::EADP.new(@p)
|
26
|
+
c01.scopecontent = sc
|
27
|
+
|
28
|
+
export
|
29
|
+
element_exists("/ead/archdesc/dsc/c01/scopecontent", "Check that the scopecontent was added")
|
30
|
+
compare_xpath(@head, "/ead/archdesc/dsc/c01/scopecontent/head")
|
31
|
+
compare_xpath(@p, "/ead/archdesc/dsc/c01/scopecontent/p")
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def test_import
|
36
|
+
import
|
37
|
+
assert_equal(1, @ead.archdesc.dsc[0].c.size)
|
38
|
+
sc = @ead.archdesc.dsc[0].c[0].scopecontent
|
39
|
+
assert_equal(@head, sc.head.value)
|
40
|
+
assert_equal(@p, sc.p[0].value)
|
41
|
+
assert_equal(@p, sc.p[1].value)
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require "TestEAD"
|
2
|
+
require "EADStreamParser"
|
3
|
+
require "rexml/document"
|
4
|
+
|
5
|
+
class MyEADStreamListener
|
6
|
+
attr_reader :eadheader, :did
|
7
|
+
|
8
|
+
def el_eadheader(el)
|
9
|
+
@eadheader = el
|
10
|
+
end
|
11
|
+
|
12
|
+
def el_did(el)
|
13
|
+
@did = el
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class MyEADStreamListener2
|
18
|
+
attr_reader :dsc, :c01
|
19
|
+
|
20
|
+
def el_dsc(el)
|
21
|
+
@dsc = el
|
22
|
+
end
|
23
|
+
|
24
|
+
def el_c01(el)
|
25
|
+
@c01 = el
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class TestEADStreamParser < TestEAD
|
30
|
+
def initialize(*args)
|
31
|
+
super(*args)
|
32
|
+
|
33
|
+
@test_file = "test_ead_stream_parser.xml"
|
34
|
+
|
35
|
+
@head = "HEADTest"
|
36
|
+
@origination = "somwhere"
|
37
|
+
@unittitle = "Some Title"
|
38
|
+
@unitid = "15235"
|
39
|
+
@abstract = "Some Abstract"
|
40
|
+
@physdesc = "Some Description"
|
41
|
+
@physloc = "Some Location"
|
42
|
+
|
43
|
+
@unitdate = "1/1/2001"
|
44
|
+
@unitdatelabel = "TestLabel"
|
45
|
+
@unitdatetype = "inclusive"
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_base_import
|
49
|
+
did = EAD::EADDescription.new
|
50
|
+
did.head = @head
|
51
|
+
did.origination = @origination
|
52
|
+
did.unittitle = @unittitle
|
53
|
+
did.unitid = @unitid
|
54
|
+
did.abstract = @abstract
|
55
|
+
did.physdesc = @physdesc
|
56
|
+
did.physloc = @physloc
|
57
|
+
|
58
|
+
did.unitdate = EAD::EADUnitDate.new(@unitdate)
|
59
|
+
did.unitdate.label = @unitdatelabel
|
60
|
+
did.unitdate.type = @unitdatetype
|
61
|
+
|
62
|
+
@ead.add_description(did)
|
63
|
+
|
64
|
+
export
|
65
|
+
|
66
|
+
listener = MyEADStreamListener.new
|
67
|
+
parser = EAD::EADStreamParser.new(listener)
|
68
|
+
parser.parse(File.new(@test_file))
|
69
|
+
|
70
|
+
assert(listener.eadheader, "Header was not imported")
|
71
|
+
assert_equal("1", listener.eadheader.eadid.value)
|
72
|
+
assert_equal("Teste", listener.eadheader.eadtitle.value)
|
73
|
+
|
74
|
+
assert(listener.did, "DID was not imported")
|
75
|
+
did = listener.did
|
76
|
+
|
77
|
+
xmlstr = did.create_xml(REXML::Document.new).to_s
|
78
|
+
assert_equal(did.__xml_text.tr(" \n\t",""), xmlstr.tr(" \n\t",""))
|
79
|
+
|
80
|
+
assert_equal(@head, did.head.value)
|
81
|
+
assert_equal(@origination, did.origination.value)
|
82
|
+
assert_equal(@unittitle, did.unittitle.value)
|
83
|
+
assert_equal(@unitid, did.unitid.value)
|
84
|
+
assert_equal(@abstract, did.abstract.value)
|
85
|
+
assert_equal(@physdesc, did.physdesc.value)
|
86
|
+
assert_equal(@physloc, did.physloc.value)
|
87
|
+
|
88
|
+
assert_equal(@unitdate, did.unitdate.value)
|
89
|
+
assert_equal(@unitdatelabel, did.unitdate.label)
|
90
|
+
assert_equal(@unitdatetype, did.unitdate.type)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_level_numbering
|
94
|
+
dsc = EAD::EADSubordinates.new
|
95
|
+
@ead.add_descelem(dsc)
|
96
|
+
|
97
|
+
c01 = EAD::EADLevel.new
|
98
|
+
dsc.add_level(c01)
|
99
|
+
|
100
|
+
export
|
101
|
+
|
102
|
+
listener = MyEADStreamListener2.new
|
103
|
+
parser = EAD::EADStreamParser.new(listener)
|
104
|
+
parser.parse(File.new(@test_file))
|
105
|
+
|
106
|
+
assert(listener.dsc, "DSC was not imported")
|
107
|
+
assert_equal(listener.dsc.element_id, listener.c01.parent_id)
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "TestEAD"
|
2
|
+
require "EADSubordinates"
|
3
|
+
|
4
|
+
class TestEADSubordinates < TestEAD
|
5
|
+
|
6
|
+
def initialize(*args)
|
7
|
+
super(*args)
|
8
|
+
|
9
|
+
@test_file = "test_ead_subordinates.xml"
|
10
|
+
|
11
|
+
@type = "combined"
|
12
|
+
@head = "Some head"
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_attrs
|
16
|
+
dsc = EAD::EADSubordinates.new
|
17
|
+
dsc.type = @type
|
18
|
+
dsc.head = @head
|
19
|
+
|
20
|
+
@ead.add_descelem(dsc)
|
21
|
+
export
|
22
|
+
compare_xpath(@type, "/ead/archdesc/dsc/@type")
|
23
|
+
compare_xpath(@head, "/ead/archdesc/dsc/head")
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_import
|
27
|
+
import
|
28
|
+
dsc = @ead.descelems[0]
|
29
|
+
|
30
|
+
assert_equal(@type, dsc.type)
|
31
|
+
assert_equal(@head, dsc.head.value)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "TestEAD"
|
2
|
+
require "EADSubtitle"
|
3
|
+
|
4
|
+
class TestEADSubtitle < TestEAD
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
@test_file = "test_ead_subtitle.xml"
|
8
|
+
@abbr = "testeabbr"
|
9
|
+
@text = "ABCD"
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_base_export
|
13
|
+
titlestmt = @ead.eadheader.filedesc.titlestmt
|
14
|
+
|
15
|
+
st = titlestmt.subtitle = EAD::EADSubtitle.new
|
16
|
+
st.subelements << @text
|
17
|
+
st.subelements << EAD::EADAbbr.new(@abbr)
|
18
|
+
st.subelements << @text
|
19
|
+
st.subelements << EAD::EADAbbr.new(@abbr)
|
20
|
+
|
21
|
+
export
|
22
|
+
# The base document has an empty archdesc and is thus not valid EAD
|
23
|
+
# Just check for well-formed XML, although REXML will probably never
|
24
|
+
# output anything else.
|
25
|
+
validate_well_formed
|
26
|
+
|
27
|
+
compare_xpath("1", "/ead/eadheader/eadid")
|
28
|
+
compare_xpath("Teste", "/ead/eadheader/filedesc/titlestmt/titleproper")
|
29
|
+
compare_xpath(@abbr, "/ead/eadheader/filedesc/titlestmt/subtitle/abbr")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_base_import
|
33
|
+
import
|
34
|
+
st = @ead.eadheader.filedesc.titlestmt.subtitle
|
35
|
+
assert_equal(@text, st.subelements[0].to_s)
|
36
|
+
assert_equal(@abbr, st.subelements[1].to_s)
|
37
|
+
assert_equal(@text, st.subelements[2].to_s)
|
38
|
+
assert_equal(@abbr, st.subelements[3].to_s)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "TestEAD"
|
2
|
+
|
3
|
+
class TestPartialExport < TestEAD
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@test_file = "test_ead_partial_export.xml"
|
7
|
+
@head = "Test head"
|
8
|
+
@type = "combined"
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_partial_export
|
12
|
+
file = File.open(@test_file, "w")
|
13
|
+
|
14
|
+
did = EAD::EADDescription.new
|
15
|
+
did.head = "abc"
|
16
|
+
did.unitid = "teste"
|
17
|
+
@ead.archdesc.did = did
|
18
|
+
|
19
|
+
dsc = EAD::EADSubordinates.new
|
20
|
+
dsc.type = @type
|
21
|
+
@ead.archdesc.dsc << dsc
|
22
|
+
|
23
|
+
c01 = EAD::EADLevel.new
|
24
|
+
c01.did = EAD::EADDescription.new
|
25
|
+
c01.did.head = "abc"
|
26
|
+
c01.did.unitid = "teste"
|
27
|
+
|
28
|
+
dsc.c << c01
|
29
|
+
c01.partial_export(file)
|
30
|
+
|
31
|
+
c01 = EAD::EADLevel.new
|
32
|
+
c01.did = EAD::EADDescription.new
|
33
|
+
c01.did.head = "abc"
|
34
|
+
c01.did.unitid = "teste"
|
35
|
+
sc = EAD::EADScopeContent.new
|
36
|
+
sc.p << EAD::EADP.new('value1')
|
37
|
+
sc.p << EAD::EADP.new('value2')
|
38
|
+
c01.scopecontent = sc
|
39
|
+
|
40
|
+
dsc.c << c01
|
41
|
+
c01.partial_export(file)
|
42
|
+
|
43
|
+
@ead.end_partial_export(file)
|
44
|
+
|
45
|
+
file.close
|
46
|
+
|
47
|
+
validate_dtd
|
48
|
+
compare_xpath("fonds", "/ead/archdesc/@level")
|
49
|
+
compare_xpath(@type, "/ead/archdesc/dsc/@type")
|
50
|
+
element_exists("/ead/archdesc/dsc/c01", "Check that the level was added")
|
51
|
+
element_exists("/ead/archdesc/dsc/c01/did", "Check that the description was added")
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
$-w = true
|
2
|
+
|
3
|
+
require "test/unit"
|
4
|
+
require "xmlcodec"
|
5
|
+
require "EAD"
|
6
|
+
require "TestEAD"
|
7
|
+
|
8
|
+
class MyStreamListener
|
9
|
+
attr_reader :ead
|
10
|
+
def el_ead(el)
|
11
|
+
@ead = el.get_object
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class MyConsumingStreamListener
|
16
|
+
attr_reader :ead
|
17
|
+
def el_ead(el)
|
18
|
+
@ead = el.get_object
|
19
|
+
end
|
20
|
+
|
21
|
+
def el_c02(el)
|
22
|
+
el.consume
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class TestXMLStreamObjectParser < TestEAD
|
27
|
+
def initialize(*args)
|
28
|
+
super(*args)
|
29
|
+
|
30
|
+
@test_file = "test_ead_stream_object_parser.xml"
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_import
|
34
|
+
@ead.eadheader.id = "1"
|
35
|
+
|
36
|
+
dsc = EAD::EADSubordinates.new
|
37
|
+
@ead.add_descelem(dsc)
|
38
|
+
|
39
|
+
c01 = EAD::EADLevel.new
|
40
|
+
c01.did = EAD::EADDescription.new
|
41
|
+
c01.phystech = EAD::EADPhysTech.new
|
42
|
+
dsc.add_level(c01)
|
43
|
+
|
44
|
+
c02 = EAD::EADLevel.new
|
45
|
+
c01.add_level(c02)
|
46
|
+
|
47
|
+
c03 = EAD::EADLevel.new
|
48
|
+
c02.add_level(c03)
|
49
|
+
|
50
|
+
export
|
51
|
+
listener = MyStreamListener.new
|
52
|
+
parser = XMLCodec::XMLStreamObjectParser.new(listener)
|
53
|
+
parser.parse(File.new(@test_file))
|
54
|
+
@ead = listener.ead
|
55
|
+
|
56
|
+
assert_equal(@ead, parser.top_element)
|
57
|
+
|
58
|
+
assert_equal("1", @ead.eadheader.eadid.value)
|
59
|
+
assert_equal("1", @ead.eadheader.id)
|
60
|
+
assert_equal("Teste", @ead.eadheader.eadtitle.value)
|
61
|
+
|
62
|
+
dsc = @ead.descelems[0]
|
63
|
+
assert(dsc.levels[0], "Check that the level was imported")
|
64
|
+
assert(dsc.levels[0].did, "Check that the description was imported")
|
65
|
+
assert(dsc.levels[0].levels[0], "Check that the second level was imported")
|
66
|
+
assert(dsc.levels[0].levels[0].levels[0], "Check that the third level was imported")
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_consume
|
70
|
+
@ead.eadheader.id = "1"
|
71
|
+
|
72
|
+
dsc = EAD::EADSubordinates.new
|
73
|
+
@ead.add_descelem(dsc)
|
74
|
+
|
75
|
+
c01 = EAD::EADLevel.new
|
76
|
+
c01.did = EAD::EADDescription.new
|
77
|
+
c01.phystech = EAD::EADPhysTech.new
|
78
|
+
dsc.add_level(c01)
|
79
|
+
|
80
|
+
c02 = EAD::EADLevel.new
|
81
|
+
c01.add_level(c02)
|
82
|
+
|
83
|
+
c03 = EAD::EADLevel.new
|
84
|
+
c02.add_level(c03)
|
85
|
+
|
86
|
+
export
|
87
|
+
|
88
|
+
listener = MyConsumingStreamListener.new
|
89
|
+
parser = XMLCodec::XMLStreamObjectParser.new(listener)
|
90
|
+
parser.parse(File.new(@test_file))
|
91
|
+
@ead = listener.ead
|
92
|
+
|
93
|
+
dsc = @ead.descelems[0]
|
94
|
+
assert(dsc.levels[0], "Check that the level was imported")
|
95
|
+
assert(dsc.levels[0].did, "Check that the description was imported")
|
96
|
+
assert_equal(0, dsc.levels[0].levels.size, "Check that c03 was consumed")
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_numbering
|
100
|
+
@ead.eadheader.id = "1"
|
101
|
+
|
102
|
+
dsc = EAD::EADSubordinates.new
|
103
|
+
@ead.add_descelem(dsc)
|
104
|
+
|
105
|
+
c01 = EAD::EADLevel.new
|
106
|
+
c01.did = EAD::EADDescription.new
|
107
|
+
c01.phystech = EAD::EADPhysTech.new
|
108
|
+
dsc.add_level(c01)
|
109
|
+
|
110
|
+
export
|
111
|
+
|
112
|
+
listener = MyStreamListener.new
|
113
|
+
parser = XMLCodec::XMLStreamObjectParser.new(listener)
|
114
|
+
parser.parse(File.new(@test_file))
|
115
|
+
@ead = listener.ead
|
116
|
+
|
117
|
+
dsc = @ead.descelems[0]
|
118
|
+
c01 = dsc.levels[0]
|
119
|
+
|
120
|
+
assert(dsc.element_id)
|
121
|
+
assert(dsc.parent_id)
|
122
|
+
assert(c01.element_id)
|
123
|
+
assert(c01.parent_id)
|
124
|
+
assert_equal(c01.parent_id, dsc.element_id)
|
125
|
+
end
|
126
|
+
end
|