mn-requirements 0.1.4 → 0.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02c327aaa54455f58c577358ea68b452942aacad9ea3f2040d112c51514a7598
4
- data.tar.gz: ebb500af5264c2cdc45f378f4ffe66fef574e699e49c23a5b30b5a1a7fc7221e
3
+ metadata.gz: f30b7b9d9468a1d20886f1d84d6992071a95a2376a5f066bd9b455571e7e425d
4
+ data.tar.gz: 2888d62224f0110f4a23980042c34490f7f32889146304c56847f0d3b2d18ddc
5
5
  SHA512:
6
- metadata.gz: 384444b896b5d29b91f7412ee1fae853f52f833bce68fc5df047ae96921632f0c2984827726767324706279bb93d654cec485f64dc90c2fa5cd73f9da38dc05f
7
- data.tar.gz: 595eb3cafc35d0b30011edcfb905e2ba6ea23235662062d3507c22e949eb733f3beb04b2b8fff30fc4f5361bef7e837405e7678257f8861b058469b62a9caf39
6
+ metadata.gz: 289876376e7c00e2c120fb64f1c4be5ab19dba91db83036c6be974eadf8f6f0d291e6316219fad482f0d5df04dee9362afb15e6844ec84ae3029bbf1860242ff
7
+ data.tar.gz: a868912d83376103770d8602b56fa0643da967a2833e9d9df59fe72f6469d1c6901edb0ef879c78cd5eaa8577f1e6d053269a7ef8eec5c2d5d1fae604c03aab0
@@ -25,3 +25,4 @@ requirements:
25
25
  identifier: المعرف
26
26
  included_in: مدرج في
27
27
  statement: بيان
28
+ guidance: إرشاد
@@ -25,3 +25,5 @@ requirements:
25
25
  identifier: Kennung
26
26
  included_in: Enthalten in
27
27
  statement: Aussage
28
+ guidance: Anleitung
29
+
@@ -25,3 +25,5 @@ requirements:
25
25
  identifier: Identifier
26
26
  included_in: Included in
27
27
  statement: Statement
28
+ guidance: Guidance
29
+
@@ -25,3 +25,4 @@ requirements:
25
25
  identifier: Identificador
26
26
  included_in: Incluido en
27
27
  statement: Declaración
28
+ guidance: Orientación
@@ -25,3 +25,5 @@ requirements:
25
25
  identifier: Identifiant
26
26
  included_in: Inclus dans
27
27
  statement: Déclaration
28
+ guidance: Avis
29
+
@@ -25,3 +25,5 @@ requirements:
25
25
  identifier: Идентификатор
26
26
  included_in: Входит в
27
27
  statement: Утверждение
28
+ guidance: Руководство
29
+
@@ -25,3 +25,5 @@ requirements:
25
25
  identifier: 标识符
26
26
  included_in: 包含在
27
27
  statement: 陈述
28
+ guidance: 指导意见
29
+
@@ -15,7 +15,7 @@ module Metanorma
15
15
 
16
16
  def requirement_metadata_component_tags
17
17
  %w(test-purpose test-method test-method-type conditions part description
18
- reference step requirement permission recommendation)
18
+ reference step requirement permission recommendation guidance)
19
19
  end
20
20
 
21
21
  def requirement_metadata1(reqt, dlist, ins)
@@ -59,9 +59,9 @@ module Metanorma
59
59
  end
60
60
 
61
61
  def requirement_metadata_to_component(reqt)
62
- reqt.xpath(".//test-method | .//test-purpose | .//conditions | "\
63
- ".//part | .//test-method-type | .//step | .//reference")
64
- .each do |c|
62
+ xpath = requirement_metadata_component_tags -
63
+ %w(description requirement permission recommendation)
64
+ reqt.xpath(xpath.map { |x| ".//#{x}" }.join(" | ")).each do |c|
65
65
  c["class"] = c.name
66
66
  c.name = "component"
67
67
  end
@@ -6,7 +6,8 @@ module Metanorma
6
6
  class Modspec < Default
7
7
  def requirement_render1(node)
8
8
  init_lookups(node.document)
9
- requirement_table_cleanup(super)
9
+ ret = requirement_guidance_parse(node, super)
10
+ requirement_table_cleanup(ret)
10
11
  end
11
12
 
12
13
  def recommendation_base(node, _klass)
@@ -86,9 +87,8 @@ module Metanorma
86
87
  subj = node.at(ns("./subject"))&.children and
87
88
  head << [rec_subj(node), subj]
88
89
  node.xpath(ns("./classification[tag = 'target']/value")).each do |v|
89
- xref = recommendation_id(v.text) and head << [
90
- rec_target(node), xref
91
- ]
90
+ xref = recommendation_id(v.text) and
91
+ head << [rec_target(node), xref]
92
92
  end
93
93
  head += recommendation_backlinks(node)
94
94
  recommendation_attributes1_dependencies(node, head)
@@ -121,35 +121,37 @@ module Metanorma
121
121
  head
122
122
  end
123
123
 
124
+ def id_attr(node)
125
+ node["id"] ? " id='#{node['id']}'" : ""
126
+ end
127
+
124
128
  def recommendation_steps(node)
125
129
  node.elements.each { |e| recommendation_steps(e) }
126
130
  return node unless node.at(ns("./component[@class = 'step']"))
127
131
 
