lucarecord 0.7.1 → 0.7.3
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 +9 -0
- data/lib/luca_cmd.rb +15 -6
- data/lib/luca_record/io.rb +20 -13
- data/lib/luca_record/version.rb +1 -1
- data/lib/luca_support/const.rb +7 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69e3e577310289d8d99054cbfa806d62650fa25263fc3f832381cae085af123e
|
4
|
+
data.tar.gz: 933a159f84ef1118223297727a028e15db9ca1d82dc40b2410051f05edf44977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2bcd328ef856b99970549f9405ea5b0c89f91a5ecfa4877b7304180bd9096f4e5c5595f0fe0b94e5b4ac67e904f830157f5678ce95442e89df7220ad6c52939
|
7
|
+
data.tar.gz: c2caec75adf8894cb97fcb5eec66474f6235ead40666d214c24471b21e9b89aea9c94898df17e72e8cdbb397f6af0fb5458ac2c926f6297a038fe1de33d6f2ae
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## LucaRecord 0.7.3
|
2
|
+
|
3
|
+
* 'config/' inside the project data dir is now used as a primary configuration dir.
|
4
|
+
* Without config files, it continues to work with warnings instead of aborts.
|
5
|
+
|
6
|
+
## LucaRecord 0.7.2
|
7
|
+
|
8
|
+
* `LucaCmd.check_dir()` accepts optional `ext_conf:` keyword.
|
9
|
+
|
1
10
|
## LucaRecord 0.7.1
|
2
11
|
|
3
12
|
* `LucaRecord::IO.load_project()` supports optional `ext_conf:` keyword for an extra config file.
|
data/lib/luca_cmd.rb
CHANGED
@@ -1,18 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'luca_record'
|
3
|
+
require 'pathname'
|
3
4
|
|
4
5
|
class LucaCmd
|
5
|
-
|
6
|
+
# Search app specific dir from pwd either in direct or monorepo configuration.
|
7
|
+
# 'config/' subdir has priority for consolidating shared config between apps.
|
8
|
+
#
|
9
|
+
def self.check_dir(essential_dir, ext_conf: nil)
|
10
|
+
if Dir.exist?('config')
|
11
|
+
LucaRecord::CONST.set_configdir(Pathname(Dir.pwd) / 'config')
|
12
|
+
end
|
6
13
|
unless Dir.exist?('data')
|
7
14
|
Dir.glob('*').reject { |f| File.symlink?(f) }
|
8
|
-
.find { |f| File.directory?("#{f}/data/#{
|
9
|
-
|
15
|
+
.find { |f| File.directory?("#{f}/data/#{essential_dir}") }.tap do |d|
|
16
|
+
abort "No valid data directory, exit..." if d.nil?
|
10
17
|
|
11
|
-
|
18
|
+
Dir.chdir(d)
|
19
|
+
if Dir.exist?('config')
|
20
|
+
LucaRecord::CONST.set_configdir(Pathname(Dir.pwd) / 'config')
|
12
21
|
end
|
22
|
+
end
|
13
23
|
end
|
14
|
-
LucaRecord::Base.load_project(Dir.pwd)
|
15
|
-
LucaRecord::Base.valid_project?
|
24
|
+
LucaRecord::Base.load_project(Dir.pwd, ext_conf: ext_conf)
|
16
25
|
yield
|
17
26
|
end
|
18
27
|
end
|
data/lib/luca_record/io.rb
CHANGED
@@ -294,29 +294,36 @@ module LucaRecord # :nodoc:
|
|
294
294
|
|
295
295
|
def load_project(path, ext_conf: nil)
|
296
296
|
CONST.set_pjdir(path)
|
297
|
+
config = {
|
298
|
+
'decimal_separator' => '.',
|
299
|
+
'thousands_separator' => ','
|
300
|
+
}
|
297
301
|
begin
|
298
|
-
config
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
config.merge(YAML.safe_load(
|
308
|
-
File.read(Pathname(CONST.
|
302
|
+
config.merge!(YAML.safe_load(
|
303
|
+
File.read(Pathname(CONST.configdir) / 'config.yml'),
|
304
|
+
permitted_classes: [Date]
|
305
|
+
))
|
306
|
+
rescue Errno::ENOENT
|
307
|
+
STDERR.puts "INFO: config.yml not found. Continue with default settings."
|
308
|
+
end
|
309
|
+
if ext_conf
|
310
|
+
begin
|
311
|
+
config.merge!(YAML.safe_load(
|
312
|
+
File.read(Pathname(CONST.configdir) / ext_conf),
|
309
313
|
permitted_classes: [Date]
|
310
314
|
))
|
315
|
+
rescue Errno::ENOENT
|
316
|
+
STDERR.puts "WARN: #{ext_conf} not found. Extended options are not effective."
|
311
317
|
end
|
312
|
-
CONST.set_config(config)
|
313
318
|
end
|
319
|
+
config['decimal_num'] ||= config['country'] == 'jp' ? 0 : 2
|
320
|
+
CONST.set_config(config)
|
314
321
|
end
|
315
322
|
|
316
323
|
# test if having required dirs/files under exec path
|
317
324
|
def valid_project?(path = CONST.pjdir)
|
318
325
|
project_dir = Pathname(path)
|
319
|
-
FileTest.
|
326
|
+
FileTest.directory?( (project_dir / 'data').to_s)
|
320
327
|
end
|
321
328
|
|
322
329
|
def new_record_id(basedir, date_obj)
|
data/lib/luca_record/version.rb
CHANGED
data/lib/luca_support/const.rb
CHANGED
@@ -5,10 +5,11 @@ require 'singleton'
|
|
5
5
|
module LucaSupport
|
6
6
|
class ConstantHolder
|
7
7
|
include Singleton
|
8
|
-
attr_reader :config, :pjdir
|
8
|
+
attr_reader :config, :configdir, :pjdir
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
@pjdir = ENV['LUCA_TEST_DIR']
|
12
|
+
@configdir = ENV['LUCA_TEST_DIR']
|
12
13
|
@config = {
|
13
14
|
'decimal_separator' => '.',
|
14
15
|
'decimal_num' => 2,
|
@@ -18,6 +19,11 @@ module LucaSupport
|
|
18
19
|
|
19
20
|
def set_pjdir(path)
|
20
21
|
@pjdir ||= path
|
22
|
+
@configdir ||= path
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_configdir(path)
|
26
|
+
@configdir = path
|
21
27
|
end
|
22
28
|
|
23
29
|
def set_config(config)
|