eadsax 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +2 -0
  4. data/Gemfile +17 -0
  5. data/Gemfile.lock +34 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.rdoc +14 -0
  8. data/Rakefile +50 -0
  9. data/VERSION +1 -0
  10. data/bin/eadsax +48 -0
  11. data/lib/eadsax.rb +75 -0
  12. data/lib/eadsax/accessrestrict.rb +15 -0
  13. data/lib/eadsax/accruals.rb +14 -0
  14. data/lib/eadsax/acqinfo.rb +14 -0
  15. data/lib/eadsax/address.rb +7 -0
  16. data/lib/eadsax/altformavail.rb +15 -0
  17. data/lib/eadsax/appraisal.rb +15 -0
  18. data/lib/eadsax/archdesc.rb +37 -0
  19. data/lib/eadsax/arrangement.rb +14 -0
  20. data/lib/eadsax/bibliography.rb +21 -0
  21. data/lib/eadsax/bioghist.rb +17 -0
  22. data/lib/eadsax/blockquote.rb +12 -0
  23. data/lib/eadsax/change.rb +8 -0
  24. data/lib/eadsax/chronitem.rb +9 -0
  25. data/lib/eadsax/chronlist.rb +9 -0
  26. data/lib/eadsax/components.rb +59 -0
  27. data/lib/eadsax/container.rb +8 -0
  28. data/lib/eadsax/controlaccess.rb +25 -0
  29. data/lib/eadsax/custodhist.rb +16 -0
  30. data/lib/eadsax/dao.rb +7 -0
  31. data/lib/eadsax/daodesc.rb +14 -0
  32. data/lib/eadsax/defitem.rb +8 -0
  33. data/lib/eadsax/did.rb +23 -0
  34. data/lib/eadsax/div.rb +15 -0
  35. data/lib/eadsax/dsc.rb +19 -0
  36. data/lib/eadsax/ead.rb +9 -0
  37. data/lib/eadsax/eadheader.rb +10 -0
  38. data/lib/eadsax/editionstmt.rb +8 -0
  39. data/lib/eadsax/filedesc.rb +11 -0
  40. data/lib/eadsax/fileplan.rb +15 -0
  41. data/lib/eadsax/frontmatter.rb +8 -0
  42. data/lib/eadsax/index.rb +17 -0
  43. data/lib/eadsax/indexentry.rb +21 -0
  44. data/lib/eadsax/list.rb +10 -0
  45. data/lib/eadsax/listhead.rb +8 -0
  46. data/lib/eadsax/namegrp.rb +17 -0
  47. data/lib/eadsax/note.rb +13 -0
  48. data/lib/eadsax/notestmt.rb +7 -0
  49. data/lib/eadsax/odd.rb +17 -0
  50. data/lib/eadsax/originalsloc.rb +15 -0
  51. data/lib/eadsax/origination.rb +22 -0
  52. data/lib/eadsax/otherfindaid.rb +21 -0
  53. data/lib/eadsax/phystech.rb +15 -0
  54. data/lib/eadsax/prefercite.rb +15 -0
  55. data/lib/eadsax/processinfo.rb +15 -0
  56. data/lib/eadsax/profiledesc.rb +9 -0
  57. data/lib/eadsax/publicationstmt.rb +11 -0
  58. data/lib/eadsax/relatedmaterial.rb +21 -0
  59. data/lib/eadsax/revisiondesc.rb +8 -0
  60. data/lib/eadsax/row.rb +7 -0
  61. data/lib/eadsax/scopecontent.rb +8 -0
  62. data/lib/eadsax/separatedmaterial.rb +21 -0
  63. data/lib/eadsax/seriesstmt.rb +9 -0
  64. data/lib/eadsax/table.rb +8 -0
  65. data/lib/eadsax/tbody.rb +7 -0
  66. data/lib/eadsax/tgroup.rb +9 -0
  67. data/lib/eadsax/thead.rb +7 -0
  68. data/lib/eadsax/titlepage.rb +22 -0
  69. data/lib/eadsax/titleproper.rb +8 -0
  70. data/lib/eadsax/titlestmt.rb +10 -0
  71. data/lib/eadsax/userestrict.rb +15 -0
  72. data/spec/accessrestrict_spec.rb +9 -0
  73. data/spec/acqinfo_spec.rb +8 -0
  74. data/spec/archdesc_spec.rb +9 -0
  75. data/spec/arrangement_spec.rb +11 -0
  76. data/spec/bioghist_spec.rb +23 -0
  77. data/spec/chronitem_spec.rb +11 -0
  78. data/spec/chronlist_spec.rb +11 -0
  79. data/spec/components_spec.rb +11 -0
  80. data/spec/controlaccess_spec.rb +11 -0
  81. data/spec/did_spec.rb +14 -0
  82. data/spec/dsc_spec.rb +11 -0
  83. data/spec/ead_spec.rb +9 -0
  84. data/spec/eadheader_spec.rb +9 -0
  85. data/spec/eads/example.xml +315 -0
  86. data/spec/eadsax_spec.rb +8 -0
  87. data/spec/filedesc_spec.rb +11 -0
  88. data/spec/prefercite_spec.rb +11 -0
  89. data/spec/profiledesc_spec.rb +11 -0
  90. data/spec/publicationstmt_spec.rb +11 -0
  91. data/spec/scopecontent_spec.rb +13 -0
  92. data/spec/spec_helper.rb +16 -0
  93. data/spec/titleproper_spec.rb +11 -0
  94. data/spec/titlestmt_spec.rb +11 -0
  95. data/spec/userestrict_spec.rb +11 -0
  96. data/watchr.rb +34 -0
  97. metadata +274 -0
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1,2 @@
1
+ rvm ree@eadsax
2
+
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "sax-machine"
7
+ gem "trollop"
8
+
9
+ # Add dependencies to develop your gem here.
10
+ # Include everything needed to run rake, tests, features, etc.
11
+ group :development do
12
+ gem "rspec", "~> 2.1.0"
13
+ gem "bundler", "~> 1.0.0"
14
+ gem "jeweler", "~> 1.5.1"
15
+ gem "rcov", ">= 0"
16
+ end
17
+
@@ -0,0 +1,34 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ git (1.2.5)
6
+ jeweler (1.5.1)
7
+ bundler (~> 1.0.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ nokogiri (1.4.3.1)
11
+ rake (0.8.7)
12
+ rcov (0.9.9)
13
+ rspec (2.1.0)
14
+ rspec-core (~> 2.1.0)
15
+ rspec-expectations (~> 2.1.0)
16
+ rspec-mocks (~> 2.1.0)
17
+ rspec-core (2.1.0)
18
+ rspec-expectations (2.1.0)
19
+ diff-lcs (~> 1.1.2)
20
+ rspec-mocks (2.1.0)
21
+ sax-machine (0.0.15)
22
+ nokogiri (> 0.0.0)
23
+ trollop (1.16.2)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.0.0)
30
+ jeweler (~> 1.5.1)
31
+ rcov
32
+ rspec (~> 2.1.0)
33
+ sax-machine
34
+ trollop
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Jason Ronallo
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,14 @@
1
+ = eadsax
2
+
3
+ Parses EAD XML into objects using sax-machine.
4
+
5
+ = Usage
6
+
7
+ require 'eadsax'
8
+ ead = Eadsax::Ead.parse(File.read('/path/to/ead.xml'))
9
+
10
+ == Copyright
11
+
12
+ Copyright (c) 2010 Jason Ronallo. See LICENSE.txt for
13
+ further details.
14
+
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "eadsax"
16
+ gem.homepage = "http://github.com/jronallo/eadsax"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Parse EAD XML}
19
+ gem.description = %Q{Parse EAD XML using sax-machine.}
20
+ gem.email = "jronallo@gmail.com"
21
+ gem.authors = ["Jason Ronallo"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "eadsax #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require 'eadsax'
4
+ require 'trollop'
5
+ require 'pp'
6
+
7
+ opts = Trollop::options do
8
+ banner <<-EOS
9
+ This script take an EAD XML or directory full of EAD XML and outputs the pretty
10
+ printed inspection of parsing it.
11
+
12
+ Usage:
13
+ eadsax --file ead.xml
14
+ eadsax --directory /path/to/eads/
15
+
16
+ where options are:
17
+ EOS
18
+ opt :file, 'Takes an EAD XML file, parses it and outputs the pretty print inspection.',
19
+ :type => String
20
+ opt :directory, 'Given a directory, parses all the EAD XML within and outputs the pretty print inspection for each.',
21
+ :type => String
22
+ end
23
+
24
+ if !opts[:file] and !opts[:directory]
25
+ Trollop::die :file, 'Must specify either file or directory to process.'
26
+ end
27
+
28
+ if opts[:file] and opts[:directory]
29
+ Trollop::die :file, 'May only specify file or directory to process.'
30
+ end
31
+
32
+ if opts[:file]
33
+ if !File.exists?(opts[:file])
34
+ Trollop::die :file, 'File does not exist.'
35
+ end
36
+ files = [opts[:file]]
37
+ elsif opts[:directory]
38
+ if !File.exists?(opts[:directory])
39
+ Trollop::die :directory, 'Directory does not exist.'
40
+ end
41
+ files = Dir.glob(File.join(opts[:directory], '*.xml'))
42
+ end
43
+
44
+ files.each do |file|
45
+ ead = Eadsax::Ead.parse(File.read(file))
46
+ pp ead
47
+ end
48
+
@@ -0,0 +1,75 @@
1
+ require 'rubygems'
2
+ require 'sax-machine'
3
+
4
+ module Eadsax
5
+ autoload :Accessrestrict, "eadsax/accessrestrict"
6
+ autoload :Accruals, "eadsax/accruals"
7
+ autoload :Acqinfo, "eadsax/acqinfo"
8
+ autoload :Address, "eadsax/address"
9
+ autoload :Altformavail, "eadsax/altformavail"
10
+ autoload :Appraisal, "eadsax/appraisal"
11
+ autoload :Archdesc, "eadsax/archdesc"
12
+ autoload :Arrangement, "eadsax/arrangement"
13
+ autoload :Bibliography, "eadsax/bibliography"
14
+ autoload :Bioghist, "eadsax/bioghist"
15
+ autoload :Blockquote, "eadsax/blockquote"
16
+ autoload :Change, "eadsax/change"
17
+ autoload :Chronitem, "eadsax/chronitem"
18
+ autoload :Chronlist, "eadsax/chronlist"
19
+ autoload :Container, "eadsax/container"
20
+ autoload :Controlaccess, "eadsax/controlaccess"
21
+ autoload :Custodhist, "eadsax/custodhist"
22
+ autoload :Dao, 'eadsax/dao'
23
+ autoload :Daodesc, 'eadsax/daodesc'
24
+ autoload :Defitem, "eadsax/defitem"
25
+ autoload :Did, "eadsax/did"
26
+ autoload :Div, "eadsax/div"
27
+ autoload :Dsc, "eadsax/dsc"
28
+ autoload :Eadheader, "eadsax/eadheader"
29
+ autoload :Editionstmt, 'eadsax/editionstmt'
30
+ autoload :Filedesc, "eadsax/filedesc"
31
+ autoload :Fileplan, 'eadsax/fileplan'
32
+ autoload :Index, "eadsax/index"
33
+ autoload :Indexentry, "eadsax/indexentry"
34
+ autoload :List, "eadsax/list"
35
+ autoload :Listhead, "eadsax/listhead"
36
+ autoload :Namegrp, "eadsax/namegrp"
37
+ autoload :Note, "eadsax/note"
38
+ autoload :Notestmt, "eadsax/notestmt"
39
+ autoload :Odd, "eadsax/odd"
40
+ autoload :Originalsloc, 'eadsax/originalsloc'
41
+ autoload :Origination, "eadsax/origination"
42
+ autoload :Otherfindaid, "eadsax/otherfindaid"
43
+ # autoload :Physdesc, "eadsax/physdesc"
44
+ autoload :Phystech, 'eadsax/phystech'
45
+ autoload :Prefercite, "eadsax/prefercite"
46
+ autoload :Processinfo, "eadsax/processinfo"
47
+ autoload :Profiledesc, "eadsax/profiledesc"
48
+ autoload :Publicationstmt, "eadsax/publicationstmt"
49
+ autoload :Relatedmaterial, "eadsax/relatedmaterial"
50
+ autoload :Row, 'eadsax/row'
51
+ autoload :Revisiondesc, "eadsax/revisiondesc"
52
+ autoload :Seriesstmt, 'eadsax/seriesstmt'
53
+ autoload :Scopecontent, "eadsax/scopecontent"
54
+ autoload :Separatedmaterial, "eadsax/separatedmaterial"
55
+ autoload :Table, 'eadsax/table'
56
+ autoload :Tbody, 'eadsax/tbody'
57
+ autoload :Tgroup, 'eadsax/tgroup'
58
+ autoload :Thead, 'eadsax/thead'
59
+ autoload :Titlepage, 'eadsax/titlepage'
60
+ autoload :Titleproper, "eadsax/titleproper"
61
+ autoload :Titlestmt, "eadsax/titlestmt"
62
+ autoload :Userestrict, "eadsax/userestrict"
63
+
64
+ autoload :C01, 'eadsax/components'
65
+
66
+ end
67
+
68
+ require 'eadsax/ead'
69
+
70
+ class String
71
+ def clean
72
+ self.gsub(/\n/, ' ').gsub(/\s+/, ' ')
73
+ end
74
+ end
75
+
@@ -0,0 +1,15 @@
1
+ module Eadsax
2
+ class Accessrestrict
3
+ include SAXMachine
4
+ element :address, :class => Address
5
+ element :blockquote, :class => Blockquote
6
+ element :chronlist, :class => Chronlist
7
+ element :head
8
+ element :legalstatus
9
+ element :list, :class => List
10
+ elements :note, :as => :notes
11
+ elements :p, :as => :ps
12
+ element :table, :class => Table
13
+ end
14
+ end
15
+
@@ -0,0 +1,14 @@
1
+ module Eadsax
2
+ class Accruals
3
+ include SAXMachine
4
+ element :address, :class => Address
5
+ element :blockquote, :class => Blockquote
6
+ element :chronlist, :class => Chronlist
7
+ element :head
8
+ element :list, :class => List
9
+ element :note, :class => Note
10
+ elements :p, :as => :ps
11
+ element :table, :class => Table
12
+ end
13
+ end
14
+
@@ -0,0 +1,14 @@
1
+ module Eadsax
2
+ class Acqinfo
3
+ include SAXMachine
4
+ element :address, :class => Address
5
+ element :blockquote, :class => Blockquote
6
+ element :chronlist, :class => Chronlist
7
+ element :head
8
+ element :list, :class => List
9
+ element :note, :class => Note
10
+ elements :p, :as => :ps
11
+ element :table, :class => Table
12
+ end
13
+ end
14
+
@@ -0,0 +1,7 @@
1
+ module Eadsax
2
+ class Address
3
+ include SAXMachine
4
+ element :addressline
5
+ end
6
+ end
7
+
@@ -0,0 +1,15 @@
1
+ module Eadsax
2
+ class Altformavail
3
+ include SAXMachine
4
+ element :address, :class => Address
5
+ element :altformavail, :class => Altformavail
6
+ element :blockquote, :class => Blockquote
7
+ element :chronlist, :class => Chronlist
8
+ element :head
9
+ element :list, :class => List
10
+ element :note, :class => Note
11
+ elements :p, :as => :ps
12
+ element :table, :class => Table
13
+ end
14
+ end
15
+
@@ -0,0 +1,15 @@
1
+ module Eadsax
2
+ class Appraisal
3
+ include SAXMachine
4
+ element :address, :class => Address
5
+ element :appraisal, :class => Appraisal
6
+ element :blockquote, :class => Blockquote
7
+ element :chronlist, :class => Chronlist
8
+ element :head
9
+ element :list, :class => List
10
+ element :note, :class => Note
11
+ elements :p, :as => :ps
12
+ element :table, :class => Table
13
+ end
14
+ end
15
+
@@ -0,0 +1,37 @@
1
+ module Eadsax
2
+ class Archdesc
3
+ include SAXMachine
4
+ element :did, :class => Did
5
+ element :dsc, :class => Dsc
6
+
7
+ element :accessrestrict, :class => Accessrestrict
8
+ element :accruals, :class => Accruals
9
+ element :acqinfo, :class => Acqinfo
10
+ element :altformavail, :class => Altformavail
11
+ element :appraisal, :class => Appraisal
12
+ element :arrangement, :class => Arrangement
13
+ element :bibliography, :class => Bibliography
14
+ element :bioghist, :class => Bioghist
15
+ element :controlaccess, :class => Controlaccess
16
+ element :custodhist, :class => Custodhist
17
+ element :dao, :class => Dao
18
+ element :daogrp
19
+ element :descgrp
20
+ element :fileplan, :class => Fileplan
21
+ element :index, :class => Index
22
+ element :note, :class => Note
23
+ element :odd, :class => Odd
24
+ element :originalsloc, :class => Originalsloc
25
+ element :otherfindaid, :class => Otherfindaid
26
+ element :phystech, :class => Phystech
27
+ element :prefercite, :class => Prefercite
28
+ element :processinfo, :class => Processinfo
29
+ element :relatedmaterial, :class => Relatedmaterial
30
+ element :runner
31
+ element :scopecontent, :class => Scopecontent
32
+ element :separatedmaterial, :class => Separatedmaterial
33
+ element :userestrict, :class => Userestrict
34
+
35
+ end
36
+ end
37
+
@@ -0,0 +1,14 @@
1
+ module Eadsax
2
+ class Arrangement
3
+ include SAXMachine
4
+ element :address, :class => Address
5
+ element :blockquote, :class => Blockquote
6
+ element :chronlist, :class => Chronlist
7
+ element :head
8
+ element :list, :class => List
9
+ element :note, :class => Note
10
+ elements :p, :as => :ps
11
+ element :table, :class => Table
12
+ end
13
+ end
14
+
@@ -0,0 +1,21 @@
1
+ module Eadsax
2
+ class Bibliography
3
+ include SAXMachine
4
+ element :address, :class => Address
5
+ element :archref
6
+ element :bibliography, :class => Bibliography
7
+ element :bibref
8
+ element :blockquote, :class => Blockquote
9
+ element :chronlist, :class => Chronlist
10
+ element :extref
11
+ element :head
12
+ element :linkgrp
13
+ element :list, :class => List
14
+ elements :note, :as => :notes
15
+ elements :p, :as => :ps
16
+ element :ref
17
+ element :table, :class => Table
18
+ element :title
19
+ end
20
+ end
21
+