eadcodec 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. data/Rakefile +12 -5
  2. data/lib/eadcodec.rb +76 -1
  3. data/lib/elements/accessrestrict.rb +12 -0
  4. data/lib/elements/accruals.rb +11 -0
  5. data/lib/elements/acqinfo.rb +12 -0
  6. data/lib/elements/altformavail.rb +12 -0
  7. data/lib/elements/appraisal.rb +11 -0
  8. data/lib/elements/archdesc.rb +32 -0
  9. data/lib/elements/arrangement.rb +11 -0
  10. data/lib/elements/bibliography.rb +12 -0
  11. data/lib/elements/bioghist.rb +11 -0
  12. data/lib/elements/c.rb +65 -0
  13. data/lib/elements/chronitem.rb +12 -0
  14. data/lib/elements/chronlist.rb +12 -0
  15. data/lib/elements/container.rb +13 -0
  16. data/lib/elements/controlaccess.rb +10 -0
  17. data/lib/elements/creation.rb +4 -0
  18. data/lib/elements/custodhist.rb +11 -0
  19. data/lib/elements/date.rb +14 -0
  20. data/lib/elements/defitem.rb +10 -0
  21. data/lib/elements/description.rb +10 -0
  22. data/lib/elements/dimensions.rb +13 -0
  23. data/lib/elements/dsc.rb +21 -0
  24. data/lib/elements/ead.rb +39 -0
  25. data/lib/elements/eadheader.rb +28 -0
  26. data/lib/elements/event.rb +9 -0
  27. data/lib/elements/extent.rb +13 -0
  28. data/lib/elements/filedesc.rb +13 -0
  29. data/lib/elements/fileplan.rb +10 -0
  30. data/lib/elements/geogname.rb +16 -0
  31. data/lib/elements/head.rb +11 -0
  32. data/lib/elements/id.rb +12 -0
  33. data/lib/elements/item.rb +9 -0
  34. data/lib/elements/label.rb +9 -0
  35. data/lib/elements/langmaterial.rb +12 -0
  36. data/lib/elements/language.rb +20 -0
  37. data/lib/elements/list.rb +13 -0
  38. data/lib/elements/materialspec.rb +13 -0
  39. data/lib/elements/name.rb +15 -0
  40. data/lib/elements/note.rb +15 -0
  41. data/lib/elements/odd.rb +13 -0
  42. data/lib/elements/originalsloc.rb +12 -0
  43. data/lib/elements/origination.rb +12 -0
  44. data/lib/elements/otherfindaid.rb +11 -0
  45. data/lib/elements/p.rb +10 -0
  46. data/lib/elements/physdesc.rb +14 -0
  47. data/lib/elements/physfacet.rb +16 -0
  48. data/lib/elements/physloc.rb +14 -0
  49. data/lib/elements/phystech.rb +11 -0
  50. data/lib/elements/processinfo.rb +11 -0
  51. data/lib/elements/profiledesc.rb +10 -0
  52. data/lib/elements/relatedmaterial.rb +12 -0
  53. data/lib/elements/repository.rb +12 -0
  54. data/lib/elements/scopecontent.rb +12 -0
  55. data/lib/elements/subtitle.rb +4 -0
  56. data/lib/elements/titlestmt.rb +12 -0
  57. data/lib/elements/unitdate.rb +7 -0
  58. data/lib/elements/unitid.rb +16 -0
  59. data/lib/elements/unittitle.rb +13 -0
  60. data/lib/elements/userestrict.rb +12 -0
  61. data/test/{TestEADDescription.rb → description_test.rb} +27 -26
  62. data/test/{TestEADDocument.rb → document_test.rb} +2 -2
  63. data/test/level_test.rb +75 -0
  64. data/test/note_test.rb +36 -0
  65. data/test/partial_export_test.rb +63 -0
  66. data/test/phystech_test.rb +45 -0
  67. data/test/scopecontent_test.rb +41 -0
  68. data/test/{TestEADSubordinates.rb → subordinates_test.rb} +7 -8
  69. data/test/{TestEADSubtitle.rb → subtitle_test.rb} +5 -6
  70. data/test/test_helper.rb +45 -0
  71. data/test/xmlsoparser_test.rb +119 -0
  72. metadata +72 -50
  73. data/lib/EAD.rb +0 -229
  74. data/lib/EADAcqInfo.rb +0 -13
  75. data/lib/EADAltFormAvail.rb +0 -13
  76. data/lib/EADAppraisal.rb +0 -12
  77. data/lib/EADArrangement.rb +0 -12
  78. data/lib/EADBiogHist.rb +0 -10
  79. data/lib/EADChronList.rb +0 -27
  80. data/lib/EADContainer.rb +0 -15
  81. data/lib/EADControlAccess.rb +0 -12
  82. data/lib/EADCustodHist.rb +0 -12
  83. data/lib/EADDate.rb +0 -24
  84. data/lib/EADDescription.rb +0 -22
  85. data/lib/EADDimensions.rb +0 -15
  86. data/lib/EADDocument.rb +0 -106
  87. data/lib/EADEvent.rb +0 -11
  88. data/lib/EADExtent.rb +0 -15
  89. data/lib/EADFilePlan.rb +0 -12
  90. data/lib/EADGeogName.rb +0 -15
  91. data/lib/EADHeader.rb +0 -70
  92. data/lib/EADLabel.rb +0 -11
  93. data/lib/EADLang.rb +0 -42
  94. data/lib/EADLevel.rb +0 -73
  95. data/lib/EADList.rb +0 -36
  96. data/lib/EADMaterialSpec.rb +0 -14
  97. data/lib/EADName.rb +0 -17
  98. data/lib/EADNote.rb +0 -24
  99. data/lib/EADOtherFindAid.rb +0 -12
  100. data/lib/EADPhysFacet.rb +0 -17
  101. data/lib/EADPhysTech.rb +0 -16
  102. data/lib/EADProcessInfo.rb +0 -13
  103. data/lib/EADProfileDesc.rb +0 -17
  104. data/lib/EADRelatedMaterial.rb +0 -21
  105. data/lib/EADRepository.rb +0 -13
  106. data/lib/EADScopeContent.rb +0 -21
  107. data/lib/EADSubordinates.rb +0 -29
  108. data/lib/EADSubtitle.rb +0 -8
  109. data/test/TestEAD.rb +0 -50
  110. data/test/TestEADLevel.rb +0 -76
  111. data/test/TestEADNote.rb +0 -36
  112. data/test/TestEADPhysTech.rb +0 -44
  113. data/test/TestEADScopeContent.rb +0 -43
  114. data/test/TestPartialExport.rb +0 -61
  115. data/test/TestXMLStreamObjectParser.rb +0 -126
