Sha256: ce51e67c25665b96e0424d7c0409832eb680362eeba46bc0f0ae262981c7a0c8
Contents?: true
Size: 869 Bytes
Versions: 1
Compression:
Stored size: 869 Bytes
Contents
module AmazonFeedValidator class FeedValidator XSDDIR = File.expand_path('../xsd', __dir__) attr_reader :feed, :options, :errors def initialize(feed, **options) @feed = Nokogiri::XML feed @options = Hashie::Mash.new options end def validate @errors = Nokogiri::XML::Schema(xsd_file(options.name)) .validate(feed) .map(&:to_s) errors.empty? end private def xsd_file(name) file = File.read File.expand_path sanitize_name(name), XSDDIR # Replace schema location references with ones pointing to local xsd # files file.gsub! \ 'schemaLocation="', "schemaLocation=\"#{XSDDIR}/" end def sanitize_name(name) name ||= 'Product.xsd' name = "#{name}.xsd" unless name.include? '.xsd' name end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
amazon_feed_validator-0.1.0 | lib/amazon_feed_validator/feed_validator.rb |