Sha256: eba0005b102936e91498397fdb40d0cc20c37ed0e79818127cf1a82b3d31383d

Contents?: true

Size: 1.53 KB

Versions: 8

Compression:

Stored size: 1.53 KB

Contents

require "isodoc"

module IsoDoc
  module Ietf
    class  Metadata < IsoDoc::Metadata
      TITLE_RFC = "//bibdata//title[@type='main' and @language='en']".freeze

      def title(isoxml, _out)
        t =  isoxml.at(ns(TITLE_RFC)) and
          set(:doctitle, t.text)
        t =  isoxml.at(ns(TITLE_RFC.sub(/main/, "abbrev"))) and
          set(:docabbrev, t.text)
        t =  isoxml.at(ns(TITLE_RFC.sub(/main/, "ascii"))) and
          set(:docascii, t.text)
      end

      def relaton_relations
        %w(included-in described-by derived-from equivalent)
        # = item describedby convertedfrom alternate
      end

      def keywords(isoxml, _out)
        ret = []
        isoxml.xpath(ns("//bibdata/keyword")).each do |kw|
          ret << kw.text
        end
        set(:keywords, ret)
      end

      def areas(isoxml, _out)
        ret = []
        isoxml.xpath(ns("//bibdata/ext/area")).each do |kw|
          ret << kw.text
        end
        set(:areas, ret)
      end

      def docid(isoxml, _out)
        dn = isoxml.at(ns("//bibdata/docnumber"))
        set(:docnumber, dn&.text&.sub(/^rfc-/, "")&.sub(/\.[a-z0-9]+$/i, ""))
      end

      def author(xml, _out)
        super
        wg(xml)
      end

       def wg(xml)
         workgroups = []
         xml.xpath(ns("//bibdata/ext/editorialgroup/workgroup")).each do |wg|
           workgroups << wg.text
        end
         set(:wg, workgroups)
      end

       def doctype(isoxml, _out)
         super
         set(:doctype, "Rfc") if get[:doctype].nil?
       end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
metanorma-ietf-2.0.7 lib/isodoc/ietf/metadata.rb
metanorma-ietf-2.0.6 lib/isodoc/ietf/metadata.rb
metanorma-ietf-2.0.5 lib/isodoc/ietf/metadata.rb
metanorma-ietf-2.0.4 lib/isodoc/ietf/metadata.rb
metanorma-ietf-2.0.3 lib/isodoc/ietf/metadata.rb
metanorma-ietf-2.0.2 lib/isodoc/ietf/metadata.rb
metanorma-ietf-2.0.1 lib/isodoc/ietf/metadata.rb
metanorma-ietf-2.0.0 lib/isodoc/ietf/metadata.rb