@@ -0,0 +1,20 @@
1
+ class Language < EADElement
2
+ elname "language"
3
+
4
+ xmlattr :altrender
5
+ xmlattr :audience
6
+ xmlattr :encodinganalog
7
+ xmlattr :id
8
+ xmlattr :langcode
9
+ xmlattr :scriptcode
10
+
11
+ xmlsubelements
12
+
13
+ def initialize(*values)
14
+ if values
15
+ values.each do |v|
16
+ self.subelements << v
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,13 @@
1
+ class List < EADElement
2
+ elname "list"
3
+
4
+ xmlattr :altrender
5
+ xmlattr :audience
6
+ xmlattr :continuation
7
+ xmlattr :id
8
+ xmlattr :mark
9
+ xmlattr :numeration
10
+ xmlattr :type
11
+
12
+ xmlsubelements
13
+ end
@@ -0,0 +1,13 @@
1
+ class MaterialSpec < EADElement
2
+ include WithText
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
@@ -0,0 +1,15 @@
1
+ class Name < EADElement
2
+ elname "name"
3
+
4
+ xmlattr :altrender
5
+ xmlattr :audience
6
+ xmlattr :authfilenumber
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :normal
10
+ xmlattr :role
11
+ xmlattr :rules
12
+ xmlattr :source
13
+
14
+ xmlsubelements
15
+ end
@@ -0,0 +1,15 @@
1
+ class Note < EADElement
2
+ include WithParagraphs
3
+ elname "note"
4
+
5
+ xmlattr :actuate
6
+ xmlattr :altrender
7
+ xmlattr :audience
8
+ xmlattr :encodinganalog
9
+ xmlattr :id
10
+ xmlattr :label
11
+ xmlattr :show
12
+ xmlattr :type
13
+
14
+ xmlsubelements
15
+ end
@@ -0,0 +1,13 @@
1
+ class Odd < EADElement
2
+ include WithParagraphs
3
+
4
+ elname 'odd'
5
+
6
+ xmlattr :altrender
7
+ xmlattr :audience
8
+ xmlattr :encodinganalog
9
+ xmlattr :id
10
+ xmlattr :type
11
+
12
+ xmlsubelements
13
+ end
@@ -0,0 +1,12 @@
1
+ class OriginalsLoc < EADElement
2
+ include WithParagraphs
3
+ elname "originalsloc"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :type
10
+
11
+ xmlsubelements
12
+ end
@@ -0,0 +1,12 @@
1
+ class Origination < EADElement
2
+ include WithText
3
+ elname "origination"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :label
10
+
11
+ xmlsubelements
12
+ end
@@ -0,0 +1,11 @@
1
+ class OtherFindAid < EADElement
2
+ include WithParagraphs
3
+ elname "otherfindaid"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+
10
+ xmlsubelements
11
+ end
data/lib/elements/p.rb ADDED
@@ -0,0 +1,10 @@
1
+ class P < EADElement
2
+ include WithText
3
+ elname "p"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :id
8
+
9
+ xmlsubelements
10
+ end
@@ -0,0 +1,14 @@
1
+ class PhysDesc < EADElement
2
+ include WithText
3
+ elname "physdesc"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :label
10
+ xmlattr :rules
11
+ xmlattr :source
12
+
13
+ xmlsubelements
14
+ end
@@ -0,0 +1,16 @@
1
+ class PhysFacet < EADElement
2
+ include WithText
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
@@ -0,0 +1,14 @@
1
+ class PhysLoc < EADElement
2
+ include WithText
3
+ elname "physloc"
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
@@ -0,0 +1,11 @@
1
+ class PhysTech < EADElement
2
+ include WithParagraphs
3
+
4
+ elname "phystech"
5
+
6
+ def initialize(value=nil)
7
+ self << P.new(value) if value
8
+ end
9
+
10
+ xmlsubelements
11
+ end
@@ -0,0 +1,11 @@
1
+ class ProcessInfo < EADElement
2
+ elname "processinfo"
3
+
4
+ xmlattr :altrender
5
+ xmlattr :audience
6
+ xmlattr :encodinganalog
7
+ xmlattr :id
8
+ xmlattr :type
9
+
10
+ xmlsubelements
11
+ end
@@ -0,0 +1,10 @@
1
+ class ProfileDesc < EADElement
2
+ elname "profiledesc"
3
+
4
+ xmlattr :altrender
5
+ xmlattr :audience
6
+ xmlattr :encodinganalog
7
+ xmlattr :id
8
+
9
+ xmlsubel :creation
10
+ end
@@ -0,0 +1,12 @@
1
+ class RelatedMaterial < EADElement
2
+ include WithParagraphs
3
+ elname "relatedmaterial"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :type
10
+
11
+ xmlsubelements
12
+ end
@@ -0,0 +1,12 @@
1
+ class Repository < EADElement
2
+ include WithText
3
+ elname "repository"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :label
10
+
11
+ xmlsubelements
12
+ end
@@ -0,0 +1,12 @@
1
+ class ScopeContent < EADElement
2
+ include WithParagraphs
3
+
4
+ elname "scopecontent"
5
+
6
+ xmlattr :altrender
7
+ xmlattr :audience
8
+ xmlattr :encodinganalog
9
+ xmlattr :id
10
+
11
+ xmlsubelements
12
+ end
@@ -0,0 +1,4 @@
1
+ class Subtitle < EADElement
2
+ elname "subtitle"
3
+ xmlsubelements
4
+ end
@@ -0,0 +1,12 @@
1
+ class TitleStatement < EADElement
2
+ elname 'titlestmt'
3
+
4
+ xmlsubel :author
5
+ xmlsubel :sponsor
6
+ xmlsubel :subtitle
7
+ xmlsubel :titleproper
8
+
9
+ def initialize(title)
10
+ self.titleproper = title
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ class UnitDate < Date
2
+ elname "unitdate"
3
+ elwithvalue
4
+
5
+ xmlattr :datechar
6
+ xmlattr :label
7
+ end
@@ -0,0 +1,16 @@
1
+ class UnitId < EADElement
2
+ include WithText
3
+ elname "unitid"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :countrycode
8
+ xmlattr :encodinganalog
9
+ xmlattr :id
10
+ xmlattr :identifier
11
+ xmlattr :label
12
+ xmlattr :repositorycode
13
+ xmlattr :type
14
+
15
+ xmlsubelements
16
+ end
@@ -0,0 +1,13 @@
1
+ class UnitTitle < EADElement
2
+ include WithText
3
+ elname "unittitle"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :label
10
+ xmlattr :type
11
+
12
+ xmlsubelements
13
+ end
@@ -0,0 +1,12 @@
1
+ class UseRestrict < EADElement
2
+ include WithParagraphs
3
+ elname "userestrict"
4
+
5
+ xmlattr :altrender
6
+ xmlattr :audience
7
+ xmlattr :encodinganalog
8
+ xmlattr :id
9
+ xmlattr :type
10
+
11
+ xmlsubelements
12
+ end
@@ -1,6 +1,6 @@
1
- require "TestEAD"
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
- class TestEADDescription < TestEAD
3
+ class TestEADDescription < Test::Unit::TestCase
4
4
  def initialize(*args)