128
132
  d = node.at(ns("./component[@class = 'step']"))
129
- id = d["id"] ? " id='#{d['id']}'" : ""
130
- d = d.replace("<ol class='steps'><li#{id}>#{d.children.to_xml}</li></ol>")
131
- .first
133
+ d = d.replace("<ol class='steps'><li#{id_attr(d)}>"\
134
+ "#{d.children.to_xml}</li></ol>").first
132
135
  node.xpath(ns("./component[@class = 'step']")).each do |f|
133
- id = f["id"] ? " id='#{f['id']}'" : ""
134
- f = f.replace("<li#{id}>#{f.children.to_xml}</li>").first
136
+ f = f.replace("<li#{id_attr(f)}>#{f.children.to_xml}</li>").first
135
137
  d << f
136
138
  end
137
139
  node
138
140
  end
139
141
 
140
142
  def recommendation_attributes1_component(node, out)
143
+ return out if node["class"] == "guidance"
144
+
141
145
  node = recommendation_steps(node)
142
- id = node["id"] ? " id='#{node['id']}'" : ""
143
- out << "<tr#{id}><td>#{node['label']}</td><td>#{node.children}</td></tr>"
146
+ out << "<tr#{id_attr(node)}><td>#{node['label']}</td>"\
147
+ "<td>#{node.children}</td></tr>"
144
148
  out
145
149
  end
146
150
 
147
151
  def recommendation_attr_keyvalue(node, key, value)
148
- tag = node.at(ns("./#{key}"))
149
- value = node.at(ns("./#{value}"))
150
- (tag && value && !%w(target
151
- indirect-dependency).include?(tag.text)) or
152
- return nil
152
+ tag = node.at(ns("./#{key}")) or return nil
153
+ value = node.at(ns("./#{value}")) or return nil
154
+ !%w(target indirect-dependency).include?(tag.text) or return nil
153
155
  [tag.text.capitalize, value.children]
154
156
  end
155
157
 
@@ -165,19 +167,26 @@ module Metanorma
165
167
  end
166
168
 
167
169
  def requirement_component_parse(node, out)
168
- return out if node["exclude"] == "true"
169
-
170
+ node["exclude"] == "true" and return out
170
171
  node.elements.size == 1 && node.first_element_child.name == "dl" and
171
172
  return reqt_dl(node.first_element_child, out)
172
173
  node.name == "component" and
173
174
  return recommendation_attributes1_component(node, out)
174
- id = node["id"] ? " id='#{node['id']}'" : ""
175
- out.add_child("<tr#{id}><td colspan='2'></td></tr>").first
175
+ out.add_child("<tr#{id_attr(node)}><td colspan='2'></td></tr>").first
176
176
  .at(ns(".//td")) <<
177
177
  (preserve_in_nested_table?(node) ? node : node.children)
178
178
  out
179
179
  end
180
180
 
181
+ def requirement_guidance_parse(node, out)
182
+ ins = out.at(ns("./tbody"))
183
+ node.xpath(ns("./component[@class = 'guidance']")).each do |f|
184
+ ins << "<tr#{id_attr(f)}><td>#{@labels['modspec']['guidance']}</td>"\
185
+ "<td>#{f.children}</td></tr>"
186
+ end
187
+ out
188
+ end
189
+
181
190
  def reqt_dl(node, out)
182
191
  node.xpath(ns("./dt")).each do |dt|
183
192
  dd = dt.next_element
@@ -189,8 +198,6 @@ module Metanorma
189
198
  end
190
199
 
191
200
  def requirement_table_cleanup(table)
192
- return table unless table["type"] == "recommendclass"
193
-
194
201
  table.xpath(ns("./tbody/tr/td/table")).each do |t|
195
202
  x = t.at(ns("./thead/tr")) or next
196
203
  t.parent.parent.replace(x)
@@ -7,14 +7,14 @@ module Metanorma
7
7
 
8
8
  label = elem.at(ns("./identifier"))&.text
9
9
  if inject_crossreference_reqt?(elem, label)
10
- recommendation_label_xref(elem, label, xrefs)
10
+ recommendation_label_xref(elem, label, xrefs, type)
11
11
  else
12
12
  type = recommendation_class_label(elem)
13
13
  super
14
14
  end
15
15
  end
16
16
 
17
- def recommendation_label_xref(elem, label, xrefs)
17
+ def recommendation_label_xref(elem, label, xrefs, type)
18
18
  id = @reqtlabels[label]
19
19
  number = xrefs.anchor(id, :xref, false)
20
20
  number.nil? and return type
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  class Requirements
3
- VERSION = "0.1.4".freeze
3
+ VERSION = "0.1.5".freeze
4
4
  end
5
5
  end
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
32
32
  spec.add_development_dependency "guard", "~> 2.14"
33
33
  spec.add_development_dependency "guard-rspec", "~> 4.7"
34
+ spec.add_development_dependency "metanorma-standoc"
34
35
  spec.add_development_dependency "rake", "~> 13.0"
35
36
  spec.add_development_dependency "rspec", "~> 3.6"
36
37
  spec.add_development_dependency "rubocop", "~> 1.5.2"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mn-requirements
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-13 00:00:00.000000000 Z
11
+ date: 2022-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: isodoc-i18n
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '4.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: metanorma-standoc
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rake
99
113
  requirement: !ruby/object:Gem::Requirement