eadcodec 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -18,5 +18,5 @@ with it allowing for stream parsing of XML files of arbitrary length with
18
18
  constant memory usage while still treating elements as ruby objects.
19
19
 
20
20
  Author:
21
- Pedro C�rte-Real
22
- <pedrocr@gmail.com>
21
+ Pedro Côrte-Real
22
+ <pedro@pedrocr.net>
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  PKG_NAME = 'eadcodec'
2
- PKG_VERSION = '0.1.1'
2
+ PKG_VERSION = '0.1.2'
3
3
 
4
4
  require 'rake'
5
5
  require 'rake/testtask'
@@ -29,7 +29,7 @@ spec = Gem::Specification.new do |s|
29
29
  s.name = PKG_NAME
30
30
  s.version = PKG_VERSION
31
31
  s.author = 'Pedro Côrte-Real'
32
- s.email = 'pedrocr@gmail.com'
32
+ s.email = 'pedro@pedrocr.net'
33
33
  s.requirements << 'xmlcodec'
34
34
  s.add_dependency('xmlcodec', '>= 0.1.0')
35
35
  s.require_path = 'lib'
@@ -39,14 +39,11 @@ spec = Gem::Specification.new do |s|
39
39
  s.rdoc_options = RDOC_OPTIONS
40
40
  s.extra_rdoc_files = RDOC_EXTRA_FILES
41
41
  s.description = <<EOF
42
- An exporter and importer for the Encoded Archival Description XML format. See
43
- http://www.loc.gov/ead/ for more information about the format.
42
+ An exporter and importer for the Encoded Archival Description XML format based on xmlcodec. See http://www.loc.gov/ead/ for more information about the format.
44
43
  EOF
45
44
  end
46
45
 
47
46
  Rake::GemPackageTask.new(spec) do |pkg|
48
- pkg.need_zip = true
49
- pkg.need_tar = true
50
47
  end
51
48
 
52
49
  Rake::TestTask.new do |t|
data/lib/elements/ead.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  class Document < EADElement
2
2
  elname "ead"
3
3
 
4
- COUNTRY_CODE = "pt"
5
- AGENCY_CODE = "iantt"
4
+ DTD_LOC = '"+//ISBN 1-931666-00-8//DTD ead.dtd '+
5
+ '(Encoded Archival Description (EAD) Version 2002)//EN" "ead.dtd"'
6
6
 
7
7
  xmlsubel :eadheader
8
8
  xmlsubel :archdesc
@@ -20,7 +20,7 @@ class Document < EADElement
20
20
  def export(filename)
21
21
  doc = REXML::Document.new
22
22
  doc << REXML::XMLDecl.new("1.0", "UTF-8")
23
- doc << REXML::DocType.new("ead SYSTEM", '"file:///home/pedrocr/ead.dtd"')
23
+ doc << REXML::DocType.new("ead PUBLIC", DTD_LOC)
24
24
  create_xml(doc)
25
25
  output = File.open(filename, "w")
26
26
 
@@ -32,7 +32,7 @@ class Document < EADElement
32
32
  def start_partial_export(file)
33
33
  if not already_partial_exported?
34
34
  file << "<?xml version='1.0' encoding='UTF-8'?>\n"
35
- file << "<!DOCTYPE ead SYSTEM \"file:///home/pedrocr/ead.dtd\">\n"
35
+ file << "<!DOCTYPE ead PUBLIC #{DTD_LOC}>"
36
36
  super
37
37
  end
38
38
  end
@@ -59,15 +59,15 @@ class TestEADDescription < Test::Unit::TestCase
59
59
  import
60
60
  did = @ead.archdesc[:did]
61
61
 
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)
62
+ assert_equal(@head, did[:head].value.strip)
63
+ assert_equal(@origination, did[:origination].value.strip)
64
+ assert_equal(@unittitle, did[:unittitle].value.strip)
65
+ assert_equal(@unitid, did[:unitid].value.strip)
66
+ assert_equal(@abstract, did[:abstract].value.strip)
67
+ assert_equal(@physdesc, did[:physdesc].value.strip)
68
+ assert_equal(@physloc, did[:physloc].value.strip)
69
69
 
70
- assert_equal(@unitdate, did[:unitdate].value)
70
+ assert_equal(@unitdate, did[:unitdate].value.strip)
71
71
  assert_equal(@unitdatelabel, did[:unitdate].label)
72
72
  assert_equal(@unitdatetype, did[:unitdate].type)
73
73
  end
@@ -18,9 +18,10 @@ class TestEADDocument < Test::Unit::TestCase
18
18
  end
19
19
 
20
20
  def test_base_import
