mn-requirements 0.1.4 → 0.1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02c327aaa54455f58c577358ea68b452942aacad9ea3f2040d112c51514a7598
4
- data.tar.gz: ebb500af5264c2cdc45f378f4ffe66fef574e699e49c23a5b30b5a1a7fc7221e
3
+ metadata.gz: d626036b19a5d6878dea7341d5d76a0dec9fdd298298517a0fc332b1045faf39
4
+ data.tar.gz: 49597201b5b2b0ac782ffb5edec441011f15922aa33b095bc3fd4ed2912a194e
5
5
  SHA512:
6
- metadata.gz: 384444b896b5d29b91f7412ee1fae853f52f833bce68fc5df047ae96921632f0c2984827726767324706279bb93d654cec485f64dc90c2fa5cd73f9da38dc05f
7
- data.tar.gz: 595eb3cafc35d0b30011edcfb905e2ba6ea23235662062d3507c22e949eb733f3beb04b2b8fff30fc4f5361bef7e837405e7678257f8861b058469b62a9caf39
6
+ metadata.gz: 8d013a395a330b2a03580e4035ac1970e0606ff0c9fb20efb498e6a0dc923024d89eb86667186f53302a9c37c84f89765ed14f668db7a13995787119136d3d03
7
+ data.tar.gz: 1eee3937b804a2bed138fcd719fd80551ea9925eac4025269f98ca8d52e28cbc0bf5fb36c6d0fe22c87d7f0d98510e11c656ecd23d72dbea319d9b1cb74d4599
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  class Requirements
3
- VERSION = "0.1.4".freeze
3
+ VERSION = "0.1.4.1".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.