dxlite 0.1.1 → 0.2.0
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 +2 -4
- data.tar.gz.sig +0 -0
- data/lib/dxlite.rb +72 -7
- metadata +4 -4
- 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: 1e0e8b4f265fe12323cca22407f3b06ce13f090192fb0abd83588aa4bd2cf13b
|
4
|
+
data.tar.gz: e9b725095dde2698fbd7a6afed799fec375f0d4009901b2021bfad73371ad0cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 439ffafee850ff7f07dd8915099c97cc24f4f9914780ce03231a57f200b43a734c3ebafeaa49d21f0b850a25bd5ce34b505e669bfac55bd911ea26c343313e6f
|
7
|
+
data.tar.gz: 370a4daca23b52c6a0b2e06c9abcd653cb061e14d93dfd4195250f41cb8c6b220261388f9812ee977bfe09963c37f7a1d3ef3fc7f20b9dc110f2fccfcdbedd0d
|
checksums.yaml.gz.sig
CHANGED
@@ -1,4 +1,2 @@
|
|
1
|
-
|
2
|
-
�[
|
3
|
-
B��D(��T��e��.�_�o.L�yZ�f���L�����M$#\�t�
|
4
|
-
멭�^��F�Œ�gG�Ӵ��:&�:k�d{OĂ'!\"�3��������M��5�T.G��nJ�;4o�p:3��~�-�
|
1
|
+
`�����$yΨìi�b���v*�0����/����8��Ж-���\75���uܥ��~������1���_��T�����<��e/Y�?E>�k��GA��~�H��!J:�z�Dxm_�z�_[�f��a`o����.TP�ͨ{��f��/�1'�ɩ9iV��^o�5����k=r�����al�ƽHjT��������V�ƝL�Җv�&�Z�a<3���J���~g����ܳ?�k/Z|w4�ö��R�8��x����A~�]#Hg8%5�ȷ�z7��
|
2
|
+
��<_�[h�8���3�4>��-������,�<=�\X\�8�~���KK���@�����ЛjzIJR����q=|���$�\<��|@���
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/dxlite.rb
CHANGED
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
# file: dxlite.rb
|
4
4
|
|
5
|
+
require 'c32'
|
5
6
|
require 'json'
|
6
7
|
require 'recordx'
|
7
8
|
require 'rxfhelper'
|
8
9
|
|
9
10
|
class DxLite
|
11
|
+
using ColouredText
|
10
12
|
|
11
13
|
attr_accessor :summary
|
12
14
|
attr_reader :records
|
@@ -17,12 +19,41 @@ class DxLite
|
|
17
19
|
|
18
20
|
buffer, type = RXFHelper.read(s)
|
19
21
|
puts 'type: ' + type.inspect if @debug
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
|
23
|
+
case type
|
24
|
+
|
25
|
+
when :file
|
26
|
+
|
27
|
+
h = JSON.parse(buffer, symbolize_names: true)
|
28
|
+
@filepath = s
|
29
|
+
|
30
|
+
@summary = h[:summary]
|
31
|
+
@records = h[:records]
|
32
|
+
|
33
|
+
when :text
|
34
|
+
|
35
|
+
@summary = {schema: s}
|
36
|
+
@records = []
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
@schema = @summary[:schema]
|
41
|
+
|
42
|
+
@summary.merge! @summary[:schema][/(?<=\[)[^\]]+/].split(',')\
|
43
|
+
.map {|x|[x.strip, nil] }.to_h
|
44
|
+
|
45
|
+
# for each summary item create get and set methods
|
46
|
+
|
47
|
+
@summary.each do |key, value|
|
48
|
+
|
49
|
+
define_singleton_method(key) { @summary[key] }
|
50
|
+
|
51
|
+
define_singleton_method (key.to_s + '=').to_sym do |value|
|
52
|
+
@summary[key] = value
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
26
57
|
@fields = @summary[:schema][/(?<=\()[^\)]+/].split(',').map(&:strip)
|
27
58
|
|
28
59
|
@fields.each do |x|
|
@@ -42,7 +73,7 @@ class DxLite
|
|
42
73
|
def all()
|
43
74
|
|
44
75
|
@records.map do |h|
|
45
|
-
RecordX.new(h, self, h
|
76
|
+
RecordX.new(h, self, h.object_id, h[:created], h[:last_modified])
|
46
77
|
end
|
47
78
|
|
48
79
|
end
|
@@ -50,9 +81,43 @@ class DxLite
|
|
50
81
|
def create(h)
|
51
82
|
@records << h
|
52
83
|
end
|
84
|
+
|
85
|
+
# Parses 1 or more lines of text to create or update existing records.
|
86
|
+
|
87
|
+
def parse(obj=nil)
|
88
|
+
|
89
|
+
if obj.is_a? Array then
|
90
|
+
|
91
|
+
unless schema() then
|
92
|
+
cols = obj.first.keys.map {|c| c == 'id' ? 'uid' : c}
|
93
|
+
self.schema = "items/item(%s)" % cols.join(', ')
|
94
|
+
end
|
95
|
+
|
96
|
+
obj.each {|x| self.create x }
|
97
|
+
return self
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
alias import parse
|
53
103
|
|
54
104
|
def save(file=@filepath)
|
55
105
|
File.write file, @records.to_json
|
56
106
|
end
|
57
107
|
|
108
|
+
# Updates a record from an id and a hash containing field name and field value.
|
109
|
+
# dynarex.update 4, name: Jeff, age: 38
|
110
|
+
|
111
|
+
def update(id, obj)
|
112
|
+
|
113
|
+
if @debug then
|
114
|
+
puts 'inside update'.info
|
115
|
+
puts ('id: ' + id.inspect).debug
|
116
|
+
puts ('obj.class: ' + obj.class.inspect).debug
|
117
|
+
end
|
118
|
+
|
119
|
+
r = @records.find {|x| x.object_id == id}
|
120
|
+
r.merge!(obj)
|
121
|
+
end
|
122
|
+
|
58
123
|
end
|
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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
dwbAN6/wokoLVZAiMRG1vZlI6RhtSOTHvFHbfBE5JI9rhjRtui8yeV+t8iI8G4Zs
|
36
36
|
2NszuYzdlVfzlrUiPWY5jL9P
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-06-
|
38
|
+
date: 2020-06-21 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: recordx
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
version: '0.5'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.5.
|
49
|
+
version: 0.5.5
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
version: '0.5'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.5.
|
59
|
+
version: 0.5.5
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: rxfhelper
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|