metanorma-iso 2.4.6 → 2.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,12 +12,18 @@ module Metanorma
12
12
  def metadata_ext(node, xml)
13
13
  super
14
14
  structured_id(node, xml)
15
+ metadata_stage(node, xml)
16
+ @amd && a = node.attr("updates-document-type") and
17
+ xml.updates_document_type a
18
+ end
19
+
20
+ def metadata_stage(node, xml)
15
21
  id = iso_id_default(iso_id_params(node))
16
22
  id.stage and
17
23
  xml.stagename metadata_stagename(id)&.strip,
18
24
  **attr_code(abbreviation: id.typed_stage_abbrev&.strip)
19
- @amd && a = node.attr("updates-document-type") and
20
- xml.updates_document_type a
25
+ rescue Pubid::Core::Errors::HarmonizedStageCodeInvalidError,
26
+ Pubid::Core::Errors::TypeStageParseError
21
27
  end
22
28
 
23
29
  def metadata_stagename(id)
@@ -92,8 +98,17 @@ module Metanorma
92
98
  xml.status do |s|
93
99
  s.stage stage, **attr_code(abbreviation: abbrev)
94
100
  s.substage substage
95
- node.attr("iteration") && (s.iteration node.attr("iteration"))
101
+ i = node.attr("iteration") and s.iteration i
96
102
  end
103
+ rescue Pubid::Core::Errors::HarmonizedStageCodeInvalidError,
104
+ Pubid::Core::Errors::TypeStageParseError
105
+ report_illegal_stage(stage, substage)
106
+ end
107
+
108
+ def report_illegal_stage(stage, substage)
109
+ err = "Illegal document stage: #{stage}.#{substage}"
110
+ @log.add("Document Attributes", nil, err)
111
+ warn err
97
112
  end
98
113
 
99
114
  def metadata_committee(node, xml)
@@ -10,41 +10,6 @@ require "pubid-iso"
10
10
  module Metanorma
11
11
  module ISO
12
12
  class Converter < Standoc::Converter
13
- STAGE_ABBRS = {
14
- "00": "PWI",
15
- "10": "NP",
16
- "20": "WD",
17
- "30": "CD",
18
- "40": "DIS",
19
- "50": "FDIS",
20
- "60": "IS",
21
- "90": "(Review)",
22
- "95": "(Withdrawal)",
23
- }.freeze
24
-
25
- STAGE_NAMES = {
26
- "00": "Preliminary work item",
27
- "10": "New work item proposal",
28
- "20": "Working draft",
29
- "30": "Committee draft",
30
- "40": "Draft",
31
- "50": "Final draft",
32
- "60": "International standard",
33
- "90": "Review",
34
- "95": "Withdrawal",
35
- }.freeze
36
-
37
- def stage_abbr(stage, substage, _doctype)
38
- return nil if stage.to_i > 60
39
-
40
- ret = STAGE_ABBRS[stage.to_sym]
41
- ret = "PRF" if stage == "60" && substage == "00"
42
- ret = nil if stage == "60" && substage != "00"
43
- ret = "AWI" if stage == "10" && substage == "99"
44
- ret = "AWI" if stage == "20" && substage == "00"
45
- ret
46
- end
47
-
48
13
  def metadata_id(node, xml)
49
14
  if id = node.attr("docidentifier")
50
15
  xml.docidentifier id, **attr_code(type: "ISO")
@@ -103,23 +68,19 @@ module Metanorma
103
68
 
104
69
  def iso_id_params_add(node)
105
70
  stage = iso_id_stage(node)
106
-
107
71
  ret = { number: node.attr("amendment-number") ||
108
72
  node.attr("corrigendum-number"),
109
73
  year: iso_id_year(node),
110
74
  iteration: node.attr("iteration") }.compact
111
- stage and ret[:stage] = stage
112
- ret[:stage] == "60.00" and ret[:stage] = :PRF
75
+ if stage
76
+ ret[:stage] = stage
77
+ ret[:stage] == "60.00" and ret[:stage] = :PRF
78
+ end
113
79
  ret
114
80
  end
115
81
 
116
82
  def iso_id_stage(node)
117
- stage = stage_abbr(get_stage(node), get_substage(node),
118
- doctype(node))
119
- harmonised = "#{get_stage(node)}.#{get_substage(node)}"
120
- harmonised = nil unless /^\d\d\.\d\d/.match?(harmonised)
121
- { abbr: stage&.to_sym, harmonized_code: harmonised }
122
- harmonised || stage&.to_sym
83
+ "#{get_stage(node)}.#{get_substage(node)}"
123
84
  end
124
85
 
125
86
  def iso_id_year(node)
@@ -195,7 +156,7 @@ module Metanorma
195
156
  def structured_id(node, xml)
196
157
  return unless node.attr("docnumber")
197
158
 
198
- part, subpart = node&.attr("partnumber")&.split(/-/)
159
+ part, subpart = node&.attr("partnumber")&.split("-")
199
160
  xml.structuredidentifier do |i|
200
161
  i.project_number(node.attr("docnumber"), **attr_code(
201
162
  part: part, subpart: subpart,
@@ -132,20 +132,6 @@ module Metanorma
132
132
  "#{script} is not a recognised script")
133
133
  end
134
134
 
135
- def stage_validate(xmldoc)
136
- stage = xmldoc&.at("//bibdata/status/stage")&.text
137
- %w(00 10 20 30 40 50 60 90 95).include? stage or
138
- @log.add("Document Attributes", nil,
139
- "#{stage} is not a recognised stage")
140
- end
141
-
142
- def substage_validate(xmldoc)
143
- substage = xmldoc&.at("//bibdata/status/substage")&.text or return
144
- %w(00 20 60 90 92 93 98 99).include? substage or
145
- @log.add("Document Attributes", nil,
146
- "#{substage} is not a recognised substage")
147
- end
148
-
149
135
  def iteration_validate(xmldoc)
150
136
  iteration = xmldoc&.at("//bibdata/status/iteration")&.text or return
151
137
  /^\d+/.match(iteration) or
@@ -156,8 +142,6 @@ module Metanorma
156
142
  def bibdata_validate(doc)
157
143
  doctype_validate(doc)
158
144
  script_validate(doc)
159
- stage_validate(doc)
160
- substage_validate(doc)
161
145
  iteration_validate(doc)
162
146
  end
163
147
 
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.4.6".freeze
3
+ VERSION = "2.4.8".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.6
4
+ version: 2.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-19 00:00:00.000000000 Z
11
+ date: 2023-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc