lib/isodoc/iso/metadata.rb in metanorma-iso-1.3.24 vs lib/isodoc/iso/metadata.rb in metanorma-iso-1.3.25

- old
+ new

@@ -14,12 +14,16 @@ obsoletes: nil, obsoletes_part: nil } end - def status_abbrev(stage, substage, iter, draft) + def status_abbrev(stage, substage, iter, draft, doctype) return "" unless stage + if %w(technical-report technical-specification).include?(doctype) + stage = "DTS" if stage == "DIS" + stage = "FDTS" if stage == "FDIS" + end stage += iter if iter stage = "Pre" + stage if draft =~ /^0\./ stage end @@ -31,11 +35,12 @@ set(:stage_int, docstatus.text.to_i) set(:unpublished, unpublished(docstatus.text)) set(:statusabbr, status_abbrev(docstatus["abbreviation"] || "??", isoxml&.at(ns("//bibdata/status/substage"))&.text, isoxml&.at(ns("//bibdata/status/iteration"))&.text, - isoxml&.at(ns("//version/draft"))&.text)) + isoxml&.at(ns("//version/draft"))&.text, + isoxml&.at(ns("//bibdata/ext/doctype"))&.text)) unpublished(docstatus.text) and set(:stageabbr, docstatus["abbreviation"]) end revdate = isoxml.at(ns("//version/revision-date")) set(:revdate, revdate&.text) @@ -63,10 +68,24 @@ when "en" then "Part" when "fr" then "Partie" end end + def amd_label(lang) + case lang + when "en" then "AMENDMENT" + when "fr" then "AMENDMENT" + end + end + + def corr_label(lang) + case lang + when "en" then "TECHNICAL CORRIGENDUM" + when "fr" then "RECTIFICATIF TECHNIQUE" + end + end + def part_title(part, partnum, subpartnum, lang) return "" unless part suffix = @c.encode(part.text, :hexadecimal) partnum = "#{partnum}–#{subpartnum}" if partnum && subpartnum suffix = "#{part_label(lang)} #{partnum}: " + suffix if partnum @@ -76,10 +95,18 @@ def part_prefix(partnum, subpartnum, lang) partnum = "#{partnum}–#{subpartnum}" if partnum && subpartnum "#{part_label(lang)} #{partnum}" end + def amd_prefix(num, lang) + "#{amd_label(lang)} #{num}" + end + + def corr_prefix(num, lang) + "#{corr_label(lang)} #{num}" + end + def compose_title(main, intro, part, partnum, subpartnum, lang) main = main.nil? ? "" : @c.encode(main.text, :hexadecimal) intro && main = "#{@c.encode(intro.text, :hexadecimal)} — #{main}" if part @@ -93,30 +120,43 @@ intro = isoxml.at(ns("//bibdata//title[@type='title-intro' and @language='en']")) main = isoxml.at(ns("//bibdata//title[@type='title-main' and @language='en']")) part = isoxml.at(ns("//bibdata//title[@type='title-part' and @language='en']")) partnumber = isoxml.at(ns("//bibdata//project-number/@part")) subpartnumber = isoxml.at(ns("//bibdata//project-number/@subpart")) + amdnumber = isoxml.at(ns("//bibdata//project-number/@amendment")) + corrnumber = isoxml.at(ns("//bibdata//project-number/@corrigendum")) + amd = isoxml.at(ns("//bibdata//title[@type='title-amd' and @language='en']")) set(:doctitlemain, @c.encode(main ? main.text : "", :hexadecimal)) main = compose_title(main, intro, part, partnumber, subpartnumber, "en") set(:doctitle, main) set(:doctitleintro, @c.encode(intro ? intro.text : "", :hexadecimal)) if intro set(:doctitlepartlabel, part_prefix(partnumber, subpartnumber, "en")) set(:doctitlepart, @c.encode(part.text, :hexadecimal)) if part + set(:doctitleamdlabel, amd_prefix(amdnumber, "en")) if amdnumber + set(:doctitleamd, @c.encode(amd.text, :hexadecimal)) if amd + set(:doctitlecorrlabel, corr_prefix(corrnumber, "en")) if corrnumber end def subtitle(isoxml, _out) intro = isoxml.at(ns("//bibdata//title[@type='title-intro' and @language='fr']")) main = isoxml.at(ns("//bibdata//title[@type='title-main' and @language='fr']")) part = isoxml.at(ns("//bibdata//title[@type='title-part' and @language='fr']")) partnumber = isoxml.at(ns("//bibdata//project-number/@part")) subpartnumber = isoxml.at(ns("//bibdata//project-number/@subpart")) + amdnumber = isoxml.at(ns("//bibdata//project-number/@amendment")) + corrnumber = isoxml.at(ns("//bibdata//project-number/@corrigendum")) + amd = isoxml.at(ns("//bibdata//title[@type='title-amd' and @language='fr']")) + set(:docsubtitlemain, @c.encode(main ? main.text : "", :hexadecimal)) main = compose_title(main, intro, part, partnumber, subpartnumber, "fr") set(:docsubtitle, main) set(:docsubtitleintro, @c.encode(intro ? intro.text : "", :hexadecimal)) if intro set(:docsubtitlepartlabel, part_prefix(partnumber, subpartnumber, "fr")) set(:docsubtitlepart, @c.encode(part.text, :hexadecimal)) if part + set(:docsubtitleamdlabel, amd_prefix(amdnumber, "fr")) if amdnumber + set(:docsubtitleamd, @c.encode(amd.text, :hexadecimal)) if amd + set(:docsubtitlecorrlabel, corr_prefix(corrnumber, "fr")) if corrnumber end def author(xml, _out) super tc(xml)