lucarecord 0.7.4 → 0.7.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab8d42ca9b608b1523b0cf5cdf85ace0795c2852c0e7abb840c7ab63c6cf10d8
4
- data.tar.gz: 7fbd74937cbcacf501a5be5296eaa586162a3646817cd46d6f973fe6740db93e
3
+ metadata.gz: fc67fbc3655278f3be52dd82f3994560fa72f3f043f272d40c1bd478a04e6126
4
+ data.tar.gz: aaff85cd17e1066344c915326b8626d312ae4add22263e198084979d624750f3
5
5
  SHA512:
6
- metadata.gz: cef169faf34676d409b44d1b40ac5ae671f9e53ff0f4900ce42734a04ba98573ae906eb51cd95798bed89e2d74a4c5189e032b60ae390fdb442130572451278d
7
- data.tar.gz: 61b8f6864ae81c2f7b90540e019be72f3be41b835274cca6fe84c9014d00126167b8d7d5b7fb08aa445fc5562fd4edf61a3fe359218d1e24b1a72b17133a9b3d
6
+ metadata.gz: e801b4ea786880fc442bbdf8c995abf1828f2a3e6ed705b8983178687da605d738dbaed3832c08bb718c7c5f23d4a540f43a55e4bd3cd51a395727ec08755e28
7
+ data.tar.gz: 9367c58a1b4ae9563f91f603f82dfdd9c674b2931cde3677e9d6ac4bc22eb3563e5bc6bf7a9fb4550473d19e319c78f0abe8c77cc1ff8b798848577b4c0fbcb0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## LucaRecord 0.7.5
2
+
3
+ * `LucaSupport::Code.parse_current() / take_current()` now accepts Date object.
4
+
1
5
  ## LucaRecord 0.7.4
2
6
 
3
7
  * `LucaSupport::ENC.encrypt() / decrypt()` use env `LUCA_ENC_PASSWORD` for automation.
@@ -78,7 +78,7 @@ module LucaRecord
78
78
  end
79
79
  end
80
80
 
81
- # generate dictionary from TSV file. Minimum assumption is as bellows:
81
+ # generate dictionary from TSV file. Minimum assumption is:
82
82
  # 1st row is converted symbol.
83
83
  #
84
84
  # * row[0] is 'code'. Converted hash keys
@@ -372,7 +372,7 @@ module LucaRecord # :nodoc:
372
372
  # '2020': All month of 2020
373
373
  # '2020[FG]': June & July of 2020
374
374
  #
375
- # Block will receive code fragments as 2nd parameter. Array format is as bellows:
375
+ # Block will receive code fragments as 2nd parameter. Array format is:
376
376
  # 1. encoded month
377
377
  # 2. encoded day + record number of the day
378
378
  # 3. codes. More than 3 are all code set except first 2 parameters.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LucaRecord
4
- VERSION = '0.7.4'
4
+ VERSION = '0.7.5'
5
5
  end
@@ -183,14 +183,14 @@ module LucaSupport # :nodoc:
183
183
  # convert effective/defunct data into current hash on @date.
184
184
  # not parse nested children.
185
185
  #
186
- def parse_current(dat)
186
+ def parse_current(dat, date = @date)
187
187
  {}.tap do |processed|
188
- dat.each { |k, _v| processed[k] = take_current(dat, k) }
188
+ dat.each { |k, _v| processed[k] = take_current(dat, k, date) }
189
189
  end
190
190
  end
191
191
 
192
192
  # return current value with effective/defunct on target @date
193
- # For multiple attribues, return hash on other than 'val'. Examples are as bellows:
193
+ # For multiple attribues, return hash on other than 'val'. Examples:
194
194
  #
195
195
  # - effective: 2020-1-1
196
196
  # val: 3000
@@ -205,7 +205,7 @@ module LucaSupport # :nodoc:
205
205
  # val: 3000
206
206
  # => nil
207
207
  #
208
- def take_current(dat, item)
208
+ def take_current(dat, item, date = @date)
209
209
  target = dat&.dig(item)
210
210
  return target unless target.is_a?(Array)
211
211
 
@@ -213,8 +213,8 @@ module LucaSupport # :nodoc:
213
213
  return target if !keys.include?('effective') && !keys.include?('defunct')
214
214
 
215
215
  latest = target
216
- .reject { |a| a['defunct'] && Date.parse(a['defunct'].to_s) < @date }
217
- .filter { |a| a['effective'] && Date.parse(a['effective'].to_s) < @date }
216
+ .reject { |a| a['defunct'] && Date.parse(a['defunct'].to_s) < date }
217
+ .filter { |a| a['effective'] && Date.parse(a['effective'].to_s) < date }
218
218
  .max { |a, b| Date.parse(a['effective'].to_s) <=> Date.parse(b['effective'].to_s) }
219
219
 
220
220
  latest&.dig('val') || latest
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.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chuma Takahiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-13 00:00:00.000000000 Z
11
+ date: 2024-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler