Sha256: 18a7b34a51377648e0ac7dcbc92dcf995643c5e172167f3b7d9b358bb1aeb164
Contents?: true
Size: 873 Bytes
Versions: 1
Compression:
Stored size: 873 Bytes
Contents
require 'nokogiri' module CDONFeedValidator class Validator XSDDIR = File.expand_path('../xsd', __dir__) attr_reader :xml, :options, :errors def initialize(xml, **options) @xml = Nokogiri::XML xml @options = options.as_json @errors = [] end def valid? validate errors.empty? end def validate @errors = file .validate(xml) .map(&:to_s) || [] end private def filename raise NotImplementedError, 'must be implemented by descendents' end def file string = File.read File.expand_path filename, XSDDIR # Replace schema location references with ones pointing to local xsd # files string.gsub! \ 'schemaLocation="', "schemaLocation=\"#{XSDDIR}/" Nokogiri::XML::Schema string end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cdon_feed_validator-1.0.0 | lib/cdon_feed_validator/validator.rb |