eadcodec 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/lib/EAD.rb +93 -4
- data/lib/EADAcqInfo.rb +13 -0
- data/lib/EADAltFormAvail.rb +13 -0
- data/lib/EADAppraisal.rb +12 -0
- data/lib/EADArrangement.rb +12 -0
- data/lib/EADChronList.rb +27 -0
- data/lib/EADContainer.rb +15 -0
- data/lib/EADControlAccess.rb +12 -0
- data/lib/EADCustodHist.rb +12 -0
- data/lib/EADDimensions.rb +15 -0
- data/lib/EADDocument.rb +11 -3
- data/lib/EADEvent.rb +11 -0
- data/lib/EADExtent.rb +15 -0
- data/lib/EADFilePlan.rb +12 -0
- data/lib/EADGeogName.rb +15 -0
- data/lib/EADLabel.rb +11 -0
- data/lib/EADLevel.rb +1 -0
- data/lib/EADList.rb +36 -0
- data/lib/EADMaterialSpec.rb +14 -0
- data/lib/EADName.rb +17 -0
- data/lib/EADOtherFindAid.rb +12 -0
- data/lib/EADPhysFacet.rb +17 -0
- data/lib/EADProcessInfo.rb +13 -0
- data/lib/EADRepository.rb +13 -0
- data/lib/EADSubordinates.rb +23 -23
- data/test/TestPartialExport.rb +18 -10
- metadata +26 -6
- data/lib/EADStreamParser.rb +0 -40
- data/test/TestEADStreamParser.rb +0 -109
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
PKG_NAME = 'eadcodec'
|
2
|
-
PKG_VERSION = '0.0.
|
2
|
+
PKG_VERSION = '0.0.4'
|
3
3
|
|
4
4
|
require 'rake'
|
5
5
|
require 'rake/testtask'
|
@@ -30,7 +30,7 @@ spec = Gem::Specification.new do |s|
|
|
30
30
|
s.author = 'Pedro Côrte-Real'
|
31
31
|
s.email = 'pedrocr@gmail.com'
|
32
32
|
s.requirements << 'xmlcodec'
|
33
|
-
s.add_dependency('xmlcodec', '>= 0.0.
|
33
|
+
s.add_dependency('xmlcodec', '>= 0.0.4')
|
34
34
|
s.require_path = 'lib'
|
35
35
|
s.autorequire = 'rake'
|
36
36
|
s.files = PKG_FILES
|
data/lib/EAD.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require "rexml/document"
|
2
2
|
require "xmlcodec"
|
3
|
-
include REXML
|
4
3
|
|
5
4
|
# This module includes all the support for EAD import/export. The main class to
|
6
5
|
# use is EADDocument that is a subclass of XMLUtils::XMLElement. All elements
|
@@ -46,9 +45,6 @@ module EAD
|
|
46
45
|
# Create a bunch of classes for simple elements with just values
|
47
46
|
# Most of these actually can have children so they should be promoted to
|
48
47
|
# actual classes.
|
49
|
-
sclass "EADOrigination", "origination"
|
50
|
-
sclass "EADUnitTitle", "unittitle"
|
51
|
-
sclass "EADUnitId", "unitid"
|
52
48
|
sclass "EADAbstract", "abstract"
|
53
49
|
sclass "EADPhysDesc", "physdesc"
|
54
50
|
sclass "EADPhysLoc", "physloc"
|
@@ -68,6 +64,77 @@ module EAD
|
|
68
64
|
sclass "EADRef", "ref"
|
69
65
|
sclass "EADLinkGrp", "linkgrp"
|
70
66
|
sclass "EADTitle", "title"
|
67
|
+
|
68
|
+
class EADOrigination < EADElement
|
69
|
+
elname "origination"
|
70
|
+
|
71
|
+
xmlattr :altrender
|
72
|
+
xmlattr :audience
|
73
|
+
xmlattr :encodinganalog
|
74
|
+
xmlattr :id
|
75
|
+
xmlattr :label
|
76
|
+
|
77
|
+
xmlsubelements
|
78
|
+
|
79
|
+
def initialize(string=nil)
|
80
|
+
if string
|
81
|
+
self.subelements << string
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def value
|
86
|
+
self.subelements[0].to_s
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class EADUnitTitle < EADElement
|
91
|
+
elname "unittitle"
|
92
|
+
|
93
|
+
xmlattr :altrender
|
94
|
+
xmlattr :audience
|
95
|
+
xmlattr :encodinganalog
|
96
|
+
xmlattr :id
|
97
|
+
xmlattr :label
|
98
|
+
xmlattr :type
|
99
|
+
|
100
|
+
xmlsubelements
|
101
|
+
|
102
|
+
def initialize(string=nil)
|
103
|
+
if string
|
104
|
+
self.subelements << string
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def value
|
109
|
+
self.subelements[0].to_s
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
class EADUnitId < EADElement
|
114
|
+
elname "unitid"
|
115
|
+
|
116
|
+
xmlattr :altrender
|
117
|
+
xmlattr :audience
|
118
|
+
xmlattr :countrycode
|
119
|
+
xmlattr :encodinganalog
|
120
|
+
xmlattr :id
|
121
|
+
xmlattr :identifier
|
122
|
+
xmlattr :label
|
123
|
+
xmlattr :repositorycode
|
124
|
+
xmlattr :type
|
125
|
+
|
126
|
+
xmlsubelements
|
127
|
+
|
128
|
+
def initialize(string=nil)
|
129
|
+
if string
|
130
|
+
self.subelements << string
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def value
|
135
|
+
self.subelements[0].to_s
|
136
|
+
end
|
137
|
+
end
|
71
138
|
|
72
139
|
# The class for the 'head' element. For convenience it can be initialized
|
73
140
|
# with a string value that is used as the first subelement.
|
@@ -130,6 +197,28 @@ require "EADHeader"
|
|
130
197
|
require "EADBiogHist"
|
131
198
|
require "EADDocument"
|
132
199
|
require "EADLang"
|
200
|
+
require 'EADExtent'
|
201
|
+
require 'EADGeogName'
|
202
|
+
require 'EADRepository'
|
203
|
+
require 'EADAcqInfo'
|
204
|
+
require 'EADChronList'
|
205
|
+
require 'EADEvent'
|
206
|
+
require 'EADControlAccess'
|
207
|
+
require 'EADList'
|
208
|
+
require 'EADLabel'
|
209
|
+
require 'EADCustodHist'
|
210
|
+
require 'EADFilePlan'
|
211
|
+
require 'EADProcessInfo'
|
212
|
+
require 'EADName'
|
213
|
+
require 'EADDimensions'
|
214
|
+
require 'EADArrangement'
|
215
|
+
require 'EADContainer'
|
216
|
+
require 'EADAltFormAvail'
|
217
|
+
require 'EADPhysFacet'
|
218
|
+
require 'EADMaterialSpec'
|
219
|
+
require 'EADAppraisal'
|
220
|
+
require 'EADOtherFindAid'
|
221
|
+
|
133
222
|
|
134
223
|
module EAD
|
135
224
|
def self.c_levels
|
data/lib/EADAcqInfo.rb
ADDED
data/lib/EADAppraisal.rb
ADDED
data/lib/EADChronList.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module EAD
|
2
|
+
class EADChronList < EADElement
|
3
|
+
elname "chronlist"
|
4
|
+
|
5
|
+
xmlattr :altrender
|
6
|
+
xmlattr :audience
|
7
|
+
xmlattr :encodinganalog
|
8
|
+
xmlattr :id
|
9
|
+
|
10
|
+
xmlsubelements
|
11
|
+
end
|
12
|
+
|
13
|
+
class EADChronItem < EADElement
|
14
|
+
elname "chronitem"
|
15
|
+
|
16
|
+
xmlattr :altrender
|
17
|
+
xmlattr :audience
|
18
|
+
xmlattr :encodinganalog
|
19
|
+
xmlattr :id
|
20
|
+
|
21
|
+
xmlsubel :date
|
22
|
+
xmlsubel :event
|
23
|
+
xmlsubel :eventgrp
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
data/lib/EADContainer.rb
ADDED
data/lib/EADDocument.rb
CHANGED
@@ -5,7 +5,15 @@ module EAD
|
|
5
5
|
class EADArchDesc < EADElement
|
6
6
|
elname "archdesc"
|
7
7
|
|
8
|
+
xmlattr :altrender
|
9
|
+
xmlattr :audience
|
10
|
+
xmlattr :encodinganalog
|
11
|
+
xmlattr :id
|
8
12
|
xmlattr :level
|
13
|
+
xmlattr :otherlevel
|
14
|
+
xmlattr :relatedencoding
|
15
|
+
xmlattr :type
|
16
|
+
|
9
17
|
xmlsubel :did
|
10
18
|
xmlsubel :bioghist
|
11
19
|
xmlsubel :scopecontent
|
@@ -76,9 +84,9 @@ module EAD
|
|
76
84
|
end
|
77
85
|
|
78
86
|
def export(filename)
|
79
|
-
doc = Document.new
|
80
|
-
doc << XMLDecl.new("1.0", "UTF-8")
|
81
|
-
doc << DocType.new("ead SYSTEM", '"file:///home/pedrocr/ead.dtd"')
|
87
|
+
doc = REXML::Document.new
|
88
|
+
doc << REXML::XMLDecl.new("1.0", "UTF-8")
|
89
|
+
doc << REXML::DocType.new("ead SYSTEM", '"file:///home/pedrocr/ead.dtd"')
|
82
90
|
create_xml(doc)
|
83
91
|
output = File.open(filename, "w")
|
84
92
|
|
data/lib/EADEvent.rb
ADDED
data/lib/EADExtent.rb
ADDED
data/lib/EADFilePlan.rb
ADDED
data/lib/EADGeogName.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module EAD
|
2
|
+
class EADGeogName < EADElement
|
3
|
+
elname 'geogname'
|
4
|
+
|
5
|
+
xmlattr :altrender
|
6
|
+
xmlattr :audience
|
7
|
+
xmlattr :authfilenumber
|
8
|
+
xmlattr :encondinganalog
|
9
|
+
xmlattr :id
|
10
|
+
xmlattr :normal
|
11
|
+
xmlattr :role
|
12
|
+
xmlattr :rules
|
13
|
+
xmlattr :source
|
14
|
+
end
|
15
|
+
end
|
data/lib/EADLabel.rb
ADDED
data/lib/EADLevel.rb
CHANGED
data/lib/EADList.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module EAD
|
2
|
+
class EADList < EADElement
|
3
|
+
elname "list"
|
4
|
+
|
5
|
+
xmlattr :altrender
|
6
|
+
xmlattr :audience
|
7
|
+
xmlattr :continuation
|
8
|
+
xmlattr :id
|
9
|
+
xmlattr :mark
|
10
|
+
xmlattr :numeration
|
11
|
+
xmlattr :type
|
12
|
+
|
13
|
+
xmlsubelements
|
14
|
+
end
|
15
|
+
|
16
|
+
class EADDefItem < EADElement
|
17
|
+
elname "defitem"
|
18
|
+
|
19
|
+
xmlattr :altrender
|
20
|
+
xmlattr :audience
|
21
|
+
xmlattr :id
|
22
|
+
|
23
|
+
xmlsubel :label
|
24
|
+
xmlsubel :item
|
25
|
+
end
|
26
|
+
|
27
|
+
class EADItem < EADElement
|
28
|
+
elname "item"
|
29
|
+
|
30
|
+
xmlattr :altrender
|
31
|
+
xmlattr :audience
|
32
|
+
xmlattr :id
|
33
|
+
|
34
|
+
xmlsubelements
|
35
|
+
end
|
36
|
+
end
|
data/lib/EADName.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module EAD
|
2
|
+
class EADName < EADElement
|
3
|
+
elname "name"
|
4
|
+
|
5
|
+
xmlattr :altrender
|
6
|
+
xmlattr :audience
|
7
|
+
xmlattr :authfilenumber
|
8
|
+
xmlattr :encodinganalog
|
9
|
+
xmlattr :id
|
10
|
+
xmlattr :normal
|
11
|
+
xmlattr :role
|
12
|
+
xmlattr :rules
|
13
|
+
xmlattr :source
|
14
|
+
|
15
|
+
xmlsubelements
|
16
|
+
end
|
17
|
+
end
|
data/lib/EADPhysFacet.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module EAD
|
2
|
+
class EADPhysFacet < EADElement
|
3
|
+
elname "physfacet"
|
4
|
+
|
5
|
+
xmlattr :altrender
|
6
|
+
xmlattr :audience
|
7
|
+
xmlattr :encodinganalog
|
8
|
+
xmlattr :id
|
9
|
+
xmlattr :label
|
10
|
+
xmlattr :rules
|
11
|
+
xmlattr :source
|
12
|
+
xmlattr :type
|
13
|
+
xmlattr :unit
|
14
|
+
|
15
|
+
xmlsubelements
|
16
|
+
end
|
17
|
+
end
|
data/lib/EADSubordinates.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
require "EAD.rb"
|
2
2
|
|
3
3
|
module EAD
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
4
|
+
class EADSubordinates < EADElement
|
5
|
+
elname "dsc"
|
6
|
+
|
7
|
+
include EADLevels
|
8
|
+
|
9
|
+
xmlattr :altrender
|
10
|
+
xmlattr :audience
|
11
|
+
xmlattr :encondinganalog
|
12
|
+
xmlattr :id
|
13
|
+
xmlattr :othertype
|
14
|
+
xmlattr :tpattern
|
15
|
+
xmlattr :type
|
16
|
+
|
17
|
+
xmlsubel :head
|
18
|
+
xmlsubel_mult :p
|
19
|
+
xmlsubel_mult :c
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
def description_level
|
22
|
+
0
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
def unnumbered?
|
26
|
+
false
|
27
|
+
end
|
28
|
+
end
|
29
29
|
end
|
data/test/TestPartialExport.rb
CHANGED
@@ -24,21 +24,27 @@ class TestPartialExport < TestEAD
|
|
24
24
|
c01.did = EAD::EADDescription.new
|
25
25
|
c01.did.head = "abc"
|
26
26
|
c01.did.unitid = "teste"
|
27
|
+
c01.did.unittitle = "teste"
|
27
28
|
|
28
29
|
dsc.c << c01
|
29
|
-
c01.
|
30
|
+
c01.start_partial_export(file)
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
c01.
|
34
|
-
|
32
|
+
dsc = EAD::EADSubordinates.new
|
33
|
+
dsc.type = @type
|
34
|
+
c01.dsc << dsc
|
35
|
+
|
36
|
+
c02 = EAD::EADLevel.new
|
37
|
+
c02.did = EAD::EADDescription.new
|
38
|
+
c02.did.head = "abc"
|
39
|
+
c02.did.unitid = "teste"
|
40
|
+
c02.did.unittitle = "teste"
|
35
41
|
sc = EAD::EADScopeContent.new
|
36
42
|
sc.p << EAD::EADP.new('value1')
|
37
43
|
sc.p << EAD::EADP.new('value2')
|
38
|
-
|
44
|
+
c02.scopecontent = sc
|
39
45
|
|
40
|
-
dsc.c <<
|
41
|
-
|
46
|
+
dsc.c << c02
|
47
|
+
c02.start_partial_export(file)
|
42
48
|
|
43
49
|
@ead.end_partial_export(file)
|
44
50
|
|
@@ -47,7 +53,9 @@ class TestPartialExport < TestEAD
|
|
47
53
|
validate_dtd
|
48
54
|
compare_xpath("fonds", "/ead/archdesc/@level")
|
49
55
|
compare_xpath(@type, "/ead/archdesc/dsc/@type")
|
50
|
-
element_exists("/ead/archdesc/dsc/c01", "
|
51
|
-
element_exists("/ead/archdesc/dsc/c01/did", "
|
56
|
+
element_exists("/ead/archdesc/dsc/c01", "the first level was not added")
|
57
|
+
element_exists("/ead/archdesc/dsc/c01/did", "the first level description was not added")
|
58
|
+
element_exists("/ead/archdesc/dsc/c01/dsc/c01", "the second level was not added")
|
59
|
+
element_exists("/ead/archdesc/dsc/c01/dsc/c01/did", "the second level description was not added")
|
52
60
|
end
|
53
61
|
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.0
|
3
3
|
specification_version: 1
|
4
4
|
name: eadcodec
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.0.4
|
7
|
+
date: 2006-07-06 00:00:00 +01:00
|
8
8
|
summary: Importer/Exporter for the EAD XML format
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
25
|
platform: ruby
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
|
+
post_install_message:
|
28
29
|
authors:
|
29
30
|
- "Pedro C\xC3\xB4rte-Real"
|
30
31
|
files:
|
@@ -36,7 +37,6 @@ files:
|
|
36
37
|
- lib/EADPhysTech.rb
|
37
38
|
- lib/EADBiogHist.rb
|
38
39
|
- lib/EADHeader.rb
|
39
|
-
- lib/EADStreamParser.rb
|
40
40
|
- lib/EADSubtitle.rb
|
41
41
|
- lib/EADDate.rb
|
42
42
|
- lib/EADDocument.rb
|
@@ -45,6 +45,27 @@ files:
|
|
45
45
|
- lib/eadcodec.rb
|
46
46
|
- lib/EADSubordinates.rb
|
47
47
|
- lib/EADLang.rb
|
48
|
+
- lib/EADExtent.rb
|
49
|
+
- lib/EADGeogName.rb
|
50
|
+
- lib/EADRepository.rb
|
51
|
+
- lib/EADAcqInfo.rb
|
52
|
+
- lib/EADChronList.rb
|
53
|
+
- lib/EADEvent.rb
|
54
|
+
- lib/EADControlAccess.rb
|
55
|
+
- lib/EADList.rb
|
56
|
+
- lib/EADLabel.rb
|
57
|
+
- lib/EADCustodHist.rb
|
58
|
+
- lib/EADFilePlan.rb
|
59
|
+
- lib/EADProcessInfo.rb
|
60
|
+
- lib/EADName.rb
|
61
|
+
- lib/EADDimensions.rb
|
62
|
+
- lib/EADArrangement.rb
|
63
|
+
- lib/EADContainer.rb
|
64
|
+
- lib/EADAltFormAvail.rb
|
65
|
+
- lib/EADPhysFacet.rb
|
66
|
+
- lib/EADMaterialSpec.rb
|
67
|
+
- lib/EADAppraisal.rb
|
68
|
+
- lib/EADOtherFindAid.rb
|
48
69
|
- test/TestXMLStreamObjectParser.rb
|
49
70
|
- test/TestEADDescription.rb
|
50
71
|
- test/TestEADScopeContent.rb
|
@@ -52,7 +73,6 @@ files:
|
|
52
73
|
- test/TestEADNote.rb
|
53
74
|
- test/TestEADPhysTech.rb
|
54
75
|
- test/TestEADLevel.rb
|
55
|
-
- test/TestEADStreamParser.rb
|
56
76
|
- test/TestEADSubtitle.rb
|
57
77
|
- test/TestEADDocument.rb
|
58
78
|
- test/TestEAD.rb
|
@@ -87,5 +107,5 @@ dependencies:
|
|
87
107
|
requirements:
|
88
108
|
- - ">="
|
89
109
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.0.
|
110
|
+
version: 0.0.4
|
91
111
|
version:
|
data/lib/EADStreamParser.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require "XMLStreamParser"
|
2
|
-
require "rexml/document"
|
3
|
-
require "EAD"
|
4
|
-
|
5
|
-
module EAD
|
6
|
-
# This is a stream parser that will output EAD element objects. To use it
|
7
|
-
# all you have to do is create a listener that responds to methods called
|
8
|
-
# el_<eadelementname> with one argument. The argument passed will be the
|
9
|
-
# object with the content of the EAD element.
|
10
|
-
#
|
11
|
-
# The actual stream parsing is done with XMLUtils::XMLStreamParser.
|
12
|
-
class EADStreamParser
|
13
|
-
def initialize(listener=nil)
|
14
|
-
@listener = listener
|
15
|
-
end
|
16
|
-
|
17
|
-
# Parse the text of the EAD file. This can be any IO capable object, like a
|
18
|
-
# string or an open file.
|
19
|
-
def parse(text)
|
20
|
-
parser = XMLUtils::XMLStreamParser.new(self)
|
21
|
-
parser.parse(text)
|
22
|
-
end
|
23
|
-
|
24
|
-
# This is the element method that is called by XMLStreamParser everytime
|
25
|
-
# a XML element is finished.
|
26
|
-
def element(el) #:nodoc:
|
27
|
-
method_sym = ("el_"+el.name).to_sym
|
28
|
-
if @listener.respond_to?(method_sym)
|
29
|
-
cl = XMLCodec::XMLElement.get_element_class(el.name.to_sym)
|
30
|
-
eadelement = cl.import_xml_text(el.content)
|
31
|
-
eadelement.element_id = el.element_id
|
32
|
-
eadelement.parent_id = el.parent_id
|
33
|
-
eadelement.__xml_text = el.content
|
34
|
-
|
35
|
-
@listener.send(method_sym, eadelement)
|
36
|
-
el.consume
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
data/test/TestEADStreamParser.rb
DELETED
@@ -1,109 +0,0 @@
|
|
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
|