lucarecord 0.2.26 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/luca_record/io.rb +21 -23
- data/lib/luca_record/version.rb +1 -1
- data/lib/luca_support/code.rb +3 -2
- data/lib/luca_support/range.rb +35 -0
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ed7b48ed86166e5a300510832dff02e9e51d4fd3184aeaa4b1c73b663845631
|
4
|
+
data.tar.gz: a2b03908af268809a66a08e600994064f5a1bf9cda2610f94f9f849b5d981188
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cefaa9401e153e6cd7f628c8141265b172ca3cec2606294b691a08acc6860c46b76ed60739f1f8ac1e40dc57e8def103d507d5b917fa3713c118bc8e333888e
|
7
|
+
data.tar.gz: b85f03f247270a7d87ab7635bf7e0dc73ecaf0f33af37660ce666d1f287259274c612112f77305f3ad317a823324058290b81d5a19e7e47c947f88d6d598788e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## LucaRecord 0.3.0
|
2
|
+
|
3
|
+
* implement LucaRecord::IO.latest_month
|
4
|
+
|
5
|
+
## LucaRecord 0.2.28
|
6
|
+
|
7
|
+
* implement LucaSupport::Range, handle #by_month enumeration between several months.
|
8
|
+
* @record_type = 'raw' is deprecated in favor of overriding LucaRecord::IO.load_data
|
9
|
+
* change code search from exact match to prefix match
|
10
|
+
|
11
|
+
## LucaRecord 0.2.27
|
12
|
+
|
13
|
+
* Fix: update_digest
|
14
|
+
|
1
15
|
## LucaRecord 0.2.26
|
2
16
|
|
3
17
|
* Support #dig / #search for TSV dictionary
|
data/lib/luca_record/io.rb
CHANGED
@@ -64,11 +64,7 @@ module LucaRecord # :nodoc:
|
|
64
64
|
|
65
65
|
LucaSupport::Code.encode_term(start_year, start_month, end_year, end_month).each do |subdir|
|
66
66
|
open_records(basedir, subdir, nil, code) do |f, path|
|
67
|
-
|
68
|
-
yield f, path
|
69
|
-
else
|
70
|
-
yield load_data(f, path)
|
71
|
-
end
|
67
|
+
yield load_data(f, path)
|
72
68
|
end
|
73
69
|
end
|
74
70
|
end
|
@@ -80,11 +76,7 @@ module LucaRecord # :nodoc:
|
|
80
76
|
|
81
77
|
subdir = year.to_s + LucaSupport::Code.encode_month(month)
|
82
78
|
open_records(basedir, subdir, LucaSupport::Code.encode_date(day), code) do |f, path|
|
83
|
-
|
84
|
-
yield f, path
|
85
|
-
else
|
86
|
-
yield load_data(f, path), path
|
87
|
-
end
|
79
|
+
yield load_data(f, path), path
|
88
80
|
end
|
89
81
|
end
|
90
82
|
|
@@ -98,6 +90,12 @@ module LucaRecord # :nodoc:
|
|
98
90
|
end
|
99
91
|
end
|
100
92
|
|
93
|
+
# [year, month] pair of the latest record
|
94
|
+
#
|
95
|
+
def latest_month(code = nil, basedir = @dirname)
|
96
|
+
LucaSupport::Code.decode_term(Dir.entries(abs_path(basedir)).max)
|
97
|
+
end
|
98
|
+
|
101
99
|
# ----------------------------------------------------------------
|
102
100
|
# :section: Write Methods
|
103
101
|
# <tt>basedir</tt> is set by class instance variable <tt>@dirname</tt>
|
@@ -311,14 +309,14 @@ module LucaRecord # :nodoc:
|
|
311
309
|
File.open(subpath, mode) { |f| yield(f, id_set) }
|
312
310
|
end
|
313
311
|
end
|
312
|
+
end
|
314
313
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
end
|
314
|
+
# Calculate md5sum with original digest, file content and filename(optional).
|
315
|
+
#
|
316
|
+
def update_digest(digest, str, filename = nil)
|
317
|
+
str = filename.nil? ? str : filename + str
|
318
|
+
content = Digest::MD5.new.update(str).hexdigest
|
319
|
+
Digest::MD5.new.update(digest + content).hexdigest
|
322
320
|
end
|
323
321
|
|
324
322
|
# git object like structure
|
@@ -360,9 +358,6 @@ module LucaRecord # :nodoc:
|
|
360
358
|
def load_data(io, path = nil)
|
361
359
|
if @record_type
|
362
360
|
case @record_type
|
363
|
-
when 'raw'
|
364
|
-
# TODO: raw may be unneeded in favor of override
|
365
|
-
io
|
366
361
|
when 'json'
|
367
362
|
# TODO: implement JSON parse
|
368
363
|
end
|
@@ -386,14 +381,17 @@ module LucaRecord # :nodoc:
|
|
386
381
|
Pathname(LucaSupport::PJDIR) / 'data' / base_dir
|
387
382
|
end
|
388
383
|
|
389
|
-
#
|
390
|
-
#
|
384
|
+
# True when file doesn't have record on code.
|
385
|
+
# False when file may have one.
|
386
|
+
# If filename doesn't record codes, always return false,
|
387
|
+
# so later check is required. This is partial optimization.
|
388
|
+
#
|
391
389
|
def skip_on_unmatch_code(subpath, code = nil)
|
392
390
|
# p filename.split('-')[1..-1]
|
393
391
|
filename = subpath.split('/').last
|
394
392
|
return false if code.nil? || filename.length <= 4
|
395
393
|
|
396
|
-
|
394
|
+
filename.split('-')[1..-1].select { |fragment| /^#{code}/.match(fragment) }.empty?
|
397
395
|
end
|
398
396
|
|
399
397
|
# AUTO INCREMENT
|
data/lib/luca_record/version.rb
CHANGED
data/lib/luca_support/code.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LucaSupport # :nodoc:
|
4
|
+
# Partial range operation
|
5
|
+
#
|
6
|
+
module Range
|
7
|
+
def self.included(klass) # :nodoc:
|
8
|
+
klass.extend ClassMethods
|
9
|
+
end
|
10
|
+
|
11
|
+
def by_month(step = nil, from: nil, to: nil)
|
12
|
+
return enum_for(:by_month, step, from: from, to: to) unless block_given?
|
13
|
+
|
14
|
+
from ||= @start_date
|
15
|
+
to ||= @end_date
|
16
|
+
self.class.term_by_month(from, to, step || 1).each do |date|
|
17
|
+
@cursor_start = date
|
18
|
+
@cursor_end = step.nil? ? date : [date.next_month(step - 1), to].min
|
19
|
+
yield @cursor_start, @cursor_end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module ClassMethods
|
24
|
+
def term_by_month(start_date, end_date, step = 1)
|
25
|
+
Enumerator.new do |yielder|
|
26
|
+
each_month = start_date
|
27
|
+
while each_month <= end_date
|
28
|
+
yielder << each_month
|
29
|
+
each_month = each_month.next_month(step)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chuma Takahiro
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
version: 12.3.3
|
69
69
|
description: 'ERP File operation framework
|
70
70
|
|
71
|
-
'
|
71
|
+
'
|
72
72
|
email:
|
73
73
|
- co.chuma@gmail.com
|
74
74
|
executables: []
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- lib/luca_support/code.rb
|
87
87
|
- lib/luca_support/config.rb
|
88
88
|
- lib/luca_support/mail.rb
|
89
|
+
- lib/luca_support/range.rb
|
89
90
|
- lib/luca_support/view.rb
|
90
91
|
homepage: https://github.com/chumaltd/luca/tree/master/lucarecord
|
91
92
|
licenses:
|
@@ -94,7 +95,7 @@ metadata:
|
|
94
95
|
homepage_uri: https://github.com/chumaltd/luca/tree/master/lucarecord
|
95
96
|
source_code_uri: https://github.com/chumaltd/luca/tree/master/lucarecord
|
96
97
|
changelog_uri: https://github.com/chumaltd/luca/tree/master/lucarecord/CHANGELOG.md
|
97
|
-
post_install_message:
|
98
|
+
post_install_message:
|
98
99
|
rdoc_options: []
|
99
100
|
require_paths:
|
100
101
|
- lib
|
@@ -109,8 +110,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
110
|
- !ruby/object:Gem::Version
|
110
111
|
version: '0'
|
111
112
|
requirements: []
|
112
|
-
rubygems_version: 3.2.
|
113
|
-
signing_key:
|
113
|
+
rubygems_version: 3.2.5
|
114
|
+
signing_key:
|
114
115
|
specification_version: 4
|
115
116
|
summary: ERP File operation framework
|
116
117
|
test_files: []
|