Sha256: 5d9e9f1d8e8fd000c0a2124e73b780f73a0f410cab3407a16ef2ab3a017c096b
Contents?: true
Size: 969 Bytes
Versions: 13
Compression:
Stored size: 969 Bytes
Contents
require 'ndr_support/safe_file' require 'ndr_import/helpers/file/xml' require_relative 'registry' module NdrImport # This is one of a collection of file handlers that deal with individual formats of data. # They can be instantiated directly or via the factory method Registry.tables module File # This class is a xml file handler that returns a single table. class Xml < Base include NdrImport::Helpers::File::Xml private # Iterate through the file, yielding each 'xml_record_xpath' element in turn. def rows(&block) return enum_for(:rows) unless block doc = read_xml_file(@filename) doc.xpath(@options['xml_record_xpath']).each(&block) rescue StandardError => e raise("#{SafeFile.basename(@filename)} [#{e.class}: #{e.message}]") end end # Not all xml files may want to be registered, so 'xml' is not registered by design. Registry.register(Xml, 'xml_table') end end
Version data entries
13 entries across 13 versions & 1 rubygems