Class: Metanorma::Requirements::Modspec::Iso
- Inherits:
-
Metanorma::Requirements::Modspec
- Object
- Metanorma::Requirements::Modspec
- Metanorma::Requirements::Modspec::Iso
- Defined in:
- lib/metanorma/requirements/modspec.rb
Overview
Don’t want to inherit from Metanorma::Requirements::Modspec
Instance Method Summary collapse
- #nested_tables_names(table) ⇒ Object
- #postprocess_anchor_struct(block, anchor) ⇒ Object
- #recommend_title(node, out) ⇒ Object
-
#recommendation_header(reqt, out) ⇒ Object
ISO labels modspec reqt as table, with reqt label as title.
- #recommendation_label(elem, type, xrefs) ⇒ Object
- #recommendation_label_xref(elem, label, xrefs, _type) ⇒ Object
- #reqt_ids(docxml) ⇒ Object
- #reqt_links_class(docxml) ⇒ Object
- #reqt_links_test(docxml) ⇒ Object
- #requirement_component_parse(node, out) ⇒ Object
- #requirement_table_cleanup(node, table) ⇒ Object
Instance Method Details
#nested_tables_names(table) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/metanorma/requirements/modspec.rb', line 62 def nested_tables_names(table) table.xpath(ns("./tbody/tr/td/table")) .each_with_object([]) do |t, m| m << t.at(ns("./name")).children.to_xml end.join("<br/>") end |
#postprocess_anchor_struct(block, anchor) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/metanorma/requirements/modspec.rb', line 69 def postprocess_anchor_struct(block, anchor) super anchor[:xref_reqt2reqt] = anchor[:xref_bare] if l = block.at(ns("./title")) anchor[:xref_reqt2reqt] = l10n("#{anchor[:xref_reqt2reqt]}: #{l.children.to_xml.strip}") end anchor end |
#recommend_title(node, out) ⇒ Object
32 33 34 35 36 |
# File 'lib/metanorma/requirements/modspec.rb', line 32 def recommend_title(node, out) label = node.at(ns("./identifier")) or return out.add_child("<tr><td>#{@labels['modspec']['identifier']}</td>"\ "<td><tt>#{label.children.to_xml}</tt></td>") end |
#recommendation_header(reqt, out) ⇒ Object
ISO labels modspec reqt as table, with reqt label as title
27 28 29 30 |
# File 'lib/metanorma/requirements/modspec.rb', line 27 def recommendation_header(reqt, out) n = reqt.at(ns("./name")) and out << n out end |
#recommendation_label(elem, type, xrefs) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/metanorma/requirements/modspec.rb', line 15 def recommendation_label(elem, type, xrefs) lbl = super title = elem.at(ns("./title")) return lbl unless title && elem.ancestors("requirement, recommendation, permission").empty? lbl += ": " if lbl lbl += title.children.to_xml l10n(lbl) end |
#recommendation_label_xref(elem, label, xrefs, _type) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/metanorma/requirements/modspec.rb', line 6 def recommendation_label_xref(elem, label, xrefs, _type) id = @reqtlabels[label] number = xrefs.anchor(id, :xref_reqt2reqt, false) number.nil? and return type elem.ancestors("requirement, recommendation, permission").empty? and return number "<xref target='#{id}'>#{number}</xref>" end |
#reqt_ids(docxml) ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'lib/metanorma/requirements/modspec.rb', line 79 def reqt_ids(docxml) docxml.xpath(ns("//requirement | //recommendation | //permission")) .each_with_object({}) do |r, m| id = r.at(ns("./identifier")) or next m[id.text] = { id: r["id"], lbl: @xrefs.anchor(r["id"], :xref_reqt2reqt, false) } end end |
#reqt_links_class(docxml) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/metanorma/requirements/modspec.rb', line 105 def reqt_links_class(docxml) docxml.xpath(ns("//requirement | //recommendation | //permission")) .each_with_object({}) do |r, m| next unless %w(class conformanceclass).include?(r["type"]) id = r.at(ns("./identifier")) or next r.xpath(ns("./requirement | ./recommendation | ./permission")) .each do |r1| id1 = r1.at(ns("./identifier")) or next lbl = @xrefs.anchor(@reqt_ids[id.text.strip][:id], :xref_reqt2reqt, false) next unless lbl m[id1.text] = { lbl: lbl, id: r["id"] } end end end |
#reqt_links_test(docxml) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/metanorma/requirements/modspec.rb', line 89 def reqt_links_test(docxml) docxml.xpath(ns("//requirement | //recommendation | //permission")) .each_with_object({}) do |r, m| next unless %w(conformanceclass verification).include?(r["type"]) subj = r.at(ns("./classification[tag = 'target']/value")) id = r.at(ns("./identifier")) or next lbl = @xrefs.anchor(@reqt_ids[id.text.strip][:id], :xref_reqt2reqt, false) next unless subj m[subj.text] = { lbl: lbl, id: r["id"] } end end |
#requirement_component_parse(node, out) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/metanorma/requirements/modspec.rb', line 38 def requirement_component_parse(node, out) if node["exclude"] != "true" && node.name == "description" lbl = "statement" recommend_class(node.parent) == "recommendclass" and lbl = "description" out << "<tr><td>#{@labels['modspec'][lbl]}</td>"\ "<td>#{node.children.to_xml}</td></tr>" else super end end |
#requirement_table_cleanup(node, table) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/metanorma/requirements/modspec.rb', line 50 def requirement_table_cleanup(node, table) return table unless table["type"] == "recommendclass" label = if node["type"] == "conformanceclass" then "conformancetests" else "provisions" end ins = table.at(ns("./tbody/tr[td/table]")) or return table ins.replace("<tr><td>#{@labels['modspec'][label]}</td>" + "<td>#{nested_tables_names(table)}</td></tr>") table.xpath(ns("./tbody/tr[td/table]")).each(&:remove) table end |