mn-requirements 0.3.7 → 0.4.0

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: a2ba672c0841ee7afdaa25c8eb3cd423b7d2033555610508dd548a3a59ca131e
4
- data.tar.gz: 595088ec2f1c850dc6654e97a4daa593a5bbca658797a3016f24335af9738bb5
3
+ metadata.gz: 01bee8304acc8f185870fb5f6960e2a7393d096acc9cdf9ea4e87918baf297e0
4
+ data.tar.gz: 11412398e35579a0e3022250101a3629409b7f784da526d152de6a1a69c00e33
5
5
  SHA512:
6
- metadata.gz: fba1dff3fce4185612b7edefa7518e1968b622b52aac5dc27f1373af2ee09990921e0cf0c009faca3a36f649ea600790b72bc887d0a5a90315f821c5449d9941
7
- data.tar.gz: 7c38a1b25ee9aa29501437afb90947ba208038b571b63195529c8ac27afe82d7b9811b98f08605a07ed5b4130b9689b0fadcd038ddb6b3d25ef0e80e1bc7af99
6
+ metadata.gz: e9d3f86cd517967140e1febd7c7852d55dd3b1b4b8c74d1159c335d42717fc51c960218caf5631d9f135701b8f812b830685ad5224ac9dbc4249ee24a0cfcda9
7
+ data.tar.gz: 7cc6c088de6e4ea5ae8050844ccf0d9cf49369bf63b89ffa4892316539d57d5ae89074fe184191a4e78e940d59efef1abc09e3bd88805125ff734aeb7f11f735
@@ -104,17 +104,22 @@ module Metanorma
104
104
  end
105
105
 
106
106
  def requirement_metadata1_set_insert(reqt, ins)
107
- return ins if ins
108
-
107
+ ins and return ins
109
108
  reqt.children.first.previous = " "
110
109
  reqt.children.first
111
110
  end
112
111
 
112
+ def unwrap_para(ddef)
113
+ e = ddef.elements and e.size == 1 && e.first.name == "p" and
114
+ ddef = e.first
115
+ ddef.children.to_xml
116
+ end
117
+
113
118
  def reqt_dl_to_classif(ins, reqt, dlist)
114
119
  if a = reqt.at("./classification[last()]") then ins = a end
115
120
  dlist.xpath("./dt[text()='classification']").each do |e|
116
- val = e.at("./following::dd/p") || e.at("./following::dd")
117
- req_classif_parse(val.children.to_xml).each do |r|
121
+ val = e.at("./following::dd").text.strip
122
+ req_classif_parse(val).each do |r|
118
123
  ins.next = "<classification><tag>#{r[0]}</tag>" \
119
124
  "<value>#{r[1]}</value></classification>"
120
125
  ins = ins.next
@@ -136,9 +141,9 @@ module Metanorma
136
141
  end
137
142
 
138
143
  def reqt_dl_to_classif2(term, ins)
139
- val = term.at("./following::dd/p") || e.at("./following::dd")
144
+ val = unwrap_para(term.at("./following::dd"))
140
145
  ins.next = "<classification><tag>#{term.text}</tag>" \
141
- "<value>#{val.children.to_xml}</value></classification>"
146
+ "<value>#{val}</value></classification>"
142
147
  ins.next
143
148
  end
144
149
  end
@@ -92,7 +92,7 @@ module Metanorma
92
92
  requirement_elems(node, ex)
93
93
  wrap_in_para(node, ex)
94
94
  end
95
- end.join("\n")
95
+ end
96
96
  end
97
97
 
98
98
  def validate(_reqt, _log)
@@ -54,8 +54,7 @@ module Metanorma
54
54
  def gather_consec_table_rows(trow, hdr)
55
55
  ret = []
56
56
  trow.xpath("./following-sibling::xmlns:tr").each do |r|
57
- break unless r.at(ns("./th[text() = '#{hdr}']"))
58
-
57
+ r.at(ns("./th[text() = '#{hdr}']")) or break
59
58
  ret << r.remove.at(ns("./td")).children.to_xml
60
59
  end
61
60
  ret
@@ -78,8 +77,7 @@ module Metanorma
78
77
  end
79
78
 
80
79
  def strip_id_base(elem, base)
81
- return elem.children if base.nil?
82
-
80
+ base.nil? and return elem.children
83
81
  elem.children.to_xml.delete_prefix(base)
84
82
  end
85
83
 
@@ -98,7 +96,8 @@ module Metanorma
98
96
  def expand_xrefs_in_reqt(table)
99
97
  table.xpath(ns(".//xref[not(@style)][normalize-space(text()) = '']"))
100
98
  .each do |x|
101
- x << @xrefs.anchor(x["target"], :xref, false)
99
+ ref = @xrefs.anchor(x["target"], :xref, false) or next
100
+ x << ref
102
101
  end
103
102
  end
104
103
 
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  class Requirements
3
- VERSION = "0.3.7".freeze
3
+ VERSION = "0.4.0".freeze
4
4
  end
5
5
  end
@@ -27,7 +27,7 @@ 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
+ spec.add_dependency "metanorma-utils", ">= 0.10.0"
31
31
 
32
32
  spec.add_development_dependency "debug"
33
33
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
@@ -40,4 +40,5 @@ Gem::Specification.new do |spec|
40
40
  spec.add_development_dependency "sassc", "2.4.0"
41
41
  spec.add_development_dependency "simplecov", "~> 0.15"
42
42
  spec.add_development_dependency "timecop", "~> 0.9"
43
+ spec.add_development_dependency "xml-c14n"
43
44
  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.3.7
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-03 00:00:00.000000000 Z
11
+ date: 2024-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: isodoc-i18n
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.7.7
33
+ version: 0.10.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.7.7
40
+ version: 0.10.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: debug
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0.9'
195
+ - !ruby/object:Gem::Dependency
196
+ name: xml-c14n
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
195
209
  description: 'Requirements processing and rendering according to different models
196
210
 
197
211
  '