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 CHANGED
@@ -1,5 +1,5 @@
1
1
  PKG_NAME = 'eadcodec'
2
- PKG_VERSION = '0.0.3'
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.3')
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
@@ -0,0 +1,13 @@
1
+ module EAD
2
+ class EADAcqInfo < EADElement
3
+ elname "acqinfo"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :label
10
+
11
+ xmlsubelements
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module EAD
2
+ class EADAltFormAvail < EADElement
3
+ elname "altformavail"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :type
10
+
11
+ xmlsubelements
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module EAD
2
+ class EADAppraisal < EADElement
3
+ elname "appraisal"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+
10
+ xmlsubelements
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module EAD
2
+ class EADArrangement < EADElement
3
+ elname "arrangement"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+
10
+ xmlsubelements
11
+ end
12
+ end
@@ -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
+
@@ -0,0 +1,15 @@
1
+ module EAD
2
+ class EADContainer < EADElement
3
+ elname "container"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :label
10
+ xmlattr :parent
11
+ xmlattr :type
12
+
13
+ xmlsubelements
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ module EAD
2
+ class EADControlAccess < EADElement
3
+ elname :controlaccess
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+
10
+ xmlsubelements
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module EAD
2
+ class EADCustodHist < EADElement
3
+ elname "custodhist"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+
10
+ xmlsubelements
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ module EAD
2
+ class EADDimensions < EADElement
3
+ elname "dimensions"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :label
10
+ xmlattr :type
11
+ xmlattr :unit
12
+
13
+ xmlsubelements
14
+ end
15
+ end
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
@@ -0,0 +1,11 @@
1
+ module EAD
2
+ class EADEvent < EADElement
3
+ elname "event"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :id
8
+
9
+ xmlsubelements
10
+ end
11
+ end
data/lib/EADExtent.rb ADDED
@@ -0,0 +1,15 @@
1
+ module EAD
2
+ class EADExtent < EADElement
3
+ elname "extent"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :label
10
+ xmlattr :type
11
+ xmlattr :unit
12
+
13
+ xmlsubelements
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ module EAD
2
+ class EADFilePlan< EADElement
3
+ elname "fileplan"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+
10
+ xmlsubelements
11
+ end
12
+ end
@@ -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
@@ -0,0 +1,11 @@
1
+ module EAD
2
+ class EADLabel < EADElement
3
+ elname "label"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :id
8
+
9
+ xmlsubelements
10
+ end
11
+ end
data/lib/EADLevel.rb CHANGED
@@ -16,6 +16,7 @@ module EAD
16
16
  xmlsubel :note
17
17
  xmlsubel :relatedmaterial
18
18
  xmlsubel_mult :c
19
+ xmlsubel_mult :dsc
19
20
 
20
21
  attr_reader :parent
21
22
 
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
@@ -0,0 +1,14 @@
1
+ module EAD
2
+ class EADMaterialSpec < EADElement
3
+ elname "materialspec"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :label
10
+ xmlattr :type
11
+
12
+ xmlsubelements
13
+ end
14
+ 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
@@ -0,0 +1,12 @@
1
+ module EAD
2
+ class EADOtherFindAid < EADElement
3
+ elname "otherfindaid"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+
10
+ xmlsubelements
11
+ end
12
+ end
@@ -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
@@ -0,0 +1,13 @@
1
+ module EAD
2
+ class EADProcessInfo < EADElement
3
+ elname "processinfo"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :type
10
+
11
+ xmlsubelements
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module EAD
2
+ class EADRepository < EADElement
3
+ elname "repository"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :label
10
+
11
+ xmlsubelements
12
+ end
13
+ end
@@ -1,29 +1,29 @@
1
1
  require "EAD.rb"
2
2
 
3
3
  module EAD
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
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
- def description_level
22
- 0
23
- end
21
+ def description_level
22
+ 0
23
+ end
24
24
 
25
- def unnumbered?
26
- false
27
- end
28
- end
25
+ def unnumbered?
26
+ false
27
+ end
28
+ end
29
29
  end
@@ -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.partial_export(file)
30
+ c01.start_partial_export(file)
30
31
 
31
- c01 = EAD::EADLevel.new
32
- c01.did = EAD::EADDescription.new
33
- c01.did.head = "abc"
34
- c01.did.unitid = "teste"
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
- c01.scopecontent = sc
44
+ c02.scopecontent = sc
39
45
 
40
- dsc.c << c01
41
- c01.partial_export(file)
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", "Check that the level was added")
51
- element_exists("/ead/archdesc/dsc/c01/did", "Check that the description was added")
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.8.11
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.3
7
- date: 2006-05-29 00:00:00 +01:00
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.3
110
+ version: 0.0.4
91
111
  version:
@@ -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
@@ -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