21
+ export
21
22
  import
22
- assert_equal("1", @ead.eadheader.eadid.value)
23
- assert_equal("Teste", @ead.eadheader.eadtitle.value)
23
+ assert_equal("1", @ead.eadheader.eadid.value.strip)
24
+ assert_equal("Teste", @ead.eadheader.eadtitle.value.strip)
24
25
  end
25
26
 
26
27
  #def test_import_export_2
data/test/note_test.rb CHANGED
@@ -30,7 +30,7 @@ class TestEADNote < Test::Unit::TestCase
30
30
  import
31
31
  note = @ead.archdesc[:dsc][:c][:note]
32
32
  ps = note.find_all_named(:p)
33
- assert_equal(@p, ps[0].value)
34
- assert_equal(@p, ps[1].value)
33
+ assert_equal(@p, ps[0].value.strip)
34
+ assert_equal(@p, ps[1].value.strip)
35
35
  end
36
36
  end
@@ -36,10 +36,10 @@ class TestEADPhysTech < Test::Unit::TestCase
36
36
  import
37
37
  phystech = @ead.archdesc[:phystech]
38
38
 
39
- assert_equal(@head, phystech[:head].value)
39
+ assert_equal(@head, phystech[:head].value.strip)
40
40
  ps = phystech.find_all_named(:p)
41
41
  (1..4).each do |i|
42
- assert_equal(@ptext+i.to_s, ps[i-1].value)
42
+ assert_equal(@ptext+i.to_s, ps[i-1].value.strip)
43
43
  end
44
44
  end
45
45
  end
@@ -33,9 +33,9 @@ class TestEADScopeContent < Test::Unit::TestCase
33
33
  import
34
34
  assert_equal(1, @ead.archdesc[:dsc].find_all_named(:c).size)
35
35
  sc = @ead.archdesc[:dsc][:c][:scopecontent]
36
- assert_equal(@head, sc[:head].value)
36
+ assert_equal(@head, sc[:head].value.strip)
37
37
  ps = sc.find_all_named(:p)
38
- assert_equal(@p, ps[0].value)
39
- assert_equal(@p, ps[1].value)
38
+ assert_equal(@p, ps[0].value.strip)
39
+ assert_equal(@p, ps[1].value.strip)
40
40
  end
41
41
  end
@@ -27,6 +27,6 @@ class TestEADSubordinates < Test::Unit::TestCase
27
27
  dsc = @ead.archdesc[:dsc]
28
28
 
29
29
  assert_equal(@type, dsc.type)
30
- assert_equal(@head, dsc[:head].value)
30
+ assert_equal(@head, dsc[:head].value.strip)
31
31
  end
32
32
  end
@@ -31,9 +31,9 @@ class TestEADSubtitle < Test::Unit::TestCase
31
31
  def test_base_import
32
32
  import
33
33
  st = @ead.eadheader.filedesc.titlestmt.subtitle
34
- assert_equal(@text, st.subelements[0].to_s)
35
- assert_equal(@abbr, st.subelements[1].to_s)
36
- assert_equal(@text, st.subelements[2].to_s)
37
- assert_equal(@abbr, st.subelements[3].to_s)
34
+ assert_equal(@text, st.subelements[0].to_s.strip)
35
+ assert_equal(@abbr, st.subelements[1].to_s.strip)
36
+ assert_equal(@text, st.subelements[2].to_s.strip)
37
+ assert_equal(@abbr, st.subelements[3].to_s.strip)
38
38
  end
39
39
  end
data/test/test_helper.rb CHANGED
@@ -4,6 +4,8 @@ require 'test/unit'
4
4
  require 'tmpdir'
5
5
 
6
6
  class Test::Unit::TestCase
7
+ DTD_PATH = File.dirname(__FILE__) + '/examples/'
8
+
7
9
  alias_method :old_setup, :setup
8
10
  def setup
9
11
  @ead = EADCodec::Document.new("1", "Teste")
@@ -22,24 +24,30 @@ class Test::Unit::TestCase
22
24
  @ead = EADCodec::Document.from_file filepath
23
25
  end
24
26
 
25
- def validate_well_formed
26
- assert(system("rxp", "-xs", filepath))
27
+ def xmllint_installed
28
+ assert(system("xmllint --version > /dev/null 2>&1"),
29
+ "xmllint utility not installed"+
30
+ "(on ubuntu/debian install package libxml2-utils)")
27
31
  end
28
32
 
33
+ def validate_well_formed
34
+ xmllint_installed
35
+ assert(system("xmllint #{filepath} >/dev/null"),
36
+ "Validation failed for #{filepath}")
37
+ end
38
+
29
39
  def validate_dtd
