class DwCR::Metaschema::Archive
This class represents the DarwinCoreArchive's meta.xml file
-
name
: the name for the DarwinCoreArchive the default is the directory name given in the path -
path
: the full path of the directory of the DarwinCoreArchives -
xmlns
: the XML Namespace default: 'rs.tdwg.org/dwc/text/' -
xmlns__xs
: the schema namespace prefix (xmlns:xs), default: 'www.w3.org/2001/XMLSchema' -
xmln__xsi
: schema instance namespace prefix (xmln:xsi), default: 'www.w3.org/2001/XMLSchema-instance' -
xsi__schema_location
(xsi:schemaLocation) default: 'rs.tdwg.org/dwc/text/http://rs.tdwg.org/dwc/text/tdwg_dwc_text.xsd'
-
#entities: the associated
Entity
objects -
#core: the associated
Entity
object that is the core node in the DwCA
Public Instance Methods
Gets core and extension nodes from the xml calls add_entity_from(xml)
to create Entity
instances to the Archive
for every node adds the foreign key field (coreid) to any extension
# File lib/dwcr/metaschema/archive.rb, line 55 def load_nodes_from(xml) self.core = add_entity_from xml.css('core').first core.save xml.css('extension').each do |node| extn = add_entity_from node extn.add_attribute(name: 'coreid', index: index_from(node)) add_extension(extn) end save end
Private Instance Methods
Creates a Entity
instance from xml node (core or extension) adds Attribute
instances for any field given adds ContentFile
instances for any child node of files
# File lib/dwcr/metaschema/archive.rb, line 78 def add_entity_from(xml) entity = add_entity(values_from(xml, :term, :key_column)) xml.css('field').each { |field| entity.add_attribute_from(field) } entity.add_files_from(xml, path: path) entity end
Sequel Model hook that creates a default name
from the term
if present
# File lib/dwcr/metaschema/archive.rb, line 70 def before_create self.name ||= path&.split('/')&.last super end