mn-requirements 0.5.2 → 0.5.5

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: 45bfa485d0ed37004f7be357184feaf264d3f1511c81d4c238fe76efbcb55160
4
- data.tar.gz: b33033cc464bdd80ff7b504d19484ae2e14ff676d286cb3482f74747fd910201
3
+ metadata.gz: 58cdfecc41db4908d909bbea682bbc79c298c16841018e58fb76c0d92d8183fc
4
+ data.tar.gz: a9a57c6fa6ae5fec7f6f14b7b7d3d7948fed1f4da9b4df71df9f9a8e4bff0fa7
5
5
  SHA512:
6
- metadata.gz: 81250e40928eb52e237ce4804509a2b4d2278eac1e2238b8b32c2badb16fe29bdecb8b59c76a2c7e441ec5a839a5a51bdbc92a2ecfe5e07d79e895085f5ea4b6
7
- data.tar.gz: 0b55d47abceb725787f91e85615a01b54e957a713c1ba9aba79278956c0ad8d1f43990e7e1f3ab311f7ec21007b48eb472ea51ef25bc750541609be9179eeaf2
6
+ metadata.gz: a3e95d50c33122bda50a4535d62646131a8a42a270a9c4a8ad1e5604471d4ae3b31cdac269989557a659c4bff7a5ce603a698d51c7abe7e8a60b943df79bd17a
7
+ data.tar.gz: a407485c15d7cef0e0e0ffe0f94bfa8c88ce567f900865836f6d26788875239f5fc7210e5fa33f9f44b8a416cdecc2781db5e4b34e5683409bc0c9cb85b41b66
data/README.adoc CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  image:https://img.shields.io/gem/v/mn-requirements.svg["Gem Version", link="https://rubygems.org/gems/mn-requirements"]
4
4
  image:https://github.com/metanorma/mn-requirements/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/mn-requirements/actions?workflow=rake"]
5
- image:https://codeclimate.com/github/metanorma/mn-requirements/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/mn-requirements"]
5
+ // image:https://codeclimate.com/github/metanorma/mn-requirements/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/mn-requirements"]
6
6
  image:https://img.shields.io/github/issues-pr-raw/metanorma/mn-requirements.svg["Pull Requests", link="https://github.com/metanorma/mn-requirements/pulls"]
7
7
  image:https://img.shields.io/github/commits-since/metanorma/mn-requirements/latest.svg["Commits since latest",link="https://github.com/metanorma/mn-requirements/releases"]
8
8
 
@@ -57,8 +57,10 @@ module Metanorma
57
57
  end
58
58
 
59
59
  def reqt_attrs(node, attrs)
