Sha256: 29fa4247083bd79edfb0a1fc1f1fac563df254fc0ec8b33d6202913756857844

Contents?: true

Size: 1.66 KB

Versions: 11

Compression:

Stored size: 1.66 KB

Contents

require "metanorma/ietf/data/workgroups"
require "metanorma-utils"

module Metanorma
  module Ietf
    class Converter < ::Metanorma::Standoc::Converter
      def content_validate(doc)
        super
        image_validate(doc)
        workgroup_validate(doc)
        submission_validate(doc)
      end

      def ns(path)
        ::Metanorma::Utils::ns(path)
      end

      def submission_validate(doc)
        stream = doc.at(("//bibdata/series[@type = 'stream']/title"))&.text
        status = doc.at(("//bibdata/status/stage"))&.text
        stream == "editorial" && status != "informational" and
          @log.add("Document Attributes", nil,
                   "Editorial stream must have Informational status")
      end

      def image_validate(doc)
        doc.xpath("//image").each do |i|
          i["mimetype"] == "image/svg+xml" and next
          @log.add("Images", i, "image #{i['src'][0, 40]} is not SVG!",
                   severity: 1)
        end
      end

      def workgroup_validate(doc)
        return if @workgroups.empty?

        doc.xpath("//bibdata/ext/editorialgroup/workgroup").each do |wg|
          wg_norm = wg.text.sub(/ (Working|Research) Group$/, "")
          @workgroups.include?(wg_norm) and next
          @log.add("Document Attributes", nil,
                   "IETF: unrecognised working group #{wg.text}",
                   severity: 1)
        end
      end

      def validate(doc)
        content_validate(doc)
        schema_validate(formattedstr_strip(doc.dup),
                        File.join(File.dirname(__FILE__), "ietf.rng"))
      end

      def cache_workgroup(_node)
        Metanorma::Ietf::Data::WORKGROUPS
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
metanorma-ietf-3.4.4 lib/metanorma/ietf/validate.rb
metanorma-ietf-3.4.3 lib/metanorma/ietf/validate.rb
metanorma-ietf-3.4.2 lib/metanorma/ietf/validate.rb
metanorma-ietf-3.4.0 lib/metanorma/ietf/validate.rb
metanorma-ietf-3.3.10 lib/metanorma/ietf/validate.rb
metanorma-ietf-3.3.9 lib/metanorma/ietf/validate.rb
metanorma-ietf-3.3.8 lib/metanorma/ietf/validate.rb
metanorma-ietf-3.3.7 lib/metanorma/ietf/validate.rb
metanorma-ietf-3.3.6 lib/metanorma/ietf/validate.rb
metanorma-ietf-3.3.5 lib/metanorma/ietf/validate.rb
metanorma-ietf-3.3.4 lib/metanorma/ietf/validate.rb