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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06b8911f4c03cb97f4a358a3d5bfeb3931f49bf205a06ff486f1897cf4413ab7
4
- data.tar.gz: a1d15ab7db12270bec314abff49b6cd16e6150c13142e6ac338df19f46c5e2a1
3
+ metadata.gz: fd89605d15a5973a46c4fbc9b88c024191e6a809e4255f34db32d57bab198cc3
4
+ data.tar.gz: 167f7c09e8b6347c0f5990656775cba5ec5cdc05a2b715690451e3c02f80fb65
5
5
  SHA512:
6
- metadata.gz: 0b69767957d3f54acd8f85b023d876097561f83e6c606051dbde0889ff7e37cf368839424576164a7fe81698eef0417cfe2a6ea019ee04f591e8e10295c00d7f
7
- data.tar.gz: c3203ed0411f37c048c558777d51955866e507c79454d686a80f4d9ab392e11f6f5332e03541d5d34cba77f779ad01275102a52127f517f4dd8eb06e626e501b
6
+ metadata.gz: 1baca64c93f1598bd4f6285ac62c912a519a36c9a9ee08dfe883fe5af0cd721983cc3be513d2dd3d8329ff9efbcc940f0f207ed40791e93556a477ac230c6bb0
7
+ data.tar.gz: f4a13c5846b93d6fa7262736a5e177e809ddf72340713c890a7bcddad8d2ba2526e71ee5eff0dd3900e10a6c45b0f00cf7944a30ab1343feef34d3679428e795
data/lib/utils/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Utils
3
- VERSION = "1.3.0".freeze
3
+ VERSION = "1.3.1".freeze
4
4
  end
5
5
  end
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.0
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-16 00:00:00.000000000 Z
11
+ date: 2022-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor