eadcodec 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +12 -5
- data/lib/eadcodec.rb +76 -1
- data/lib/elements/accessrestrict.rb +12 -0
- data/lib/elements/accruals.rb +11 -0
- data/lib/elements/acqinfo.rb +12 -0
- data/lib/elements/altformavail.rb +12 -0
- data/lib/elements/appraisal.rb +11 -0
- data/lib/elements/archdesc.rb +32 -0
- data/lib/elements/arrangement.rb +11 -0
- data/lib/elements/bibliography.rb +12 -0
- data/lib/elements/bioghist.rb +11 -0
- data/lib/elements/c.rb +65 -0
- data/lib/elements/chronitem.rb +12 -0
- data/lib/elements/chronlist.rb +12 -0
- data/lib/elements/container.rb +13 -0
- data/lib/elements/controlaccess.rb +10 -0
- data/lib/elements/creation.rb +4 -0
- data/lib/elements/custodhist.rb +11 -0
- data/lib/elements/date.rb +14 -0
- data/lib/elements/defitem.rb +10 -0
- data/lib/elements/description.rb +10 -0
- data/lib/elements/dimensions.rb +13 -0
- data/lib/elements/dsc.rb +21 -0
- data/lib/elements/ead.rb +39 -0
- data/lib/elements/eadheader.rb +28 -0
- data/lib/elements/event.rb +9 -0
- data/lib/elements/extent.rb +13 -0
- data/lib/elements/filedesc.rb +13 -0
- data/lib/elements/fileplan.rb +10 -0
- data/lib/elements/geogname.rb +16 -0
- data/lib/elements/head.rb +11 -0
- data/lib/elements/id.rb +12 -0
- data/lib/elements/item.rb +9 -0
- data/lib/elements/label.rb +9 -0
- data/lib/elements/langmaterial.rb +12 -0
- data/lib/elements/language.rb +20 -0
- data/lib/elements/list.rb +13 -0
- data/lib/elements/materialspec.rb +13 -0
- data/lib/elements/name.rb +15 -0
- data/lib/elements/note.rb +15 -0
- data/lib/elements/odd.rb +13 -0
- data/lib/elements/originalsloc.rb +12 -0
- data/lib/elements/origination.rb +12 -0
- data/lib/elements/otherfindaid.rb +11 -0
- data/lib/elements/p.rb +10 -0
- data/lib/elements/physdesc.rb +14 -0
- data/lib/elements/physfacet.rb +16 -0
- data/lib/elements/physloc.rb +14 -0
- data/lib/elements/phystech.rb +11 -0
- data/lib/elements/processinfo.rb +11 -0
- data/lib/elements/profiledesc.rb +10 -0
- data/lib/elements/relatedmaterial.rb +12 -0
- data/lib/elements/repository.rb +12 -0
- data/lib/elements/scopecontent.rb +12 -0
- data/lib/elements/subtitle.rb +4 -0
- data/lib/elements/titlestmt.rb +12 -0
- data/lib/elements/unitdate.rb +7 -0
- data/lib/elements/unitid.rb +16 -0
- data/lib/elements/unittitle.rb +13 -0
- data/lib/elements/userestrict.rb +12 -0
- data/test/{TestEADDescription.rb → description_test.rb} +27 -26
- data/test/{TestEADDocument.rb → document_test.rb} +2 -2
- data/test/level_test.rb +75 -0
- data/test/note_test.rb +36 -0
- data/test/partial_export_test.rb +63 -0
- data/test/phystech_test.rb +45 -0
- data/test/scopecontent_test.rb +41 -0
- data/test/{TestEADSubordinates.rb → subordinates_test.rb} +7 -8
- data/test/{TestEADSubtitle.rb → subtitle_test.rb} +5 -6
- data/test/test_helper.rb +45 -0
- data/test/xmlsoparser_test.rb +119 -0
- metadata +72 -50
- data/lib/EAD.rb +0 -229
- data/lib/EADAcqInfo.rb +0 -13
- data/lib/EADAltFormAvail.rb +0 -13
- data/lib/EADAppraisal.rb +0 -12
- data/lib/EADArrangement.rb +0 -12
- data/lib/EADBiogHist.rb +0 -10
- data/lib/EADChronList.rb +0 -27
- data/lib/EADContainer.rb +0 -15
- data/lib/EADControlAccess.rb +0 -12
- data/lib/EADCustodHist.rb +0 -12
- data/lib/EADDate.rb +0 -24
- data/lib/EADDescription.rb +0 -22
- data/lib/EADDimensions.rb +0 -15
- data/lib/EADDocument.rb +0 -106
- data/lib/EADEvent.rb +0 -11
- data/lib/EADExtent.rb +0 -15
- data/lib/EADFilePlan.rb +0 -12
- data/lib/EADGeogName.rb +0 -15
- data/lib/EADHeader.rb +0 -70
- data/lib/EADLabel.rb +0 -11
- data/lib/EADLang.rb +0 -42
- data/lib/EADLevel.rb +0 -73
- data/lib/EADList.rb +0 -36
- data/lib/EADMaterialSpec.rb +0 -14
- data/lib/EADName.rb +0 -17
- data/lib/EADNote.rb +0 -24
- data/lib/EADOtherFindAid.rb +0 -12
- data/lib/EADPhysFacet.rb +0 -17
- data/lib/EADPhysTech.rb +0 -16
- data/lib/EADProcessInfo.rb +0 -13
- data/lib/EADProfileDesc.rb +0 -17
- data/lib/EADRelatedMaterial.rb +0 -21
- data/lib/EADRepository.rb +0 -13
- data/lib/EADScopeContent.rb +0 -21
- data/lib/EADSubordinates.rb +0 -29
- data/lib/EADSubtitle.rb +0 -8
- data/test/TestEAD.rb +0 -50
- data/test/TestEADLevel.rb +0 -76
- data/test/TestEADNote.rb +0 -36
- data/test/TestEADPhysTech.rb +0 -44
- data/test/TestEADScopeContent.rb +0 -43
- data/test/TestPartialExport.rb +0 -61
- data/test/TestXMLStreamObjectParser.rb +0 -126
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class TestEADScopeContent < Test::Unit::TestCase
|
4
|
+
def initialize(*args)
|
5
|
+
super(*args)
|
6
|
+
|
7
|
+
@test_file = "test_ead_scopecontent.xml"
|
8
|
+
@head = "Test Head"
|
9
|
+
@p = "Test p"
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_attrs
|
13
|
+
dsc = EADCodec::Subordinates.new
|
14
|
+
@ead.archdesc << dsc
|
15
|
+
|
16
|
+
c01 = EADCodec::Level.new
|
17
|
+
dsc << c01
|
18
|
+
|
19
|
+
sc = EADCodec::ScopeContent.new
|
20
|
+
sc << EADCodec::Head.new(@head)
|
21
|
+
sc << EADCodec::P.new(@p)
|
22
|
+
sc << EADCodec::P.new(@p)
|
23
|
+
c01 << sc
|
24
|
+
|
25
|
+
export
|
26
|
+
element_exists("/ead/archdesc/dsc/c/scopecontent", "Check that the scopecontent was added")
|
27
|
+
compare_xpath(@head, "/ead/archdesc/dsc/c/scopecontent/head")
|
28
|
+
compare_xpath(@p, "/ead/archdesc/dsc/c/scopecontent/p")
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def test_import
|
33
|
+
import
|
34
|
+
assert_equal(1, @ead.archdesc[:dsc].find_all_named(:c).size)
|
35
|
+
sc = @ead.archdesc[:dsc][:c][:scopecontent]
|
36
|
+
assert_equal(@head, sc[:head].value)
|
37
|
+
ps = sc.find_all_named(:p)
|
38
|
+
assert_equal(@p, ps[0].value)
|
39
|
+
assert_equal(@p, ps[1].value)
|
40
|
+
end
|
41
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require "EADSubordinates"
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
3
2
|
|
4
|
-
class TestEADSubordinates <
|
3
|
+
class TestEADSubordinates < Test::Unit::TestCase
|
5
4
|
|
6
5
|
def initialize(*args)
|
7
6
|
super(*args)
|
@@ -13,11 +12,11 @@ class TestEADSubordinates < TestEAD
|
|
13
12
|
end
|
14
13
|
|
15
14
|
def test_attrs
|
16
|
-
dsc =
|
15
|
+
dsc = EADCodec::Subordinates.new
|
17
16
|
dsc.type = @type
|
18
|
-
dsc
|
17
|
+
dsc << EADCodec::Head.new(@head)
|
19
18
|
|
20
|
-
@ead.
|
19
|
+
@ead.archdesc << dsc
|
21
20
|
export
|
22
21
|
compare_xpath(@type, "/ead/archdesc/dsc/@type")
|
23
22
|
compare_xpath(@head, "/ead/archdesc/dsc/head")
|
@@ -25,9 +24,9 @@ class TestEADSubordinates < TestEAD
|
|
25
24
|
|
26
25
|
def test_import
|
27
26
|
import
|
28
|
-
dsc = @ead.
|
27
|
+
dsc = @ead.archdesc[:dsc]
|
29
28
|
|
30
29
|
assert_equal(@type, dsc.type)
|
31
|
-
assert_equal(@head, dsc
|
30
|
+
assert_equal(@head, dsc[:head].value)
|
32
31
|
end
|
33
32
|
end
|
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require "EADSubtitle"
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
3
2
|
|
4
|
-
class TestEADSubtitle <
|
3
|
+
class TestEADSubtitle < Test::Unit::TestCase
|
5
4
|
def setup
|
6
5
|
super
|
7
6
|
@test_file = "test_ead_subtitle.xml"
|
@@ -12,11 +11,11 @@ class TestEADSubtitle < TestEAD
|
|
12
11
|
def test_base_export
|
13
12
|
titlestmt = @ead.eadheader.filedesc.titlestmt
|
14
13
|
|
15
|
-
st = titlestmt.subtitle =
|
14
|
+
st = titlestmt.subtitle = EADCodec::Subtitle.new
|
16
15
|
st.subelements << @text
|
17
|
-
st.subelements <<
|
16
|
+
st.subelements << EADCodec::Abbr.new(@abbr)
|
18
17
|
st.subelements << @text
|
19
|
-
st.subelements <<
|
18
|
+
st.subelements << EADCodec::Abbr.new(@abbr)
|
20
19
|
|
21
20
|
export
|
22
21
|
# The base document has an empty archdesc and is thus not valid EAD
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
$-w = true
|
2
|
+
require File.dirname(__FILE__) + '/../lib/eadcodec'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'tmpdir'
|
5
|
+
|
6
|
+
class Test::Unit::TestCase
|
7
|
+
alias_method :old_setup, :setup
|
8
|
+
def setup
|
9
|
+
@ead = EADCodec::Document.new("1", "Teste")
|
10
|
+
end
|
11
|
+
|
12
|
+
def filepath(name=nil)
|
13
|
+
name = @test_file if not name
|
14
|
+
File.join(Dir::tmpdir, name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def export(name=nil)
|
18
|
+
@ead.export filepath(name)
|
19
|
+
end
|
20
|
+
|
21
|
+
def import
|
22
|
+
@ead = EADCodec::Document.from_file filepath
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate_well_formed
|
26
|
+
assert(system("rxp", "-xs", filepath))
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate_dtd
|
30
|
+
assert(system("rxp", "-VVs", filepath))
|
31
|
+
#assert(system("xmlstarlet", "val", "-d", "ead.dtd", @test_file))
|
32
|
+
end
|
33
|
+
|
34
|
+
def compare_xpath(value, path)
|
35
|
+
assert_equal(value, select(path))
|
36
|
+
end
|
37
|
+
|
38
|
+
def element_exists(xpath, *args)
|
39
|
+
assert(XMLUtils::element_exists(xpath, filepath), *args)
|
40
|
+
end
|
41
|
+
|
42
|
+
def select(xpath)
|
43
|
+
XMLUtils::select_path(xpath, filepath)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class MyStreamListener
|
4
|
+
attr_reader :ead
|
5
|
+
def el_ead(el)
|
6
|
+
@ead = el.get_object
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class MyConsumingStreamListener
|
11
|
+
attr_reader :ead
|
12
|
+
def el_ead(el)
|
13
|
+
@ead = el.get_object
|
14
|
+
end
|
15
|
+
|
16
|
+
def el_c(el)
|
17
|
+
el.consume
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class TestXMLStreamObjectParser < Test::Unit::TestCase
|
22
|
+
def initialize(*args)
|
23
|
+
super(*args)
|
24
|
+
|
25
|
+
@test_file = "test_ead_stream_object_parser.xml"
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_import
|
29
|
+
@ead.eadheader.id = "1"
|
30
|
+
|
31
|
+
dsc = EADCodec::Subordinates.new
|
32
|
+
@ead.archdesc << dsc
|
33
|
+
|
34
|
+
c01 = EADCodec::Level.new
|
35
|
+
c01 << EADCodec::Description.new
|
36
|
+
c01 << EADCodec::PhysTech.new
|
37
|
+
dsc << c01
|
38
|
+
|
39
|
+
c02 = EADCodec::Level.new
|
40
|
+
c01 << c02
|
41
|
+
|
42
|
+
c03 = EADCodec::Level.new
|
43
|
+
c02 << c03
|
44
|
+
|
45
|
+
export
|
46
|
+
listener = MyStreamListener.new
|
47
|
+
parser = XMLCodec::XMLStreamObjectParser.new(EADCodec::EADElement, listener)
|
48
|
+
parser.parse(File.new(filepath))
|
49
|
+
@ead = listener.ead
|
50
|
+
|
51
|
+
assert_equal(@ead, parser.top_element)
|
52
|
+
|
53
|
+
assert_equal("1", @ead.eadheader.eadid.value)
|
54
|
+
assert_equal("1", @ead.eadheader.id)
|
55
|
+
assert_equal("Teste", @ead.eadheader.eadtitle.value)
|
56
|
+
|
57
|
+
dsc = @ead.archdesc[:dsc]
|
58
|
+
assert(dsc[:c], "Check that the level was imported")
|
59
|
+
assert(dsc[:c][:did], "Check that the description was imported")
|
60
|
+
assert(dsc[:c][:c], "Check that the second level was imported")
|
61
|
+
assert(dsc[:c][:c][:c], "Check that the third level was imported")
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_consume
|
65
|
+
@ead.eadheader.id = "1"
|
66
|
+
|
67
|
+
dsc = EADCodec::Subordinates.new
|
68
|
+
@ead.archdesc << dsc
|
69
|
+
|
70
|
+
c01 = EADCodec::Level.new
|
71
|
+
c01 << EADCodec::Description.new
|
72
|
+
c01 << EADCodec::PhysTech.new
|
73
|
+
dsc << c01
|
74
|
+
|
75
|
+
c02 = EADCodec::Level.new
|
76
|
+
c01 << c02
|
77
|
+
|
78
|
+
c03 = EADCodec::Level.new
|
79
|
+
c02 << c03
|
80
|
+
|
81
|
+
export
|
82
|
+
|
83
|
+
listener = MyConsumingStreamListener.new
|
84
|
+
parser = XMLCodec::XMLStreamObjectParser.new(EADCodec::EADElement, listener)
|
85
|
+
parser.parse(File.new(filepath))
|
86
|
+
@ead = listener.ead
|
87
|
+
|
88
|
+
dsc = @ead.archdesc[:dsc]
|
89
|
+
assert_nil(dsc[:c], "Check that the levels were consumed")
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_numbering
|
93
|
+
@ead.eadheader.id = "1"
|
94
|
+
|
95
|
+
dsc = EADCodec::Subordinates.new
|
96
|
+
@ead.archdesc << dsc
|
97
|
+
|
98
|
+
c01 = EADCodec::Level.new
|
99
|
+
c01 << EADCodec::Description.new
|
100
|
+
c01 << EADCodec::PhysTech.new
|
101
|
+
dsc << c01
|
102
|
+
|
103
|
+
export
|
104
|
+
|
105
|
+
listener = MyStreamListener.new
|
106
|
+
parser = XMLCodec::XMLStreamObjectParser.new(EADCodec::EADElement, listener)
|
107
|
+
parser.parse(File.new(filepath))
|
108
|
+
@ead = listener.ead
|
109
|
+
|
110
|
+
dsc = @ead.archdesc[:dsc]
|
111
|
+
c01 = dsc[:c]
|
112
|
+
|
113
|
+
assert(dsc.element_id)
|
114
|
+
assert(dsc.parent_id)
|
115
|
+
assert(c01.element_id)
|
116
|
+
assert(c01.parent_id)
|
117
|
+
assert_equal(c01.parent_id, dsc.element_id)
|
118
|
+
end
|
119
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ 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-07-
|
6
|
+
version: 0.1.0
|
7
|
+
date: 2006-07-27 00:00:00 +01:00
|
8
8
|
summary: Importer/Exporter for the EAD XML format
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -29,54 +29,76 @@ post_install_message:
|
|
29
29
|
authors:
|
30
30
|
- "Pedro C\xC3\xB4rte-Real"
|
31
31
|
files:
|
32
|
-
- lib/EADRelatedMaterial.rb
|
33
|
-
- lib/EADDescription.rb
|
34
|
-
- lib/EADScopeContent.rb
|
35
|
-
- lib/EADNote.rb
|
36
|
-
- lib/EADLevel.rb
|
37
|
-
- lib/EADPhysTech.rb
|
38
|
-
- lib/EADBiogHist.rb
|
39
|
-
- lib/EADHeader.rb
|
40
|
-
- lib/EADSubtitle.rb
|
41
|
-
- lib/EADDate.rb
|
42
|
-
- lib/EADDocument.rb
|
43
|
-
- lib/EAD.rb
|
44
|
-
- lib/EADProfileDesc.rb
|
45
32
|
- lib/eadcodec.rb
|
46
|
-
- lib/
|
47
|
-
- lib/
|
48
|
-
- lib/
|
49
|
-
- lib/
|
50
|
-
- lib/
|
51
|
-
- lib/
|
52
|
-
- lib/
|
53
|
-
- lib/
|
54
|
-
- lib/
|
55
|
-
- lib/
|
56
|
-
- lib/
|
57
|
-
- lib/
|
58
|
-
- lib/
|
59
|
-
- lib/
|
60
|
-
- lib/
|
61
|
-
- lib/
|
62
|
-
- lib/
|
63
|
-
- lib/
|
64
|
-
- lib/
|
65
|
-
- lib/
|
66
|
-
- lib/
|
67
|
-
- lib/
|
68
|
-
- lib/
|
69
|
-
-
|
70
|
-
-
|
71
|
-
-
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
33
|
+
- lib/elements/p.rb
|
34
|
+
- lib/elements/head.rb
|
35
|
+
- lib/elements/accessrestrict.rb
|
36
|
+
- lib/elements/accruals.rb
|
37
|
+
- lib/elements/acqinfo.rb
|
38
|
+
- lib/elements/altformavail.rb
|
39
|
+
- lib/elements/appraisal.rb
|
40
|
+
- lib/elements/arrangement.rb
|
41
|
+
- lib/elements/bibliography.rb
|
42
|
+
- lib/elements/bioghist.rb
|
43
|
+
- lib/elements/chronlist.rb
|
44
|
+
- lib/elements/container.rb
|
45
|
+
- lib/elements/controlaccess.rb
|
46
|
+
- lib/elements/custodhist.rb
|
47
|
+
- lib/elements/date.rb
|
48
|
+
- lib/elements/description.rb
|
49
|
+
- lib/elements/dimensions.rb
|
50
|
+
- lib/elements/defitem.rb
|
51
|
+
- lib/elements/event.rb
|
52
|
+
- lib/elements/extent.rb
|
53
|
+
- lib/elements/fileplan.rb
|
54
|
+
- lib/elements/geogname.rb
|
55
|
+
- lib/elements/language.rb
|
56
|
+
- lib/elements/label.rb
|
57
|
+
- lib/elements/langmaterial.rb
|
58
|
+
- lib/elements/list.rb
|
59
|
+
- lib/elements/dsc.rb
|
60
|
+
- lib/elements/item.rb
|
61
|
+
- lib/elements/materialspec.rb
|
62
|
+
- lib/elements/name.rb
|
63
|
+
- lib/elements/note.rb
|
64
|
+
- lib/elements/odd.rb
|
65
|
+
- lib/elements/originalsloc.rb
|
66
|
+
- lib/elements/otherfindaid.rb
|
67
|
+
- lib/elements/physdesc.rb
|
68
|
+
- lib/elements/physfacet.rb
|
69
|
+
- lib/elements/physloc.rb
|
70
|
+
- lib/elements/phystech.rb
|
71
|
+
- lib/elements/processinfo.rb
|
72
|
+
- lib/elements/profiledesc.rb
|
73
|
+
- lib/elements/relatedmaterial.rb
|
74
|
+
- lib/elements/repository.rb
|
75
|
+
- lib/elements/scopecontent.rb
|
76
|
+
- lib/elements/subtitle.rb
|
77
|
+
- lib/elements/userestrict.rb
|
78
|
+
- lib/elements/origination.rb
|
79
|
+
- lib/elements/unitid.rb
|
80
|
+
- lib/elements/unittitle.rb
|
81
|
+
- lib/elements/chronitem.rb
|
82
|
+
- lib/elements/unitdate.rb
|
83
|
+
- lib/elements/archdesc.rb
|
84
|
+
- lib/elements/ead.rb
|
85
|
+
- lib/elements/id.rb
|
86
|
+
- lib/elements/titlestmt.rb
|
87
|
+
- lib/elements/filedesc.rb
|
88
|
+
- lib/elements/eadheader.rb
|
89
|
+
- lib/elements/creation.rb
|
90
|
+
- lib/elements/c.rb
|
91
|
+
- test/xmlsoparser_test.rb
|
92
|
+
- test/subtitle_test.rb
|
93
|
+
- test/subordinates_test.rb
|
94
|
+
- test/test_helper.rb
|
95
|
+
- test/phystech_test.rb
|
96
|
+
- test/document_test.rb
|
97
|
+
- test/note_test.rb
|
98
|
+
- test/level_test.rb
|
99
|
+
- test/description_test.rb
|
100
|
+
- test/partial_export_test.rb
|
101
|
+
- test/scopecontent_test.rb
|
80
102
|
- test/examples/example1.xml
|
81
103
|
- test/examples/example2.xml
|
82
104
|
- README
|
@@ -107,5 +129,5 @@ dependencies:
|
|
107
129
|
requirements:
|
108
130
|
- - ">="
|
109
131
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.0
|
132
|
+
version: 0.1.0
|
111
133
|
version:
|
data/lib/EAD.rb
DELETED
@@ -1,229 +0,0 @@
|
|
1
|
-
require "rexml/document"
|
2
|
-
require "xmlcodec"
|
3
|
-
|
4
|
-
# This module includes all the support for EAD import/export. The main class to
|
5
|
-
# use is EADDocument that is a subclass of XMLUtils::XMLElement. All elements
|
6
|
-
# supported are based on the EAD DTD and have the same names. Currently not all
|
7
|
-
# attributes and elements have been added. Adding an element is pretty easy
|
8
|
-
# though.
|
9
|
-
module EAD
|
10
|
-
class EADElement < XMLCodec::XMLElement #:nodoc:
|
11
|
-
end
|
12
|
-
|
13
|
-
class EADSimpleElement < EADElement
|
14
|
-
elwithvalue
|
15
|
-
|
16
|
-
def to_s
|
17
|
-
value
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
include XMLUtils
|
22
|
-
# Module used in EADSubordinates and EADLevels to add new levels to a file
|
23
|
-
module EADLevels
|
24
|
-
public
|
25
|
-
# Returns the list of all the child levels of the current element.
|
26
|
-
def levels
|
27
|
-
(self.c ||= []).dup
|
28
|
-
end
|
29
|
-
|
30
|
-
# Adds a child level to the current element.
|
31
|
-
def add_level(level)
|
32
|
-
self.c << level
|
33
|
-
end
|
34
|
-
|
35
|
-
# Removes a child level from the current element.
|
36
|
-
def remove_level(level)
|
37
|
-
self.c.delete(level)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.sclass(name, string)
|
42
|
-
const_set(name, Class.new(EADSimpleElement)).send(:elname, string)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Create a bunch of classes for simple elements with just values
|
46
|
-
# Most of these actually can have children so they should be promoted to
|
47
|
-
# actual classes.
|
48
|
-
sclass "EADAbstract", "abstract"
|
49
|
-
sclass "EADPhysDesc", "physdesc"
|
50
|
-
sclass "EADPhysLoc", "physloc"
|
51
|
-
sclass "EADAuthor", "author"
|
52
|
-
sclass "EADSponsor", "sponsor"
|
53
|
-
sclass "EADTitleProper", "titleproper"
|
54
|
-
sclass "EADAbbr", "abbr"
|
55
|
-
sclass "EADEmph", "emph"
|
56
|
-
sclass "EADExpan", "expan"
|
57
|
-
sclass "EADExtPtr", "extptr"
|
58
|
-
sclass "EADLb", "lb"
|
59
|
-
sclass "EADNum", "num"
|
60
|
-
sclass "EADPtr", "ptr"
|
61
|
-
sclass "EADArchRef", "archref"
|
62
|
-
sclass "EADBibRef", "bibref"
|
63
|
-
sclass "EADExtRef", "extref"
|
64
|
-
sclass "EADRef", "ref"
|
65
|
-
sclass "EADLinkGrp", "linkgrp"
|
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
|
138
|
-
|
139
|
-
# The class for the 'head' element. For convenience it can be initialized
|
140
|
-
# with a string value that is used as the first subelement.
|
141
|
-
class EADHead < EADElement
|
142
|
-
elname "head"
|
143
|
-
|
144
|
-
xmlattr :althead
|
145
|
-
xmlattr :altrender
|
146
|
-
xmlattr :audience
|
147
|
-
xmlattr :id
|
148
|
-
|
149
|
-
xmlsubelements
|
150
|
-
|
151
|
-
def initialize(string=nil)
|
152
|
-
if string
|
153
|
-
self.subelements << string
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def value
|
158
|
-
self.subelements[0].to_s
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
# The class for the 'p' element. For convenience it can be initialized
|
163
|
-
# with a string value that is used as the first subelement.
|
164
|
-
class EADP < EADElement
|
165
|
-
elname "p"
|
166
|
-
|
167
|
-
xmlattr :altrender
|
168
|
-
xmlattr :audience
|
169
|
-
xmlattr :id
|
170
|
-
|
171
|
-
xmlsubelements
|
172
|
-
|
173
|
-
def initialize(string=nil)
|
174
|
-
if string
|
175
|
-
self.subelements << string
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
def value
|
180
|
-
self.subelements[0].to_s
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
end
|
185
|
-
|
186
|
-
require "EADDate"
|
187
|
-
require "EADSubtitle"
|
188
|
-
require "EADPhysTech"
|
189
|
-
require "EADScopeContent"
|
190
|
-
require "EADRelatedMaterial"
|
191
|
-
require "EADNote"
|
192
|
-
require "EADDescription"
|
193
|
-
require "EADLevel"
|
194
|
-
require "EADSubordinates"
|
195
|
-
require "EADProfileDesc"
|
196
|
-
require "EADHeader"
|
197
|
-
require "EADBiogHist"
|
198
|
-
require "EADDocument"
|
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
|
-
|
222
|
-
|
223
|
-
module EAD
|
224
|
-
def self.c_levels
|
225
|
-
["c","c01","c02","c03","c04","c05","c06","c07","c08","c09","c10","c11","c12"]
|
226
|
-
end
|
227
|
-
|
228
|
-
#c_levels.each{|level| ElClasses[level.to_sym] = EADLevel}
|
229
|
-
end
|
data/lib/EADAcqInfo.rb
DELETED
data/lib/EADAltFormAvail.rb
DELETED
data/lib/EADAppraisal.rb
DELETED