Sha256: 9e27df1235fed07bdd4ab7f38498d0b31a693bc38018382616bae68bd6af0a30

Contents?: true

Size: 1015 Bytes

Versions: 6

Compression:

Stored size: 1015 Bytes

Contents

require "nokogiri"

module RelatonIetf
  class XMLParser < RelatonBib::XMLParser
    class << self
      private

      def item_data(doc)
        data = super
        data[:stream] = doc.at("ext/stream")&.text
        data
      end

      # override RelatonBib::BibliographicItem.bib_item method
      # @param item_hash [Hash]
      # @return [RelatonIetf::IetfBibliographicItem]
      def bib_item(item_hash)
        IetfBibliographicItem.new(**item_hash)
      end

      # @param ext [Nokogiri::XML::Element]
      # @return [RelatonBib::EditorialGroup, nil]
      def fetch_editorialgroup(ext)
        return unless ext && (eg = ext.at "editorialgroup")

        eg = eg.xpath("committee").map do |tc|
          wg = RelatonBib::WorkGroup.new(
            name: tc.text, number: tc[:number]&.to_i, type: tc[:type],
            identifier: tc[:identifier], prefix: tc[:prefix]
          )
          Committee.new wg
        end
        RelatonBib::EditorialGroup.new eg if eg.any?
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
relaton-ietf-1.18.0 lib/relaton_ietf/xml_parser.rb
relaton-ietf-1.17.0 lib/relaton_ietf/xml_parser.rb
relaton-ietf-1.16.2 lib/relaton_ietf/xml_parser.rb
relaton-ietf-1.16.1 lib/relaton_ietf/xml_parser.rb
relaton-ietf-1.16.0 lib/relaton_ietf/xml_parser.rb
relaton-ietf-1.14.5 lib/relaton_ietf/xml_parser.rb