mn-requirements 0.1.5 → 0.1.6

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: f30b7b9d9468a1d20886f1d84d6992071a95a2376a5f066bd9b455571e7e425d
4
- data.tar.gz: 2888d62224f0110f4a23980042c34490f7f32889146304c56847f0d3b2d18ddc
3
+ metadata.gz: 9e3ca9ac70068ad84544ecd69a028aa771675c790affd49f35812b2a8677ffdc
4
+ data.tar.gz: e47bf092f613aa369275f154a9937f5d32c3b88f9cfddf8492a95268c6d3d76c
5
5
  SHA512:
6
- metadata.gz: 289876376e7c00e2c120fb64f1c4be5ab19dba91db83036c6be974eadf8f6f0d291e6316219fad482f0d5df04dee9362afb15e6844ec84ae3029bbf1860242ff
7
- data.tar.gz: a868912d83376103770d8602b56fa0643da967a2833e9d9df59fe72f6469d1c6901edb0ef879c78cd5eaa8577f1e6d053269a7ef8eec5c2d5d1fae604c03aab0
6
+ metadata.gz: aa55fdb9e247e0c5c22daa72a3ce16e5a953af35bf128cd02782e1a24b261acc0a3bc5ac8eb19db04164b0375d5c6a3d62455eac0eacbb9c1be7e14546e220a1
7
+ data.tar.gz: 58eba09e93a17784d3cf4540e0c90a6dbf8c7e44a364038d3926183acdb842d061e9375b1e07c9e28955eb768e21d4556517fc3a4caeafb6cc70187614b77db7
@@ -1,28 +1,41 @@
1
1
  module Metanorma
2
2
  class Requirements
3
3
  class Modspec < Default
4
+ REQT_TYPE_NORM = {
5
+ requirement: "general",
6
+ recommendation: "general",
7
+ permission: "general",
8
+ requirements_class: "class",
9
+ requirement_class: "class",
10
+ recommendation_class: "class",
11
+ permission_class: "class",
12
+ conformance_test: "verification",
13
+ conformance_class: "conformanceclass",
14
+ abstract_test: "abstracttest",
15
+ }.freeze
16
+
4
17
  def requirement_type_cleanup(reqt)
5
- reqt["type"] = case reqt["type"]
6
- when "requirement", "recommendation", "permission"
7
- "general"
8
- when "requirements_class" then "class"
9
- when "conformance_test" then "verification"
10
- when "conformance_class" then "conformanceclass"
11
- when "abstract_test" then "abstracttest"
12
- else reqt["type"]
13
- end
18
+ ret = REQT_TYPE_NORM[reqt["type"]&.to_sym] or return
19
+ reqt["type"] = ret
14
20
  end
15
21
 
16
22
  def requirement_metadata_component_tags
17
23
  %w(test-purpose test-method test-method-type conditions part description
18
- reference step requirement permission recommendation guidance)
24
+ reference step guidance) +
25
+ requirement_metadata_requirement_tags
26
+ end
27
+
28
+ def requirement_metadata_requirement_tags
29
+ %w(conformance-test conformance-class abstract-test requirement-class
30
+ recommendation-class permission-class requirement permission
31
+ recommendation)
19
32
  end
20
33
 
21
34
  def requirement_metadata1(reqt, dlist, ins)
22
35
  ins1 = super
23
36
  dlist.xpath("./dt").each do |e|
24
- tag = e&.text&.gsub(/ /, "-")&.downcase
25
- next unless requirement_metadata_component_tags.include? tag
37
+ tag = e.text&.gsub(/ /, "-")&.downcase
38
+ next unless requirement_metadata_component_tags.include?(tag)
26
39
 
27
40
  ins1.next = requirement_metadata1_component(e, tag)
28
41
  ins1 = ins1.next
@@ -36,9 +49,9 @@ module Metanorma
36
49
  requirement_metadata1(val, d, d)
37
50
  d.remove
38
51
  end
39
- if REQS.include?(term.text) && !val.text.empty?
52
+ requirement_metadata_requirement_tags.include?(term.text) &&
53
+ !val.text.empty? and
40
54
  val.children = "<identifier>#{val.text.strip}</identifier>"
41
- end
42
55
  val
43
56
  end
44
57
 
@@ -59,8 +72,8 @@ module Metanorma
59
72
  end
60
73
 
61
74
  def requirement_metadata_to_component(reqt)
62
- xpath = requirement_metadata_component_tags -
63
- %w(description requirement permission recommendation)
75
+ xpath = requirement_metadata_component_tags - %w(description) -
76
+ requirement_metadata_requirement_tags
64
77
  reqt.xpath(xpath.map { |x| ".//#{x}" }.join(" | ")).each do |c|
65
78
  c["class"] = c.name
66
79
  c.name = "component"
@@ -68,13 +81,25 @@ module Metanorma
68
81
  end
69
82
 
70
83
  def requirement_metadata_to_requirement(reqt)
71
- reqt.xpath("./requirement | ./permission | ./recommendation")
72
- .each do |c|
84
+ xpath = requirement_metadata_requirement_tags
85
+ reqt.xpath(xpath.map { |x| "./#{x}" }.join(" | ")).each do |c|
73
86
  c["id"] = Metanorma::Utils::anchor_or_uuid
74
87
  c["model"] = reqt["model"] # all requirements must have a model
88
+ requirement_metadata_to_requirement1(c)
75
89
  end
76
90
  end
77
91
 
92
+ def requirement_metadata_to_requirement1(reqt)
93
+ reqt["type"] = reqt.name.sub(/-/, "_")
94
+ reqt.name =
95
+ case reqt.name
96
+ when "recommendation-class", "recommendation" then "recommendation"
97
+ when "permission-class", "permission" then "permission"
98
+ else "requirement"
99
+ end
100
+ requirement_type_cleanup(reqt)
101
+ end
102
+
78
103
  def requirement_subparts_to_blocks(reqt)
79
104
  reqt.xpath(".//component | .//description").each do |c|
80
105
  next if %w(p ol ul dl table component description)
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  class Requirements
3
- VERSION = "0.1.5".freeze
3
+ VERSION = "0.1.6".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.5
4
+ version: 0.1.6
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-22 00:00:00.000000000 Z
11
+ date: 2022-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: isodoc-i18n