kvx 0.8.1 → 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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/kvx.rb +76 -11
- metadata +38 -37
- 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: c255b6ca87fbc7ec29656a2f7e33a4bf6770f33fbdeb17a9ec9743051055530f
|
4
|
+
data.tar.gz: baffbe4607834ba2ef49c78b21059b92d9e344d5c6fdd9d7a04252d2d0409d49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
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,12 +115,25 @@ 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
|
|
112
|
-
|
133
|
+
puts 'a: ' + a.inspect if @debug
|
134
|
+
doc = Rexle.new a
|
135
|
+
doc.instructions = @instructions || []
|
136
|
+
doc
|
113
137
|
|
114
138
|
end
|
115
139
|
|
@@ -124,11 +148,34 @@ class Kvx
|
|
124
148
|
header = '<?' + @identifier
|
125
149
|
header += attr
|
126
150
|
header += "?>\n"
|
127
|
-
|
128
|
-
|
151
|
+
|
152
|
+
if @summary and @summary.any? then
|
153
|
+
header += scan_to_s @summary
|
154
|
+
header += "\n----------------------------------\n\n"
|
155
|
+
end
|
156
|
+
|
129
157
|
end
|
158
|
+
|
159
|
+
# -- use the nested description Hash object if there are multiple lines
|
160
|
+
h = {}
|
130
161
|
|
131
|
-
|
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
|
177
|
+
|
178
|
+
header + scan_to_s(h)
|
132
179
|
|
133
180
|
end
|
134
181
|
|
@@ -138,6 +185,13 @@ class Kvx
|
|
138
185
|
doc.xml(options)
|
139
186
|
|
140
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
|
141
195
|
|
142
196
|
private
|
143
197
|
|
@@ -197,7 +251,15 @@ class Kvx
|
|
197
251
|
|
198
252
|
buffer, type = RXFHelper.read(s)
|
199
253
|
puts ('buffer: ' + buffer.inspect).debug if @debug
|
200
|
-
|
254
|
+
|
255
|
+
if buffer.lstrip =~ /^<\?xml/ then
|
256
|
+
doc = Rexle.new(buffer)
|
257
|
+
@instructions = doc.instructions
|
258
|
+
puts '@instructions: ' + @instructions.inspect if @debug
|
259
|
+
xml_to_h(doc.root)
|
260
|
+
else
|
261
|
+
parse_to_h(buffer)
|
262
|
+
end
|
201
263
|
|
202
264
|
end
|
203
265
|
|
@@ -230,7 +292,7 @@ class Kvx
|
|
230
292
|
@attributes.merge! attr
|
231
293
|
@header = true
|
232
294
|
body, summary = a.join.strip.split(/^----*$/).reverse
|
233
|
-
@summary = scan_to_h summary
|
295
|
+
@summary = scan_to_h summary if summary
|
234
296
|
|
235
297
|
body
|
236
298
|
else
|
@@ -286,7 +348,7 @@ class Kvx
|
|
286
348
|
|
287
349
|
if line.join.length > 0 then
|
288
350
|
|
289
|
-
r2 = if line[0][0][/^[^:]
|
351
|
+
r2 = if line[0][0][/^[^:]+: /] then
|
290
352
|
|
291
353
|
padding = line[0].length < 2 ? "\n" : "\n "
|
292
354
|
|
@@ -345,6 +407,9 @@ class Kvx
|
|
345
407
|
|
346
408
|
def xml_to_h(node)
|
347
409
|
|
410
|
+
puts 'node: ' + node.xml.inspect if @debug
|
411
|
+
@attributes = node.attributes.to_h
|
412
|
+
|
348
413
|
summary = node.element('summary')
|
349
414
|
|
350
415
|
if summary then
|
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.
|
4
|
+
version: 0.9.4
|
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
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwMjIwMjI0ODU5WhcN
|
15
|
+
MjIwMjIwMjI0ODU5WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDEZUlA
|
17
|
+
5Xwb1PhCpUwcey7fBjLJHAHnBg9lFLAFNGWr1QDpH166qx7w9Q9ckPeFNMiH5ZFs
|
18
|
+
/D9GrO+BVU3Lz5/CaL3q5eB3L8+JC+VjNiJijvynBa2TeB2aenlRqdUqvJ/RGTu0
|
19
|
+
9v8tWq/Mn3batCRCpuLJJ25C49hyzYts2UWetRAqfuvukJY+BoPISYntAs3g2elo
|
20
|
+
Za/9sY69ezCvOmwyw+B8dGXjqINlZxJKfuR3xf87uR/4vBC9DI4EE7dS1pjsyDws
|
21
|
+
d3e9fBWBKIM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BxGnDf6G3K9P6Rg9yEzpSbGTED9U+nlX
|
35
|
+
m/+jxdgFjKKGxeZqunu9cp5ca9wSjjtKh/VA/3xZtPwokCa7vCMB+ZxUP0jvd++u
|
36
|
+
OTXy8k/zqddw/VfD/It1UUK4
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2021-05-18 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: line-tree
|
@@ -43,40 +43,40 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0.
|
46
|
+
version: '0.9'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
49
|
+
version: 0.9.1
|
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.9'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.
|
59
|
+
version: 0.9.1
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: rxfhelper
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- - "~>"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '0.9'
|
67
64
|
- - ">="
|
68
65
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
66
|
+
version: 1.0.0
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.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: '0.9'
|
77
74
|
- - ">="
|
78
75
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.
|
76
|
+
version: 1.0.0
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '1.0'
|
80
80
|
description:
|
81
81
|
email: james@jamesrobertson.eu
|
82
82
|
executables: []
|
@@ -103,7 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.7.10
|
107
108
|
signing_key:
|
108
109
|
specification_version: 4
|
109
110
|
summary: Kvx (Keys, Values, and XML) makes it convenient to store and retrieve the
|
metadata.gz.sig
CHANGED
Binary file
|