dxlite 0.4.1 → 0.5.3

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/lib/dxlite.rb +51 -32
  4. data.tar.gz.sig +0 -0
  5. metadata +13 -14
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a826f1bbdc7b1560d8a66ff303a87a1cf3a789cf0281b1aa8130ce0cdaf4893e
4
- data.tar.gz: e4e5401e812f9b69def5f87f6cd2178292c7fb58d604bf6a091da1a8d634ea64
3
+ metadata.gz: 311deba556bb981c48b947115339623283f0dfc76a3a671fed8e218f69aebdf0
4
+ data.tar.gz: d5b969ae74713577ee67fb1784fb39c7630af74f6d9eed124be53c8df9773256
5
5
  SHA512:
6
- metadata.gz: fc84a8ef5723964235e215ceaad244725dc882917a4475da3b5f8ca702aacf375b0d8bd8536fe297580a5a8be321367867332a3aff2839636ccb0113beaf8cba
7
- data.tar.gz: 21daf4162a732639f0b8c5c0b41f9e09edf552db9a55aa632a8c0f082273074b54b2a588bab166804fc9079452340a0956baf98a790abaa1214553e85b16eeb5
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, :schema
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
- @summary = {schema: s}
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
- self.schema = "items/item(%s)" % cols.join(', ')
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
- File.write file, s
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.1
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: 2021-12-29 00:00:00.000000000 Z
38
+ date: 2022-02-19 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
- name: recordx
41
+ name: kvx
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.5'
46
+ version: '1.0'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.5.5
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.5'
56
+ version: '1.0'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 0.5.5
59
+ version: 1.0.2
60
60
  - !ruby/object:Gem::Dependency
61
- name: rxfhelper
61
+ name: recordx
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '1.1'
66
+ version: '0.5'
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 1.1.3
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: '1.1'
76
+ version: '0.5'
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 1.1.3
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
- rubyforge_project:
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