5
5
  super(*args)
6
6
 
@@ -20,20 +20,21 @@ class TestEADDescription < TestEAD
20
20
  end
21
21
 
22
22
  def test_description
23
- did = EAD::EADDescription.new
24
- did.head = @head
25
- did.origination = @origination
26
- did.unittitle = @unittitle
27
- did.unitid = @unitid
28
- did.abstract = @abstract
29
- did.physdesc = @physdesc
30
- did.physloc = @physloc
23
+ did = EADCodec::Description.new
24
+ did << EADCodec::Head.new(@head)
25
+ did << EADCodec::Origination.new(@origination)
26
+ did << EADCodec::UnitTitle.new(@unittitle)
27
+ did << EADCodec::UnitId.new(@unitid)
28
+ did << EADCodec::Abstract.new(@abstract)
29
+ did << EADCodec::PhysDesc.new(@physdesc)
30
+ did << EADCodec::PhysLoc.new(@physloc)
31
31
 
32
- did.unitdate = EAD::EADUnitDate.new(@unitdate)
33
- did.unitdate.label = @unitdatelabel
34
- did.unitdate.type = @unitdatetype
35
-
36
- @ead.add_description(did)
32
+ ud = EADCodec::UnitDate.new(@unitdate)
33
+ ud.label = @unitdatelabel
34
+ ud.type = @unitdatetype
35
+ did << ud
36
+
37
+ @ead.archdesc << did
37
38
  export