30
- assert(system("rxp", "-VVs", filepath))
31
- #assert(system("xmlstarlet", "val", "-d", "ead.dtd", @test_file))
40
+ xmllint_installed
41
+ assert(system("xmllint --nonet --loaddtd --path #{DTD_PATH}"+
42
+ " #{filepath} > /dev/null"),
43
+ "Validation failed for #{filepath}")
32
44
  end
33
45
 
34
46
  def compare_xpath(value, path)
35
- assert_equal(value, select(path))
36
- end
47
+ assert_equal(value.strip, XMLUtils::select_path(path, filepath).strip)
48
+ end
37
49
 
38
50
  def element_exists(xpath, *args)
39
51
  assert(XMLUtils::element_exists(xpath, filepath), *args)
40
52
  end
41
-
42
- def select(xpath)
43
- XMLUtils::select_path(xpath, filepath)
44
- end
45
53
  end
@@ -50,9 +50,9 @@ class TestXMLStreamObjectParser < Test::Unit::TestCase
50
50
 
51
51
  assert_equal(@ead, parser.top_element)
52
52
 
53
- assert_equal("1", @ead.eadheader.eadid.value)
53
+ assert_equal("1", @ead.eadheader.eadid.value.strip)
54
54
  assert_equal("1", @ead.eadheader.id)
55
- assert_equal("Teste", @ead.eadheader.eadtitle.value)
55
+ assert_equal("Teste", @ead.eadheader.eadtitle.value.strip)
56
56
 
57
57
  dsc = @ead.archdesc[:dsc]
58
58
  assert(dsc[:c], "Check that the level was imported")
metadata CHANGED
@@ -1,113 +1,130 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
3
- specification_version: 1
4
2
  name: eadcodec
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
7
- date: 2006-09-14 00:00:00 +01:00
8
- summary: Importer/Exporter for the EAD XML format
9
- require_paths:
10
- - lib
11
- email: pedrocr@gmail.com
12
- homepage:
13
- rubyforge_project:
14
- description: An exporter and importer for the Encoded Archival Description XML format. See http://www.loc.gov/ead/ for more information about the format.
15
- autorequire: rake
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ hash: 31
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 2
10
+ version: 0.1.2
25
11
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
12
  authors:
30
13
  - "Pedro C\xC3\xB4rte-Real"
14
+ autorequire: rake
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-14 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: xmlcodec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 27
30
+ segments:
31
+ - 0
32
+ - 1
33
+ - 0
34
+ version: 0.1.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: |
38
+ An exporter and importer for the Encoded Archival Description XML format based on xmlcodec. See http://www.loc.gov/ead/ for more information about the format.
39
+
40
+ email: pedro@pedrocr.net
41
+ executables: []
42
+
43
+ extensions: []
44
+
45
+ extra_rdoc_files:
46
+ - README
31
47
  files:
32
48
  - lib/eadcodec.rb
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
49
+ - lib/elements/physfacet.rb
50
+ - lib/elements/repository.rb
51
+ - lib/elements/event.rb
52
+ - lib/elements/titlestmt.rb
53
+ - lib/elements/scopecontent.rb
54
+ - lib/elements/language.rb
55
+ - lib/elements/profiledesc.rb
39
56
  - 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
57
  - lib/elements/container.rb
58
+ - lib/elements/p.rb
59
+ - lib/elements/phystech.rb
60
+ - lib/elements/dsc.rb
45
61
  - 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
62
+ - lib/elements/accessrestrict.rb
52
63
  - 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
64
  - lib/elements/item.rb
65
+ - lib/elements/id.rb
66
+ - lib/elements/list.rb
67
+ - lib/elements/unittitle.rb
68
+ - lib/elements/fileplan.rb
69
+ - lib/elements/chronlist.rb
70
+ - lib/elements/chronitem.rb
61
71
  - lib/elements/materialspec.rb
62
- - lib/elements/name.rb
63
- - lib/elements/note.rb
64
- - lib/elements/odd.rb
72
+ - lib/elements/altformavail.rb
73
+ - lib/elements/bioghist.rb
65
74
  - lib/elements/originalsloc.rb
75
+ - lib/elements/date.rb
76
+ - lib/elements/processinfo.rb
77
+ - lib/elements/ead.rb
78
+ - lib/elements/odd.rb
79
+ - lib/elements/unitdate.rb
80
+ - lib/elements/userestrict.rb
81
+ - lib/elements/creation.rb
82
+ - lib/elements/arrangement.rb
83
+ - lib/elements/eadheader.rb
84
+ - lib/elements/acqinfo.rb
85
+ - lib/elements/label.rb
86
+ - lib/elements/head.rb
87
+ - lib/elements/name.rb
88
+ - lib/elements/archdesc.rb
89
+ - lib/elements/accruals.rb
66
90
  - lib/elements/otherfindaid.rb
