Skip to content

Commit

Permalink
Merge pull request #329 from metanorma/feature/pubid
Browse files Browse the repository at this point in the history
Feature/pubid
  • Loading branch information
opoudjis authored Feb 5, 2024
2 parents 99d9d54 + 4fd95e1 commit f70971e
Show file tree
Hide file tree
Showing 15 changed files with 1,595 additions and 1,518 deletions.
Binary file added lib/isodoc/ieee/html/wp_image001_icr.emz
Binary file not shown.
Binary file added lib/isodoc/ieee/html/wp_image003_icr.emz
Binary file not shown.
Binary file added lib/isodoc/ieee/html/wp_image008_icr.emz
Binary file not shown.
73 changes: 69 additions & 4 deletions lib/metanorma/ieee/front.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "isoics"
require "pubid-ieee"

module Metanorma
module IEEE
Expand All @@ -16,7 +17,8 @@ def metadata_committee(node, xml)
def metadata_committee_prep(node)
node.attr("doctype") == "whitepaper" &&
node.attr("docsubtype") == "industry-connection-report" and
node.set_attr("working-group", "IEEE SA Industry Connections activity")
node.set_attr("working-group",
"IEEE SA Industry Connections activity")
node.attr("committee") || node.attr("society") ||
node.attr("working-group") or return
node.attr("balloting-group") && !node.attr("balloting-group-type") and
Expand All @@ -32,15 +34,76 @@ def metadata_other_id(node, xml)
end

def metadata_id(node, xml)
id = node.attr("docnumber") || ""
xml.docidentifier (node.attr("docidentifier") || id), type: "IEEE"
if id = node.attr("docidentifier")
xml.docidentifier id, **attr_code(type: "IEEE")
else ieee_id(node, xml)
end
id = node.attr("stdid-pdf") and
xml.docidentifier id, type: "IEEE", scope: "PDF"
id = node.attr("stdid-print") and
xml.docidentifier id, type: "IEEE", scope: "print"
xml.docnumber node.attr("docnumber")
end

def ieee_id(node, xml)
params = ieee_id_params(node)
params[:number] or return
ieee_id_out(xml, params)
end

def ieee_id_params(node)
core = ieee_id_params_core(node)
amd = ieee_id_params_amd(node, core) || {}
core.merge(amd)
end

def ieee_id_params_core(node)
pub = ieee_id_pub(node)
ret = { number: node.attr("docnumber"),
part: node.attr("partnumber"),
year: ieee_id_year(node, initial: true),
redline: @doctype == "redline",
publisher: pub[0],
copublisher: pub[1..-1] }.compact
ret[:copublisher].empty? and ret.delete(:copublisher)
ret
end

def ieee_id_params_amd(node, core)
if a = node.attr("corrigendum-number")
{ corrigendum: { version: a,
year: ieee_id_year(node, initial: false) } }
elsif node.attr("amendment-number")
{ amendment: pubid_select(core).create(**core) }
end
end

def ieee_id_pub(node)
(node.attr("publisher") || default_publisher).split(/[;,]/)
.map(&:strip).map { |x| org_abbrev[x] || x }
end

def ieee_id_year(node, initial: false)
unless initial
y = node.attr("copyright-year") || node.attr("updated-date")
end
y ||= node.attr("published-date") || node.attr("copyright-year")
y&.sub(/-.*$/, "") || Date.today.year
end

def ieee_id_out(xml, params)
id = pubid_select(params).create(**params)
xml.docidentifier id.to_s, type: "IEEE"
end

def pubid_select(_params)
base_pubid
end

def base_pubid
Pubid::Ieee::Identifier
end

def default_publisher
"IEEE"
end
Expand All @@ -63,7 +126,9 @@ def metadata_subdoctype(node, xml)
end

def org_abbrev
{ "Institute of Electrical and Electronic Engineers" => "IEEE" }
{ "Institute of Electrical and Electronic Engineers" => "IEEE",
"International Organization for Standardization" => "ISO",
"International Electrotechnical Commission" => "IEC" }
end

def relaton_relations
Expand Down
2 changes: 1 addition & 1 deletion metanorma-ieee.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Gem::Specification.new do |spec|

