kvx 0.9.5 → 0.9.10

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/kvx.rb +43 -10
  5. metadata +9 -10
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cadaf1215b2da0fd1ad43738ace4067eaaa34854163d46d2813cdbaed2c12b81
4
- data.tar.gz: c12db9591acdec03bef9453eb28c02a476c732f2bf19e7dfe0c6f37f392ddd78
3
+ metadata.gz: 109d12cb0e82c682e94c369c81726331070e2a7e57d6d88fea4c1701701c7c1e
4
+ data.tar.gz: f84bdb9a378f13abb834f6e7be36924812ad1028b7c6846c002c44f3e4b69ead
5
5
  SHA512:
6
- metadata.gz: 0b9d0408cd7218d7191ea7b709df8806b29c8ca3a4d7fd5858111089b57154eb3b030cc3eab3ccd145aedd50493bf1349be1fb10ace2a0986761e976929334a7
7
- data.tar.gz: 3d203c56ac70d4f8c50fd51fd115922782fa50f64a6be2d11453f74aa8818c373e36ecbfa84662b8831969537b7bc1fe99e161b9339e071132f99327108b29a7
6
+ metadata.gz: 5769d109589a3c4d5d65131ef45cc78a27d3e63c82029a86d60cb12adcd2be2ec5da7b0c5fde77646fee357072fad8c58934ac1d413d97e2c313905c3cd8c709
7
+ data.tar.gz: 56982a372339f230ea947a8ac0f2d0e0cd5e297c86b1cd4fd38aec1a0557e6a273bbe25e0cfc5c7cb959af73a56fcf972387ec595a73eae7327d49302bfaa19b
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/kvx.rb CHANGED
@@ -244,7 +244,10 @@ class Kvx
244
244
  def make_xml(h)
245
245
 
246
246
  puts 'inside make_xml: ' + h.inspect if @debug
247
- RexleBuilder.new(h, debug: false).to_a[3..-1]
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]
248
251
  end
249
252
 
250
253
  def parse_string(s)
@@ -323,22 +326,48 @@ class Kvx
323
326
 
324
327
 
325
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|
326
338
 
339
+ if not line[/^ *\w+:|^ +/] then
340
+ indent + ' ' + line
341
+ else
342
+ indent = line[/^ +/] || ''
343
+ line
344
+ end
345
+
346
+ end
347
+ puts ('lines: ' + lines.inspect).debug if @debug
348
+
327
349
  puts ('inside scan_to_h').info if @debug
328
- raw_a = LineTree.new(txt.gsub(/(^-*$)|(^ *#.*)/,'').strip,
350
+ raw_a = LineTree.new(lines.join.gsub(/(^-*$)|(?<=\S) +#.*/,'').strip,
329
351
  ignore_blank_lines: @ignore_blank_lines).to_a
330
352
  puts ('raw_a: ' + raw_a.inspect).debug if @debug
331
353
 
332
354
  # if there are any orphan lines which aren't nested underneath a
333
355
  # label, they will be fixed using the following statement
334
356
 
335
- a = raw_a.chunk {|x| x[0][/^[^:]+:|.*/]}.inject([]) do |r,y|
357
+ a = raw_a.chunk {|x| x[0][/^[^:]+:/]}.inject([]) do |r,y|
358
+
359
+
360
+ puts 'r: ' + r.inspect if @debug
361
+
336
362
  if r.last and !y.first[/[^:]+:/] then
337
363
  r.last << y.last[-1]
338
364
  else
365
+ puts 'y: ' + y.inspect if @debug
339
366
  r << y.last[-1]
340
367
  end
368
+
341
369
  r
370
+
342
371
  end
343
372
 
344
373
  @body = a.inject({}) do |r, line|
@@ -346,13 +375,16 @@ class Kvx
346
375
  s = line.shift
347
376
  puts ('s: ' + s.inspect).debug if @debug
348
377
 
349
- if line.join.length > 0 then
350
-
351
- r2 = if line[0][0][/^[^:]+: /] then
352
-
353
- padding = line[0].length < 2 ? "\n" : "\n "
378
+ if line.join.length > 0 then
379
+
380
+ puts 'line: ' + line.inspect if @debug
381
+
382
+ padding = line[0].length < 2 ? "\n" : "\n "
383
+ s10 = line.map{|x| x.join(padding)}.join("\n")
384
+
385
+ r2 = if s10[/^ *\w+:[\n ]/] then
354
386
 
355
- scan_to_h(line.map{|x| x.join(padding)}.join("\n"))
387
+ scan_to_h(s10)
356
388
 
357
389
  else
358
390
 
@@ -366,6 +398,7 @@ class Kvx
366
398
  end
367
399
 
368
400
  r3 = {description: txt2, items: h}
401
+ puts 'remaining: ' + remaining.inspect if @debug
369
402
 
370
403
  if remaining then
371
404
  r3.merge!(scan_to_h remaining + "\n ")
@@ -378,7 +411,7 @@ class Kvx
378
411
 
379
412
  else
380
413
 
381
- value, name = s.split(': ',2).reverse
414
+ value, name = s.split(/: */,2).reverse
382
415
  name ||= 'description'
383
416
  v = value =~ /^\{\s*\}$/ ? {} : value.to_s
384
417
 
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.5
4
+ version: 0.9.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  m/+jxdgFjKKGxeZqunu9cp5ca9wSjjtKh/VA/3xZtPwokCa7vCMB+ZxUP0jvd++u
36
36
  OTXy8k/zqddw/VfD/It1UUK4
37
37
  -----END CERTIFICATE-----
38
- date: 2021-05-18 00:00:00.000000000 Z
38
+ date: 2021-06-06 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: line-tree
@@ -61,22 +61,22 @@ dependencies:
61
61
  name: rxfhelper
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 1.0.0
67
64
  - - "~>"
68
65
  - !ruby/object:Gem::Version
69
66
  version: '1.0'
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 1.0.0
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: 1.0.0
77
74
  - - "~>"
78
75
  - !ruby/object:Gem::Version
79
76
  version: '1.0'
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 1.0.0
80
80
  description:
81
81
  email: james@jamesrobertson.eu
82
82
  executables: []
@@ -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
- rubyforge_project:
107
- rubygems_version: 2.7.10
106
+ rubygems_version: 3.1.2
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