mead 0.0.6 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -1
- data/Gemfile.lock +4 -4
- data/VERSION +1 -1
- data/lib/mead/component_part.rb +80 -0
- data/lib/mead/container.rb +9 -0
- data/lib/mead/extractor.rb +4 -3
- data/lib/mead/identifier.rb +4 -17
- data/lib/mead/validations.rb +1 -1
- data/lib/mead.rb +1 -0
- data/mead.gemspec +8 -5
- data/test/test_component_part.rb +135 -0
- data/test/test_extractor.rb +8 -7
- data/test/test_mc00240.rb +6 -14
- data/test/test_ua015_010.rb +2 -11
- data/test/test_ua023_006_buildings.rb +1 -11
- data/test/test_ua023_006_faculty.rb +2 -11
- data/test/test_ua110_041.rb +2 -12
- metadata +11 -11
    
        data/Gemfile
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -10,9 +10,9 @@ GEM | |
| 10 10 | 
             
                  bundler (~> 1.0.0)
         | 
| 11 11 | 
             
                  git (>= 1.2.5)
         | 
| 12 12 | 
             
                  rake
         | 
| 13 | 
            -
                json (1.5. | 
| 13 | 
            +
                json (1.5.1)
         | 
| 14 14 | 
             
                linecache (0.43)
         | 
| 15 | 
            -
                nokogiri (1.4. | 
| 15 | 
            +
                nokogiri (1.4.4)
         | 
| 16 16 | 
             
                rake (0.8.7)
         | 
| 17 17 | 
             
                rcov (0.9.9)
         | 
| 18 18 | 
             
                reek (1.2.8)
         | 
| @@ -30,7 +30,7 @@ GEM | |
| 30 30 | 
             
                ruby2ruby (1.2.5)
         | 
| 31 31 | 
             
                  ruby_parser (~> 2.0)
         | 
| 32 32 | 
             
                  sexp_processor (~> 3.0)
         | 
| 33 | 
            -
                ruby_parser (2.0. | 
| 33 | 
            +
                ruby_parser (2.0.6)
         | 
| 34 34 | 
             
                  sexp_processor (~> 3.0)
         | 
| 35 35 | 
             
                sexp_processor (3.0.5)
         | 
| 36 36 | 
             
                shoulda (2.11.3)
         | 
| @@ -46,7 +46,7 @@ DEPENDENCIES | |
| 46 46 | 
             
              gbarcode (>= 0.98.20)
         | 
| 47 47 | 
             
              jeweler (~> 1.5.1)
         | 
| 48 48 | 
             
              json
         | 
| 49 | 
            -
              nokogiri | 
| 49 | 
            +
              nokogiri
         | 
| 50 50 | 
             
              rcov
         | 
| 51 51 | 
             
              reek (~> 1.2.8)
         | 
| 52 52 | 
             
              rmagick
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.0 | 
| 1 | 
            +
            0.1.0
         | 
| @@ -0,0 +1,80 @@ | |
| 1 | 
            +
            module Mead
         | 
| 2 | 
            +
              class ComponentPart
         | 
| 3 | 
            +
                attr_accessor :unittitle, :unitdate, :unitid, :level, 
         | 
| 4 | 
            +
                  :series_sequence, :containers, 
         | 
| 5 | 
            +
                  :item_location #FIXME: temporary attribute while refactoring
         | 
| 6 | 
            +
                
         | 
| 7 | 
            +
                def initialize(opts={})
         | 
| 8 | 
            +
                  @item_location = opts[:item_location] if opts[:item_location]
         | 
| 9 | 
            +
                  @unittitle = opts[:unittitle] if opts[:unittitle]
         | 
| 10 | 
            +
                  @unitdate = opts[:unitdate] if opts[:unitdate]
         | 
| 11 | 
            +
                  @unitid = opts[:unitid] if opts[:unitid]
         | 
| 12 | 
            +
                  @level = opts[:level] if opts[:level]
         | 
| 13 | 
            +
                  self.series_sequence = opts[:series_sequence] if opts[:series_sequence]
         | 
| 14 | 
            +
                  
         | 
| 15 | 
            +
                  
         | 
| 16 | 
            +
                  if opts[:containers] 
         | 
| 17 | 
            +
                    @containers = []
         | 
| 18 | 
            +
                    # FIXME: What is a better way to insure the Array-ness of containers?
         | 
| 19 | 
            +
                    if opts[:containers].is_a? Array
         | 
| 20 | 
            +
                      opts[:containers].each do |container|
         | 
| 21 | 
            +
                        if container.is_a?(Mead::Container)
         | 
| 22 | 
            +
                          @containers << container
         | 
| 23 | 
            +
                        else
         | 
| 24 | 
            +
                          raise 'containers must have only Mead::Containers'
         | 
| 25 | 
            +
                        end
         | 
| 26 | 
            +
                      end
         | 
| 27 | 
            +
                    else
         | 
| 28 | 
            +
                      raise 'containers must be in an Array'
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
                
         | 
| 33 | 
            +
                def series_sequence=(integer)
         | 
| 34 | 
            +
                  if !integer.is_a?(Integer)
         | 
| 35 | 
            +
                    # FIXME: create better error class
         | 
| 36 | 
            +
                    raise RuntimeError, 'series_sequence must be an integer'
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
                  @series_sequence = integer
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
                
         | 
| 41 | 
            +
            #    def <<(container)
         | 
| 42 | 
            +
            #      @containers << container
         | 
| 43 | 
            +
            #    end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                # FIXME: must be a better way to implement my own equality. How to get all
         | 
| 46 | 
            +
                # the symbols for the possible attributes for an instance of a class?
         | 
| 47 | 
            +
                def ==(another_cp)
         | 
| 48 | 
            +
                  return false if !another_cp.is_a?(Mead::ComponentPart)
         | 
| 49 | 
            +
                  [:unittitle, :unitdate, :unitid, :level, 
         | 
| 50 | 
            +
                  :series_sequence, :containers, 
         | 
| 51 | 
            +
                  :item_location].each do |attribute|
         | 
| 52 | 
            +
                    if self.send(attribute) != another_cp.send(attribute)
         | 
| 53 | 
            +
                      return false
         | 
| 54 | 
            +
                    end
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
                  return true
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
                
         | 
| 59 | 
            +
                def containers=(container)
         | 
| 60 | 
            +
                  @containers = []
         | 
| 61 | 
            +
                  self.containers << container
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
                
         | 
| 64 | 
            +
                # FIXME: temporary method while refactoring
         | 
| 65 | 
            +
                def [](attribute)
         | 
| 66 | 
            +
                  self.send(attribute)
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
                
         | 
| 69 | 
            +
                def to_json(*a)
         | 
| 70 | 
            +
                 h = {
         | 
| 71 | 
            +
                   'json_class'   => self.class.name
         | 
| 72 | 
            +
                 }
         | 
| 73 | 
            +
                 self.instance_variables.each do |var|
         | 
| 74 | 
            +
                   h[var.sub('@','').to_sym] = self.send(var.sub('@','').to_sym)
         | 
| 75 | 
            +
                 end
         | 
| 76 | 
            +
                 h.to_json(*a)
         | 
| 77 | 
            +
               end
         | 
| 78 | 
            +
                    
         | 
| 79 | 
            +
              end
         | 
| 80 | 
            +
            end
         | 
    
        data/lib/mead/container.rb
    CHANGED
    
    | @@ -16,6 +16,15 @@ module Mead | |
| 16 16 | 
             
                  self.text == another_container.text
         | 
| 17 17 | 
             
                end
         | 
| 18 18 |  | 
| 19 | 
            +
                def to_json(*a)
         | 
| 20 | 
            +
                 h = {
         | 
| 21 | 
            +
                   'json_class'   => self.class.name
         | 
| 22 | 
            +
                 }
         | 
| 23 | 
            +
                 self.instance_variables.each do |var|
         | 
| 24 | 
            +
                   h[var.sub('@','').to_sym] = self.send(var.sub('@','').to_sym)
         | 
| 25 | 
            +
                 end
         | 
| 26 | 
            +
                 h.to_json(*a)
         | 
| 27 | 
            +
               end
         | 
| 19 28 |  | 
| 20 29 | 
             
              end
         | 
| 21 30 | 
             
            end
         | 
    
        data/lib/mead/extractor.rb
    CHANGED
    
    | @@ -57,14 +57,13 @@ module Mead | |
| 57 57 | 
             
                  additional_did[:item_location] = did_location_text if did_location_text
         | 
| 58 58 |  | 
| 59 59 | 
             
                  add_containers(additional_did, node)
         | 
| 60 | 
            -
                  
         | 
| 61 60 | 
             
                  if additional_did[:level] == 'series'
         | 
| 62 | 
            -
                    additional_did[: | 
| 61 | 
            +
                    additional_did[:series_sequence] = series_number(node)
         | 
| 63 62 | 
             
                  end
         | 
| 64 63 | 
             
                  if @stack.last == additional_did
         | 
| 65 64 | 
             
                    return
         | 
| 66 65 | 
             
                  end
         | 
| 67 | 
            -
                  @stack << additional_did
         | 
| 66 | 
            +
                  @stack << Mead::ComponentPart.new(additional_did)
         | 
| 68 67 | 
             
                  if !node.parent.parent.xpath('xmlns:did').empty?
         | 
| 69 68 | 
             
                    push_to_stack(node.parent.parent.xpath('xmlns:did')[0])
         | 
| 70 69 | 
             
                  end
         | 
| @@ -93,6 +92,8 @@ module Mead | |
| 93 92 | 
             
                  end
         | 
| 94 93 | 
             
                end
         | 
| 95 94 |  | 
| 95 | 
            +
                # FIXME: This currently depends on series being numbered sequentially and being
         | 
| 96 | 
            +
                # arranged in that order in the EAD XML.
         | 
| 96 97 | 
             
                def get_series
         | 
| 97 98 | 
             
                  c01_series = @dsc.xpath(".//xmlns:c01[@level='series']")
         | 
| 98 99 | 
             
                  if c01_series and !c01_series.empty?
         | 
    
        data/lib/mead/identifier.rb
    CHANGED
    
    | @@ -1,7 +1,10 @@ | |
| 1 1 | 
             
            module Mead
         | 
| 2 2 | 
             
              class Identifier
         | 
| 3 3 |  | 
| 4 | 
            -
                attr_accessor :mead, :eadid, :series,  | 
| 4 | 
            +
                attr_accessor :mead, :eadid, :series, 
         | 
| 5 | 
            +
                  # container is just the first container and folder the second container
         | 
| 6 | 
            +
                  :container, :folder, 
         | 
| 7 | 
            +
                  :sequence, :page, 
         | 
| 5 8 | 
             
                  :ead_location, :metadata
         | 
| 6 9 | 
             
                include Mead::Validations
         | 
| 7 10 | 
             
                validates_format_of_mead
         | 
| @@ -92,21 +95,5 @@ module Mead | |
| 92 95 | 
             
                  self
         | 
| 93 96 | 
             
                end
         | 
| 94 97 |  | 
| 95 | 
            -
            #    def ead_has_series?
         | 
| 96 | 
            -
            #      if series > 1
         | 
| 97 | 
            -
            #        true
         | 
| 98 | 
            -
            #      else
         | 
| 99 | 
            -
            #        if 
         | 
| 100 | 
            -
            #        false
         | 
| 101 | 
            -
            #      end
         | 
| 102 | 
            -
            #    end
         | 
| 103 | 
            -
             | 
| 104 | 
            -
            #    def replace_underscores(*args)
         | 
| 105 | 
            -
            #      args.each do |field|
         | 
| 106 | 
            -
            #        value = instance_variable_get('@' + field).gsub('_', '.')
         | 
| 107 | 
            -
            #        instance_variable_set('@' + field, value)
         | 
| 108 | 
            -
            #      end
         | 
| 109 | 
            -
            #    end
         | 
| 110 | 
            -
             | 
| 111 98 | 
             
              end
         | 
| 112 99 | 
             
            end
         | 
    
        data/lib/mead/validations.rb
    CHANGED
    
    | @@ -82,7 +82,7 @@ module Mead | |
| 82 82 | 
             
                      if result.nil? or result.empty?
         | 
| 83 83 | 
             
                        add_error(instance, :mead, 'No matching container.')
         | 
| 84 84 | 
             
                      # even if the instance.series is 1 there may not be any series in the EAD XML yet
         | 
| 85 | 
            -
             | 
| 85 | 
            +
                    elsif result.last[:series_sequence] and instance.series != result.last[:series_sequence].to_s
         | 
| 86 86 | 
             
                        add_error(instance, :mead, 'Bad series.') 
         | 
| 87 87 | 
             
                      end
         | 
| 88 88 | 
             
                      rescue => e
         | 
    
        data/lib/mead.rb
    CHANGED
    
    
    
        data/mead.gemspec
    CHANGED
    
    | @@ -5,11 +5,11 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = %q{mead}
         | 
| 8 | 
            -
              s.version = "0.0 | 
| 8 | 
            +
              s.version = "0.1.0"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["Jason Ronallo"]
         | 
| 12 | 
            -
              s.date = %q{2011-02- | 
| 12 | 
            +
              s.date = %q{2011-02-27}
         | 
| 13 13 | 
             
              s.description = %q{Extract identifiers and metadata from EAD XML.}
         | 
| 14 14 | 
             
              s.email = %q{jronallo@gmail.com}
         | 
| 15 15 | 
             
              s.executables = ["mead2barcode", "meadbfv", "emv", "automead", "ead2meads"]
         | 
| @@ -32,6 +32,7 @@ Gem::Specification.new do |s| | |
| 32 32 | 
             
                "bin/meadbfv",
         | 
| 33 33 | 
             
                "lib/mead.rb",
         | 
| 34 34 | 
             
                "lib/mead/barcode.rb",
         | 
| 35 | 
            +
                "lib/mead/component_part.rb",
         | 
| 35 36 | 
             
                "lib/mead/container.rb",
         | 
| 36 37 | 
             
                "lib/mead/ead.rb",
         | 
| 37 38 | 
             
                "lib/mead/ead_validator.rb",
         | 
| @@ -51,6 +52,7 @@ Gem::Specification.new do |s| | |
| 51 52 | 
             
                "test/fixtures/ua023_031.xml",
         | 
| 52 53 | 
             
                "test/helper.rb",
         | 
| 53 54 | 
             
                "test/test_barcode.rb",
         | 
| 55 | 
            +
                "test/test_component_part.rb",
         | 
| 54 56 | 
             
                "test/test_ead.rb",
         | 
| 55 57 | 
             
                "test/test_ead_validator.rb",
         | 
| 56 58 | 
             
                "test/test_extractor.rb",
         | 
| @@ -73,6 +75,7 @@ Gem::Specification.new do |s| | |
| 73 75 | 
             
              s.test_files = [
         | 
| 74 76 | 
             
                "test/helper.rb",
         | 
| 75 77 | 
             
                "test/test_barcode.rb",
         | 
| 78 | 
            +
                "test/test_component_part.rb",
         | 
| 76 79 | 
             
                "test/test_ead.rb",
         | 
| 77 80 | 
             
                "test/test_ead_validator.rb",
         | 
| 78 81 | 
             
                "test/test_extractor.rb",
         | 
| @@ -92,7 +95,7 @@ Gem::Specification.new do |s| | |
| 92 95 | 
             
                s.specification_version = 3
         | 
| 93 96 |  | 
| 94 97 | 
             
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         | 
| 95 | 
            -
                  s.add_runtime_dependency(%q<nokogiri>, [" | 
| 98 | 
            +
                  s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
         | 
| 96 99 | 
             
                  s.add_runtime_dependency(%q<json>, [">= 0"])
         | 
| 97 100 | 
             
                  s.add_runtime_dependency(%q<trollop>, [">= 0"])
         | 
| 98 101 | 
             
                  s.add_runtime_dependency(%q<fastercsv>, [">= 0"])
         | 
| @@ -107,7 +110,7 @@ Gem::Specification.new do |s| | |
| 107 110 | 
             
                  s.add_development_dependency(%q<fakeweb>, [">= 0"])
         | 
| 108 111 | 
             
                  s.add_development_dependency(%q<ruby-debug>, [">= 0"])
         | 
| 109 112 | 
             
                else
         | 
| 110 | 
            -
                  s.add_dependency(%q<nokogiri>, [" | 
| 113 | 
            +
                  s.add_dependency(%q<nokogiri>, [">= 0"])
         | 
| 111 114 | 
             
                  s.add_dependency(%q<json>, [">= 0"])
         | 
| 112 115 | 
             
                  s.add_dependency(%q<trollop>, [">= 0"])
         | 
| 113 116 | 
             
                  s.add_dependency(%q<fastercsv>, [">= 0"])
         | 
| @@ -123,7 +126,7 @@ Gem::Specification.new do |s| | |
| 123 126 | 
             
                  s.add_dependency(%q<ruby-debug>, [">= 0"])
         | 
| 124 127 | 
             
                end
         | 
| 125 128 | 
             
              else
         | 
| 126 | 
            -
                s.add_dependency(%q<nokogiri>, [" | 
| 129 | 
            +
                s.add_dependency(%q<nokogiri>, [">= 0"])
         | 
| 127 130 | 
             
                s.add_dependency(%q<json>, [">= 0"])
         | 
| 128 131 | 
             
                s.add_dependency(%q<trollop>, [">= 0"])
         | 
| 129 132 | 
             
                s.add_dependency(%q<fastercsv>, [">= 0"])
         | 
| @@ -0,0 +1,135 @@ | |
| 1 | 
            +
            require 'helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class TestComponentPart < Test::Unit::TestCase
         | 
| 4 | 
            +
              
         | 
| 5 | 
            +
              should "create a new component part with no options" do
         | 
| 6 | 
            +
                assert Mead::ComponentPart.new 
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
              
         | 
| 9 | 
            +
              context "creating a component part with good options" do
         | 
| 10 | 
            +
                should "have a unittitle attribute" do
         | 
| 11 | 
            +
                  cp = Mead::ComponentPart.new(:unittitle => 'unit title')
         | 
| 12 | 
            +
                  assert_equal 'unit title', cp.unittitle
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
                
         | 
| 15 | 
            +
                should "have a unitdate attribute" do
         | 
| 16 | 
            +
                  cp = Mead::ComponentPart.new(:unitdate => 'unit date')
         | 
| 17 | 
            +
                  assert_equal 'unit date', cp.unitdate
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
                
         | 
| 20 | 
            +
                should 'have a unitid attribute' do
         | 
| 21 | 
            +
                  cp = Mead::ComponentPart.new(:unitid => 'unit id')
         | 
| 22 | 
            +
                  assert_equal 'unit id', cp.unitid
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
                
         | 
| 25 | 
            +
                should 'have a level attribute' do
         | 
| 26 | 
            +
                  cp = Mead::ComponentPart.new(:level => 'level')
         | 
| 27 | 
            +
                  assert_equal 'level', cp.level
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
                
         | 
| 30 | 
            +
                should 'have a series_sequence attribute' do
         | 
| 31 | 
            +
                  cp = Mead::ComponentPart.new(:series_sequence => 8)
         | 
| 32 | 
            +
                  assert_equal 8, cp.series_sequence
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
                
         | 
| 35 | 
            +
                should 'not allow a non-Integer as the series_sequence' do
         | 
| 36 | 
            +
                  assert_raise(RuntimeError){ Mead::ComponentPart.new(:series_sequence => '8')}
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
                
         | 
| 39 | 
            +
                should 'allow for assinging containers as an option' do
         | 
| 40 | 
            +
                  container1 = Mead::Container.new(:level => 'file')
         | 
| 41 | 
            +
                  container2 = Mead::Container.new(:level => 'series')
         | 
| 42 | 
            +
                  cp = Mead::ComponentPart.new(:containers => [container1, container2])
         | 
| 43 | 
            +
                  assert_equal [container1, container2], cp.containers
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
                
         | 
| 46 | 
            +
                should 'raise if trying to mass assign non-Array to containers' do
         | 
| 47 | 
            +
                  assert_raise(RuntimeError){ Mead::ComponentPart.new(:containers => 'asdfa')}      
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
                
         | 
| 50 | 
            +
                should 'raise if trying to mass assign non-Containers to containers' do
         | 
| 51 | 
            +
                  assert_raise(RuntimeError){Mead::ComponentPart.new(:containers => ['asdfa'])}
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
                
         | 
| 54 | 
            +
                should 'not automatically create an empty array for containers' do
         | 
| 55 | 
            +
                  cp = Mead::ComponentPart.new
         | 
| 56 | 
            +
                  assert_nil cp.containers
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
                
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
              
         | 
| 61 | 
            +
              context "build up component part values" do
         | 
| 62 | 
            +
                setup do
         | 
| 63 | 
            +
                  @cp = Mead::ComponentPart.new
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
                
         | 
| 66 | 
            +
                should 'allow a unittitle to be assigned' do
         | 
| 67 | 
            +
                  @cp.unittitle = 'unit title'
         | 
| 68 | 
            +
                  assert_equal 'unit title', @cp.unittitle
         | 
| 69 | 
            +
                end
         | 
| 70 | 
            +
                
         | 
| 71 | 
            +
                should 'allow a unitdate to be assigned' do
         | 
| 72 | 
            +
                  @cp.unitdate = 'unit date'
         | 
| 73 | 
            +
                  assert_equal 'unit date', @cp.unitdate
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
                
         | 
| 76 | 
            +
                should 'allow a unitid to be assigned' do
         | 
| 77 | 
            +
                  @cp.unitid = 'unit id'
         | 
| 78 | 
            +
                  assert_equal 'unit id', @cp.unitid
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
                
         | 
| 81 | 
            +
                should 'allow a level to be assigned' do
         | 
| 82 | 
            +
                  @cp.level = 'level'
         | 
| 83 | 
            +
                  assert_equal 'level', @cp.level
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
                
         | 
| 86 | 
            +
                should 'allow a series_sequence to be assigned' do
         | 
| 87 | 
            +
                  @cp.series_sequence = 8
         | 
| 88 | 
            +
                  assert_equal 8, @cp.series_sequence
         | 
| 89 | 
            +
                end
         | 
| 90 | 
            +
                
         | 
| 91 | 
            +
                should 'not allow a string to be assigned to the series_sequence' do
         | 
| 92 | 
            +
                  assert_raise(RuntimeError) {@cp.series_sequence = '9'}
         | 
| 93 | 
            +
                end
         | 
| 94 | 
            +
                
         | 
| 95 | 
            +
                should 'store containers as an array' do
         | 
| 96 | 
            +
                  @cp.containers = [Mead::Container.new]
         | 
| 97 | 
            +
                  assert @cp.containers.is_a? Array
         | 
| 98 | 
            +
                end
         | 
| 99 | 
            +
                
         | 
| 100 | 
            +
                should 'allow for adding to the containers array' #do
         | 
| 101 | 
            +
            #      container = Mead::Container.new
         | 
| 102 | 
            +
            #      @cp.containers << container
         | 
| 103 | 
            +
            #      assert_equal [container], @cp.containers
         | 
| 104 | 
            +
            #    end
         | 
| 105 | 
            +
                
         | 
| 106 | 
            +
                should 'not allow for adding a non-Container to containers' #do
         | 
| 107 | 
            +
            #      assert_raise(RuntimeError){@cp.containers << 'asdf'}
         | 
| 108 | 
            +
            #    end
         | 
| 109 | 
            +
                
         | 
| 110 | 
            +
                context 'multiple containers' do
         | 
| 111 | 
            +
                  setup do
         | 
| 112 | 
            +
                    @container1 = Mead::Container.new(:type => 'file')
         | 
| 113 | 
            +
                    @container2 = Mead::Container.new(:type => 'series')
         | 
| 114 | 
            +
                  end      
         | 
| 115 | 
            +
                  
         | 
| 116 | 
            +
                  should 'allow assigning directly to containers, but resetting everything there' #do        
         | 
| 117 | 
            +
            #        @cp.containers << @container1
         | 
| 118 | 
            +
            #        assert_equal [@container1], @cp.containers
         | 
| 119 | 
            +
            #        
         | 
| 120 | 
            +
            #        @cp.containers = @container2
         | 
| 121 | 
            +
            #        assert_equal [@container2], @cp.containers
         | 
| 122 | 
            +
            #      end
         | 
| 123 | 
            +
                  
         | 
| 124 | 
            +
                  should 'add a container on to the end of the containers' #do
         | 
| 125 | 
            +
            #        @cp.containers << @container1 
         | 
| 126 | 
            +
            #        @cp.containers << @container2
         | 
| 127 | 
            +
            #        assert_equal [@container1, @container2], @cp.containers
         | 
| 128 | 
            +
            #      end
         | 
| 129 | 
            +
                  
         | 
| 130 | 
            +
                end
         | 
| 131 | 
            +
                
         | 
| 132 | 
            +
              end
         | 
| 133 | 
            +
              
         | 
| 134 | 
            +
              
         | 
| 135 | 
            +
            end
         | 
    
        data/test/test_extractor.rb
    CHANGED
    
    | @@ -6,6 +6,7 @@ class TestMeadExtractor < Test::Unit::TestCase | |
| 6 6 |  | 
| 7 7 | 
             
                  @identifier = 'ua023_031-008-cb0013-001-001'
         | 
| 8 8 | 
             
                  @expected_1 = [
         | 
| 9 | 
            +
                   Mead::ComponentPart.new(
         | 
| 9 10 | 
             
                    {:level=>"file", 
         | 
| 10 11 | 
             
                    :unitdate=>nil, 
         | 
| 11 12 | 
             
                    :unitid=>nil, 
         | 
| @@ -15,9 +16,9 @@ class TestMeadExtractor < Test::Unit::TestCase | |
| 15 16 | 
             
                    :containers => [
         | 
| 16 17 | 
             
                      Mead::Container.new(:type => 'cardbox', :label => "Mixed materials", :text => '13'), 
         | 
| 17 18 | 
             
                      Mead::Container.new(:type => 'Envelope', :text => '1')]
         | 
| 18 | 
            -
                    },
         | 
| 19 | 
            -
                    {:level=>"subseries", :unitdate=>nil, :unitid=>nil, :unittitle=>"Students"},
         | 
| 20 | 
            -
                    {:level=>"series", :unitdate=>nil, : | 
| 19 | 
            +
                    }),
         | 
| 20 | 
            +
                    Mead::ComponentPart.new({:level=>"subseries", :unitdate=>nil, :unitid=>nil, :unittitle=>"Students"}),
         | 
| 21 | 
            +
                    Mead::ComponentPart.new({:level=>"series", :unitdate=>nil, :series_sequence=>8, :unitid=>"Series 8", :unittitle=>"People"})]
         | 
| 21 22 | 
             
                end
         | 
| 22 23 |  | 
| 23 24 | 
             
                should "produce a good extraction with a filehandle location for the Ead" do
         | 
| @@ -36,18 +37,18 @@ class TestMeadExtractor < Test::Unit::TestCase | |
| 36 37 |  | 
| 37 38 | 
             
                context 'mc00240-001-ff0052-000-001' do
         | 
| 38 39 | 
             
                  setup do
         | 
| 39 | 
            -
                    @expected_mc00240 = [{:unittitle=>"Friends Church",
         | 
| 40 | 
            +
                    @expected_mc00240 = [Mead::ComponentPart.new({:unittitle=>"Friends Church",
         | 
| 40 41 | 
             
                                :item_location=>"flatfolder 52",
         | 
| 41 42 | 
             
                                :unitdate=>"1927",
         | 
| 42 43 | 
             
                                :level=>"file",
         | 
| 43 44 | 
             
                                :unitid=>"903",
         | 
| 44 45 | 
             
                                :containers => 
         | 
| 45 | 
            -
                                [Mead::Container.new(:type => 'flatfolder', :label => 'Mixed materials', :text => '52')]},
         | 
| 46 | 
            -
                               {: | 
| 46 | 
            +
                                [Mead::Container.new(:type => 'flatfolder', :label => 'Mixed materials', :text => '52')]}),
         | 
| 47 | 
            +
                               Mead::ComponentPart.new({:series_sequence=>1,
         | 
| 47 48 | 
             
                                :unittitle=>"Drawings",
         | 
| 48 49 | 
             
                                :unitdate=>"1917-1980",
         | 
| 49 50 | 
             
                                :level=>"series",
         | 
| 50 | 
            -
                                :unitid=>"MC 240 Series 1"}]
         | 
| 51 | 
            +
                                :unitid=>"MC 240 Series 1"})]
         | 
| 51 52 | 
             
                  end
         | 
| 52 53 | 
             
                  should 'handle empty folder properly' do
         | 
| 53 54 | 
             
                    mead = Mead::Identifier.new('mc00240-001-ff0052-000-001', File.open('test/ead/mc00240.xml'))
         | 
    
        data/test/test_mc00240.rb
    CHANGED
    
    | @@ -10,15 +10,15 @@ class TestMeadMC00240 < Test::Unit::TestCase | |
| 10 10 | 
             
                end
         | 
| 11 11 | 
             
                should "retrieve the correct metadata" do
         | 
| 12 12 | 
             
                  @mead.extract
         | 
| 13 | 
            -
                  expected = [{:unittitle=>"Moravian Chapel at Southside", :level=>"file",
         | 
| 13 | 
            +
                  expected = [Mead::ComponentPart.new({:unittitle=>"Moravian Chapel at Southside", :level=>"file",
         | 
| 14 14 | 
             
                                :item_location=>"flatfolder 147", :unitdate=>"1928", :unitid=>"1034",
         | 
| 15 15 | 
             
                                  :containers => 
         | 
| 16 16 | 
             
                                  [Mead::Container.new(:type => 'flatfolder', 
         | 
| 17 17 | 
             
                                                        :label => "Mixed materials",
         | 
| 18 18 | 
             
                                                        :text => '147')]
         | 
| 19 | 
            -
                                }, 
         | 
| 20 | 
            -
                               {:unittitle=>"Drawings", : | 
| 21 | 
            -
                                :level=>"series", :unitdate=>"1917-1980", :unitid=>"MC 240 Series 1"}]
         | 
| 19 | 
            +
                                }), 
         | 
| 20 | 
            +
                               Mead::ComponentPart.new({:unittitle=>"Drawings", :series_sequence=>1,
         | 
| 21 | 
            +
                                :level=>"series", :unitdate=>"1917-1980", :unitid=>"MC 240 Series 1"})]
         | 
| 22 22 | 
             
                  assert_equal expected, @mead.metadata
         | 
| 23 23 | 
             
                end
         | 
| 24 24 | 
             
              end
         | 
| @@ -116,18 +116,10 @@ class TestMeadMC00240 < Test::Unit::TestCase | |
| 116 116 | 
             
                    end
         | 
| 117 117 |  | 
| 118 118 | 
             
                    should "extract a series' series number" do
         | 
| 119 | 
            -
                      assert_equal 1, @extractor.stack[1][: | 
| 119 | 
            +
                      assert_equal 1, @extractor.stack[1][:series_sequence]
         | 
| 120 120 | 
             
                    end
         | 
| 121 121 |  | 
| 122 | 
            -
             | 
| 123 | 
            -
            #          assert_equal [
         | 
| 124 | 
            -
            #            {:unittitle=>"Amos Hosiery Mill - Addition", :unitdate=>"1953",
         | 
| 125 | 
            -
            #            :level => 'file', :unitid => '1421', :item_location => 'flatfolder 42'},
         | 
| 126 | 
            -
            #            {:unittitle=>"Drawings", :unitdate=>"1917-1980", :level => 'series',
         | 
| 127 | 
            -
            #              :unitid => 'MC 240 Series 1', :series_number => 1
         | 
| 128 | 
            -
            #            }
         | 
| 129 | 
            -
            #          ], @extractor.stack
         | 
| 130 | 
            -
            #        end
         | 
| 122 | 
            +
             | 
| 131 123 |  | 
| 132 124 | 
             
                  end
         | 
| 133 125 |  | 
    
        data/test/test_ua015_010.rb
    CHANGED
    
    | @@ -86,19 +86,10 @@ class TestMeadUA015_010 < Test::Unit::TestCase | |
| 86 86 | 
             
                    end
         | 
| 87 87 |  | 
| 88 88 | 
             
                    should "extract a series' series number" do
         | 
| 89 | 
            -
                      assert_equal 4, @extractor.stack[1][: | 
| 89 | 
            +
                      assert_equal 4, @extractor.stack[1][:series_sequence]
         | 
| 90 90 | 
             
                    end
         | 
| 91 91 |  | 
| 92 | 
            -
             | 
| 93 | 
            -
            #          assert_equal [
         | 
| 94 | 
            -
            #            {:unittitle=>"Programs", :unitdate=>"1949-1950",
         | 
| 95 | 
            -
            #            :level => 'file', :unitid => nil, :item_location => 'Box 39, Folder 5'},
         | 
| 96 | 
            -
            #            {:unittitle=>"Men's Basketball", :unitdate=>"1911-2006",
         | 
| 97 | 
            -
            #              :level => 'series', :unitid => 'Series 4',
         | 
| 98 | 
            -
            #              :series_number => 4
         | 
| 99 | 
            -
            #            }
         | 
| 100 | 
            -
            #          ], @extractor.stack
         | 
| 101 | 
            -
            #        end
         | 
| 92 | 
            +
             | 
| 102 93 |  | 
| 103 94 | 
             
                  end
         | 
| 104 95 |  | 
| @@ -86,19 +86,9 @@ class TestMeadUA023_006B < Test::Unit::TestCase | |
| 86 86 | 
             
                    end
         | 
| 87 87 |  | 
| 88 88 | 
             
                    should "extract a series' series number" do
         | 
| 89 | 
            -
                      assert_equal 3, @extractor.stack[1][: | 
| 89 | 
            +
                      assert_equal 3, @extractor.stack[1][:series_sequence]
         | 
| 90 90 | 
             
                    end
         | 
| 91 91 |  | 
| 92 | 
            -
            #        should "only extract up to the series level" do
         | 
| 93 | 
            -
            #          assert_equal [
         | 
| 94 | 
            -
            #            {:unittitle=>"Food Science Building and Phytotron", :unitdate=>nil,
         | 
| 95 | 
            -
            #            :level => 'file', :unitid => nil, :item_location => 'Box 1, Folder 8'},
         | 
| 96 | 
            -
            #            {:unittitle=>"Buildings", :unitdate=>"1968, 1970, undated",
         | 
| 97 | 
            -
            #              :level => 'series', :unitid => nil,
         | 
| 98 | 
            -
            #              :series_number => 3
         | 
| 99 | 
            -
            #            }
         | 
| 100 | 
            -
            #          ], @extractor.stack
         | 
| 101 | 
            -
            #        end
         | 
| 102 92 |  | 
| 103 93 | 
             
                  end
         | 
| 104 94 |  | 
| @@ -87,19 +87,10 @@ class TestMeadUA023_006 < Test::Unit::TestCase | |
| 87 87 | 
             
                    end
         | 
| 88 88 |  | 
| 89 89 | 
             
                    should "extract a series' series number" do
         | 
| 90 | 
            -
                      assert_equal 2, @extractor.stack[1][: | 
| 90 | 
            +
                      assert_equal 2, @extractor.stack[1][:series_sequence]
         | 
| 91 91 | 
             
                    end
         | 
| 92 92 |  | 
| 93 | 
            -
             | 
| 94 | 
            -
            #          assert_equal [
         | 
| 95 | 
            -
            #            {:unittitle=>"Faculty and Staff", :unitdate=>nil, :level => 'file',
         | 
| 96 | 
            -
            #            :unitid => nil, :item_location => 'Box 1, Folder 7'},
         | 
| 97 | 
            -
            #            {:unittitle=>"Faculty and Staff", :unitdate=>"circa 1900-1988",
         | 
| 98 | 
            -
            #              :level => 'series', :unitid => nil,
         | 
| 99 | 
            -
            #              :series_number => 2
         | 
| 100 | 
            -
            #            }
         | 
| 101 | 
            -
            #          ], @extractor.stack
         | 
| 102 | 
            -
            #        end
         | 
| 93 | 
            +
             | 
| 103 94 |  | 
| 104 95 | 
             
                  end
         | 
| 105 96 |  | 
    
        data/test/test_ua110_041.rb
    CHANGED
    
    | @@ -86,20 +86,10 @@ class TestMeadUA110_041 < Test::Unit::TestCase | |
| 86 86 | 
             
                    end
         | 
| 87 87 |  | 
| 88 88 | 
             
                    should "extract a series' series number" do
         | 
| 89 | 
            -
                      assert_equal 1, @extractor.stack[1][: | 
| 89 | 
            +
                      assert_equal 1, @extractor.stack[1][:series_sequence]
         | 
| 90 90 | 
             
                    end
         | 
| 91 91 |  | 
| 92 | 
            -
             | 
| 93 | 
            -
            #          assert_equal [
         | 
| 94 | 
            -
            #            {:unittitle=>"North Carolina, Wake County, Raleigh: Dix Hill [Dorothea Dix Hospital] Drawings",
         | 
| 95 | 
            -
            #              :unitdate=>nil, :level => 'file', :unitid => nil,
         | 
| 96 | 
            -
            #            :item_location => 'Folder 1.1'},
         | 
| 97 | 
            -
            #            {:unittitle=>"UA 110.041 Series 1: Projects", :unitdate=>"1951-1976",
         | 
| 98 | 
            -
            #              :level => 'series', :unitid => nil,
         | 
| 99 | 
            -
            #              :series_number => 1
         | 
| 100 | 
            -
            #            }
         | 
| 101 | 
            -
            #          ], @extractor.stack
         | 
| 102 | 
            -
            #        end
         | 
| 92 | 
            +
             | 
| 103 93 |  | 
| 104 94 | 
             
                  end
         | 
| 105 95 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: mead
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 27
         | 
| 5 5 | 
             
              prerelease: false
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 | 
            +
              - 1
         | 
| 8 9 | 
             
              - 0
         | 
| 9 | 
            -
               | 
| 10 | 
            -
              version: 0.0.6
         | 
| 10 | 
            +
              version: 0.1.0
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Jason Ronallo
         | 
| @@ -15,22 +15,19 @@ autorequire: | |
| 15 15 | 
             
            bindir: bin
         | 
| 16 16 | 
             
            cert_chain: []
         | 
| 17 17 |  | 
| 18 | 
            -
            date: 2011-02- | 
| 18 | 
            +
            date: 2011-02-27 00:00:00 -05:00
         | 
| 19 19 | 
             
            default_executable: 
         | 
| 20 20 | 
             
            dependencies: 
         | 
| 21 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 22 22 | 
             
              version_requirements: &id001 !ruby/object:Gem::Requirement 
         | 
| 23 23 | 
             
                none: false
         | 
| 24 24 | 
             
                requirements: 
         | 
| 25 | 
            -
                - - " | 
| 25 | 
            +
                - - ">="
         | 
| 26 26 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 27 | 
            -
                    hash:  | 
| 27 | 
            +
                    hash: 3
         | 
| 28 28 | 
             
                    segments: 
         | 
| 29 | 
            -
                    -  | 
| 30 | 
            -
                     | 
| 31 | 
            -
                    - 3
         | 
| 32 | 
            -
                    - 1
         | 
| 33 | 
            -
                    version: 1.4.3.1
         | 
| 29 | 
            +
                    - 0
         | 
| 30 | 
            +
                    version: "0"
         | 
| 34 31 | 
             
              requirement: *id001
         | 
| 35 32 | 
             
              prerelease: false
         | 
| 36 33 | 
             
              type: :runtime
         | 
| @@ -255,6 +252,7 @@ files: | |
| 255 252 | 
             
            - bin/meadbfv
         | 
| 256 253 | 
             
            - lib/mead.rb
         | 
| 257 254 | 
             
            - lib/mead/barcode.rb
         | 
| 255 | 
            +
            - lib/mead/component_part.rb
         | 
| 258 256 | 
             
            - lib/mead/container.rb
         | 
| 259 257 | 
             
            - lib/mead/ead.rb
         | 
| 260 258 | 
             
            - lib/mead/ead_validator.rb
         | 
| @@ -274,6 +272,7 @@ files: | |
| 274 272 | 
             
            - test/fixtures/ua023_031.xml
         | 
| 275 273 | 
             
            - test/helper.rb
         | 
| 276 274 | 
             
            - test/test_barcode.rb
         | 
| 275 | 
            +
            - test/test_component_part.rb
         | 
| 277 276 | 
             
            - test/test_ead.rb
         | 
| 278 277 | 
             
            - test/test_ead_validator.rb
         | 
| 279 278 | 
             
            - test/test_extractor.rb
         | 
| @@ -324,6 +323,7 @@ summary: Extract identifiers and metadata from EAD XML. | |
| 324 323 | 
             
            test_files: 
         | 
| 325 324 | 
             
            - test/helper.rb
         | 
| 326 325 | 
             
            - test/test_barcode.rb
         | 
| 326 | 
            +
            - test/test_component_part.rb
         | 
| 327 327 | 
             
            - test/test_ead.rb
         | 
| 328 328 | 
             
            - test/test_ead_validator.rb
         | 
| 329 329 | 
             
            - test/test_extractor.rb
         |