spec.add_dependency "metanorma-standoc", "~> 2.8.0"
spec.add_dependency "mnconvert", "~> 1.20"
#spec.add_dependency "pubid-ieee", "~> 0.1.1"
spec.add_dependency "pubid-ieee"
#spec.add_dependency "pubid-iso", "~> 0.5.3"
#spec.add_dependency "relaton-iso", "~> 1.15.4"

Expand Down
210 changes: 111 additions & 99 deletions spec/metanorma/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
:copyright-year: 2000
:horizontal: true
:confirmed-date: 1000-12-01
:updated-date: 2023-12-01
:issued-date: 1001-12-01
:obsoleted-date: 1002-12-01
:feedback-ended-date: 1003-12-01
Expand Down Expand Up @@ -117,109 +118,120 @@
output = output.at("//xmlns:bibdata")
expect(xmlpp(output.to_xml))
.to be_equivalent_to xmlpp(<<~OUTPUT)
<bibdata type='standard'>
<title language='en' format='text/plain'>Document title</title>
<title type='provenance' language='en' format='application/xml'>Revision of ABC<br/>Incorporates BCD and EFG</title>
<title language='intro-en' format='text/plain'>Introduction</title>
<title language='main-en' format='text/plain'>Main Title -- Title</title>
<title language='part-en' format='text/plain'>Title Part</title>
<title language='intro-fr' format='text/plain'>Introduction Française</title>
<title language='main-fr' format='text/plain'>Titre Principal</title>
<title language='part-fr' format='text/plain'>Part du Titre</title>
<docidentifier type='IEEE'>1000</docidentifier>
<docidentifier type='IEEE' scope='PDF'>GHI</docidentifier>
<docidentifier type='IEEE' scope='print'>JKL</docidentifier>
<docidentifier type='ISBN' scope='PDF'>ABC</docidentifier>
<docidentifier type='ISBN' scope='print'>DEF</docidentifier>
<docnumber>1000</docnumber>
<date type='obsoleted'><on>1002-12-01</on></date>
<date type='confirmed'><on>1000-12-01</on></date>
<date type='issued'><on>1001-12-01</on></date>
<date type='feedback-ended'><on>1003-12-01</on></date>
<contributor>
<role type="author"/>
<bibdata type="standard">
<title language="en" format="text/plain">Document title</title>
<title type="provenance" language="en" format="application/xml">Revision of ABC<br/>Incorporates BCD and EFG</title>
<title language="intro-en" format="text/plain">Introduction</title>
<title language="main-en" format="text/plain">Main Title -- Title</title>
<title language="part-en" format="text/plain">Title Part</title>
<title language="intro-fr" format="text/plain">Introduction Française</title>
<title language="main-fr" format="text/plain">Titre Principal</title>
<title language="part-fr" format="text/plain">Part du Titre</title>
<docidentifier type="IEEE">IEEE Std 10001-2000/Cor C1-2000</docidentifier>
<docidentifier type="IEEE" scope="PDF">GHI</docidentifier>
<docidentifier type="IEEE" scope="print">JKL</docidentifier>
<docidentifier type="ISBN" scope="PDF">ABC</docidentifier>
<docidentifier type="ISBN" scope="print">DEF</docidentifier>
<docnumber>1000</docnumber>
<date type="obsoleted">
<on>1002-12-01</on>
</date>
<date type="confirmed">
<on>1000-12-01</on>
</date>
<date type="updated">
<on>2023-12-01</on>
</date>
<date type="issued">
<on>1001-12-01</on>
</date>
<date type="feedback-ended">
<on>1003-12-01</on>
</date>
<contributor>
<role type="author"/>
<organization>
<name>Institute of Electrical and Electronic Engineers</name>
<abbreviation>IEEE</abbreviation>
</organization>
</contributor>
<contributor>
<role type="publisher"/>
<organization>
<name>Institute of Electrical and Electronic Engineers</name>
<abbreviation>IEEE</abbreviation>
</organization>
</contributor>
<edition>2</edition>
<version>
<revision-date>2000-01-01</revision-date>
<draft>0.3.4</draft>
</version>
<language>en</language>
<script>Latn</script>
<status>
<stage>inactive</stage>
</status>
<copyright>
<from>2000</from>
<owner>
<organization>
<name>Institute of Electrical and Electronic Engineers</name>
<abbreviation>IEEE</abbreviation>
</organization>
</contributor>
<contributor>
<role type='publisher'/>
<organization>
<name>Institute of Electrical and Electronic Engineers</name>
<abbreviation>IEEE</abbreviation>
</organization>
</contributor>
<edition>2</edition>
<version>
<revision-date>2000-01-01</revision-date>
<draft>0.3.4</draft>
</version>
<language>en</language>
<script>Latn</script>
<status>
<stage>inactive</stage>
</status>
<copyright>
<from>2000</from>
<owner>
<organization>
<name>Institute of Electrical and Electronic Engineers</name>
<abbreviation>IEEE</abbreviation>
</organization>
</owner>
</copyright>
<relation type='merges'>
<bibitem>
<title>--</title>
<docidentifier>BCD</docidentifier>
</bibitem>
</relation>
<relation type='merges'>
<bibitem>
<title>--</title>
<docidentifier>EFG</docidentifier>
</bibitem>
</relation>
<relation type='updates'>
<bibitem>
<title>--</title>
<docidentifier>ABC</docidentifier>
</bibitem>
</relation>
<ext>
<doctype>recommended-practice</doctype>
<subdoctype>amendment</subdoctype>
<trial-use>true</trial-use>
<editorialgroup>
<society>SECRETARIAT</society>
<balloting-group type='entity'>SC</balloting-group>
<working-group>WG</working-group>
<working-group>WG1</working-group>
<committee>TC</committee>
<committee>TC1</committee>
</editorialgroup>
<ics>
<code>01.040.11</code>
<text>Health care technology (Vocabularies)</text>
</ics>
<ics>
<code>11.060.01</code>
<text>Dentistry in general</text>
</ics>
<structuredidentifier>
<docnumber>1000</docnumber>
<agency>IEEE</agency>
<class>recommended-practice</class>
<edition>2</edition>
<version>0.3.4</version>
<amendment>A1</amendment>
<corrigendum>C1</corrigendum>
<year>2000</year>
</structuredidentifier>
<program>HIJ</program>
</ext>
</bibdata>
</owner>
</copyright>
<relation type="merges">
<bibitem>
<title>--</title>
<docidentifier>BCD</docidentifier>
</bibitem>
</relation>
<relation type="merges">
<bibitem>
<title>--</title>
<docidentifier>EFG</docidentifier>
</bibitem>
</relation>
<relation type="updates">
<bibitem>
<title>--</title>
<docidentifier>ABC</docidentifier>
</bibitem>
</relation>
<ext>
<doctype>recommended-practice</doctype>
<subdoctype>amendment</subdoctype>
<trial-use>true</trial-use>
<editorialgroup>
<society>SECRETARIAT</society>
<balloting-group type="entity">SC</balloting-group>
<working-group>WG</working-group>
<working-group>WG1</working-group>
<committee>TC</committee>
<committee>TC1</committee>
</editorialgroup>
<ics>
<code>01.040.11</code>
<text>Health care technology (Vocabularies)</text>
</ics>
<ics>
<code>11.060.01</code>
<text>Dentistry in general</text>
</ics>
<structuredidentifier>
<docnumber>1000</docnumber>
<agency>IEEE</agency>
<class>recommended-practice</class>
<edition>2</edition>
<version>0.3.4</version>
<amendment>A1</amendment>
<corrigendum>C1</corrigendum>
<year>2000</year>
</structuredidentifier>
<program>HIJ</program>
</ext>
</bibdata>
OUTPUT
end

Expand Down
2 changes: 1 addition & 1 deletion spec/metanorma/refs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@
<bibitem id="ref2" type="standard">
<docidentifier type="ISO" primary="true">ISO 10642</docidentifier>
<docidentifier type="iso-reference">ISO 10642(E)</docidentifier>
<docidentifier type="URN">urn:iso:std:iso:10642:stage-60.60:ed-3</docidentifier>
<docidentifier type="URN">urn:iso:std:iso:10642:stage-90.20:ed-3</docidentifier>
<note type="Availability">
<p id="_">ISO publications are available from the ISO Central Secretariat
(http://www.iso.org/). ISO publications are also available in the United
Expand Down
Loading

0 comments on commit f70971e

Please sign in to comment.