kvx 0.9.3 → 0.9.4

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 +29 -7
  5. metadata +2 -2
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 771c274bf56fb9f8758aee53d0112cd88e6844e542325210c707a6af52dec20e
4
- data.tar.gz: f87fa3a2078e512766f1eef4a48753472105aa37c194a5d290e9f2bd54fb7cd6
3
+ metadata.gz: c255b6ca87fbc7ec29656a2f7e33a4bf6770f33fbdeb17a9ec9743051055530f
4
+ data.tar.gz: baffbe4607834ba2ef49c78b21059b92d9e344d5c6fdd9d7a04252d2d0409d49
5
5
  SHA512:
6
- metadata.gz: bd1f304798404629150a18a8287670ed0102e34d67e6734e374b33f19c19e146385cb4fdd2c06f1dbed6c97969a831a20ac168b66d25e9081b4f5e20eb6e5a9d
7
- data.tar.gz: b10f98724ecb9f052818b5b8c1fe6cbf841fa982772cd5c6e955d6836cc13b267085cb89dc213c38bd1a8479c5603cdf8cbf6d222464d86b187541c4799c9036
6
+ metadata.gz: c03ade6587fa5c1475aac9badde784b5929766d60d59ea53d70ca698b9bbe973acfcf9f4173ab5c2056dba13acb102b7a5c2fba509897f504b10d299489032b5
7
+ data.tar.gz: c38a4f5f215403a51006cfd1004a8a7a5977e3a034c9d994445c58a48bbd8fa5c7976e60691309c0013a17781d64dfaeb12e802e9c820ad099450785da34f022
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 = false
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
- def to_h()
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
- {summary: deep_clone(@summary), body: deep_clone(@body)}
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
@@ -137,8 +148,12 @@ class Kvx
137
148
  header = '<?' + @identifier
138
149
  header += attr
139
150
  header += "?>\n"
140
- header += scan_to_s @summary
141
- header += "\n----------------------------------\n\n"
151
+
152
+ if @summary and @summary.any? then
153
+ header += scan_to_s @summary
154
+ header += "\n----------------------------------\n\n"
155
+ end
156
+
142
157
  end
143
158
 
144
159
  # -- use the nested description Hash object if there are multiple lines
@@ -170,6 +185,13 @@ class Kvx
170
185
  doc.xml(options)
171
186
 
172
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
173
195
 
174
196
  private
175
197
 
@@ -270,7 +292,7 @@ class Kvx
270
292
  @attributes.merge! attr
271
293
  @header = true
272
294
  body, summary = a.join.strip.split(/^----*$/).reverse
273
- @summary = scan_to_h summary
295
+ @summary = scan_to_h summary if summary
274
296
 
275
297
  body
276
298
  else
@@ -326,7 +348,7 @@ class Kvx
326
348
 
327
349
  if line.join.length > 0 then
328
350
 
329
- r2 = if line[0][0][/^[^:]+:/] then
351
+ r2 = if line[0][0][/^[^:]+: /] then
330
352
 
331
353
  padding = line[0].length < 2 ? "\n" : "\n "
332
354
 
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.3
4
+ version: 0.9.4
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-02-20 00:00:00.000000000 Z
38
+ date: 2021-05-18 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: line-tree
metadata.gz.sig CHANGED
Binary file