67
91
  - lib/elements/physdesc.rb
68
- - lib/elements/physfacet.rb
92
+ - lib/elements/c.rb
93
+ - lib/elements/unitid.rb
69
94
  - 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/descgrp.rb
95
+ - lib/elements/note.rb
96
+ - lib/elements/bibliography.rb
97
+ - lib/elements/langmaterial.rb
98
+ - lib/elements/dimensions.rb
99
+ - lib/elements/filedesc.rb
77
100
  - lib/elements/subtitle.rb
78
- - lib/elements/userestrict.rb
101
+ - lib/elements/description.rb
79
102
  - lib/elements/origination.rb
80
- - lib/elements/unitid.rb
81
- - lib/elements/dao.rb
82
- - lib/elements/unittitle.rb
83
- - lib/elements/chronitem.rb
84
- - lib/elements/unitdate.rb
85
- - lib/elements/archdesc.rb
86
- - lib/elements/ead.rb
87
- - lib/elements/id.rb
88
- - lib/elements/titlestmt.rb
89
- - lib/elements/filedesc.rb
90
- - lib/elements/eadheader.rb
91
- - lib/elements/creation.rb
92
- - lib/elements/c.rb
93
- - test/xmlsoparser_test.rb
94
- - test/subtitle_test.rb
95
- - test/subordinates_test.rb
103
+ - lib/elements/custodhist.rb
104
+ - lib/elements/geogname.rb
105
+ - lib/elements/defitem.rb
106
+ - lib/elements/relatedmaterial.rb
107
+ - test/partial_export_test.rb
108
+ - test/note_test.rb
109
+ - test/description_test.rb
110
+ - test/level_test.rb
96
111
  - test/test_helper.rb
112
+ - test/subordinates_test.rb
113
+ - test/xmlsoparser_test.rb
97
114
  - test/phystech_test.rb
98
115
  - test/document_test.rb
99
- - test/note_test.rb
100
- - test/level_test.rb
101
- - test/description_test.rb
102
- - test/partial_export_test.rb
103
116
  - test/scopecontent_test.rb
117
+ - test/subtitle_test.rb
104
118
  - test/examples/example1.xml
105
119
  - test/examples/example2.xml
106
120
  - README
107
121
  - LICENSE
108
122
  - Rakefile
109
- test_files: []
123
+ has_rdoc: true
124
+ homepage:
125
+ licenses: []
110
126
 
127
+ post_install_message:
111
128
  rdoc_options:
112
129
  - -S
113
130
  - -w 2
@@ -115,21 +132,32 @@ rdoc_options:
115
132
  - -Axmlsubel_mult=XML Subelement Collection
116
133
  - -Axmlsubel=XML Subelement
117
134
  - -Axmlattr=XML Attribute
118
- extra_rdoc_files:
119
- - README
120
- executables: []
121
-
122
- extensions: []
123
-
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ hash: 3
143
+ segments:
144
+ - 0
145
+ version: "0"
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ none: false
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ hash: 3
152
+ segments:
153
+ - 0
154
+ version: "0"
124
155
  requirements:
125
156
  - xmlcodec
126
- dependencies:
127
- - !ruby/object:Gem::Dependency
128
- name: xmlcodec
129
- version_requirement:
130
- version_requirements: !ruby/object:Gem::Version::Requirement
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- version: 0.1.0
135
- version:
157
+ rubyforge_project:
158
+ rubygems_version: 1.3.7
159
+ signing_key:
160
+ specification_version: 3
161
+ summary: Importer/Exporter for the EAD XML format
162
+ test_files: []
163
+
data/lib/elements/dao.rb DELETED
@@ -1,16 +0,0 @@
1
- class Dao < EADElement
2
- elname "dao"
3
-
4
- xmlattr :actuate
5
- xmlattr :altrender
6
- xmlattr :arcrole
7
- xmlattr :audience
8
- xmlattr :entityref
9
- xmlattr :href
10
- xmlattr :id
11
- xmlattr :linktype
12
- xmlattr :role
13
- xmlattr :show
14
- xmlattr :title
15
- xmlattr :xpointer
16
- end
@@ -1,11 +0,0 @@
1
- class DescGrp < EADElement
2
- elname "descgrp"
3
-
4
- xmlattr :altrender
5
- xmlattr :audience
6
- xmlattr :encodinganalog
7
- xmlattr :id
8
- xmlattr :type
9
-
10
- xmlsubelements
11
- end