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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33414d3ac6b85f24c09e8dd8555f26e776b5c1ddd67aaf0a15217e0b9466e324
4
- data.tar.gz: '098df5f8bba64b14bfef2ceead84bc5cc230f4601a33329092f382fcc9bce7d2'
3
+ metadata.gz: a2ba672c0841ee7afdaa25c8eb3cd423b7d2033555610508dd548a3a59ca131e
4
+ data.tar.gz: 595088ec2f1c850dc6654e97a4daa593a5bbca658797a3016f24335af9738bb5
5
5
  SHA512:
6
- metadata.gz: b7fe62355d49df8647545cdacff491d6d7aa4696f8f680ef468839930b5c12614706f80e8adf99fa4ab2f48b42a03adf4a282acdafc23d52ceabe4d2e8093fa5
7
- data.tar.gz: 1a7babef01ab00b531200e100b8feaf99f4a817dc14e7c9e7c0c200525443d71d0a8fa0dcee17dfdced1197104067c4e254b707f1f69d04581cd5a32dd01395a
6
+ metadata.gz: fba1dff3fce4185612b7edefa7518e1968b622b52aac5dc27f1373af2ee09990921e0cf0c009faca3a36f649ea600790b72bc887d0a5a90315f821c5449d9941
7
+ data.tar.gz: 7c38a1b25ee9aa29501437afb90947ba208038b571b63195529c8ac27afe82d7b9811b98f08605a07ed5b4130b9689b0fadcd038ddb6b3d25ef0e80e1bc7af99
data/Gemfile CHANGED
@@ -6,6 +6,4 @@ git_source(:github) { |repo| "https://github.com/#{repo}" }
6
6
 
7
7
  gemspec
8
8
 
9
- if File.exist? "Gemfile.devel"
10
- eval File.read("Gemfile.devel"), nil, "Gemfile.devel" # rubocop:disable Security/Eval
11
- end
9
+ eval_gemfile("Gemfile.devel") rescue nil
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  class Requirements
3
- VERSION = "0.3.5".freeze
3
+ VERSION = "0.3.7".freeze
4
4
  end
5
5
  end
@@ -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.5
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: 2023-11-18 00:00:00.000000000 Z
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: '0'
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: '0'
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.26
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