38
39
 
39
40
  # Since we've added content it is now valid EAD
@@ -56,18 +57,18 @@ class TestEADDescription < TestEAD
56
57
 
57
58
  def test_import_description
58
59
  import
59
- did = @ead.ead_did
60
+ did = @ead.archdesc[:did]
60
61
 
61
- assert_equal(@head, did.head.value)
62
- assert_equal(@origination, did.origination.value)
63
- assert_equal(@unittitle, did.unittitle.value)
64
- assert_equal(@unitid, did.unitid.value)
65
- assert_equal(@abstract, did.abstract.value)
66
- assert_equal(@physdesc, did.physdesc.value)
67
- assert_equal(@physloc, did.physloc.value)
62
+ assert_equal(@head, did[:head].value)
63
+ assert_equal(@origination, did[:origination].value)
64
+ assert_equal(@unittitle, did[:unittitle].value)
65
+ assert_equal(@unitid, did[:unitid].value)
66
+ assert_equal(@abstract, did[:abstract].value)
67
+ assert_equal(@physdesc, did[:physdesc].value)
68
+ assert_equal(@physloc, did[:physloc].value)
68
69
 
69
- assert_equal(@unitdate, did.unitdate.value)
70
- assert_equal(@unitdatelabel, did.unitdate.label)
71
- assert_equal(@unitdatetype, did.unitdate.type)
70
+ assert_equal(@unitdate, did[:unitdate].value)
71
+ assert_equal(@unitdatelabel, did[:unitdate].label)
72
+ assert_equal(@unitdatetype, did[:unitdate].type)
72
73
  end
