kvx 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
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 +30 -4
  5. metadata +3 -4
  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: 9ddaef947e49b210dbee31fcf56ec84e3644681c6a790c9ec80cb9fe314cd9d8
4
+ data.tar.gz: 56fae3981651c158701eb34023477125fbe7dd0ee8421d49d0e15174f550aae4
5
5
  SHA512:
6
- metadata.gz: 0b9d0408cd7218d7191ea7b709df8806b29c8ca3a4d7fd5858111089b57154eb3b030cc3eab3ccd145aedd50493bf1349be1fb10ace2a0986761e976929334a7
7
- data.tar.gz: 3d203c56ac70d4f8c50fd51fd115922782fa50f64a6be2d11453f74aa8818c373e36ecbfa84662b8831969537b7bc1fe99e161b9339e071132f99327108b29a7
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
@@ -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,9 +326,27 @@ 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|
338
+
339
+ if not line[/^ *\w+:|^ +/] then
340
+ indent + ' ' + line
341
+ else
342
+ indent = line[/^ +/] || ''
343
+ line
344
+ end
345
+
346
+ end
326
347
 
327
348
  puts ('inside scan_to_h').info if @debug
328
- raw_a = LineTree.new(txt.gsub(/(^-*$)|(^ *#.*)/,'').strip,
349
+ raw_a = LineTree.new(lines.join.gsub(/(^-*$)|(^ *#.*)/,'').strip,
329
350
  ignore_blank_lines: @ignore_blank_lines).to_a
330
351
  puts ('raw_a: ' + raw_a.inspect).debug if @debug
331
352
 
@@ -333,12 +354,17 @@ class Kvx
333
354
  # label, they will be fixed using the following statement
334
355
 
335
356
  a = raw_a.chunk {|x| x[0][/^[^:]+:|.*/]}.inject([]) do |r,y|
357
+
358
+ puts 'r: ' + r.inspect if @debug
359
+
336
360
  if r.last and !y.first[/[^:]+:/] then
337
361
  r.last << y.last[-1]
338
362
  else
339
363
  r << y.last[-1]
340
364
  end
365
+
341
366
  r
367
+
342
368
  end
343
369
 
344
370
  @body = a.inject({}) do |r, line|
@@ -348,7 +374,7 @@ class Kvx
348
374
 
349
375
  if line.join.length > 0 then
350
376
 
351
- r2 = if line[0][0][/^[^:]+: /] then
377
+ r2 = if line[0][0][/^[^:]+:/] then
352
378
 
353
379
  padding = line[0].length < 2 ? "\n" : "\n "
354
380
 
@@ -378,7 +404,7 @@ class Kvx
378
404
 
379
405
  else
380
406
 
381
- value, name = s.split(': ',2).reverse
407
+ value, name = s.split(/: */,2).reverse
382
408
  name ||= 'description'
383
409
  v = value =~ /^\{\s*\}$/ ? {} : value.to_s
384
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.5
4
+ version: 0.9.6
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-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
- rubyforge_project:
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