mods 0.0.6 → 0.0.7
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/README.rdoc +1 -0
 - data/lib/mods/nom_terminology.rb +36 -0
 - data/lib/mods/version.rb +1 -1
 - data/spec/part_spec.rb +236 -0
 - metadata +6 -4
 
    
        data/README.rdoc
    CHANGED
    
    
    
        data/lib/mods/nom_terminology.rb
    CHANGED
    
    | 
         @@ -259,6 +259,42 @@ module Mods 
     | 
|
| 
       259 
259 
     | 
    
         
             
                      end
         
     | 
| 
       260 
260 
     | 
    
         
             
                    end
         
     | 
| 
       261 
261 
     | 
    
         | 
| 
      
 262 
     | 
    
         
            +
                    # PART -----------------------------------------------------------------------------------
         
     | 
| 
      
 263 
     | 
    
         
            +
                    t.part :path => '/mods/part' do |n|
         
     | 
| 
      
 264 
     | 
    
         
            +
                      # attributes
         
     | 
| 
      
 265 
     | 
    
         
            +
                      n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
         
     | 
| 
      
 266 
     | 
    
         
            +
                      n.order :path => '@order', :accessor => lambda { |a| a.text }
         
     | 
| 
      
 267 
     | 
    
         
            +
                      n.type_at :path => '@type', :accessor => lambda { |a| a.text }
         
     | 
| 
      
 268 
     | 
    
         
            +
                      # child elements
         
     | 
| 
      
 269 
     | 
    
         
            +
                      n.detail :path => 'detail' do |e|
         
     | 
| 
      
 270 
     | 
    
         
            +
                        # attributes
         
     | 
| 
      
 271 
     | 
    
         
            +
                        e.level :path => '@level', :accessor => lambda { |a| a.text }
         
     | 
| 
      
 272 
     | 
    
         
            +
                        e.type_at :path => '@type', :accessor => lambda { |a| a.text }
         
     | 
| 
      
 273 
     | 
    
         
            +
                        # elements
         
     | 
| 
      
 274 
     | 
    
         
            +
                        e.number :path => 'number'
         
     | 
| 
      
 275 
     | 
    
         
            +
                        e.caption :path => 'caption'
         
     | 
| 
      
 276 
     | 
    
         
            +
                        e.title :path => 'title'
         
     | 
| 
      
 277 
     | 
    
         
            +
                      end
         
     | 
| 
      
 278 
     | 
    
         
            +
                      n.extent :path => 'extent' do |e|  # TODO:  extent is ordered in xml schema
         
     | 
| 
      
 279 
     | 
    
         
            +
                        # attributes
         
     | 
| 
      
 280 
     | 
    
         
            +
                        e.unit :path => '@unit', :accessor => lambda { |a| a.text }
         
     | 
| 
      
 281 
     | 
    
         
            +
                        # elements
         
     | 
| 
      
 282 
     | 
    
         
            +
                        e.start :path => 'start'
         
     | 
| 
      
 283 
     | 
    
         
            +
                        e.end :path => 'end'
         
     | 
| 
      
 284 
     | 
    
         
            +
                        e.total :path => 'total'
         
     | 
| 
      
 285 
     | 
    
         
            +
                        e.list :path => 'list'
         
     | 
| 
      
 286 
     | 
    
         
            +
                      end
         
     | 
| 
      
 287 
     | 
    
         
            +
                      n.date :path => 'date' do |e|  # TODO:  extent is ordered in xml schema
         
     | 
| 
      
 288 
     | 
    
         
            +
                        Mods::DATE_ATTRIBS.reject { |a| a == 'keyDate' }.each { |attr_name|
         
     | 
| 
      
 289 
     | 
    
         
            +
                          e.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
         
     | 
| 
      
 290 
     | 
    
         
            +
                        }
         
     | 
| 
      
 291 
     | 
    
         
            +
                      end
         
     | 
| 
      
 292 
     | 
    
         
            +
                      n.text_el :path => 'text' do |e|  
         
     | 
| 
      
 293 
     | 
    
         
            +
                        e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
         
     | 
