lucarecord 0.2.24 → 0.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/luca_record/io.rb +27 -6
- data/lib/luca_record/version.rb +1 -1
- data/lib/luca_support/code.rb +22 -18
- data/lib/luca_support/view.rb +4 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1982b60b00eddc3d201368a2f436835fa51c6ba58538de3fcd0ce962c4529246
|
4
|
+
data.tar.gz: 894ef1778f5a8be1f2091575ec86e84ceb61d0d158ba0cb4b8bc297c7070593a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 396bfbd54619361753b576fdda9f715b115ab274df10dce07abb1a5f180ed161946c72bae02c4926ff05d828e20af6920c689a412c71234c5baef072f870b528
|
7
|
+
data.tar.gz: 633d8920f547c893b2b1ac6645bdd108439d3568cfa3ec738c70ec61f1f658374e598bce0144a5a85142a15e4353d102e35b48ea84988f4dae06b0658a3952f7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## LucaRecord 0.2.25
|
2
|
+
|
3
|
+
* Implement `dir_digest()` for data validation.
|
4
|
+
* support defunct without effective history record
|
5
|
+
|
1
6
|
## LucaRecord 0.2.24
|
2
7
|
|
3
8
|
* Digit delimiter for `delimit_num` can be customized through `thousands_separator` and `decimal_separator` in config.yml.
|
data/lib/luca_record/io.rb
CHANGED
@@ -252,6 +252,17 @@ module LucaRecord # :nodoc:
|
|
252
252
|
LucaSupport::Code.encode_txid(new_record_no(basedir, date_obj))
|
253
253
|
end
|
254
254
|
|
255
|
+
# Calculate md5sum under specific month directory.
|
256
|
+
#
|
257
|
+
def dir_digest(year, month, basedir = @dirname)
|
258
|
+
subdir = year.to_s + LucaSupport::Code.encode_month(month)
|
259
|
+
digest = String.new
|
260
|
+
open_records(basedir, subdir).each do |f, path|
|
261
|
+
digest = update_digest(digest, f.read, path[1])
|
262
|
+
end
|
263
|
+
digest
|
264
|
+
end
|
265
|
+
|
255
266
|
private
|
256
267
|
|
257
268
|
# define new transaction ID & write data at once
|
@@ -339,12 +350,14 @@ module LucaRecord # :nodoc:
|
|
339
350
|
# If specific decode is needed, override this method in each class.
|
340
351
|
#
|
341
352
|
def load_data(io, path = nil)
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
353
|
+
if @record_type
|
354
|
+
case @record_type
|
355
|
+
when 'raw'
|
356
|
+
# TODO: raw may be unneeded in favor of override
|
357
|
+
io
|
358
|
+
when 'json'
|
359
|
+
# TODO: implement JSON parse
|
360
|
+
end
|
348
361
|
else
|
349
362
|
LucaSupport::Code.decimalize(YAML.load(io.read)).tap { |obj| validate_keys(obj) }
|
350
363
|
end
|
@@ -420,5 +433,13 @@ module LucaRecord # :nodoc:
|
|
420
433
|
{}
|
421
434
|
end
|
422
435
|
end
|
436
|
+
|
437
|
+
# Calculate md5sum with original digest, file content and filename(optional).
|
438
|
+
#
|
439
|
+
def update_digest(digest, str, filename = nil)
|
440
|
+
str = filename.nil? ? str : filename + str
|
441
|
+
content = Digest::MD5.new.update(str).hexdigest
|
442
|
+
Digest::MD5.new.update(digest + content).hexdigest
|
443
|
+
end
|
423
444
|
end
|
424
445
|
end
|
data/lib/luca_record/version.rb
CHANGED
data/lib/luca_support/code.rb
CHANGED
@@ -59,18 +59,18 @@ module LucaSupport
|
|
59
59
|
case num
|
60
60
|
when BigDecimal
|
61
61
|
if decimal == 0
|
62
|
-
num.floor.to_s.reverse
|
63
|
-
.gsub
|
62
|
+
num.floor.to_s.reverse!.gsub(/(\d{3})(?=\d)/, '\1 ').reverse!
|
63
|
+
.gsub(/\s/, delimiter)
|
64
64
|
else
|
65
65
|
fragments = num.floor(decimal).to_s('F').split('.')
|
66
|
-
fragments[0].reverse!.gsub!(/(\d{3})(?=\d)/, '\1 ')
|
67
|
-
|
66
|
+
fragments[0].reverse!.gsub!(/(\d{3})(?=\d)/, '\1 ')
|
67
|
+
fragments[0].reverse!.gsub!(/\s/, delimiter)
|
68
68
|
fragments[1].gsub!(/(\d{3})(?=\d)/, '\1 ')
|
69
69
|
fragments.join(LucaSupport::CONFIG['decimal_separator'])
|
70
70
|
end
|
71
71
|
else
|
72
|
-
num.to_s.reverse.gsub
|
73
|
-
.gsub
|
72
|
+
num.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\1 ').reverse!
|
73
|
+
.gsub(/\s/, delimiter)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -187,7 +187,6 @@ module LucaSupport
|
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
190
|
-
#
|
191
190
|
# return current value with effective/defunct on target @date
|
192
191
|
# For multiple attribues, return hash on other than 'val'. Examples are as bellows:
|
193
192
|
#
|
@@ -200,18 +199,23 @@ module LucaSupport
|
|
200
199
|
# point: 1000
|
201
200
|
# => { 'effective' => 2020-1-1, 'rank' => 5, 'point' => 1000 }
|
202
201
|
#
|
202
|
+
# - defunct: 2020-1-1
|
203
|
+
# val: 3000
|
204
|
+
# => nil
|
205
|
+
#
|
203
206
|
def take_current(dat, item)
|
204
|
-
target = dat
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
207
|
+
target = dat&.dig(item)
|
208
|
+
return target unless target.is_a?(Array)
|
209
|
+
|
210
|
+
keys = target.map(&:keys).flatten
|
211
|
+
return target if !keys.include?('effective') && !keys.include?('defunct')
|
212
|
+
|
213
|
+
latest = target
|
214
|
+
.reject { |a| a['defunct'] && Date.parse(a['defunct'].to_s) < @date }
|
215
|
+
.filter { |a| a['effective'] && Date.parse(a['effective'].to_s) < @date }
|
216
|
+
.max { |a, b| Date.parse(a['effective'].to_s) <=> Date.parse(b['effective'].to_s) }
|
217
|
+
|
218
|
+
latest&.dig('val') || latest
|
215
219
|
end
|
216
220
|
|
217
221
|
def has_status?(dat, status)
|
data/lib/luca_support/view.rb
CHANGED
@@ -34,6 +34,10 @@ module LucaSupport
|
|
34
34
|
out
|
35
35
|
end
|
36
36
|
|
37
|
+
# Search existing file and return path under:
|
38
|
+
# 1. 'templates/' in Project directory that data resides
|
39
|
+
# 2. 'templates/' in Library directory that calls LucaSupport::View#search_template
|
40
|
+
#
|
37
41
|
def search_template(file, dir = 'templates')
|
38
42
|
# TODO: load config
|
39
43
|
[LucaSupport::PJDIR, lib_path].each do |base|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lucarecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chuma Takahiro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
|
-
rubygems_version: 3.
|
112
|
+
rubygems_version: 3.2.3
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: ERP File operation framework
|