Class Core::Providers::Multiverse::Parsers::MetaSectionParser
In: core/serviceproviders/multiverse/parsers/meta_section_parser.rb
Parent: Object

Parser for the meta section of the XML document. The meta section needs to contain at least a universe name and uid. Their presence and validity is checked in the check(document) method.

Methods

check   parse  

Included Modules

Interfaces::Parsers::SectionParser

Public Instance methods

Check that the required meta tags are present in the document.

[Source]

# File core/serviceproviders/multiverse/parsers/meta_section_parser.rb, line 27
          def check(document) 
            if ( document.root.elements['meta/name'].nil?  )
              raise Core::Exceptions::Multiverse::UniverseParsingException.new('Required <name> tag not found inside the <meta> section.')
            end
            if ( document.root.elements['meta/uid'].nil? )
              raise Core::Exceptions::Multiverse::UniverseParsingException.new('Required <uid> tag not found inside the <meta> section.') 
            end
            if ( document.root.elements['meta/uid'].text.nil? )
              raise Core::Exceptions::Multiverse::UniverseParsingException.new('<uid> value is not meaningful.') 
            end

            if ( document.root.elements['meta/creator'] )
              creatortag = document.root.elements['meta/creator']
              if ( creatortag.attributes['name'].nil? && creatortag.attributes['email'].nil?  )
                raise Core::Exceptions::Multiverse::UniverseParsingException.new('<creator> tag needs at least a name or an email attribute.') 
              end
            end
          
          end

Parse the meta section of the document and return a hash containing all the information

[Source]

# File core/serviceproviders/multiverse/parsers/meta_section_parser.rb, line 49
          def parse(document, universe) 
            universe.meta = {}
            metaroot = document.root.elements['meta']
            metaroot.elements.each do |m|
              key = m.name.to_sym
              if (:creator == key)
                universe.meta[key] = {}
                m.attributes.each do |name, value|
                  universe.meta[key][name.to_sym] = value
                end
              else
                universe.meta[key] = m.text
              end
            end
          end

[Validate]