mn-requirements 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metanorma/modspec/cleanup.rb +43 -18
- data/lib/metanorma/requirements/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e3ca9ac70068ad84544ecd69a028aa771675c790affd49f35812b2a8677ffdc
|
4
|
+
data.tar.gz: e47bf092f613aa369275f154a9937f5d32c3b88f9cfddf8492a95268c6d3d76c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
6
|
-
|
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
|
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
|
25
|
-
next unless requirement_metadata_component_tags.include?
|
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
|
-
|
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
|
-
|
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
|
-
|
72
|
-
|
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)
|
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
|
+
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-
|
11
|
+
date: 2022-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: isodoc-i18n
|