dxlite 0.5.3 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 311deba556bb981c48b947115339623283f0dfc76a3a671fed8e218f69aebdf0
4
- data.tar.gz: d5b969ae74713577ee67fb1784fb39c7630af74f6d9eed124be53c8df9773256
3
+ metadata.gz: ceb35ccf99574494fddc04bcff1ca0da8f3e9105ff96663c4127e001e6c0d0f4
4
+ data.tar.gz: cb7d10780d5fe0930c82ef96918662a9bb0cfa7b52b340987e633e4d5a52c531
5
5
  SHA512:
6
- metadata.gz: b8ca6e083258756136a584b45d875312aefed4892f9472f45bc55d97a79949bf32d86d1a5f8105a1e50424ff64cb69b1d4cba07ace8291b80cb5c9395bcf2f8c
7
- data.tar.gz: 2b03e0a74f483a7af0eec600d73c5e449b528fc1c18e8d2af74144087cd6c2a4b0a67ff6e5212912e6297d4828a569e26886113734ceb3c829436a41ce259869
6
+ metadata.gz: 6cc80cf0885f8973443fd2301cbaf9a1f85eb65c47600feb3cf33097ccdc2953a7f0dc9dfd670b80f38255088d2a643bcff2bb80e55b8e179bb20fafc89e5214
7
+ data.tar.gz: f75f94e5af4dbdc3277f698915661d6028b9f04cda8c17f8626767586b69139febfd30cdcb3e9fc40528c297b6125a7dea2e81b0385204852fe174748b9c9d23
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/dxlite.rb CHANGED
@@ -6,7 +6,7 @@ require 'c32'
6
6
  require 'kvx'
7
7
  require 'json'
8
8
  require 'recordx'
9
- require 'rxfhelper'
9
+ require 'rxfreadwrite'
10
10
 
11
11
 
12
12
  # DxLite can perform the following:
@@ -20,17 +20,17 @@ require 'rxfhelper'
20
20
 
21
21
  class DxLite
22
22
  using ColouredText
23
- include RXFHelperModule
23
+ include RXFReadWriteModule
24
24
 
25
25
  attr_accessor :summary, :filepath
26
26
  attr_reader :records, :schema
27
27
 
28
- def initialize(s=nil, autosave: false, debug: false)
28
+ def initialize(s=nil, autosave: false, order: 'ascending', debug: false)
29
29
 
30
30
  @autosave, @debug = autosave, debug
31
31
 
32
32
  return unless s
33
- buffer, type = RXFHelper.read(s)
33
+ buffer, type = RXFReader.read(s)
34
34
 
35
35
  @filepath = s if type == :file or type == :dfs
36
36
 
@@ -51,7 +51,7 @@ class DxLite
51
51
 
52
52
  when :text
53
53
 
54
- new_summary(s)
54
+ new_summary(s, order)
55
55
 
56
56
  when :url
57
57
 
@@ -133,6 +133,17 @@ class DxLite
133
133
  @fields
134
134
  end
135
135
 
136
+ def record(id)
137
+
138
+ h = @records.find {|x| x[:id] == id }
139
+ return unless h
140
+ RecordX.new(h[:body], self, h[:id], h[:created], h[:last_modified])
141
+
142
+ end
143
+
144
+ alias find record
145
+ alias find_by_id record
146
+
136
147
  def inspect()
137
148
  "#<DxLite:%s @debug=%s, @summary=%s, ...>" % [object_id, @debug,
138
149
  @summary.inspect]
@@ -213,11 +224,14 @@ class DxLite
213
224
  root_name = schema()[/^\w+/]
214
225
  record_name = schema()[/(?<=\/)[^\(]+/]
215
226
 
227
+ records = @records.map {|h| {record_name.to_sym => h} }
228
+ records.reverse! if @summary[:order] == 'descending'
229
+
216
230
  h = {
217
231
  root_name.to_sym =>
218
232
  {
219
233
  summary: @summary,
220
- records: @records.map {|h| {record_name.to_sym => h} }
234
+ records: records
221
235
  }
222
236
  }
223
237
 
@@ -324,7 +338,7 @@ class DxLite
324
338
 
325
339
  end
326
340
 
327
- def new_summary(schema)
341
+ def new_summary(schema, order)
328
342
 
329
343
  @summary = {schema: schema}
330
344
 
@@ -333,7 +347,8 @@ class DxLite
333
347
 
334
348
  summary_attributes = {
335
349
  recordx_type: 'dynarex',
336
- default_key: schema[/(?<=\()\w+/]
350
+ default_key: schema[/(?<=\()\w+/],
351
+ order: order
337
352
  }
338
353
 
339
354
  puts 'before merge' if @debug
@@ -369,7 +384,8 @@ class DxLite
369
384
 
370
385
  h[:summary].each do |key, value|
371
386
 
372
- if %i(recordx_type format_mask schema).include? key then
387
+ if %i(recordx_type format_mask schema default_key order)\
388
+ .include? key then
373
389
  @summary[key] = value
374
390
  else
375
391
  @summary[key.to_s] = value
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.5.3
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,48 +35,28 @@ cert_chain:
35
35
  9pK+pqislEMFrWscGeMsc6YMS7ALxEujTuwTWyxmWAXnYft4ff2O1Zh2sPmdOlgf
36
36
  camg7d8q+VZZzAtz0cFc4pip
37
37
  -----END CERTIFICATE-----
38
- date: 2022-02-19 00:00:00.000000000 Z
38
+ date: 2022-03-19 00:00:00.000000000 Z
39
39
  dependencies:
40
- - !ruby/object:Gem::Dependency
41
- name: kvx
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '1.0'
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 1.0.2
50
- type: :runtime
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - "~>"
55
- - !ruby/object:Gem::Version
56
- version: '1.0'
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: 1.0.2
60
40
  - !ruby/object:Gem::Dependency
61
41
  name: recordx
62
42
  requirement: !ruby/object:Gem::Requirement
63
43
  requirements:
64
44
  - - "~>"
65
45
  - !ruby/object:Gem::Version
66
- version: '0.5'
46
+ version: '0.6'
67
47
  - - ">="
68
48
  - !ruby/object:Gem::Version
69
- version: 0.5.5
49
+ version: 0.6.0
70
50
  type: :runtime
71
51
  prerelease: false
72
52
  version_requirements: !ruby/object:Gem::Requirement
73
53
  requirements:
74
54
  - - "~>"
75
55
  - !ruby/object:Gem::Version
76
- version: '0.5'
56
+ version: '0.6'
77
57
  - - ">="
78
58
  - !ruby/object:Gem::Version
79
- version: 0.5.5
59
+ version: 0.6.0
80
60
  description:
81
61
  email: digital.robertson@gmail.com
82
62
  executables: []
metadata.gz.sig CHANGED
Binary file