lucarecord 0.2.27 → 0.2.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/luca_record/io.rb +8 -16
- 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 +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c52d38b86c9670e3358ef9e94553902a3a511f626689566a4dc0b1d5e480c041
|
4
|
+
data.tar.gz: 064b974bbeeaa1dbb8e644532c5e2bee67cdd5d697e1cdde99087204698aa665
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20ece81a5471e985bdc6b46aa341b3d859ad050b28a5976b0b20f15a44971ac0111b16a58db1053c91da73d91f8c37dc26e6bd825b4604a3c17ced65239a19b2
|
7
|
+
data.tar.gz: fc4af325295583e739fb972f3d96470f0a84d74ea4a4b330a16178d88de0c4700f64b28f36166539904c3b589c7540ec4486e36e74d6fd0d1e908da22e4cc685
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## LucaRecord 0.2.28
|
2
|
+
|
3
|
+
* implement LucaSupport::Range, handle #by_month enumeration between several months.
|
4
|
+
* @record_type = 'raw' is deprecated in favor of overriding LucaRecord::IO.load_data
|
5
|
+
* change code search from exact match to prefix match
|
6
|
+
|
7
|
+
## LucaRecord 0.2.27
|
8
|
+
|
9
|
+
* Fix: update_digest
|
10
|
+
|
1
11
|
## LucaRecord 0.2.26
|
2
12
|
|
3
13
|
* 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
|
|
@@ -360,9 +352,6 @@ module LucaRecord # :nodoc:
|
|
360
352
|
def load_data(io, path = nil)
|
361
353
|
if @record_type
|
362
354
|
case @record_type
|
363
|
-
when 'raw'
|
364
|
-
# TODO: raw may be unneeded in favor of override
|
365
|
-
io
|
366
355
|
when 'json'
|
367
356
|
# TODO: implement JSON parse
|
368
357
|
end
|
@@ -386,14 +375,17 @@ module LucaRecord # :nodoc:
|
|
386
375
|
Pathname(LucaSupport::PJDIR) / 'data' / base_dir
|
387
376
|
end
|
388
377
|
|
389
|
-
#
|
390
|
-
#
|
378
|
+
# True when file doesn't have record on code.
|
379
|
+
# False when file may have one.
|
380
|
+
# If filename doesn't record codes, always return false,
|
381
|
+
# so later check is required. This is partial optimization.
|
382
|
+
#
|
391
383
|
def skip_on_unmatch_code(subpath, code = nil)
|
392
384
|
# p filename.split('-')[1..-1]
|
393
385
|
filename = subpath.split('/').last
|
394
386
|
return false if code.nil? || filename.length <= 4
|
395
387
|
|
396
|
-
|
388
|
+
filename.split('-')[1..-1].select { |fragment| /^#{code}/.match(fragment) }.empty?
|
397
389
|
end
|
398
390
|
|
399
391
|
# 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.2.
|
4
|
+
version: 0.2.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chuma Takahiro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -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:
|