Sha256: c60d7182abf8ff051b0e903a756f959658eb8570f85f74af1255acbdf31f1e9d

Contents?: true

Size: 1.62 KB

Versions: 8

Compression:

Stored size: 1.62 KB

Contents

require "isodoc"
require "metanorma/cc"

module IsoDoc
  module CC
    # A {Converter} implementation that generates CC output, and a document
    # schema encapsulation of the document for validation
    class Metadata < IsoDoc::Metadata
      def initialize(lang, script, labels)
        super
        set(:tc, "XXXX")
      end

      def title(isoxml, _out)
        main = isoxml&.at(ns("//bibdata/title[@language='en']"))&.text
        set(:doctitle, main)
      end

      def subtitle(_isoxml, _out)
        nil
      end

      def author(isoxml, _out)
        tc = isoxml.at(ns("//bibdata/ext/editorialgroup/technical-committee"))
        set(:tc, tc.text) if tc
        super
      end

      def personal_authors(isoxml)
        persons = {}
        roles = isoxml.xpath(ns("//bibdata/contributor/role/@type")).
          inject([]) { |m, t| m << t.value }
        roles.uniq.sort.each do |r|
          names = isoxml.xpath(ns("//bibdata/contributor[role/@type = '#{r}']"\
                                    "/person"))
          persons[r] = extract_person_names_affiliations(names) unless names.empty?
        end
        set(:roles_authors_affiliations, persons)
        super
      end

      def docid(isoxml, _out)
        docnumber = isoxml.at(ns("//bibdata/docidentifier"))
        prefix = "CC"
        if docnumber.nil?
          set(:docnumber, prefix)
        else
          set(:docnumber, docnumber.text)
        end
      end

      def stage_abbr(status)
        ::Metanorma::CC::DOCSTATUS[status] || ""
      end

      def unpublished(status)
        !%w(published withdrawn).include? status.downcase
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
metanorma-cc-1.5.6 lib/isodoc/cc/metadata.rb
metanorma-cc-1.5.5 lib/isodoc/cc/metadata.rb
metanorma-cc-1.5.4 lib/isodoc/cc/metadata.rb
metanorma-cc-1.5.3 lib/isodoc/cc/metadata.rb
metanorma-cc-1.5.2 lib/isodoc/cc/metadata.rb
metanorma-cc-1.5.1 lib/isodoc/cc/metadata.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/metanorma-cc-1.5.0/lib/isodoc/cc/metadata.rb
metanorma-cc-1.5.0 lib/isodoc/cc/metadata.rb