Sha256: a8f0e9add9c72150d639af667547ceaa67ad1416acd342dbd094dd45ec16c14d
Contents?: true
Size: 1.99 KB
Versions: 74
Compression:
Stored size: 1.99 KB
Contents
# frozen_string_literal: true require 'isodoc' module IsoDoc module Csa # A {Converter} implementation that generates CSA output, and a document # schema encapsulation of the document for validation class Metadata < IsoDoc::Generic::Metadata def configuration Metanorma::Csa.configuration 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) set(:tc, "XXXX") tc = isoxml.at(ns("//bibdata/ext/editorialgroup/committee")) set(:tc, tc.text) if tc super end def docid(isoxml, _out) docnumber = isoxml.at(ns("//bibdata/docidentifier[@type = 'csa']")) set(:docnumber, docnumber&.text) end def personal_authors(isoxml) persons = auth_roles(isoxml, nonauth_roles(isoxml, {})) set(:roles_authors_affiliations, persons) super end def nonauth_roles(isoxml, persons) roles = isoxml.xpath(ns("//bibdata/contributor[person]/role/@type")). inject([]) { |m, t| m << t.value }.reject { |i| i == "author" } roles.uniq.sort.each do |r| n = isoxml.xpath(ns("//bibdata/contributor[role/@type = '#{r}']"\ "/person")) n.empty? or persons[r] = extract_person_names_affiliations(n) end persons end def auth_roles(isoxml, persons) roles = isoxml.xpath(ns("//bibdata/contributor[person]/"\ "role[@type = 'author']/description")). inject([]) { |m, t| m << t.text } roles.uniq.sort.each do |r| n = isoxml.xpath( ns("//bibdata/contributor[role/@type = 'author']"\ "[xmlns:role/description = '#{r}']/person")) n.empty? or persons[r] = extract_person_names_affiliations(n) end persons end end end end
Version data entries
74 entries across 74 versions & 1 rubygems