| 
      
 294 
     | 
    
         
            +
                        e.type_at :path => '@type', :accessor => lambda { |a| a.text }
         
     | 
| 
      
 295 
     | 
    
         
            +
                      end
         
     | 
| 
      
 296 
     | 
    
         
            +
                    end
         
     | 
| 
      
 297 
     | 
    
         
            +
                    
         
     | 
| 
       262 
298 
     | 
    
         
             
                    # RECORD_INFO --------------------------------------------------------------------------
         
     | 
| 
       263 
299 
     | 
    
         
             
                    t.record_info :path => '/mods/recordInfo'
         
     | 
| 
       264 
300 
     | 
    
         
             
                    t._record_info :path => '//recordInfo' do |n|
         
     | 
    
        data/lib/mods/version.rb
    CHANGED
    
    
    
        data/spec/part_spec.rb
    ADDED
    
    | 
         @@ -0,0 +1,236 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "Mods <part> Element" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 5 
     | 
    
         
            +
                @mods_rec = Mods::Record.new
         
     | 
| 
      
 6 
     | 
    
         
            +
                @ex = @mods_rec.from_str('<mods><part>
         
     | 
| 
      
 7 
     | 
    
         
            +
                        	<detail>
         
     | 
| 
      
 8 
     | 
    
         
            +
                        	  	<title>Wayfarers (Poem)</title>
         
     | 
| 
      
 9 
     | 
    
         
            +
                        	</detail>
         
     | 
| 
      
 10 
     | 
    
         
            +
                        	<extent unit="pages">
         
     | 
| 
      
 11 
     | 
    
         
            +
                        	  	<start>97</start>
         
     | 
| 
      
 12 
     | 
    
         
            +
                        	  	<end>98</end>
         
     | 
| 
      
 13 
     | 
    
         
            +
                        	</extent>
         
     | 
| 
      
 14 
     | 
    
         
            +
                      </part></mods>').part
         
     | 
| 
      
 15 
     | 
    
         
            +
                @ex2 = @mods_rec.from_str('<mods><part>
         
     | 
| 
      
 16 
     | 
    
         
            +
                        	<detail type="page number">
         
     | 
| 
      
 17 
     | 
    
         
            +
                        	  	<number>3</number>
         
     | 
| 
      
 18 
     | 
    
         
            +
                        	</detail>
         
     | 
| 
      
 19 
     | 
    
         
            +
                        	<extent unit="pages">
         
     | 
| 
      
 20 
     | 
    
         
            +
                        	  	<start>3</start>
         
     | 
| 
      
 21 
     | 
    
         
            +
                        	</extent>
         
     | 
| 
      
 22 
     | 
    
         
            +
                      </part></mods>').part
         
     | 
| 
      
 23 
     | 
    
         
            +
                @detail = @mods_rec.from_str('<mods><part>
         
     | 
| 
      
 24 
     | 
    
         
            +
                          <detail type="issue">
         
     | 
| 
      
 25 
     | 
    
         
            +
                              <number>1</number>
         
     | 
| 
      
 26 
     | 
    
         
            +
                              <caption>no.</caption>
         
     | 
| 
      
 27 
     | 
    
         
            +
                          </detail>
         
     | 
| 
      
 28 
     | 
    
         
            +
                      </part></mods>').part
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              it "should normalize dates" do
         
     | 
| 
      
 32 
     | 
    
         
            +
                pending "to be implemented"
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
              
         
     | 
| 
      
 35 
     | 
    
         
            +
              context "basic <part> terminology pieces" do
         
     | 
| 
      
 36 
     | 
    
         
            +
                it "should be a NodeSet" do
         
     | 
| 
      
 37 
     | 
    
         
            +
                  [@ex, @ex2, @detail].each { |p| p.should be_an_instance_of(Nokogiri::XML::NodeSet) }
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
                it "should have as many members as there are <part> elements in the xml" do
         
     | 
| 
      
 40 
     | 
    
         
            +
                  [@ex, @ex2, @detail].each { |p| p.size.should == 1 }
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
                it "should recognize type(_at) attribute on <part> element" do
         
     | 
| 
      
 43 
     | 
    
         
            +
                  @mods_rec.from_str("<mods><part type='val'>anything</part></mods>")
         
     | 
| 
      
 44 
     | 
    
         
            +
                  @mods_rec.part.type_at.should == ['val']
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
                it "should recognize order attribute on <part> element" do
         
     | 
| 
      
 47 
     | 
    
         
            +
                  @mods_rec.from_str("<mods><part order='val'>anything</part></mods>")
         
     | 
| 
      
 48 
     | 
    
         
            +
                  @mods_rec.part.order.should == ['val']
         
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
      
 50 
     | 
    
         
            +
                it "should recognize ID attribute on <part> element as id_at term" do
         
     | 
| 
      
 51 
     | 
    
         
            +
                  @mods_rec.from_str("<mods><part ID='val'>anything</part></mods>")
         
     | 
| 
      
 52 
     | 
    
         
            +
                  @mods_rec.part.id_at.should == ['val']
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                context "<detail> child element" do
         
     | 
| 
      
 56 
     | 
    
         
            +
                  it "should be a NodeSet" do
         
     | 
| 
      
 57 
     | 
    
         
            +
                    [@ex, @ex2, @detail].each { |p| p.detail.should be_an_instance_of(Nokogiri::XML::NodeSet) }
         
     | 
| 
      
 58 
     | 
    
         
            +
                  end
         
     | 
| 
      
 59 
     | 
    
         
            +
                  it "detail NodeSet should have as many Nodes as there are <detail> elements in the xml" do
         
     | 
| 
      
 60 
     | 
    
         
            +
                    [@ex, @ex2, @detail].each { |p| p.detail.size.should == 1 }
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end
         
     | 
| 
      
 62 
     | 
    
         
            +
                  it "should recognize type(_at) attribute on <detail> element" do
         
     | 
| 
      
 63 
     | 
    
         
            +
                    @ex2.detail.type_at.should == ['page number']
         
     | 
| 
      
 64 
     | 
    
         
            +
                    @detail.detail.type_at.should == ['issue']
         
     | 
| 
      
 65 
     | 
    
         
            +
                  end
         
     | 
| 
      
 66 
     | 
    
         
            +
                  it "should recognize level attribute on <detail> element" do
         
     | 
| 
      
 67 
     | 
    
         
            +
                    @mods_rec.from_str("<mods><part><detail level='val'>anything</detail></part></mods>")
         
     | 
| 
      
 68 
     | 
    
         
            +
                    @mods_rec.part.detail.level.should == ['val']
         
     | 
| 
      
 69 
     | 
    
         
            +
                  end
         
     | 
| 
      
 70 
     | 
    
         
            +
                  context "<number> child element" do
         
     | 
| 
      
 71 
     | 
    
         
            +
                    it "should be a NodeSet" do
         
     | 
| 
      
 72 
     | 
    
         
            +
                      [@ex, @ex2, @detail].each { |p| p.detail.number.should be_an_instance_of(Nokogiri::XML::NodeSet) }
         
     | 
| 
      
 73 
     | 
    
         
            +
                    end
         
     | 
| 
      
 74 
     | 
    
         
            +
                    it "number NodeSet should have as many Nodes as there are <number> elements in the xml" do
         
     | 
| 
      
 75 
     | 
    
         
            +
                      [@ex2, @detail].each { |p| p.detail.number.size.should == 1 }
         
     | 
| 
      
 76 
     | 
    
         
            +
                      @ex.detail.number.size.should == 0
         
     | 
| 
      
 77 
     | 
    
         
            +
                    end
         
     | 
| 
      
 78 
     | 
    
         
            +
                    it "text should get element value" do
         
     | 
| 
      
 79 
     | 
    
         
            +
                      @ex2.detail.number.map { |n| n.text }.should == ['3']
         
     | 
| 
      
 80 
     | 
    
         
            +
                      @detail.detail.number.map { |n| n.text }.should == ['1']
         
     | 
| 
      
 81 
     | 
    
         
            +
                    end
         
     | 
| 
      
 82 
     | 
    
         
            +
                  end # <number>
         
     | 
| 
      
 83 
     | 
    
         
            +
                  context "<caption> child element" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                    before(:all) do
         
     | 
| 
      
 85 
     | 
    
         
            +
                      @mods_rec.from_str("<mods><part><detail><caption>anything</caption></detail></part></mods>")
         
     | 
| 
      
 86 
     | 
    
         
            +
                      @caption = @mods_rec.part.detail.caption
         
     | 
| 
      
 87 
     | 
    
         
            +
                    end
         
     | 
| 
      
 88 
     | 
    
         
            +
                    it "should be a NodeSet" do
         
     | 
| 
      
 89 
     | 
    
         
            +
                      [@ex, @ex2, @detail].each { |p| p.detail.caption.should be_an_instance_of(Nokogiri::XML::NodeSet) }
         
     | 
| 
      
 90 
     | 
    
         
            +
                      @caption.should be_an_instance_of(Nokogiri::XML::NodeSet)
         
     | 
| 
      
 91 
     | 
    
         
            +
                    end
         
     | 
| 
      
 92 
     | 
    
         
            +
                    it "caption NodeSet should have as many Nodes as there are <caption> elements in the xml" do
         
     | 
| 
      
 93 
     | 
    
         
            +
                      [@ex, @ex2].each { |p| p.detail.caption.size.should == 0 }
         
     | 
| 
      
 94 
     | 
    
         
            +
                      @detail.detail.caption.size.should == 1
         
     | 
| 
      
 95 
     | 
    
         
            +
                      @caption.size.should == 1
         
     | 
| 
      
 96 
     | 
    
         
            +
                    end
         
     | 
| 
      
 97 
     | 
    
         
            +
                    it "text should get element value" do
         
     | 
| 
      
 98 
     | 
    
         
            +
                      @detail.detail.caption.map { |n| n.text }.should == ['no.']
         
     | 
| 
      
 99 
     | 
    
         
            +
                      @caption.map { |n| n.text }.should == ['anything']
         
     | 
| 
      
 100 
     | 
    
         
            +
                    end
         
     | 
| 
      
 101 
     | 
    
         
            +
                  end # <caption>
         
     | 
| 
      
 102 
     | 
    
         
            +
                  context "<title> child element" do
         
     | 
| 
      
 103 
     | 
    
         
            +
                    it "should be a NodeSet" do
         
     | 
| 
      
 104 
     | 
    
         
            +
                      [@ex, @ex2, @detail].each { |p| p.detail.title.should be_an_instance_of(Nokogiri::XML::NodeSet) }
         
     | 
| 
      
 105 
     | 
    
         
            +
                    end
         
     | 
| 
      
 106 
     | 
    
         
            +
                    it "title NodeSet should have as many Nodes as there are <title> elements in the xml" do
         
     | 
| 
      
 107 
     | 
    
         
            +
                      @ex.detail.title.size.should == 1
         
     | 
| 
      
 108 
     | 
    
         
            +
                      [@ex2, @detail].each { |p| p.detail.title.size.should == 0 }
         
     | 
| 
      
 109 
     | 
    
         
            +
                    end
         
     | 
| 
      
 110 
     | 
    
         
            +
                    it "text should get element value" do
         
     | 
| 
      
 111 
     | 
    
         
            +
                      @ex.detail.title.map { |n| n.text }.should == ['Wayfarers (Poem)']
         
     | 
| 
      
 112 
     | 
    
         
            +
                      [@ex2, @detail].each { |p| p.detail.title.map { |n| n.text }.should == [] }
         
     | 
| 
      
 113 
     | 
    
         
            +
                    end
         
     | 
| 
      
 114 
     | 
    
         
            +
                  end # <title>
         
     | 
| 
      
 115 
     | 
    
         
            +
                end # <detail>
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
                context "<extent> child element" do
         
     | 
| 
      
 118 
     | 
    
         
            +
                  it "should be a NodeSet" do
         
     | 
| 
      
 119 
     | 
    
         
            +
                    [@ex, @ex2, @detail].each { |p| p.extent.should be_an_instance_of(Nokogiri::XML::NodeSet) }
         
     | 
| 
      
 120 
     | 
    
         
            +
                  end
         
     | 
| 
      
 121 
     | 
    
         
            +
                  it "extent NodeSet should have as many Nodes as there are <extent> elements in the xml" do
         
     | 
| 
      
 122 
     | 
    
         
            +
                    [@ex, @ex2].each { |p| p.extent.size.should == 1 }
         
     | 
| 
      
 123 
     | 
    
         
            +
                    @detail.extent.size.should == 0
         
     | 
| 
      
 124 
     | 
    
         
            +
                  end
         
     | 
| 
      
 125 
     | 
    
         
            +
                  it "should recognize unit attribute on <extent> element" do
         
     | 
| 
      
 126 
     | 
    
         
            +
                    [@ex, @ex2].each { |p| p.extent.unit.should == ['pages'] }
         
     | 
| 
      
 127 
     | 
    
         
            +
                  end
         
     | 
| 
      
 128 
     | 
    
         
            +
                  context "<start> child element" do
         
     | 
| 
      
 129 
     | 
    
         
            +
                    it "should be a NodeSet" do
         
     | 
| 
      
 130 
     | 
    
         
            +
                      [@ex, @ex2, @detail].each { |p| p.extent.start.should be_an_instance_of(Nokogiri::XML::NodeSet) }
         
     | 
| 
      
 131 
     | 
    
         
            +
                    end
         
     | 
| 
      
 132 
     | 
    
         
            +
                    it "start NodeSet should have as many Nodes as there are <start> elements in the xml" do
         
     | 
| 
      
 133 
     | 
    
         
            +
                      [@ex, @ex2].each { |p| p.extent.start.size.should == 1 }
         
     | 
| 
      
 134 
     | 
    
         
            +
                      @detail.extent.start.size.should == 0
         
     | 
| 
      
 135 
     | 
    
         
            +
                    end
         
     | 
| 
      
 136 
     | 
    
         
            +
                    it "text should get element value" do
         
     | 
| 
      
 137 
     | 
    
         
            +
                      @ex.extent.start.map { |n| n.text }.should == ['97']
         
     | 
| 
      
 138 
     | 
    
         
            +
                      @ex2.extent.start.map { |n| n.text }.should == ['3']
         
     | 
| 
      
 139 
     | 
    
         
            +
                    end
         
     | 
| 
      
 140 
     | 
    
         
            +
                  end # <start>
         
     | 
| 
      
 141 
     | 
    
         
            +
                  context "<end> child element" do
         
     | 
| 
      
 142 
     | 
    
         
            +
                    it "should be a NodeSet" do
         
     | 
| 
      
 143 
     | 
    
         
            +
                      [@ex, @ex2, @detail].each { |p| p.extent.end.should be_an_instance_of(Nokogiri::XML::NodeSet) }
         
     | 
| 
      
 144 
     | 
    
         
            +
                    end
         
     | 
| 
      
 145 
     | 
    
         
            +
                    it "end NodeSet should have as many Nodes as there are <end> elements in the xml" do
         
     | 
| 
      
 146 
     | 
    
         
            +
                      @ex.extent.end.size.should == 1
         
     | 
| 
      
 147 
     | 
    
         
            +
                      [@ex2, @detail].each { |p| p.extent.end.size.should == 0 }
         
     | 
| 
      
 148 
     | 
    
         
            +
                    end
         
     | 
| 
      
 149 
     | 
    
         
            +
                    it "text should get element value" do
         
     | 
| 
      
 150 
     | 
    
         
            +
                      @ex.extent.end.map { |n| n.text }.should == ['98']
         
     | 
| 
      
 151 
     | 
    
         
            +
                    end
         
     | 
| 
      
 152 
     | 
    
         
            +
                  end # <end>
         
     | 
| 
      
 153 
     | 
    
         
            +
                  context "<total> child element" do
         
     | 
| 
      
 154 
     | 
    
         
            +
                    before(:all) do
         
     | 
| 
      
 155 
     | 
    
         
            +
                      @mods_rec.from_str("<mods><part><extent><total>anything</total></extent></part></mods>")
         
     | 
| 
      
 156 
     | 
    
         
            +
                      @total = @mods_rec.part.extent.total
         
     | 
| 
      
 157 
     | 
    
         
            +
                    end
         
     | 
| 
      
 158 
     | 
    
         
            +
                    it "should be a NodeSet" do
         
     | 
| 
      
 159 
     | 
    
         
            +
                      [@ex, @ex2, @detail].each { |p| p.extent.total.should be_an_instance_of(Nokogiri::XML::NodeSet) }
         
     | 
| 
      
 160 
     | 
    
         
            +
                      @total.should be_an_instance_of(Nokogiri::XML::NodeSet)
         
     | 
| 
      
 161 
     | 
    
         
            +
                    end
         
     | 
| 
      
 162 
     | 
    
         
            +
                    it "total NodeSet should have as many Nodes as there are <total> elements in the xml" do
         
     | 
| 
      
 163 
     | 
    
         
            +
                      [@ex, @ex2, @detail].each { |p| p.extent.total.size.should == 0 }
         
     | 
| 
      
 164 
     | 
    
         
            +
                      @total.size.should == 1
         
     | 
| 
      
 165 
     | 
    
         
            +
                    end
         
     | 
| 
      
 166 
     | 
    
         
            +
                    it "text should get element value" do
         
     | 
| 
      
 167 
     | 
    
         
            +
                      @total.map { |n| n.text }.should == ['anything']
         
     | 
| 
      
 168 
     | 
    
         
            +
                    end
         
     | 
| 
      
 169 
     | 
    
         
            +
                  end # <total>
         
     | 
| 
      
 170 
     | 
    
         
            +
                  context "<list> child element" do
         
     | 
| 
      
 171 
     | 
    
         
            +
                    before(:all) do
         
     | 
| 
      
 172 
     | 
    
         
            +
                      @mods_rec.from_str("<mods><part><extent><list>anything</list></extent></part></mods>")
         
     | 
| 
      
 173 
     | 
    
         
            +
                      @list = @mods_rec.part.extent.list
         
     | 
| 
      
 174 
     | 
    
         
            +
                    end
         
     | 
| 
      
 175 
     | 
    
         
            +
                    it "should be a NodeSet" do
         
     | 
| 
      
 176 
     | 
    
         
            +
                      [@ex, @ex2, @detail].each { |p| p.extent.list.should be_an_instance_of(Nokogiri::XML::NodeSet) }
         
     | 
| 
      
 177 
     | 
    
         
            +
                      @list.should be_an_instance_of(Nokogiri::XML::NodeSet)
         
     | 
| 
      
 178 
     | 
    
         
            +
                    end
         
     | 
| 
      
 179 
     | 
    
         
            +
                    it "list NodeSet should have as many Nodes as there are <list> elements in the xml" do
         
     | 
| 
      
 180 
     | 
    
         
            +
                      [@ex, @ex2, @detail].each { |p| p.extent.list.size.should == 0 }
         
     | 
| 
      
 181 
     | 
    
         
            +
                      @list.size.should == 1
         
     | 
| 
      
 182 
     | 
    
         
            +
                    end
         
     | 
| 
      
 183 
     | 
    
         
            +
                    it "text should get element value" do
         
     | 
| 
      
 184 
     | 
    
         
            +
                      @list.map { |n| n.text }.should == ['anything']
         
     | 
| 
      
 185 
     | 
    
         
            +
                    end
         
     | 
| 
      
 186 
     | 
    
         
            +
                  end # <list>
         
     | 
| 
      
 187 
     | 
    
         
            +
                end # <extent>
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
                context "<date> child element" do
         
     | 
| 
      
 190 
     | 
    
         
            +
                  before(:all) do
         
     | 
| 
      
 191 
     | 
    
         
            +
                    @date = @mods_rec.from_str('<mods><part><date encoding="w3cdtf">1999</date></part></mods').part.date
         
     | 
| 
      
 192 
     | 
    
         
            +
                  end
         
     | 
| 
      
 193 
     | 
    
         
            +
                  it "should be a NodeSet" do
         
     | 
| 
      
 194 
     | 
    
         
            +
                    [@ex, @ex2, @detail].each { |p| p.date.should be_an_instance_of(Nokogiri::XML::NodeSet) }
         
     | 
| 
      
 195 
     | 
    
         
            +
                    @date.should be_an_instance_of(Nokogiri::XML::NodeSet)
         
     | 
| 
      
 196 
     | 
    
         
            +
                  end
         
     | 
| 
      
 197 
     | 
    
         
            +
                  it "extent NodeSet should have as many Nodes as there are <extent> elements in the xml" do
         
     | 
| 
      
 198 
     | 
    
         
            +
                    [@ex, @ex2, @detail].each { |p| p.date.size.should == 0 }
         
     | 
| 
      
 199 
     | 
    
         
            +
                    @date.size.should == 1
         
     | 
| 
      
 200 
     | 
    
         
            +
                  end
         
     | 
| 
      
 201 
     | 
    
         
            +
                  it "should recognize all date attributes except keyDate" do
         
     | 
| 
      
 202 
     | 
    
         
            +
                    Mods::DATE_ATTRIBS.reject { |n| n == 'keyDate' }.each { |a|  
         
     | 
| 
      
 203 
     | 
    
         
            +
                      @mods_rec.from_str("<mods><part><date #{a}='attr_val'>zzz</date></part></mods>")
         
     | 
| 
      
 204 
     | 
    
         
            +
                      @mods_rec.part.date.send(a.to_sym).should == ['attr_val']
         
     | 
| 
      
 205 
     | 
    
         
            +
                    }
         
     | 
| 
      
 206 
     | 
    
         
            +
                  end
         
     | 
| 
      
 207 
     | 
    
         
            +
                  it "should not recognize keyDate attribute" do
         
     | 
| 
      
 208 
     | 
    
         
            +
                    @mods_rec.from_str("<mods><part><date keyDate='yes'>zzz</date></part></mods>")
         
     | 
| 
      
 209 
     | 
    
         
            +
                    expect { @mods_rec.part.date.keyDate }.to raise_error(NoMethodError, /undefined method.*keyDate/)
         
     | 
| 
      
 210 
     | 
    
         
            +
                  end
         
     | 
| 
      
 211 
     | 
    
         
            +
                end # <date>
         
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
      
 213 
     | 
    
         
            +
                context "<text> child element as .text_el term" do
         
     | 
| 
      
 214 
     | 
    
         
            +
                  before(:all) do
         
     | 
| 
      
 215 
     | 
    
         
            +
                    @text_ns = @mods_rec.from_str('<mods><part><text encoding="w3cdtf">1999</text></part></mods').part.text_el
         
     | 
| 
      
 216 
     | 
    
         
            +
                  end
         
     | 
| 
      
 217 
     | 
    
         
            +
                  it "should be a NodeSet" do
         
     | 
| 
      
 218 
     | 
    
         
            +
                    [@ex, @ex2, @detail].each { |p| p.text_el.should be_an_instance_of(Nokogiri::XML::NodeSet) }
         
     | 
| 
      
 219 
     | 
    
         
            +
                    @text_ns.should be_an_instance_of(Nokogiri::XML::NodeSet)
         
     | 
| 
      
 220 
     | 
    
         
            +
                  end
         
     | 
| 
      
 221 
     | 
    
         
            +
                  it "text_el NodeSet should have as many Nodes as there are <text> elements in the xml" do
         
     | 
| 
      
 222 
     | 
    
         
            +
                    [@ex, @ex2, @detail].each { |p| p.text_el.size.should == 0 }
         
     | 
| 
      
 223 
     | 
    
         
            +
                    @text_ns.size.should == 1
         
     | 
| 
      
 224 
     | 
    
         
            +
                  end
         
     | 
| 
      
 225 
     | 
    
         
            +
                  it "should recognize displayLabel attribute" do
         
     | 
| 
      
 226 
     | 
    
         
            +
                    @mods_rec.from_str("<mods><part><text displayLabel='foo'>zzz</text></part></mods>")
         
     | 
| 
      
 227 
     | 
    
         
            +
                    @mods_rec.part.text_el.displayLabel.should == ['foo']
         
     | 
| 
      
 228 
     | 
    
         
            +
                  end
         
     | 
| 
      
 229 
     | 
    
         
            +
                  it "should recognize type(_at) attribute on <text> element" do
         
     | 
| 
      
 230 
     | 
    
         
            +
                    @mods_rec.from_str("<mods><part><text type='bar'>anything</text></part></mods>")
         
     | 
| 
      
 231 
     | 
    
         
            +
                    @mods_rec.part.text_el.type_at.should == ['bar']
         
     | 
| 
      
 232 
     | 
    
         
            +
                  end
         
     | 
| 
      
 233 
     | 
    
         
            +
                end # <text>
         
     | 
| 
      
 234 
     | 
    
         
            +
             
     | 
| 
      
 235 
     | 
    
         
            +
              end # basic <part> terminoology
         
     | 
| 
      
 236 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: mods
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.7
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -10,7 +10,7 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date: 2012-11- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2012-11-10 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: nokogiri
         
     | 
| 
         @@ -190,6 +190,7 @@ files: 
     | 
|
| 
       190 
190 
     | 
    
         
             
            - spec/location_spec.rb
         
     | 
| 
       191 
191 
     | 
    
         
             
            - spec/name_spec.rb
         
     | 
| 
       192 
192 
     | 
    
         
             
            - spec/origin_info_spec.rb
         
     | 
| 
      
 193 
     | 
    
         
            +
            - spec/part_spec.rb
         
     | 
| 
       193 
194 
     | 
    
         
             
            - spec/physical_description_spec.rb
         
     | 
| 
       194 
195 
     | 
    
         
             
            - spec/reader_spec.rb
         
     | 
| 
       195 
196 
     | 
    
         
             
            - spec/record_info_spec.rb
         
     | 
| 
         @@ -211,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       211 
212 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       212 
213 
     | 
    
         
             
                  segments:
         
     | 
| 
       213 
214 
     | 
    
         
             
                  - 0
         
     | 
| 
       214 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 215 
     | 
    
         
            +
                  hash: 2974692396202214908
         
     | 
| 
       215 
216 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       216 
217 
     | 
    
         
             
              none: false
         
     | 
| 
       217 
218 
     | 
    
         
             
              requirements:
         
     | 
| 
         @@ -220,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       220 
221 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       221 
222 
     | 
    
         
             
                  segments:
         
     | 
| 
       222 
223 
     | 
    
         
             
                  - 0
         
     | 
| 
       223 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 224 
     | 
    
         
            +
                  hash: 2974692396202214908
         
     | 
| 
       224 
225 
     | 
    
         
             
            requirements: []
         
     | 
| 
       225 
226 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       226 
227 
     | 
    
         
             
            rubygems_version: 1.8.24
         
     | 
| 
         @@ -232,6 +233,7 @@ test_files: 
     | 
|
| 
       232 
233 
     | 
    
         
             
            - spec/location_spec.rb
         
     | 
| 
       233 
234 
     | 
    
         
             
            - spec/name_spec.rb
         
     | 
| 
       234 
235 
     | 
    
         
             
            - spec/origin_info_spec.rb
         
     | 
| 
      
 236 
     | 
    
         
            +
            - spec/part_spec.rb
         
     | 
| 
       235 
237 
     | 
    
         
             
            - spec/physical_description_spec.rb
         
     | 
| 
       236 
238 
     | 
    
         
             
            - spec/reader_spec.rb
         
     | 
| 
       237 
239 
     | 
    
         
             
            - spec/record_info_spec.rb
         
     |