60
+ anchor = node&.id
60
61
  attr_code(attrs.merge(
61
- id: Metanorma::Utils.anchor_or_uuid(node),
62
+ id: "_#{UUIDTools::UUID.random_create}",
63
+ anchor: anchor && !anchor.empty? ? anchor : nil,
62
64
  unnumbered: node.option?("unnumbered") ? "true" : nil,
63
65
  number: node.attr("number"),
64
66
  subsequence: node.attr("subsequence"),
@@ -76,11 +76,21 @@ module Metanorma
76
76
  end
77
77
 
78
78
  def requirement_anchor_identifier(reqt)
79
- Metanorma::Utils::guid_anchor?(reqt["id"]) or return
79
+ (!reqt["anchor"] || Metanorma::Utils::guid_anchor?(reqt["anchor"])) or
80
+ return
80
81
  id = reqt.at("./identifier") or return
81
- anchor = id.text.strip
82
+ anchor = identifier2text(id)
82
83
  anchor.empty? and return
83
- reqt["id"] = Metanorma::Utils::to_ncname(anchor)
84
+ reqt["anchor"] = anchor
85
+ end
86
+
87
+ # allow case where identifier contains a link, which has not yet been
88
+ # converted to its target text
89
+ def identifier2text(ident)
90
+ m = ident.dup
91
+ l = m.at("./link[normalize-space(.)='']") and
92
+ l.replace(l["target"])
93
+ m.text.strip
84
94
  end
85
95
 
86
96
  def requirement_target_identifiers(reqt)
@@ -105,7 +115,8 @@ module Metanorma
105
115
  def requirement_metadata_to_requirement(reqt)
106
116
  xpath = requirement_metadata_requirement_tags
107
117
  reqt.xpath(xpath.map { |x| "./#{x}" }.join(" | ")).each do |c|
108
- c["id"] = Metanorma::Utils::anchor_or_uuid
118
+ # c["id"] = Metanorma::Utils::anchor_or_uuid
119
+ c["id"] = "_#{UUIDTools::UUID.random_create}"
109
120
  c["model"] = reqt["model"] # all requirements must have a model
110
121
  requirement_metadata_to_requirement1(c)
111
122
  end
@@ -142,22 +153,29 @@ module Metanorma
142
153
 
143
154
  def add_misccontainer_anchor_aliases(xmldoc)
144
155
  m = add_misc_container(xmldoc)
145
- x = ".//table[@id = '_misccontainer_anchor_aliases']/tbody"
156
+ x = ".//table[@anchor='_misccontainer_anchor_aliases']/tbody"
146
157
  unless ins = m.at(x)
147
- m << "<table id = '_misccontainer_anchor_aliases'><tbody/></table>"
158
+ m << "<table anchor='_misccontainer_anchor_aliases' id='_#{UUIDTools::UUID.random_create}'><tbody/></table>"
148
159
  ins = m.at(x)
149
160
  end
150
161
  ins
151
162
  end
152
163
 
153
164
  def requirement_anchor_aliases(reqt)
165
+ ids = requirement_anchor_aliases_extract(reqt) or return
166
+ table = add_misccontainer_anchor_aliases(reqt.document)
167
+ alias_id = reqt["anchor"] or return
168
+ table << "<tr><th>#{alias_id}</th>#{ids.join}</tr>"
169
+ end
170
+
171
+ def requirement_anchor_aliases_extract(reqt)
154
172
  x = reqt.xpath("./identifier")
155
173
  x.empty? and return
156
- table = add_misccontainer_anchor_aliases(reqt.document)
157
- ids = x.each_with_object([]) do |i, m|
174
+ x.each_with_object([]) do |i, m|
158
175
  m << "<td>#{i.text}</td>"
176
+ alias_id = ::Metanorma::Utils.to_ncname(i.text)
177
+ alias_id != i.text and m << "<td>#{alias_id}</td>"
159
178
  end
160
- table << "<tr><th>#{reqt['id']}</th>#{ids.join}</tr>"
161
179
  end
162
180
 
163
181
  def requirement_identifier_cleanup(reqt)
@@ -71,7 +71,6 @@ module Metanorma
71
71
 
72
72
  def reqt_to_conformance(reqt, reqtclass, confclass)
73
73
  return unless type2validate(reqt) == reqtclass
74
-
75
74
  r = @ids[:id][reqt["id"]]
76
75
  (r[:label] && @ids[:class][confclass]&.any? do |x|
77
76
  x[:subject].include?(r[:label])
@@ -143,7 +142,7 @@ module Metanorma
143
142
  end
144
143
 
145
144
  def reqt_links_struct(reqt)
146
- { id: reqt["id"], elem: reqt, label: reqt.at("./identifier")&.text,
145
+ { id: reqt["anchor"], elem: reqt, label: reqt.at("./identifier")&.text,
147
146
  subject: classif_tag(reqt, "target"),
148
147
  child: reqt.xpath("./requirement | ./recommendation | ./permission")
149
148
  .map { |r| r.at("./identifier")&.text },
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  class Requirements
3
- VERSION = "0.5.2".freeze
3
+ VERSION = "0.5.5".freeze
4
4
  end
5
5
  end
@@ -42,5 +42,5 @@ spec.add_development_dependency "rubocop-performance"
42
42
  spec.add_development_dependency "sassc-embedded", "~> 1"
43
43
  spec.add_development_dependency "simplecov", "~> 0.15"
44
44
  spec.add_development_dependency "timecop", "~> 0.9"
45
- spec.add_development_dependency "xml-c14n"
45
+ spec.add_development_dependency "canon"
46
46
  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.5.2
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-25 00:00:00.000000000 Z
11
+ date: 2025-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: isodoc-i18n
@@ -221,7 +221,7 @@ dependencies:
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0.9'
223
223
  - !ruby/object:Gem::Dependency
224
- name: xml-c14n
224
+ name: canon
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - ">="