mn-requirements 0.1.3.1 → 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: 8c6daaae7b2380a13eacd8c2abd7bc18795532e824c1901fcab476ed5fdd55a1
4
- data.tar.gz: e630016785ad74e041b6c5049d57d43807fe803d2593452b2c8ebaaf1e22f8d6
3
+ metadata.gz: d626036b19a5d6878dea7341d5d76a0dec9fdd298298517a0fc332b1045faf39
4
+ data.tar.gz: 49597201b5b2b0ac782ffb5edec441011f15922aa33b095bc3fd4ed2912a194e
5
5
  SHA512:
6
- metadata.gz: 31d37eeb8a10ca7722ace26d5f315557eb0251cf47f901f14526962492a43c85a6960ab08254ed3a3626070014e4ce46e3e27dbdc7cdbddf93ea0f446398e0f9
7
- data.tar.gz: 9ca8c5478b8f39309315988646fb2859f7c15d5b0a971324778fc135302b8d711fdf8e5267ecc2bee9cb3df7fef7851d47d7641cb62f2ddc604442be5bc44ea2
6
+ metadata.gz: 8d013a395a330b2a03580e4035ac1970e0606ff0c9fb20efb498e6a0dc923024d89eb86667186f53302a9c37c84f89765ed14f668db7a13995787119136d3d03
7
+ data.tar.gz: 1eee3937b804a2bed138fcd719fd80551ea9925eac4025269f98ca8d52e28cbc0bf5fb36c6d0fe22c87d7f0d98510e11c656ecd23d72dbea319d9b1cb74d4599
data/Rakefile CHANGED
@@ -1,8 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
- require "isodoc/gem_tasks"
4
3
 
5
- IsoDoc::GemTasks.install
6
4
  RSpec::Core::RakeTask.new(:spec)
7
5
 
8
6
  task default: :spec
@@ -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,32 +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
- d = d.replace("<ol class='steps'><li>#{d.children.to_xml}</li></ol>")
130
- .first
133
+ d = d.replace("<ol class='steps'><li#{id_attr(d)}>"\
134
+ "#{d.children.to_xml}</li></ol>").first
131
135
  node.xpath(ns("./component[@class = 'step']")).each do |f|
132
- f = f.replace("<li>#{f.children.to_xml}</li>").first
136
+ f = f.replace("<li#{id_attr(f)}>#{f.children.to_xml}</li>").first
133
137
  d << f
134
138
  end
135
139
  node
136
140
  end
137
141
 
138
142
  def recommendation_attributes1_component(node, out)
143
+ return out if node["class"] == "guidance"
144
+
139
145
  node = recommendation_steps(node)
140
- out << "<tr><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>"
141
148
  out
142
149
  end
143
150
 
144
151
  def recommendation_attr_keyvalue(node, key, value)
145
- tag = node.at(ns("./#{key}"))
146
- value = node.at(ns("./#{value}"))
147
- (tag && value && !%w(target
148
- indirect-dependency).include?(tag.text)) or
149
- 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
150
155
  [tag.text.capitalize, value.children]
151
156
  end
152
157
 
@@ -162,18 +167,26 @@ module Metanorma
162
167
  end
163
168
 
164
169
  def requirement_component_parse(node, out)
165
- return out if node["exclude"] == "true"
166
-
170
+ node["exclude"] == "true" and return out
167
171
  node.elements.size == 1 && node.first_element_child.name == "dl" and
168
172
  return reqt_dl(node.first_element_child, out)
169
173
  node.name == "component" and
170
174
  return recommendation_attributes1_component(node, out)
171
- out.add_child("<tr><td colspan='2'></td></tr>").first
175
+ out.add_child("<tr#{id_attr(node)}><td colspan='2'></td></tr>").first
172
176
  .at(ns(".//td")) <<
173
177
  (preserve_in_nested_table?(node) ? node : node.children)
174
178
  out
175
179
  end
176
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
+
177
190
  def reqt_dl(node, out)
178
191
  node.xpath(ns("./dt")).each do |dt|
179
192
  dd = dt.next_element
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  class Requirements
3
- VERSION = "0.1.3.1".freeze
3
+ VERSION = "0.1.4.1".freeze
4
4
  end
5
5
  end
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.3.1
4
+ version: 0.1.4.1
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-06 00:00:00.000000000 Z
11
+ date: 2022-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: isodoc-i18n