73
74
  end
@@ -1,6 +1,6 @@
1
- require "TestEAD"
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
- class TestEADDocument < TestEAD
3
+ class TestEADDocument < Test::Unit::TestCase
4
4
  def setup
5
5
  super
6
6
  @test_file = "test_ead_document.xml"
@@ -0,0 +1,75 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class TestEADLevel < Test::Unit::TestCase
4
+ def initialize(*args)
5
+ super(*args)
6
+ end
7
+
8
+ def export_doc(opt)
9
+ dsc = EADCodec::Subordinates.new
10
+ @ead.archdesc << dsc
11
+
12
+ c01 = EADCodec::Level.new
13
+ c01.set_unnumbered if opt == :unnumbered
14
+ c01 << EADCodec::Description.new
15
+ c01 << EADCodec::PhysTech.new
16
+ dsc << c01
17
+
18
+ c02 = EADCodec::Level.new
19
+ c01 << c02
20
+
21
+ c03 = EADCodec::Level.new
22
+ c02 << c03
23
+
24
+ @test_file = 'test_ead_level_'+opt.to_s+'.xml'
25
+ export @test_file
26
+ end
27
+
28
+ #def test_attrs
29
+ # export_doc(:numbered)
30
+ # element_exists("/ead/archdesc/dsc/c01", "Check that the level was added")
31
+ # element_exists("/ead/archdesc/dsc/c01/did", "Check that the description was added")
32
+ # element_exists("/ead/archdesc/dsc/c01/phystech", "Check that the phystech was added")
33
+ # element_exists("/ead/archdesc/dsc/c01/c02", "Check that the second level was added")
34
+ # element_exists("/ead/archdesc/dsc/c01/c02/c03", "Check that the third level was added")
35
+ #end
36
+
37
+ #def test_import
38
+ # export_doc(:numbered)
39
+ # import
40
+ # dsc = @ead.archdesc.find_first_named(:dsc)
41
+ #
42
+ # c01 = dsc.find_first_named(:c01)
43
+ # assert(c01, "Check that the level was imported")
44
+ # assert(c01.find_first_named(:did), "Check that the description was imported")
45
+ #
46
+ # c02 = c01.find_first_named(:c02)
47
+ # assert(c02, "Check that the second level was imported")
48
+ # assert(c02.find_first_named(:c03), "Check that the third level was imported")
49
+ #end
50
+
51
+ def test_attrs_unnumbered
52
+ @test_file = "test_ead_level_unnumbered.xml"
53
+ export_doc(:unnumbered)
54
+ export
55
+ element_exists("/ead/archdesc/dsc/c", "Check that the level was added")
56
+ element_exists("/ead/archdesc/dsc/c/did", "Check that the description was added")
57
+ element_exists("/ead/archdesc/dsc/c/phystech", "Check that the phystech was added")
58
+ element_exists("/ead/archdesc/dsc/c/c", "Check that the second level was added")
59
+ element_exists("/ead/archdesc/dsc/c/c/c", "Check that the third level was added")
60
+ end
61
+
62
+ def test_import_unnumbered
63
+ @test_file = "test_ead_level_unnumbered.xml"
64
+ export_doc(:unnumbered)
65
+ import
66
+ dsc = @ead.archdesc[:dsc]
67
+ c01 = dsc[:c]
68
+ assert(c01, "Check that the level was imported")
69
+ assert(c01[:did], "Check that the description was imported")
70
+
71
+ c02 = c01[:c]
72
+ assert(c02, "Check that the second level was imported")
73
+ assert(c02[:c], "Check that the third level was imported")
74
+ end
75
+ end
data/test/note_test.rb ADDED
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class TestEADNote < Test::Unit::TestCase
4
+ def initialize(*args)
5
+ super(*args)
6
+
7
+ @test_file = "test_ead_note.xml"
8
+ @p = "Test p"
9
+ end
10
+
11
+ def test_attrs
12
+ dsc = EADCodec::Subordinates.new
13
+ @ead.archdesc << dsc
14
+
15
+ c01 = EADCodec::Level.new
16
+ dsc << c01
17
+
18
+ note = EADCodec::Note.new
19
+ note << EADCodec::P.new(@p)
20
+ note << EADCodec::P.new(@p)
21
+ c01 << note
22
+
23
+ export
24
+ element_exists("/ead/archdesc/dsc/c/note", "Check that the note was added")
25
+ compare_xpath(@p, "/ead/archdesc/dsc/c/note/p")
26
+ end
27
+
28
+
29
+ def test_import
30
+ import
31
+ note = @ead.archdesc[:dsc][:c][:note]
32
+ ps = note.find_all_named(:p)
33
+ assert_equal(@p, ps[0].value)
34
+ assert_equal(@p, ps[1].value)
35
+ end
36
+ end
@@ -0,0 +1,63 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class TestPartialExport < Test::Unit::TestCase
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(filepath, "w")
13
+
14
+ did = EADCodec::Description.new
15
+ did << EADCodec::Head.new("abc")
16
+ did << EADCodec::UnitId.new("teste")
17
+ @ead.archdesc << did
18
+
19
+ dsc = EADCodec::Subordinates.new
20
+ dsc.type = @type
21
+ @ead.archdesc << dsc
22
+
23
+ c01 = EADCodec::Level.new
24
+ did = EADCodec::Description.new
25
+ did << EADCodec::Head.new("abc")
26
+ did << EADCodec::UnitId.new("teste")
27
+ did << EADCodec::UnitTitle.new("teste")
28
+ c01 << did
29
+
30
+ dsc << c01
31
+ c01.start_partial_export(file)
32
+
33
+ dsc = EADCodec::Subordinates.new
34
+ dsc.type = @type
35
+ c01 << dsc
36
+
37
+ c02 = EADCodec::Level.new
38
+ did = EADCodec::Description.new
39
+ did << EADCodec::Head.new("abc")
40
+ did << EADCodec::UnitId.new("teste")
41
+ did << EADCodec::UnitTitle.new("teste")
42
+ c02 << did
43
+ sc = EADCodec::ScopeContent.new
44
+ sc << EADCodec::P.new('value1')
45
+ sc << EADCodec::P.new('value2')
46
+ c02 << sc
47
+
48
+ dsc << c02
49
+ c02.start_partial_export(file)
50
+
51
+ @ead.end_partial_export(file)
52
+
53
+ file.close
54
+
55
+ validate_dtd
56
+ compare_xpath("fonds", "/ead/archdesc/@level")
57
+ compare_xpath(@type, "/ead/archdesc/dsc/@type")
58
+ element_exists("/ead/archdesc/dsc/c", "the first level was not added")
59
+ element_exists("/ead/archdesc/dsc/c/did", "the first level description was not added")
60
+ element_exists("/ead/archdesc/dsc/c/dsc/c", "the second level was not added")
61
+ element_exists("/ead/archdesc/dsc/c/dsc/c/did", "the second level description was not added")
62
+ end
63
+ end
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class TestEADPhysTech < Test::Unit::TestCase
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 = EADCodec::PhysTech.new
13
+ phystech << EADCodec::Head.new(@head)
14
+ (1..4).each {|i| phystech << EADCodec::P.new(@ptext+i.to_s)}
15
+
16
+ did = EADCodec::Description.new
17
+ did << EADCodec::Head.new("head")
18
+ did << EADCodec::UnitId.new("id")
19
+
20
+ @ead.archdesc << did
21
+ @ead.archdesc << phystech
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
+ ps = phystech.find_all_named(:p)
41
+ (1..4).each do |i|
42
+ assert_equal(@ptext+i.to_s, ps[i-1].value)
43
+ end
44
+ end
45
+ end