lucarecord 0.7.3 → 0.7.5

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: 69e3e577310289d8d99054cbfa806d62650fa25263fc3f832381cae085af123e
4
- data.tar.gz: 933a159f84ef1118223297727a028e15db9ca1d82dc40b2410051f05edf44977
3
+ metadata.gz: fc67fbc3655278f3be52dd82f3994560fa72f3f043f272d40c1bd478a04e6126
4
+ data.tar.gz: aaff85cd17e1066344c915326b8626d312ae4add22263e198084979d624750f3
5
5
  SHA512:
6
- metadata.gz: e2bcd328ef856b99970549f9405ea5b0c89f91a5ecfa4877b7304180bd9096f4e5c5595f0fe0b94e5b4ac67e904f830157f5678ce95442e89df7220ad6c52939
7
- data.tar.gz: c2caec75adf8894cb97fcb5eec66474f6235ead40666d214c24471b21e9b89aea9c94898df17e72e8cdbb397f6af0fb5458ac2c926f6297a038fe1de33d6f2ae
6
+ metadata.gz: e801b4ea786880fc442bbdf8c995abf1828f2a3e6ed705b8983178687da605d738dbaed3832c08bb718c7c5f23d4a540f43a55e4bd3cd51a395727ec08755e28
7
+ data.tar.gz: 9367c58a1b4ae9563f91f603f82dfdd9c674b2931cde3677e9d6ac4bc22eb3563e5bc6bf7a9fb4550473d19e319c78f0abe8c77cc1ff8b798848577b4c0fbcb0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## LucaRecord 0.7.5
2
+
3
+ * `LucaSupport::Code.parse_current() / take_current()` now accepts Date object.
4
+
5
+ ## LucaRecord 0.7.4
6
+
7
+ * `LucaSupport::ENC.encrypt() / decrypt()` use env `LUCA_ENC_PASSWORD` for automation.
8
+
1
9
  ## LucaRecord 0.7.3
2
10
 
3
11
  * 'config/' inside the project data dir is now used as a primary configuration dir.
@@ -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.3'
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
@@ -13,8 +13,11 @@ module LucaSupport # :nodoc:
13
13
  # TODO: check space in dir string
14
14
  # TODO: check if origin exists
15
15
  def encrypt(dir, iter: 10000, cleanup: false)
16
+ passopt = ENV['LUCA_ENC_PASSWORD'] ? "-pass pass:#{ENV['LUCA_ENC_PASSWORD']}" : ''
16
17
  Dir.chdir(Pathname(CONST.pjdir) / 'data') do
17
- system "tar -czf - #{dir} | openssl enc -e -aes256 -iter #{iter} -out #{dir}.tar.gz"
18
+ abort "Directory #{dir} not found. exit..." unless Dir.exist?(dir)
19
+
20
+ system "tar czf - #{dir} | openssl enc -e -aes256 -iter #{iter} -out #{dir}.tar.gz #{passopt}"
18
21
  return if ! cleanup
19
22
 
20
23
  FileUtils.rm_rf dir
@@ -23,8 +26,11 @@ module LucaSupport # :nodoc:
23
26
 
24
27
  # TODO: check space in dir string
25
28
  def decrypt(dir, iter: 10000)
29
+ passopt = ENV['LUCA_ENC_PASSWORD'] ? "-pass pass:#{ENV['LUCA_ENC_PASSWORD']}" : ''
26
30
  Dir.chdir(Pathname(CONST.pjdir) / 'data') do
27
- system "openssl enc -d -aes256 -iter #{iter} -in #{dir}.tar.gz | tar xz"
31
+ abort "Archive #{dir}.tar.gz not found. exit..." unless File.exist?("#{dir}.tar.gz")
32
+
33
+ system "openssl enc -d -aes256 -iter #{iter} -in #{dir}.tar.gz #{passopt} | tar xz"
28
34
  end
29
35
  end
30
36
  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.7.3
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-11 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