metanorma-utils 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/utils/version.rb +1 -1
- data/lib/utils/xml.rb +7 -0
- data/spec/xml_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd89605d15a5973a46c4fbc9b88c024191e6a809e4255f34db32d57bab198cc3
|
4
|
+
data.tar.gz: 167f7c09e8b6347c0f5990656775cba5ec5cdc05a2b715690451e3c02f80fb65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1baca64c93f1598bd4f6285ac62c912a519a36c9a9ee08dfe883fe5af0cd721983cc3be513d2dd3d8329ff9efbcc940f0f207ed40791e93556a477ac230c6bb0
|
7
|
+
data.tar.gz: f4a13c5846b93d6fa7262736a5e177e809ddf72340713c890a7bcddad8d2ba2526e71ee5eff0dd3900e10a6c45b0f00cf7944a30ab1343feef34d3679428e795
|
data/lib/utils/version.rb
CHANGED
data/lib/utils/xml.rb
CHANGED
@@ -54,6 +54,13 @@ module Metanorma
|
|
54
54
|
.gsub("—", "\u0097")
|
55
55
|
end
|
56
56
|
end
|
57
|
+
|
58
|
+
def ns(xpath)
|
59
|
+
xpath.gsub(%r{/([a-zA-z])}, "/xmlns:\\1")
|
60
|
+
.gsub(%r{::([a-zA-z])}, "::xmlns:\\1")
|
61
|
+
.gsub(%r{\[([a-zA-z][a-z0-9A-Z@/-]* ?=)}, "[xmlns:\\1")
|
62
|
+
.gsub(%r{\[([a-zA-z][a-z0-9A-Z@/-]*[/\[\]])}, "[xmlns:\\1")
|
63
|
+
end
|
57
64
|
end
|
58
65
|
end
|
59
66
|
end
|
data/spec/xml_spec.rb
CHANGED
@@ -66,4 +66,10 @@ RSpec.describe Metanorma::Utils do
|
|
66
66
|
<div class="paragraph"><p>A</p></div><div class="paragraph"><p>B</p></div>
|
67
67
|
OUTPUT
|
68
68
|
end
|
69
|
+
|
70
|
+
it "applies namespace to xpath" do
|
71
|
+
expect(Metanorma::Utils.ns("//ab/Bb/c1-d[ancestor::c][d = 'x'][e/f]"))
|
72
|
+
.to be_equivalent_to("//xmlns:ab/xmlns:Bb/xmlns:c1-d[ancestor::xmlns:c]"\
|
73
|
+
"[xmlns:d = 'x'][xmlns:e/xmlns:f]")
|
74
|
+
end
|
69
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|