mn-requirements 0.3.5 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -3
- data/lib/metanorma/modspec/cleanup.rb +9 -0
- data/lib/metanorma/modspec/reqt_label.rb +0 -2
- data/lib/metanorma/modspec/table_cleanup.rb +18 -1
- data/lib/metanorma/modspec/validate.rb +1 -4
- data/lib/metanorma/requirements/version.rb +1 -1
- data/mn-requirements.gemspec +2 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2ba672c0841ee7afdaa25c8eb3cd423b7d2033555610508dd548a3a59ca131e
|
4
|
+
data.tar.gz: 595088ec2f1c850dc6654e97a4daa593a5bbca658797a3016f24335af9738bb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fba1dff3fce4185612b7edefa7518e1968b622b52aac5dc27f1373af2ee09990921e0cf0c009faca3a36f649ea600790b72bc887d0a5a90315f821c5449d9941
|
7
|
+
data.tar.gz: 7c38a1b25ee9aa29501437afb90947ba208038b571b63195529c8ac27afe82d7b9811b98f08605a07ed5b4130b9689b0fadcd038ddb6b3d25ef0e80e1bc7af99
|
data/Gemfile
CHANGED
@@ -72,6 +72,15 @@ module Metanorma
|
|
72
72
|
requirement_metadata_to_requirement(reqt)
|
73
73
|
requirement_subparts_to_blocks(reqt)
|
74
74
|
requirement_target_identifiers(reqt)
|
75
|
+
requirement_anchor_identifier(reqt)
|
76
|
+
end
|
77
|
+
|
78
|
+
def requirement_anchor_identifier(reqt)
|
79
|
+
Metanorma::Utils::guid_anchor?(reqt["id"]) or return
|
80
|
+
id = reqt.at("./identifier") or return
|
81
|
+
anchor = id.text.strip
|
82
|
+
anchor.empty? and return
|
83
|
+
reqt["id"] = Metanorma::Utils::to_ncname(anchor)
|
75
84
|
end
|
76
85
|
|
77
86
|
def requirement_target_identifiers(reqt)
|
@@ -11,7 +11,6 @@ module Metanorma
|
|
11
11
|
def recommendation_label(elem, type, xrefs)
|
12
12
|
@xrefs ||= xrefs.dup
|
13
13
|
init_lookups(elem.document)
|
14
|
-
|
15
14
|
label = elem.at(ns("./identifier"))&.text
|
16
15
|
if inject_crossreference_reqt?(elem, label)
|
17
16
|
recommendation_label_xref(elem, label, xrefs, type)
|
@@ -182,7 +181,6 @@ module Metanorma
|
|
182
181
|
|
183
182
|
def truncate_id_base_outside_reqts(docxml)
|
184
183
|
@modspecidentifierbase or return
|
185
|
-
|
186
184
|
(docxml.xpath(ns("//xref[@style = 'id']")) - docxml
|
187
185
|
.xpath(ns("//requirement//xref | //permission//xref | " \
|
188
186
|
"//recommendation//xref"))).each do |x|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "uri"
|
2
|
+
|
1
3
|
module Metanorma
|
2
4
|
class Requirements
|
3
5
|
class Modspec < Default
|
@@ -6,9 +8,25 @@ module Metanorma
|
|
6
8
|
requirement_table_consec_rows_cleanup(node, table)
|
7
9
|
node.ancestors("requirement, recommendation, permission").empty? and
|
8
10
|
truncate_id_base_in_reqt(table)
|
11
|
+
cell2link(table)
|
9
12
|
table
|
10
13
|
end
|
11
14
|
|
15
|
+
def cell2link(table)
|
16
|
+
table.xpath(ns(".//td")).each do |td|
|
17
|
+
td.elements.empty? or next
|
18
|
+
uri?(td.text.strip) or next
|
19
|
+
td.children = "<link target='#{td.text.strip}'/>"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def uri?(string)
|
24
|
+
uri = URI.parse(string)
|
25
|
+
%w(http https).include?(uri.scheme)
|
26
|
+
rescue URI::BadURIError, URI::InvalidURIError
|
27
|
+
false
|
28
|
+
end
|
29
|
+
|
12
30
|
def requirement_table_consec_rows_cleanup(_node, table)
|
13
31
|
table.xpath(ns("./tbody/tr")).each do |tr|
|
14
32
|
conflate_table_rows?(tr) or next
|
@@ -19,7 +37,6 @@ module Metanorma
|
|
19
37
|
def conflate_table_rows?(trow)
|
20
38
|
tr1 = trow.next or return
|
21
39
|
tr1.name == "tr" or return
|
22
|
-
|
23
40
|
th = trow.at(ns("./th"))&.text
|
24
41
|
th && th == tr1.at(ns("./th"))&.text
|
25
42
|
end
|
@@ -4,12 +4,10 @@ module Metanorma
|
|
4
4
|
class Requirements
|
5
5
|
class Modspec < Default
|
6
6
|
def validate(reqt, log)
|
7
|
-
@fatalerrors = []
|
8
7
|
@log ||= log
|
9
8
|
@ids ||= reqt_links(reqt.document)
|
10
9
|
reqt_cycles_validate
|
11
10
|
reqt_link_validate(reqt)
|
12
|
-
@fatalerrors
|
13
11
|
end
|
14
12
|
|
15
13
|
def nested_reqt?(reqt)
|
@@ -130,8 +128,7 @@ module Metanorma
|
|
130
128
|
|
131
129
|
if hash[:label][struct[:label]]
|
132
130
|
msg = "Modspec identifier #{struct[:label]} is used more than once"
|
133
|
-
@log.add("Requirements", reqt, msg)
|
134
|
-
@fatalerrors << msg
|
131
|
+
@log.add("Requirements", reqt, msg, severity: 0)
|
135
132
|
end
|
136
133
|
hash[:label][struct[:label]] = reqt["id"]
|
137
134
|
hash
|
data/mn-requirements.gemspec
CHANGED
@@ -27,12 +27,13 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
# precise version is on relaton-render
|
29
29
|
spec.add_dependency "isodoc-i18n", ">= 1.1.0"
|
30
|
+
spec.add_dependency "metanorma-utils", ">= 0.7.7"
|
30
31
|
|
31
32
|
spec.add_development_dependency "debug"
|
32
33
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
33
34
|
spec.add_development_dependency "guard", "~> 2.14"
|
34
35
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
35
|
-
spec.add_development_dependency "metanorma-standoc"
|
36
|
+
spec.add_development_dependency "metanorma-standoc", ">= 2.8.0"
|
36
37
|
spec.add_development_dependency "rake", "~> 13.0"
|
37
38
|
spec.add_development_dependency "rspec", "~> 3.6"
|
38
39
|
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.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: isodoc-i18n
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: metanorma-utils
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.7
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.7.7
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: debug
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +100,14 @@ dependencies:
|
|
86
100
|
requirements:
|
87
101
|
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: 2.8.0
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
110
|
+
version: 2.8.0
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rake
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -236,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
250
|
- !ruby/object:Gem::Version
|
237
251
|
version: '0'
|
238
252
|
requirements: []
|
239
|
-
rubygems_version: 3.3.
|
253
|
+
rubygems_version: 3.3.27
|
240
254
|
signing_key:
|
241
255
|
specification_version: 4
|
242
256
|
summary: Requirements processing and rendering according to different models
|