dxlite 0.6.0 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/dxlite.rb +42 -6
- data.tar.gz.sig +0 -0
- metadata +6 -26
- 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: 6f01e71eb6492777d8d892c3ba33c662de229a26adb5141aa946355a7202c0a0
|
4
|
+
data.tar.gz: f84b22c52e8decf1a0cf870e322463d1de725523ed02acf0d545c52ea5a167c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee41e2b9acd447bb03536592dce815cbd7c803805bcefd9676392fde951446aab689748614031d1e5405d263f5429b91767cc72f1b39924b728b141f4bcd2fcb
|
7
|
+
data.tar.gz: 51d67cc2d50bcd0111ef60571cf2421d2854245f3408e287f375502aaf49ef824d6ec2bc34e0c3b61612b47206ea807965780b1fc3c0a42ea6da8241c22f4442
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/dxlite.rb
CHANGED
@@ -25,7 +25,7 @@ class DxLite
|
|
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
|
|
@@ -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
|
|
@@ -94,8 +94,16 @@ class DxLite
|
|
94
94
|
if key then
|
95
95
|
|
96
96
|
r = records.find {|x| x[:body][key.to_sym] == rawh[key.to_sym]}
|
97
|
+
|
97
98
|
if r then
|
99
|
+
|
100
|
+
# if the client is using create() instead of update() to update a
|
101
|
+
# record then update the record
|
102
|
+
#
|
103
|
+
r[:body].merge!(rawh)
|
98
104
|
r[:last_modified] = Time.now.to_s
|
105
|
+
save() if @autosave
|
106
|
+
|
99
107
|
return false
|
100
108
|
end
|
101
109
|
|
@@ -133,6 +141,17 @@ class DxLite
|
|
133
141
|
@fields
|
134
142
|
end
|
135
143
|
|
144
|
+
def record(id)
|
145
|
+
|
146
|
+
h = @records.find {|x| x[:id] == id }
|
147
|
+
return unless h
|
148
|
+
RecordX.new(h[:body], self, h[:id], h[:created], h[:last_modified])
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
alias find record
|
153
|
+
alias find_by_id record
|
154
|
+
|
136
155
|
def inspect()
|
137
156
|
"#<DxLite:%s @debug=%s, @summary=%s, ...>" % [object_id, @debug,
|
138
157
|
@summary.inspect]
|
@@ -213,11 +232,25 @@ class DxLite
|
|
213
232
|
root_name = schema()[/^\w+/]
|
214
233
|
record_name = schema()[/(?<=\/)[^\(]+/]
|
215
234
|
|
235
|
+
records = @records.map {|h| {record_name.to_sym => h} }
|
236
|
+
|
237
|
+
a = if @summary[:order] == 'descending' then
|
238
|
+
|
239
|
+
records.sort_by do |x|
|
240
|
+
x[:last_modified] || x[:created]
|
241
|
+
end.reverse
|
242
|
+
|
243
|
+
else
|
244
|
+
|
245
|
+
records
|
246
|
+
|
247
|
+
end
|
248
|
+
|
216
249
|
h = {
|
217
250
|
root_name.to_sym =>
|
218
251
|
{
|
219
252
|
summary: @summary,
|
220
|
-
records:
|
253
|
+
records: a
|
221
254
|
}
|
222
255
|
}
|
223
256
|
|
@@ -271,6 +304,7 @@ class DxLite
|
|
271
304
|
if r then
|
272
305
|
|
273
306
|
r[:body].merge!(obj)
|
307
|
+
r[:last_modified] = Time.now
|
274
308
|
save() if @autosave
|
275
309
|
|
276
310
|
end
|
@@ -324,7 +358,7 @@ class DxLite
|
|
324
358
|
|
325
359
|
end
|
326
360
|
|
327
|
-
def new_summary(schema)
|
361
|
+
def new_summary(schema, order)
|
328
362
|
|
329
363
|
@summary = {schema: schema}
|
330
364
|
|
@@ -333,7 +367,8 @@ class DxLite
|
|
333
367
|
|
334
368
|
summary_attributes = {
|
335
369
|
recordx_type: 'dynarex',
|
336
|
-
default_key: schema[/(?<=\()\w+/]
|
370
|
+
default_key: schema[/(?<=\()\w+/],
|
371
|
+
order: order
|
337
372
|
}
|
338
373
|
|
339
374
|
puts 'before merge' if @debug
|
@@ -369,7 +404,8 @@ class DxLite
|
|
369
404
|
|
370
405
|
h[:summary].each do |key, value|
|
371
406
|
|
372
|
-
if %i(recordx_type format_mask schema
|
407
|
+
if %i(recordx_type format_mask schema default_key order)\
|
408
|
+
.include? key then
|
373
409
|
@summary[key] = value
|
374
410
|
else
|
375
411
|
@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.6.
|
4
|
+
version: 0.6.3
|
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-
|
38
|
+
date: 2022-03-21 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.1.0
|
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.1.0
|
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.
|
46
|
+
version: '0.6'
|
67
47
|
- - ">="
|
68
48
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
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.
|
56
|
+
version: '0.6'
|
77
57
|
- - ">="
|
78
58
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.
|
59
|
+
version: 0.6.0
|
80
60
|
description:
|
81
61
|
email: digital.robertson@gmail.com
|
82
62
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|