lib/isodoc/iso/metadata.rb in metanorma-iso-1.0.8 vs lib/isodoc/iso/metadata.rb in metanorma-iso-1.0.9

- old
+ new

@@ -18,38 +18,33 @@ "90": "(Review)", "95": "(Withdrawal)", }.freeze def stage_abbrev(stage, iter, draft) + return "" unless stage stage = STAGE_ABBRS[stage.to_sym] || "??" - stage += iter.text if iter - stage = "Pre" + stage if draft&.text =~ /^0\./ + stage += iter if iter + stage = "Pre" + stage if draft =~ /^0\./ stage end def docstatus(isoxml, _out) docstatus = isoxml.at(ns("//bibdata/status/stage")) if docstatus set(:stage, docstatus.text) set(:stage_int, docstatus.text.to_i) - abbr = stage_abbrev(docstatus.text, isoxml.at(ns("//bibdata/status/iteration")), - isoxml.at(ns("//version/draft"))) + abbr = stage_abbrev(docstatus.text, isoxml&.at(ns("//bibdata/status/iteration"))&.text, + isoxml&.at(ns("//version/draft"))&.text) set(:stageabbr, abbr) end revdate = isoxml.at(ns("//version/revision-date")) set(:revdate, revdate&.text) end def docid(isoxml, _out) - dn = docnumber(isoxml) # e.g. ISO 8601, ISO/IEC DIR 2 - docstatus = get[:stage] - if docstatus - abbr = get[:stageabbr] - docstatus = get[:stage] - (docstatus.to_i < 60) && dn = dn.sub(/ /, "/#{abbr} ") - end - set(:docnumber, dn) - tcdn = isoxml.at(ns("//bibdata/docidentifier/tc-document-number")) + dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso']")) + set(:docnumber, dn&.text) + tcdn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-tc']")) set(:tc_docnumber, tcdn&.text) end # we don't leave this to i18n.rb, because we have both English and # French titles in the same document