Skip to content

Commit

Permalink
Merge pull request #1110 from metanorma/fix/committee-document-id
Browse files Browse the repository at this point in the history
add workgroup to TC number for committee documents: https://github.co…
  • Loading branch information
opoudjis authored Feb 22, 2024
2 parents 23f9e03 + c9c58aa commit 1d379bf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/metanorma/iso/front_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ def iso_id_params_add(node)

def tc_number(ret, node)
doctype(node) == "committee-document" or return ret
n = node.attr("subcommittee-number") and
ret.merge!({ sctype: node.attr("subcommittee-type") || "SC",
scnumber: n })
n = node.attr("technical-committee-number") and
ret.merge!({ tctype: node.attr("technical-committee-type") || "TC",
tcnumber: n })
{ sc: "subcommittee", tc: "technical-committee",
wg: "workgroup" }.each do |k, v|
n = node.attr("#{v}-number") and
ret.merge!({ "#{k}type": node.attr("#{v}-type") || k.to_s.upcase,
"#{k}number": n })
end
ret
end

Expand Down
32 changes: 30 additions & 2 deletions spec/metanorma/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@
:doctype: committee-document
INPUT
output = <<~OUTPUT
<docidentifier type="ISO">ISO/A 1/B 2 N1000</docidentifier>
<docidentifier type="ISO">ISO/A 1/B 2/C 3 N1000</docidentifier>
OUTPUT
xml = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
xml = xml.xpath("//xmlns:bibdata/xmlns:docidentifier")
Expand All @@ -962,15 +962,43 @@

input1 = input.gsub(/:technical-committee-type:.+?[\r\n]+/m, "")
.gsub(/:subcommittee-type:.+?[\r\n]+/m, "")
.gsub(/:workgroup-type:.+?[\r\n]+/m, "")
output = <<~OUTPUT
<docidentifier type="ISO">ISO/TC 1/SC 2 N1000</docidentifier>
<docidentifier type="ISO">ISO/TC 1/SC 2/WG 3 N1000</docidentifier>
OUTPUT
xml = Nokogiri::XML(Asciidoctor.convert(input1, *OPTIONS))
xml = xml.xpath("//xmlns:bibdata/xmlns:docidentifier")
expect(xmlpp(strip_guid(xml.to_xml)))
.to be_equivalent_to xmlpp(output)

input1 = input.gsub(/:technical-committee-type:.+?[\r\n]+/m, "")
.gsub(/:subcommittee-type:.+?[\r\n]+/m, "")
output = <<~OUTPUT
<docidentifier type="ISO">ISO/TC 1/SC 2/C 3 N1000</docidentifier>
OUTPUT
xml = Nokogiri::XML(Asciidoctor.convert(input1, *OPTIONS))
xml = xml.xpath("//xmlns:bibdata/xmlns:docidentifier")
expect(xmlpp(strip_guid(xml.to_xml)))
.to be_equivalent_to xmlpp(output)

input2 = input.gsub(/:workgroup.+?[\r\n]+/m, "")
output = <<~OUTPUT
<docidentifier type="ISO">ISO/A 1/B 2 N1000</docidentifier>
OUTPUT
xml = Nokogiri::XML(Asciidoctor.convert(input2, *OPTIONS))
xml = xml.xpath("//xmlns:bibdata/xmlns:docidentifier")
expect(xmlpp(strip_guid(xml.to_xml)))
.to be_equivalent_to xmlpp(output)

input2 = input.gsub(/:subcommittee.+?[\r\n]+/m, "")
.gsub(/:workgroup.+?[\r\n]+/m, "")
output = <<~OUTPUT
<docidentifier type="ISO">ISO/A 1 N1000</docidentifier>
OUTPUT
xml = Nokogiri::XML(Asciidoctor.convert(input2, *OPTIONS))
xml = xml.xpath("//xmlns:bibdata/xmlns:docidentifier")
expect(xmlpp(strip_guid(xml.to_xml)))
.to be_equivalent_to xmlpp(output)
output = <<~OUTPUT
<docidentifier type="ISO">ISO/A 1 N1000</docidentifier>
OUTPUT
Expand Down

0 comments on commit 1d379bf

Please sign in to comment.