lib/isodoc/iso/metadata.rb in metanorma-iso-2.3.3 vs lib/isodoc/iso/metadata.rb in metanorma-iso-2.3.4
- old
+ new
@@ -4,11 +4,10 @@
module Iso
class Metadata < IsoDoc::Metadata
def initialize(lang, script, locale, i18n)
super
DATETYPES.each { |w| @metadata["#{w.gsub(/-/, '_')}date".to_sym] = nil }
- set(:editorialgroup, [])
set(:obsoletes, nil)
set(:obsoletes_part, nil)
end
def status_abbrev(stage, _substage, iter, draft, doctype)
@@ -98,11 +97,11 @@
def compose_title(tparts, tnums, lang)
main = ""
tparts[:main].nil? or
main = @c.encode(tparts[:main].text, :hexadecimal)
- tparts[:intro] &&
+ tparts[:intro] and
main = "#{@c.encode(tparts[:intro].text,
:hexadecimal)} — #{main}"
if tparts[:part]
suffix = part_title(tparts[:part], tnums, lang)
main = "#{main} — #{suffix}"
@@ -117,24 +116,23 @@
amd: isoxml.at(ns("#{prefix}/@amendment")),
corr: isoxml.at(ns("#{prefix}/@corrigendum")) }
end
def title_parts(isoxml, lang)
- { intro: isoxml.at(ns("//bibdata/title[@type='title-intro' and "\
+ { intro: isoxml.at(ns("//bibdata/title[@type='title-intro' and " \
"@language='#{lang}']")),
- main: isoxml.at(ns("//bibdata/title[@type='title-main' and "\
+ main: isoxml.at(ns("//bibdata/title[@type='title-main' and " \
"@language='#{lang}']")),
- part: isoxml.at(ns("//bibdata/title[@type='title-part' and "\
+ part: isoxml.at(ns("//bibdata/title[@type='title-part' and " \
"@language='#{lang}']")),
- amd: isoxml.at(ns("//bibdata/title[@type='title-amd' and "\
+ amd: isoxml.at(ns("//bibdata/title[@type='title-amd' and " \
"@language='#{lang}']")) }
end
def title(isoxml, _out)
lang = case @lang
- when "fr" then "fr"
- when "ru" then "ru"
+ when "fr", "ru" then @lang
else "en"
end
# intro, main, part, amd = title_parts(isoxml, lang)
tp = title_parts(isoxml, lang)
tn = title_nums(isoxml)
@@ -177,61 +175,60 @@
def author(xml, _out)
super
tc(xml)
sc(xml)
wg(xml)
- approvalgroup(xml)
+ editorialgroup(xml)
secretariat(xml)
end
def tc(xml)
tcid = tc_base(xml, "editorialgroup") or return
set(:tc, tcid)
- set(:editorialgroup, get[:editorialgroup] << tcid)
end
def tc_base(xml, grouptype)
- tc_num = xml.at(ns("//bibdata/ext/#{grouptype}/"\
+ tc_num = xml.at(ns("//bibdata/ext/#{grouptype}/" \
"technical-committee/@number")) or return nil
- tc_type = xml.at(ns("//bibdata/ext/#{grouptype}/technical-committee/"\
+ tc_type = xml.at(ns("//bibdata/ext/#{grouptype}/technical-committee/" \
"@type"))&.text || "TC"
- "#{tc_type} #{tc_num.text}"
+ tc_type == "Other" and tc_type = ""
+ "#{tc_type} #{tc_num.text}".strip
end
def sc(xml)
scid = sc_base(xml, "editorialgroup") or return
set(:sc, scid)
- set(:editorialgroup, get[:editorialgroup] << scid)
end
def sc_base(xml, grouptype)
- sc_num = xml.at(ns("//bibdata/ext/#{grouptype}/subcommittee/"\
+ sc_num = xml.at(ns("//bibdata/ext/#{grouptype}/subcommittee/" \
"@number")) or return nil
- sc_type = xml.at(ns("//bibdata/ext/#{grouptype}/subcommittee/"\
+ sc_type = xml.at(ns("//bibdata/ext/#{grouptype}/subcommittee/" \
"@type"))&.text || "SC"
+ sc_type == "Other" and sc_type = ""
"#{sc_type} #{sc_num.text}"
end
def wg(xml)
wgid = wg_base(xml, "editorialgroup") or return
set(:wg, wgid)
- set(:editorialgroup, get[:editorialgroup] << wgid)
end
def wg_base(xml, grouptype)
- wg_num = xml.at(ns("//bibdata/ext/#{grouptype}/workgroup/"\
+ wg_num = xml.at(ns("//bibdata/ext/#{grouptype}/workgroup/" \
"@number")) or return
- wg_type = xml.at(ns("//bibdata/ext/#{grouptype}/workgroup/"\
+ wg_type = xml.at(ns("//bibdata/ext/#{grouptype}/workgroup/" \
"@type"))&.text || "WG"
+ wg_type == "Other" and wg_type = ""
"#{wg_type} #{wg_num.text}"
end
- def approvalgroup(xml)
- ag = tc_base(xml, "approvalgroup") or return
- ret = [ag]
- ret << sc_base(xml, "approvalgroup")
- ret << wg_base(xml, "approvalgroup")
- set(:approvalgroup, ret.compact)
+ def editorialgroup(xml)
+ a = xml.at(ns("//bibdata/ext/editorialgroup/@identifier")) and
+ set(:editorialgroup, a.text)
+ a = xml.at(ns("//bibdata/ext/approvalgroup/@identifier")) and
+ set(:approvalgroup, a.text)
end
def secretariat(xml)
sec = xml.at(ns("//bibdata/ext/editorialgroup/secretariat"))
set(:secretariat, sec.text) if sec