dxlite 0.3.0 → 0.3.1

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: 6638bca4c2fef3679ec9d456318f51b51eeeb49230afadbd1baa8af4308620ca
4
- data.tar.gz: 1fcaedf6a4692a244e5930ed1d8ec10e7784b5003958faafb45b8e32cdaa707a
3
+ metadata.gz: 90e750d486323e8a58475cb5471ce9724fb1e74c723aade42c9ed8e8b8eeb146
4
+ data.tar.gz: 1fa49e26bd6b74fcbc68cfde7a7ff38746adb1227de26bd7241ff2c494eb2127
5
5
  SHA512:
6
- metadata.gz: 54a8938acfd2116234f3a750c9e007adae6e2bc7cb894379702aebe2730b8a601c88f178a490f4b260275e5682c211efee2c5c9da57b9fa645f5146b66a5c7d9
7
- data.tar.gz: ec2fde50afa20bbea953fc3ffb503ae07f160580248ecde88e99f1c272f64404cf6bea099c75e4286f411f3c83df27516df39394c27e78d3bc1846e2fce2b88d
6
+ metadata.gz: 7fc7a7fe58be371ba3ae9120cba0cad446917c55c8e5e438ebe9be4b74eefca0f2bf36b48813683d406fda740c45b1de9aed0b773a1815c624344b8d978f6bc7
7
+ data.tar.gz: c82bde55b5410360b3e2114750e24bf8ce6b7747913b6e9dbcc6e38e47549407171ea836cfcc251d0025d6a91bd6b8c160109711d69687e2d975898fbdf57fe7
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -14,12 +14,15 @@ class DxLite
14
14
  attr_accessor :summary
15
15
  attr_reader :records
16
16
 
17
- def initialize(s=nil, filepath: nil, debug: false)
17
+ def initialize(s=nil, autosave: false, debug: false)
18
18
 
19
- @filepath, @debug = filepath, debug
19
+ @autosave, @debug = autosave, debug
20
20
 
21
21
  return unless s
22
22
  buffer, type = RXFHelper.read(s)
23
+
24
+ @filepath = s if type == :file or type == :dfs
25
+
23
26
  puts 'type: ' + type.inspect if @debug
24
27
  puts 'buffer: ' + buffer.inspect if @debug
25
28
 
@@ -80,7 +83,12 @@ class DxLite
80
83
 
81
84
  def delete(id)
82
85
  found = @records.find {|x| x[:id] == id}
83
- @records.delete found if found
86
+
87
+ if found then
88
+ @records.delete found
89
+ save() if @autosave
90
+ end
91
+
84
92
  end
85
93
 
86
94
  def create(rawh, id: nil, custom_attributes: {created: Time.now})
@@ -90,6 +98,8 @@ class DxLite
90
98
  h = fields.map {|x| [x.to_sym, nil] }.to_h.merge(rawh)
91
99
  @records << {id: id.to_s, created: h2[:created], last_modified: nil,
92
100
  body: h}
101
+
102
+ save() if @autosave
93
103
  end
94
104
 
95
105
  def fields()
@@ -155,6 +165,9 @@ class DxLite
155
165
  end
156
166
 
157
167
  def save(file=@filepath)
168
+
169
+ return unless file
170
+
158
171
  s = File.extname(file) == '.json' ? to_json() : to_xml()
159
172
  File.write file, s
160
173
  end
@@ -222,7 +235,14 @@ class DxLite
222
235
  end
223
236
 
224
237
  r = @records.find {|x| x[:id] == id}
225
- r[:body].merge!(obj)
238
+
239
+ if r then
240
+
241
+ r[:body].merge!(obj)
242
+ save() if @autosave
243
+
244
+ end
245
+
226
246
  end
227
247
 
228
248
  private
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.3.0
4
+ version: 0.3.1
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: 2021-01-23 00:00:00.000000000 Z
38
+ date: 2021-01-27 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: recordx
metadata.gz.sig CHANGED
Binary file