dxlite 0.4.1 → 0.5.3
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/lib/dxlite.rb +51 -32
- data.tar.gz.sig +0 -0
- metadata +13 -14
- 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: 311deba556bb981c48b947115339623283f0dfc76a3a671fed8e218f69aebdf0
|
4
|
+
data.tar.gz: d5b969ae74713577ee67fb1784fb39c7630af74f6d9eed124be53c8df9773256
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8ca6e083258756136a584b45d875312aefed4892f9472f45bc55d97a79949bf32d86d1a5f8105a1e50424ff64cb69b1d4cba07ace8291b80cb5c9395bcf2f8c
|
7
|
+
data.tar.gz: 2b03e0a74f483a7af0eec600d73c5e449b528fc1c18e8d2af74144087cd6c2a4b0a67ff6e5212912e6297d4828a569e26886113734ceb3c829436a41ce259869
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/dxlite.rb
CHANGED
@@ -3,16 +3,27 @@
|
|
3
3
|
# file: dxlite.rb
|
4
4
|
|
5
5
|
require 'c32'
|
6
|
+
require 'kvx'
|
6
7
|
require 'json'
|
7
8
|
require 'recordx'
|
8
9
|
require 'rxfhelper'
|
9
10
|
|
10
11
|
|
12
|
+
# DxLite can perform the following:
|
13
|
+
#
|
14
|
+
# * read or write an XML file
|
15
|
+
# * read or write a JSON file (in Dynarex format)
|
16
|
+
# * import an Array of records (Hash objects)
|
17
|
+
#
|
18
|
+
# note: It cannot read a Dynarex file in
|
19
|
+
# the raw Dynarex format (.txt plain text)
|
20
|
+
|
11
21
|
class DxLite
|
12
22
|
using ColouredText
|
23
|
+
include RXFHelperModule
|
13
24
|
|
14
|
-
attr_accessor :summary, :filepath
|
15
|
-
attr_reader :records
|
25
|
+
attr_accessor :summary, :filepath
|
26
|
+
attr_reader :records, :schema
|
16
27
|
|
17
28
|
def initialize(s=nil, autosave: false, debug: false)
|
18
29
|
|
@@ -40,8 +51,7 @@ class DxLite
|
|
40
51
|
|
41
52
|
when :text
|
42
53
|
|
43
|
-
|
44
|
-
|
54
|
+
new_summary(s)
|
45
55
|
|
46
56
|
when :url
|
47
57
|
|
@@ -49,29 +59,6 @@ class DxLite
|
|
49
59
|
|
50
60
|
end
|
51
61
|
|
52
|
-
puts '@summary: ' + @summary.inspect if @debug
|
53
|
-
@schema = @summary[:schema]
|
54
|
-
|
55
|
-
summary_attributes = {
|
56
|
-
recordx_type: 'dynarex',
|
57
|
-
default_key: @schema[/(?<=\()\w+/]
|
58
|
-
}
|
59
|
-
|
60
|
-
puts 'before merge' if @debug
|
61
|
-
@summary.merge!(summary_attributes)
|
62
|
-
|
63
|
-
summary = @summary[:schema][/(?<=\[)[^\]]+/]
|
64
|
-
|
65
|
-
if summary then
|
66
|
-
|
67
|
-
summary.split(/ *, */).each do |x|
|
68
|
-
@summary[x] = nil unless @summary[x]
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
make_methods()
|
74
|
-
|
75
62
|
end
|
76
63
|
|
77
64
|
def all()
|
@@ -155,13 +142,15 @@ class DxLite
|
|
155
142
|
|
156
143
|
def parse(obj=nil)
|
157
144
|
|
145
|
+
@records ||= []
|
146
|
+
|
158
147
|
if obj.is_a? Array then
|
159
148
|
|
160
149
|
unless schema() then
|
161
150
|
puts 'obj.first: ' + obj.first.inspect if @debug
|
162
151
|
cols = obj.first.keys.map {|c| c == 'id' ? 'uid' : c}
|
163
152
|
puts 'after cols' if @debug
|
164
|
-
|
153
|
+
new_summary "items/item(%s)" % cols.join(', ')
|
165
154
|
end
|
166
155
|
|
167
156
|
obj.each do |x|
|
@@ -178,7 +167,7 @@ class DxLite
|
|
178
167
|
|
179
168
|
def parse_xml(buffer)
|
180
169
|
|
181
|
-
doc = Rexle.new(buffer)
|
170
|
+
doc = Rexle.new(buffer.force_encoding('UTF-8'))
|
182
171
|
|
183
172
|
asummary = doc.root.xpath('summary/*').map do |node|
|
184
173
|
puts 'node: ' + node.xml.inspect if @debug
|
@@ -189,10 +178,10 @@ class DxLite
|
|
189
178
|
summary[:schema] = summary['schema']
|
190
179
|
%w(recordx_type format_mask schema).each {|x| summary.delete x}
|
191
180
|
|
192
|
-
schema = summary[:schema]
|
181
|
+
@schema = summary[:schema]
|
193
182
|
puts 'schema: ' + schema.inspect if @debug
|
194
183
|
|
195
|
-
@fields = schema[/\(([^\)]+)/,1].split(/ *,
|
184
|
+
@fields = @schema[/\(([^\)]+)/,1].split(/ *, */)
|
196
185
|
puts 'fields: ' + @fields.inspect if @debug
|
197
186
|
|
198
187
|
@summary = summary
|
@@ -212,7 +201,7 @@ class DxLite
|
|
212
201
|
@filepath = file
|
213
202
|
|
214
203
|
s = File.extname(file) == '.json' ? to_json() : to_xml()
|
215
|
-
|
204
|
+
FileX.write file, s
|
216
205
|
end
|
217
206
|
|
218
207
|
def to_a()
|
@@ -335,6 +324,34 @@ class DxLite
|
|
335
324
|
|
336
325
|
end
|
337
326
|
|
327
|
+
def new_summary(schema)
|
328
|
+
|
329
|
+
@summary = {schema: schema}
|
330
|
+
|
331
|
+
puts '@summary: ' + @summary.inspect if @debug
|
332
|
+
@schema = @summary[:schema]
|
333
|
+
|
334
|
+
summary_attributes = {
|
335
|
+
recordx_type: 'dynarex',
|
336
|
+
default_key: schema[/(?<=\()\w+/]
|
337
|
+
}
|
338
|
+
|
339
|
+
puts 'before merge' if @debug
|
340
|
+
@summary.merge!(summary_attributes)
|
341
|
+
|
342
|
+
summary = @summary[:schema][/(?<=\[)[^\]]+/]
|
343
|
+
|
344
|
+
if summary then
|
345
|
+
|
346
|
+
summary.split(/ *, */).each do |x|
|
347
|
+
@summary[x] = nil unless @summary[x]
|
348
|
+
end
|
349
|
+
|
350
|
+
end
|
351
|
+
|
352
|
+
make_methods()
|
353
|
+
end
|
354
|
+
|
338
355
|
def read(buffer)
|
339
356
|
|
340
357
|
if buffer[0] == '<' then
|
@@ -364,6 +381,8 @@ class DxLite
|
|
364
381
|
|
365
382
|
end
|
366
383
|
|
384
|
+
make_methods()
|
385
|
+
|
367
386
|
end
|
368
387
|
|
369
388
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dxlite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,48 +35,48 @@ cert_chain:
|
|
35
35
|
9pK+pqislEMFrWscGeMsc6YMS7ALxEujTuwTWyxmWAXnYft4ff2O1Zh2sPmdOlgf
|
36
36
|
camg7d8q+VZZzAtz0cFc4pip
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2022-02-19 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
|
-
name:
|
41
|
+
name: kvx
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0
|
46
|
+
version: '1.0'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
49
|
+
version: 1.0.2
|
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: '1.0'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.
|
59
|
+
version: 1.0.2
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
|
-
name:
|
61
|
+
name: recordx
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: '
|
66
|
+
version: '0.5'
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 0.5.5
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '0.5'
|
77
77
|
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version:
|
79
|
+
version: 0.5.5
|
80
80
|
description:
|
81
81
|
email: digital.robertson@gmail.com
|
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
|
-
|
107
|
-
rubygems_version: 2.7.10
|
106
|
+
rubygems_version: 3.2.22
|
108
107
|
signing_key:
|
109
108
|
specification_version: 4
|
110
109
|
summary: Handles Dynarex documents (in JSON format) faster and with less overheads.
|
metadata.gz.sig
CHANGED
Binary file
|