mn-requirements 0.5.10 → 0.5.11

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: e446f52e8a55fc21a99df29ce798a2a7ea84d987d07aceb23d64b5c1c77be7e3
4
- data.tar.gz: f1142726f55149df21ff127df360b656cd14b9c376f7d13844ba04451239b5b1
3
+ metadata.gz: bec40fff7706ba8af4ebbc7e39c0a9110cd5ffc96730cace20586ae6beeb93c2
4
+ data.tar.gz: 7c3d55500016be83b0cbb85e2f85dfcbc416208a3d2a48ec8fa527ecd54f4607
5
5
  SHA512:
6
- metadata.gz: 2617c33c902c0caddd8ac9f47f4b9fd497ce04482ef53195d50e13776e3f2a165ec1c13f3891efb67cfdbfc11b891dcff9a598894bf344d6f97a3b538bc171b8
7
- data.tar.gz: dba9959bd392290b870c539410f8d50b55203308d96b3ec786c1c6a9532bcbc7e650f89a614390425f2fe21d52853109dfd63f792729de68aab92b20345ab684
6
+ metadata.gz: 307c6f011e3b445bdb3cd2a3340286d4012dde7da55bad0473ec15924cc47dbac6661a330e06d4946344e03c9cc40571a59419566fde258aecd0f23f2656ad76
7
+ data.tar.gz: 6dadbc51c3ca8304eb295d14175b805709310bf13b7fdf4ddfafa4febac2dd54f3271d4b6eb735b28dc00896c03021d4cd0b6fdee074ad7cde0de071f2a48518
@@ -69,31 +69,27 @@ module Metanorma
69
69
  r.at(ns("./th"))&.text&.strip == hdr or break
70
70
  td = r.remove.at(ns("./td"))
71
71
  id = td["id"] ? "<bookmark id='#{td['id']}'/>" : ""
72
- ret << id + to_xml(td.children).strip
72
+ ret << (id + to_xml(td.children).strip)
73
73
  end
74
74
  ret
75
75
  end
76
76
 
77
77
  def requirement_table_nested_cleanup(node, out, table)
78
78
  rows = []
79
- table.xpath(ns("./tbody/tr/td/*/fmt-provision/table"))
80
- .sort_by do |t|
81
- [t.at(ns(".//fmt-name//span[@class = 'fmt-element-name']"))&.text,
82
- t.at(ns(".//fmt-name//semx[@element = 'autonum']"))&.text&.to_i]
83
- end.each do |t|
84
- x = t.at(ns("./thead/tr")) or next
85
- x.at(ns("./th")).children =
86
- requirement_table_nested_cleanup_hdr(node)
87
- f = x.at(ns("./td/fmt-name")) and
88
- f.parent.children = to_xml(f.children).strip
89
- td = x.at(ns("./td"))
90
- td["id"] = t["original-id"] || t["id"]
91
- if desc = t.at(ns("./tbody/tr/td/semx[@element = 'description']"))
92
- p = desc.at(ns("./p")) and p.replace(p.children)
93
- td << " #{to_xml(desc)}"
94
- end
95
- rows << x
79
+ requirement_table_nested_cleanup_sort(table).each do |t|
80
+ x = t.at(ns("./thead/tr")) or next
81
+ x.at(ns("./th")).children =
82
+ requirement_table_nested_cleanup_hdr(node)
83
+ f = x.at(ns("./td/fmt-name")) and
84
+ f.parent.children = to_xml(f.children).strip
85
+ td = x.at(ns("./td"))
86
+ td["id"] = t["original-id"] || t["id"]
87
+ if desc = t.at(ns("./tbody/tr/td/semx[@element = 'description']"))
88
+ p = desc.at(ns("./p")) and p.replace(p.children)
89
+ td << " #{to_xml(desc)}"
96
90
  end
91
+ rows << x
92
+ end
97
93
  table.xpath(ns("./tbody/tr[./td/*/fmt-provision/table]"))
98
94
  .each_with_index do |t, i|
99
95
  t.replace(rows[i])
@@ -102,6 +98,25 @@ module Metanorma
102
98
  table
103
99
  end
104
100
 
101
+ def requirement_table_nested_cleanup_sort(table)
102
+ table.xpath(ns("./tbody/tr/td/*/fmt-provision/table"))
103
+ .sort_by do |t|
104
+ [t.at(ns(".//fmt-name//span[@class = 'fmt-element-name']"))&.text,
105
+ *autonum_sort_key(
106
+ t.at(ns(".//fmt-name//semx[@element = 'autonum']"))&.text,
107
+ )]
108
+ end
109
+ end
110
+
111
+ # allow autonum to be sorted numerically, but break up non-numeric text
112
+ # to allow for autonum values like "1a", "1b", etc. and delimited autonum
113
+ # values like "1.1", "1.2", etc.
114
+ def autonum_sort_key(text)
115
+ text ||= ""
116
+ nums = text.scan(/\d+/).map(&:to_i)
117
+ [nums, text]
118
+ end
119
+
105
120
  def requirement_table_nested_cleanup_hdr(node)
106
121
  label = "provision"
107
122
  node["type"] == "conformanceclass" and label = "conformancetest"
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  class Requirements
3
- VERSION = "0.5.10".freeze
3
+ VERSION = "0.5.11".freeze
4
4
  end
5
5
  end
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
38
38
  spec.add_development_dependency "guard", "~> 2.14"
39
39
  spec.add_development_dependency "guard-rspec", "~> 4.7"
40
- spec.add_development_dependency "metanorma-standoc", ">= 3.4.1"
40
+ spec.add_development_dependency "metanorma-standoc", ">= 3.4.2"
41
41
  spec.add_development_dependency "rake", "~> 13.0"
42
42
  spec.add_development_dependency "rspec", "~> 3.6"
43
43
  spec.add_development_dependency "rubocop", "~> 1"
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.10
4
+ version: 0.5.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-04-27 00:00:00.000000000 Z
11
+ date: 2026-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: isodoc-i18n
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: 3.4.1
159
+ version: 3.4.2
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
- version: 3.4.1
166
+ version: 3.4.2
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: rake
169
169
  requirement: !ruby/object:Gem::Requirement