xml-registry 0.7.0 → 0.7.1
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/xml-registry.rb +55 -55
- data.tar.gz.sig +0 -0
- metadata +30 -30
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 667bdd8cb557aaca4ea00df166d7bf0f8542a0c6d2faedeabc14c26dba83d6a0
|
|
4
|
+
data.tar.gz: 8a1ecbca36cee8fe8bf5e31612265f4dc384642d4c53a4d042bf324114b1a8a7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3f73f6a72768069389584be2e733f2ad85494088bd4ad95ff98f6f86fd183e0f38152777971e1633fc3e59ec4e8e3fcbae9a76161039b8c48ff9be1d3c3f2c1
|
|
7
|
+
data.tar.gz: fb077f993036fe580363abeb6e00300e6fee9989ec18b928f95c2e5d390c39e5df1e6fc100fcbb527d8045fba896f7dd1b9130fe29d982ee1e419a06275dc6f0
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/xml-registry.rb
CHANGED
|
@@ -8,13 +8,13 @@ require 'simple-config'
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
module NumberCheck
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
refine String do
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
def is_number?
|
|
15
15
|
self.to_i.to_s == self
|
|
16
16
|
end
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -22,9 +22,9 @@ class XMLRegistry
|
|
|
22
22
|
using NumberCheck
|
|
23
23
|
|
|
24
24
|
attr_reader :doc
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
def initialize(template = '<root></root>', debug: false)
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
@debug = debug
|
|
29
29
|
super()
|
|
30
30
|
@template, _ = RXFHelper.read(template)
|
|
@@ -49,21 +49,21 @@ class XMLRegistry
|
|
|
49
49
|
# if the 1st element doesn't exist create it
|
|
50
50
|
e = path.split('/',2).first
|
|
51
51
|
@doc.root.add_element Rexle::Element.new(e) unless @doc.root.element e
|
|
52
|
-
create_path = find_path(path)
|
|
52
|
+
create_path = find_path(path)
|
|
53
53
|
|
|
54
54
|
if not create_path.empty? then
|
|
55
55
|
parent_path = (path.split('/') - create_path.reverse).join('/')
|
|
56
56
|
key_builder(parent_path, create_path)
|
|
57
57
|
end
|
|
58
|
-
|
|
59
|
-
add_value(path, value)
|
|
58
|
+
|
|
59
|
+
add_value(path, value)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def []=(path, val)
|
|
63
63
|
s = path.split('/').map {|x| x[0].is_number? ? x.prepend('x') : x}.join '/'
|
|
64
64
|
self.set_key(s, val)
|
|
65
65
|
end
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
# get the key value by passing the path
|
|
68
68
|
# example: get_key('app/gtd/funday').value #=> 'friday'
|
|
69
69
|
#
|
|
@@ -73,13 +73,13 @@ class XMLRegistry
|
|
|
73
73
|
|
|
74
74
|
key = @doc.root.element path
|
|
75
75
|
raise ("xml-registry: key %s not found" % path) unless key
|
|
76
|
-
|
|
77
|
-
key.instance_eval {
|
|
78
|
-
@path = path
|
|
76
|
+
|
|
77
|
+
key.instance_eval {
|
|
78
|
+
@path = path
|
|
79
79
|
|
|
80
80
|
def to_h(e)
|
|
81
81
|
|
|
82
|
-
v = if e.has_elements? then
|
|
82
|
+
v = if e.has_elements? then
|
|
83
83
|
e.elements.inject({}) do |r, x|
|
|
84
84
|
r.merge to_h(x)
|
|
85
85
|
end
|
|
@@ -88,24 +88,24 @@ class XMLRegistry
|
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
{e.name => v}
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def to_config()
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def to_config()
|
|
94
94
|
SimpleConfig.new(to_h(self), attributes: {key: @path})
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def to_kvx()
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def to_kvx()
|
|
98
98
|
Kvx.new(to_h(self), attributes: {key: @path})
|
|
99
|
-
end
|
|
100
|
-
|
|
99
|
+
end
|
|
100
|
+
|
|
101
101
|
def to_os()
|
|
102
102
|
OpenStruct.new(to_h(self).first.last)
|
|
103
103
|
end
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
key
|
|
107
107
|
end
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
# get several keys using a Rexle XPath
|
|
110
110
|
# example: get_keys('//funday') #=> [<funday>tuesday</funday>,<funday>friday</funday>]
|
|
111
111
|
#
|
|
@@ -113,7 +113,7 @@ class XMLRegistry
|
|
|
113
113
|
#
|
|
114
114
|
def get_keys(path)
|
|
115
115
|
@doc.root.xpath(path)
|
|
116
|
-
end
|
|
116
|
+
end
|
|
117
117
|
|
|
118
118
|
def [](path)
|
|
119
119
|
s = path.split('/').map {|x| x.is_number? ? x.prepend('x') : x}.join '/'
|
|
@@ -125,7 +125,7 @@ class XMLRegistry
|
|
|
125
125
|
#
|
|
126
126
|
#
|
|
127
127
|
def delete_key(path)
|
|
128
|
-
@doc.root.delete path
|
|
128
|
+
@doc.root.delete path
|
|
129
129
|
end
|
|
130
130
|
|
|
131
131
|
# return the registry as an XML document
|
|
@@ -136,15 +136,15 @@ class XMLRegistry
|
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
alias :display_xml :to_xml
|
|
139
|
-
|
|
139
|
+
|
|
140
140
|
def xml(options={})
|
|
141
141
|
@doc.root.xml options
|
|
142
|
-
end
|
|
142
|
+
end
|
|
143
143
|
|
|
144
144
|
# load a new registry xml document replacing the existing registry
|
|
145
145
|
#
|
|
146
|
-
def load_xml(s='')
|
|
147
|
-
@doc = Rexle.new(RXFHelper.read(s)[0])
|
|
146
|
+
def load_xml(s='')
|
|
147
|
+
@doc = Rexle.new(RXFHelper.read(s)[0].force_encoding("UTF-8"))
|
|
148
148
|
self
|
|
149
149
|
end
|
|
150
150
|
|
|
@@ -168,40 +168,40 @@ class XMLRegistry
|
|
|
168
168
|
#"pin-no"="4321"
|
|
169
169
|
#REG
|
|
170
170
|
#
|
|
171
|
-
#reg = XMLRegistry.new
|
|
172
|
-
#reg.import s
|
|
171
|
+
#reg = XMLRegistry.new
|
|
172
|
+
#reg.import s
|
|
173
173
|
#
|
|
174
|
-
def import(s)
|
|
175
|
-
|
|
174
|
+
def import(s)
|
|
175
|
+
|
|
176
176
|
r = RXFHelper.read(s)
|
|
177
177
|
reg_buffer = r.first
|
|
178
178
|
raise "read file error" unless reg_buffer
|
|
179
179
|
|
|
180
180
|
if reg_buffer.strip[/^\[/] then
|
|
181
181
|
|
|
182
|
-
reg_items = reg_buffer.gsub(/\n/,'').split(/(?=\[.[^\]]+\])/).map do |x|
|
|
182
|
+
reg_items = reg_buffer.gsub(/\n/,'').split(/(?=\[.[^\]]+\])/).map do |x|
|
|
183
183
|
[x[/^\[(.[^\]]+)\]/,1], Hash[*($').scan(/"([^"]+)"="(.[^"]*)"/).flatten]]
|
|
184
184
|
end
|
|
185
|
-
|
|
186
|
-
elsif reg_buffer.strip.lines.grep(/^\s+\w/).any?
|
|
185
|
+
|
|
186
|
+
elsif reg_buffer.strip.lines.grep(/^\s+\w/).any?
|
|
187
187
|
|
|
188
188
|
puts 'hierachical import' if @debug
|
|
189
189
|
doc = LineTree.new(reg_buffer).to_doc
|
|
190
|
-
|
|
190
|
+
|
|
191
191
|
reg_items = []
|
|
192
|
-
|
|
192
|
+
|
|
193
193
|
doc.root.each_recursive do |e|
|
|
194
|
-
|
|
194
|
+
|
|
195
195
|
puts 'e: ' + e.inspect if @debug
|
|
196
196
|
if e.is_a?(Rexle::Element) and e.children.length < 2 then
|
|
197
|
-
|
|
197
|
+
|
|
198
198
|
reg_items << [e.backtrack.to_xpath.sub(/^root\//,'')\
|
|
199
199
|
.sub(/\/[^\/]+$/,''), {e.name => e.text }]
|
|
200
|
-
|
|
200
|
+
|
|
201
201
|
end
|
|
202
|
-
|
|
203
|
-
end
|
|
204
|
-
|
|
202
|
+
|
|
203
|
+
end
|
|
204
|
+
|
|
205
205
|
else
|
|
206
206
|
|
|
207
207
|
reg_items = reg_buffer.split(/(?=^[^:]+$)/).map do |raw_section|
|
|
@@ -211,21 +211,21 @@ class XMLRegistry
|
|
|
211
211
|
path = lines.shift.rstrip
|
|
212
212
|
[path, Hash[lines.map{|x| x.split(':',2).map(&:strip)}]]
|
|
213
213
|
end
|
|
214
|
-
|
|
214
|
+
|
|
215
215
|
reg_items.compact!
|
|
216
|
-
|
|
216
|
+
|
|
217
217
|
end
|
|
218
218
|
|
|
219
219
|
puts 'reg_items: ' + reg_items.inspect if @debug
|
|
220
220
|
reg_items.each do |path, items|
|
|
221
221
|
items.each {|k,value| self.set_key("%s/%s" % [path,k], value)}
|
|
222
222
|
end
|
|
223
|
-
|
|
223
|
+
|
|
224
224
|
:import
|
|
225
225
|
end
|
|
226
226
|
|
|
227
|
-
# Export the registry to file if the filepath is specified. Regardless,
|
|
228
|
-
# the registry will be returned as a string in the registry
|
|
227
|
+
# Export the registry to file if the filepath is specified. Regardless,
|
|
228
|
+
# the registry will be returned as a string in the registry
|
|
229
229
|
# export format.
|
|
230
230
|
#
|
|
231
231
|
def export(s=nil)
|
|
@@ -267,21 +267,21 @@ class XMLRegistry
|
|
|
267
267
|
|
|
268
268
|
def print_scan(node, parent=[])
|
|
269
269
|
out = []
|
|
270
|
-
parent << node.name
|
|
270
|
+
parent << node.name
|
|
271
271
|
items = []
|
|
272
272
|
|
|
273
273
|
node.elements.each do |e|
|
|
274
274
|
if e.has_elements? then
|
|
275
|
-
out << print_scan(e, parent.clone)
|
|
275
|
+
out << print_scan(e, parent.clone)
|
|
276
276
|
else
|
|
277
277
|
items << [e.name, e.text]
|
|
278
278
|
end
|
|
279
|
-
end
|
|
279
|
+
end
|
|
280
280
|
if parent.length > 1 and items.length > 0 then
|
|
281
|
-
out << "[%s]\n%s\n" % [parent[1..-1].join("/"),
|
|
282
|
-
items.map {|x| "\"%s\"=\"%s\"" % x}.join("\n")]
|
|
281
|
+
out << "[%s]\n%s\n" % [parent[1..-1].join("/"),
|
|
282
|
+
items.map {|x| "\"%s\"=\"%s\"" % x}.join("\n")]
|
|
283
283
|
end
|
|
284
|
-
out
|
|
284
|
+
out
|
|
285
285
|
end
|
|
286
286
|
|
|
287
287
|
end
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: xml-registry
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Robertson
|
|
@@ -11,31 +11,31 @@ cert_chain:
|
|
|
11
11
|
- |
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
|
13
13
|
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwMjE2MTgwNzIwWhcN
|
|
15
|
+
MjMwMjE2MTgwNzIwWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9am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dwt6vzQdR
|
|
29
|
+
kdwTQwbS83bzwtgMva+34LZYD1Rukfo8TlKi8jspSd6vMnU1KNicsiMphKgjPFZ/
|
|
30
|
+
IQOF/zOcQevEmPeis9/I8q8krX4515jaQAy/B1umRAAaBZ5HaG6RP//RfgFXiP7N
|
|
31
|
+
O+o7cMXuG5mtSBZiDsWFJbnm/jxYxsu2/KP0nptKacfGYuJ1AhbzbXcIuBDQPPds
|
|
32
|
+
iLOmzi+BcvbB5CS3COOQ3/ZfxXlpeq+SXZMd0tMuSXAi+iMQxR+L/siByoDXKzPw
|
|
33
|
+
7ipnNUzjevQz/sMYRKQIGsIn6AkJc34WtKQMxFKXvgeHlfkEinrviwxHm4dSh3Hi
|
|
34
|
+
ye5NuslP3b2U0cAcVuw3vXAufZEezb0TGxNQUFio52UGCFfj371cxj4u7VNnB55q
|
|
35
|
+
qQ7EyBaXak1o/nkw5pybDKSbUjVOvQpzjla62Xe4FzHerw4+UYRKyq6OjeDckoJD
|
|
36
|
+
qwMwsoB0WJMRTqSZ4g1aEmfr
|
|
37
37
|
-----END CERTIFICATE-----
|
|
38
|
-
date:
|
|
38
|
+
date: 2022-02-16 00:00:00.000000000 Z
|
|
39
39
|
dependencies:
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: simple-config
|
|
@@ -43,22 +43,22 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '0.
|
|
46
|
+
version: '0.7'
|
|
47
47
|
- - ">="
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
|
-
version: 0.
|
|
49
|
+
version: 0.7.2
|
|
50
50
|
type: :runtime
|
|
51
51
|
prerelease: false
|
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
53
53
|
requirements:
|
|
54
54
|
- - "~>"
|
|
55
55
|
- !ruby/object:Gem::Version
|
|
56
|
-
version: '0.
|
|
56
|
+
version: '0.7'
|
|
57
57
|
- - ">="
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: 0.
|
|
59
|
+
version: 0.7.2
|
|
60
60
|
description:
|
|
61
|
-
email:
|
|
61
|
+
email: digital.robertson@gmail.com
|
|
62
62
|
executables: []
|
|
63
63
|
extensions: []
|
|
64
64
|
extra_rdoc_files: []
|
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
83
83
|
- !ruby/object:Gem::Version
|
|
84
84
|
version: '0'
|
|
85
85
|
requirements: []
|
|
86
|
-
rubygems_version: 3.
|
|
86
|
+
rubygems_version: 3.2.22
|
|
87
87
|
signing_key:
|
|
88
88
|
specification_version: 4
|
|
89
89
|
summary: The XML registry can be used to store or retrieve app settings etc. in an
|
metadata.gz.sig
CHANGED
|
Binary file
|