kvx 0.9.1 → 0.9.6
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.tar.gz.sig +0 -0
- data/lib/kvx.rb +91 -13
- metadata +25 -26
- 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: 9ddaef947e49b210dbee31fcf56ec84e3644681c6a790c9ec80cb9fe314cd9d8
|
4
|
+
data.tar.gz: 56fae3981651c158701eb34023477125fbe7dd0ee8421d49d0e15174f550aae4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd452778a00be2a43d078b61ffdbb2616c1b631a0a1806c6027453c739b755ac90c7cd7e804ee6fe0839dae01d083d02abbffb7900e54fa6b7ba6159abee3248
|
7
|
+
data.tar.gz: 27c99e9368bc2dfd7cd49527eed157a31a9e2a2bd3d8caaf357fb12c1c5ccf898dc8913a963fdb2594eacf660054403302bc9425b54dfc46e06b588565ed9dd7
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/kvx.rb
CHANGED
@@ -36,7 +36,7 @@ class Kvx
|
|
36
36
|
|
37
37
|
def initialize(x=nil, attributes: {}, debug: false)
|
38
38
|
|
39
|
-
@header =
|
39
|
+
@header = attributes.any?
|
40
40
|
@identifier = 'kvx'
|
41
41
|
@summary = {}
|
42
42
|
@ignore_blank_lines ||= false
|
@@ -76,12 +76,23 @@ class Kvx
|
|
76
76
|
FileX.write filename, self.to_s
|
77
77
|
end
|
78
78
|
|
79
|
-
|
79
|
+
# flattening is helpful when passing the Hash object to
|
80
|
+
# RecordX as a new record
|
81
|
+
#
|
82
|
+
def to_h(flatten: false)
|
80
83
|
|
81
84
|
if @summary.empty? then
|
85
|
+
|
82
86
|
deep_clone @body
|
87
|
+
|
83
88
|
else
|
84
|
-
|
89
|
+
|
90
|
+
if flatten then
|
91
|
+
@summary.merge @body
|
92
|
+
else
|
93
|
+
{summary: deep_clone(@summary), body: deep_clone(@body)}
|
94
|
+
end
|
95
|
+
|
85
96
|
end
|
86
97
|
|
87
98
|
end
|
@@ -104,13 +115,24 @@ class Kvx
|
|
104
115
|
end
|
105
116
|
|
106
117
|
summary = [:summary, {}, *summary]
|
107
|
-
|
118
|
+
|
119
|
+
# -- use the nested description Hash object if there are multiple lines
|
120
|
+
h = {}
|
121
|
+
|
122
|
+
@body.each do |key, value|
|
123
|
+
|
124
|
+
h[key] = value.is_a?(String) ? value : value[:description]
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
body = [:body, {}, *make_xml(h)]
|
108
129
|
[self.class.to_s.downcase, @attributes, '', summary, body]
|
109
130
|
|
110
131
|
end
|
111
132
|
|
133
|
+
puts 'a: ' + a.inspect if @debug
|
112
134
|
doc = Rexle.new a
|
113
|
-
doc.instructions = @instructions
|
135
|
+
doc.instructions = @instructions || []
|
114
136
|
doc
|
115
137
|
|
116
138
|
end
|
@@ -126,11 +148,34 @@ class Kvx
|
|
126
148
|
header = '<?' + @identifier
|
127
149
|
header += attr
|
128
150
|
header += "?>\n"
|
129
|
-
|
130
|
-
|
151
|
+
|
152
|
+
if @summary and @summary.any? then
|
153
|
+
header += scan_to_s @summary
|
154
|
+
header += "\n----------------------------------\n\n"
|
155
|
+
end
|
156
|
+
|
131
157
|
end
|
158
|
+
|
159
|
+
# -- use the nested description Hash object if there are multiple lines
|
160
|
+
h = {}
|
161
|
+
|
162
|
+
@body.each do |key, value|
|
163
|
+
|
164
|
+
h[key] = if value.is_a?(String) then
|
165
|
+
|
166
|
+
if value.lines.length < 2 then
|
167
|
+
value
|
168
|
+
else
|
169
|
+
"\n" + value.lines.map {|x| ' ' + x }.join
|
170
|
+
end
|
171
|
+
|
172
|
+
else
|
173
|
+
"\n" + value[:description].lines.map {|x| ' ' + x }.join
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
132
177
|
|
133
|
-
header + scan_to_s(
|
178
|
+
header + scan_to_s(h)
|
134
179
|
|
135
180
|
end
|
136
181
|
|
@@ -140,6 +185,13 @@ class Kvx
|
|
140
185
|
doc.xml(options)
|
141
186
|
|
142
187
|
end
|
188
|
+
|
189
|
+
# used by RecordX to update a KVX record
|
190
|
+
# id is unnecssary because there is only 1 record mapped to RecordX
|
191
|
+
#
|
192
|
+
def update(id=nil, hpair={})
|
193
|
+
@body.merge! hpair
|
194
|
+
end
|
143
195
|
|
144
196
|
private
|
145
197
|
|
@@ -192,7 +244,10 @@ class Kvx
|
|
192
244
|
def make_xml(h)
|
193
245
|
|
194
246
|
puts 'inside make_xml: ' + h.inspect if @debug
|
195
|
-
|
247
|
+
h2 = h.clone
|
248
|
+
h2.each {|key,value| value.delete :items if value.is_a?(Hash) }
|
249
|
+
|
250
|
+
RexleBuilder.new(h2, debug: false).to_a[3..-1]
|
196
251
|
end
|
197
252
|
|
198
253
|
def parse_string(s)
|
@@ -240,7 +295,7 @@ class Kvx
|
|
240
295
|
@attributes.merge! attr
|
241
296
|
@header = true
|
242
297
|
body, summary = a.join.strip.split(/^----*$/).reverse
|
243
|
-
@summary = scan_to_h summary
|
298
|
+
@summary = scan_to_h summary if summary
|
244
299
|
|
245
300
|
body
|
246
301
|
else
|
@@ -271,22 +326,45 @@ class Kvx
|
|
271
326
|
|
272
327
|
|
273
328
|
def scan_to_h(txt)
|
329
|
+
|
330
|
+
txt.gsub!(/^\w+:(?=$)/,'\0 ')
|
331
|
+
puts 'txt:' + txt.inspect if @debug
|
332
|
+
|
333
|
+
# auto indent any multiline values which aren't already indented
|
334
|
+
|
335
|
+
indent = ''
|
336
|
+
|
337
|
+
lines = txt.gsub(/^-+$/m,'').lines.map do |line|
|
338
|
+
|
339
|
+
if not line[/^ *\w+:|^ +/] then
|
340
|
+
indent + ' ' + line
|
341
|
+
else
|
342
|
+
indent = line[/^ +/] || ''
|
343
|
+
line
|
344
|
+
end
|
345
|
+
|
346
|
+
end
|
274
347
|
|
275
348
|
puts ('inside scan_to_h').info if @debug
|
276
|
-
raw_a = LineTree.new(
|
277
|
-
|
349
|
+
raw_a = LineTree.new(lines.join.gsub(/(^-*$)|(^ *#.*)/,'').strip,
|
350
|
+
ignore_blank_lines: @ignore_blank_lines).to_a
|
278
351
|
puts ('raw_a: ' + raw_a.inspect).debug if @debug
|
279
352
|
|
280
353
|
# if there are any orphan lines which aren't nested underneath a
|
281
354
|
# label, they will be fixed using the following statement
|
282
355
|
|
283
356
|
a = raw_a.chunk {|x| x[0][/^[^:]+:|.*/]}.inject([]) do |r,y|
|
357
|
+
|
358
|
+
puts 'r: ' + r.inspect if @debug
|
359
|
+
|
284
360
|
if r.last and !y.first[/[^:]+:/] then
|
285
361
|
r.last << y.last[-1]
|
286
362
|
else
|
287
363
|
r << y.last[-1]
|
288
364
|
end
|
365
|
+
|
289
366
|
r
|
367
|
+
|
290
368
|
end
|
291
369
|
|
292
370
|
@body = a.inject({}) do |r, line|
|
@@ -326,7 +404,7 @@ class Kvx
|
|
326
404
|
|
327
405
|
else
|
328
406
|
|
329
|
-
value, name = s.split(
|
407
|
+
value, name = s.split(/: */,2).reverse
|
330
408
|
name ||= 'description'
|
331
409
|
v = value =~ /^\{\s*\}$/ ? {} : value.to_s
|
332
410
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kvx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
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
|
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQs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bWFzdGVyQGphbWVzcm9iZXJ0
|
27
27
|
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAZZ3jLwdvRBNjGqxBFpwbE+6lOlMADiza+vUe5DLr
|
29
|
+
Pwi54Wf+IF91M56S6zxw3BQ6aIzTqltXdHMkVJokQeGqzrGfJQO5Yhnh1Y1kxRtl
|
30
|
+
ZXCMasMdAE6NvW+1FIT/ilZDAoeaoLcoQ4JylHW25Y/FZ9tt++6EEkDFWZn6zxxw
|
31
|
+
wETcFLVEdzWeyJyTnjrfVYCJMlHr+mR9gXx2Fgz8vjqCu2O39NXuJqO9BrmoxkoD
|
32
|
+
jGcTdRnq6g6KcNOHlJCw6jvZUHSTeTtBPUEGkSNS5L3GejW65iwHWLY/WNtI4kzQ
|
33
|
+
9uR/zCKdJ0zJ/N7OEpBBMg05VTSR2nBwlTmacHdL/keDUuIUDd2APddKSr5F+voZ
|
34
|
+
ci+ozAEgQCeqDFapyRPqMGm8fO7Sa4i4BxGnDf6G3K9P6Rg9yEzpSbGTED9U+nlX
|
35
|
+
m/+jxdgFjKKGxeZqunu9cp5ca9wSjjtKh/VA/3xZtPwokCa7vCMB+ZxUP0jvd++u
|
36
|
+
OTXy8k/zqddw/VfD/It1UUK4
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2021-05-19 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: line-tree
|
@@ -103,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
|
107
|
-
rubygems_version: 2.7.10
|
106
|
+
rubygems_version: 3.0.3
|
108
107
|
signing_key:
|
109
108
|
specification_version: 4
|
110
109
|
summary: Kvx (Keys, Values, and XML) makes it convenient to store and retrieve the
|
metadata.gz.sig
CHANGED
Binary file
|