lucarecord 0.6.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/luca_cmd.rb +18 -0
- data/lib/luca_record/base.rb +0 -2
- data/lib/luca_record/dict.rb +1 -1
- data/lib/luca_record/io.rb +24 -3
- data/lib/luca_record/version.rb +1 -1
- data/lib/luca_record.rb +3 -2
- data/lib/luca_support/code.rb +5 -5
- data/lib/luca_support/const.rb +29 -0
- data/lib/luca_support/enc.rb +2 -2
- data/lib/luca_support/view.rb +1 -1
- data/lib/luca_support.rb +0 -2
- metadata +7 -6
- data/lib/luca_support/config.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75aa7ba67a42741a9b533dcdbd83a52a3a9d4d113b8bdb558d894d39cdab453b
|
4
|
+
data.tar.gz: 1f80272124518bfdf0f8f2461e8e5f24a2d60ca5bffa1c4f06e386b5f5b966d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b18fe1bb5b4094d76330adb36445c673941f4b75987657029c72fb987bbc1b64dd405623bb6b4a1636288c7f3054bf02cdb0e77a1161b761d6b7e5e4510e8663
|
7
|
+
data.tar.gz: 0eb7fda772606eec3019b08fcaccc89c99b17fb9d52169c7c31b529ac70fbd16c18a6b305dc95acc29dfee04f22f14381ee8302b081c4e26d4f3c352c45df87e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## LucaRecord 0.7.1
|
2
|
+
|
3
|
+
* `LucaRecord::IO.load_project()` supports optional `ext_conf:` keyword for an extra config file.
|
4
|
+
|
5
|
+
## LucaRecord 0.7.0
|
6
|
+
|
7
|
+
Reworked global constants to be singleton Class instance:
|
8
|
+
|
9
|
+
* Breaking change: LucaSupport::CONFIG is now LucaSupport::CONST.config
|
10
|
+
* Breaking change: LucaSupport::PJDIR is now LucaSupport::CONST.pjdir
|
11
|
+
* Removed bundler from test suite avoiding casual native build
|
12
|
+
|
1
13
|
## LucaRecord 0.5.6
|
2
14
|
|
3
15
|
* add Nushell render mode: expand(default) | collapse | explore(`less` like)
|
data/lib/luca_cmd.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'luca_record'
|
3
|
+
|
4
|
+
class LucaCmd
|
5
|
+
def self.check_dir(target)
|
6
|
+
unless Dir.exist?('data')
|
7
|
+
Dir.glob('*').reject { |f| File.symlink?(f) }
|
8
|
+
.find { |f| File.directory?("#{f}/data/#{target}") }.tap do |d|
|
9
|
+
abort "No valid data directory, exit..." if d.nil?
|
10
|
+
|
11
|
+
Dir.chdir(d)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
LucaRecord::Base.load_project(Dir.pwd)
|
15
|
+
LucaRecord::Base.valid_project?
|
16
|
+
yield
|
17
|
+
end
|
18
|
+
end
|
data/lib/luca_record/base.rb
CHANGED
data/lib/luca_record/dict.rb
CHANGED
data/lib/luca_record/io.rb
CHANGED
@@ -8,7 +8,7 @@ require 'json'
|
|
8
8
|
require 'yaml'
|
9
9
|
require 'pathname'
|
10
10
|
require 'luca_support/code'
|
11
|
-
require 'luca_support/
|
11
|
+
require 'luca_support/const'
|
12
12
|
|
13
13
|
module LucaRecord # :nodoc:
|
14
14
|
# == IO
|
@@ -292,8 +292,29 @@ module LucaRecord # :nodoc:
|
|
292
292
|
end
|
293
293
|
end
|
294
294
|
|
295
|
+
def load_project(path, ext_conf: nil)
|
296
|
+
CONST.set_pjdir(path)
|
297
|
+
begin
|
298
|
+
config = {
|
299
|
+
'decimal_separator' => '.',
|
300
|
+
'thousands_separator' => ','
|
301
|
+
}.merge(YAML.safe_load(
|
302
|
+
File.read(Pathname(CONST.pjdir) / 'config.yml'),
|
303
|
+
permitted_classes: [Date]
|
304
|
+
))
|
305
|
+
config['decimal_num'] ||= config['country'] == 'jp' ? 0 : 2
|
306
|
+
if ext_conf
|
307
|
+
config.merge(YAML.safe_load(
|
308
|
+
File.read(Pathname(CONST.pjdir) / ext_conf),
|
309
|
+
permitted_classes: [Date]
|
310
|
+
))
|
311
|
+
end
|
312
|
+
CONST.set_config(config)
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
295
316
|
# test if having required dirs/files under exec path
|
296
|
-
def valid_project?(path =
|
317
|
+
def valid_project?(path = CONST.pjdir)
|
297
318
|
project_dir = Pathname(path)
|
298
319
|
FileTest.file?((project_dir + 'config.yml').to_s) and FileTest.directory?( (project_dir + 'data').to_s)
|
299
320
|
end
|
@@ -452,7 +473,7 @@ module LucaRecord # :nodoc:
|
|
452
473
|
|
453
474
|
# TODO: replace with data_dir method
|
454
475
|
def abs_path(base_dir)
|
455
|
-
Pathname(
|
476
|
+
Pathname(CONST.pjdir) / 'data' / base_dir
|
456
477
|
end
|
457
478
|
|
458
479
|
# True when file doesn't have record on code.
|
data/lib/luca_record/version.rb
CHANGED
data/lib/luca_record.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'luca_support'
|
4
|
-
require 'luca_support/config'
|
3
|
+
require 'luca_support/const'
|
5
4
|
require 'luca_record/version'
|
6
5
|
|
7
6
|
module LucaRecord
|
7
|
+
CONST = LucaSupport::CONST
|
8
|
+
|
8
9
|
autoload :Base, 'luca_record/base'
|
9
10
|
autoload :Dict, 'luca_record/dict'
|
10
11
|
end
|
data/lib/luca_support/code.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'date'
|
4
4
|
require 'securerandom'
|
5
5
|
require 'digest/sha1'
|
6
|
-
require 'luca_support/
|
6
|
+
require 'luca_support/const'
|
7
7
|
|
8
8
|
module LucaSupport # :nodoc:
|
9
9
|
# implement Luca IDs convention
|
@@ -55,8 +55,8 @@ module LucaSupport # :nodoc:
|
|
55
55
|
def delimit_num(num, decimal: nil, delimiter: nil)
|
56
56
|
return nil if num.nil?
|
57
57
|
|
58
|
-
decimal ||=
|
59
|
-
delimiter ||=
|
58
|
+
decimal ||= CONST.config['decimal_num']
|
59
|
+
delimiter ||= CONST.config['thousands_separator']
|
60
60
|
case num
|
61
61
|
when BigDecimal
|
62
62
|
if decimal == 0
|
@@ -67,7 +67,7 @@ module LucaSupport # :nodoc:
|
|
67
67
|
fragments[0].reverse!.gsub!(/(\d{3})(?=\d)/, '\1 ')
|
68
68
|
fragments[0].reverse!.gsub!(/\s/, delimiter)
|
69
69
|
fragments[1].gsub!(/(\d{3})(?=\d)/, '\1 ')
|
70
|
-
fragments.join(
|
70
|
+
fragments.join(CONST.config['decimal_separator'])
|
71
71
|
end
|
72
72
|
else
|
73
73
|
num.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\1 ').reverse!
|
@@ -162,7 +162,7 @@ module LucaSupport # :nodoc:
|
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
|
-
def readable(obj, len =
|
165
|
+
def readable(obj, len = CONST.config['decimal_num'])
|
166
166
|
case obj
|
167
167
|
when Array
|
168
168
|
obj.map { |i| readable(i) }
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'singleton'
|
4
|
+
|
5
|
+
module LucaSupport
|
6
|
+
class ConstantHolder
|
7
|
+
include Singleton
|
8
|
+
attr_reader :config, :pjdir
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@pjdir = ENV['LUCA_TEST_DIR']
|
12
|
+
@config = {
|
13
|
+
'decimal_separator' => '.',
|
14
|
+
'decimal_num' => 2,
|
15
|
+
'thousands_separator' => ','
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def set_pjdir(path)
|
20
|
+
@pjdir ||= path
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_config(config)
|
24
|
+
@config = config
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
CONST = ConstantHolder.instance
|
29
|
+
end
|
data/lib/luca_support/enc.rb
CHANGED
@@ -13,7 +13,7 @@ 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
|
-
Dir.chdir(Pathname(
|
16
|
+
Dir.chdir(Pathname(CONST.pjdir) / 'data') do
|
17
17
|
system "tar -czf - #{dir} | openssl enc -e -aes256 -iter #{iter} -out #{dir}.tar.gz"
|
18
18
|
return if ! cleanup
|
19
19
|
|
@@ -23,7 +23,7 @@ module LucaSupport # :nodoc:
|
|
23
23
|
|
24
24
|
# TODO: check space in dir string
|
25
25
|
def decrypt(dir, iter: 10000)
|
26
|
-
Dir.chdir(Pathname(
|
26
|
+
Dir.chdir(Pathname(CONST.pjdir) / 'data') do
|
27
27
|
system "openssl enc -d -aes256 -iter #{iter} -in #{dir}.tar.gz | tar xz"
|
28
28
|
end
|
29
29
|
end
|
data/lib/luca_support/view.rb
CHANGED
@@ -41,7 +41,7 @@ module LucaSupport
|
|
41
41
|
#
|
42
42
|
def search_template(file, dir = 'templates')
|
43
43
|
# TODO: load config
|
44
|
-
[
|
44
|
+
[CONST.pjdir, lib_path].each do |base|
|
45
45
|
path = (Pathname(base) / dir / file)
|
46
46
|
return path.to_path if path.file?
|
47
47
|
end
|
data/lib/luca_support.rb
CHANGED
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.7.1
|
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: 2024-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -63,6 +63,7 @@ extra_rdoc_files: []
|
|
63
63
|
files:
|
64
64
|
- CHANGELOG.md
|
65
65
|
- LICENSE
|
66
|
+
- lib/luca_cmd.rb
|
66
67
|
- lib/luca_record.rb
|
67
68
|
- lib/luca_record/base.rb
|
68
69
|
- lib/luca_record/dict.rb
|
@@ -70,7 +71,7 @@ files:
|
|
70
71
|
- lib/luca_record/version.rb
|
71
72
|
- lib/luca_support.rb
|
72
73
|
- lib/luca_support/code.rb
|
73
|
-
- lib/luca_support/
|
74
|
+
- lib/luca_support/const.rb
|
74
75
|
- lib/luca_support/enc.rb
|
75
76
|
- lib/luca_support/mail.rb
|
76
77
|
- lib/luca_support/range.rb
|
@@ -82,7 +83,7 @@ metadata:
|
|
82
83
|
homepage_uri: https://github.com/chumaltd/luca/tree/master/lucarecord
|
83
84
|
source_code_uri: https://github.com/chumaltd/luca/tree/master/lucarecord
|
84
85
|
changelog_uri: https://github.com/chumaltd/luca/tree/master/lucarecord/CHANGELOG.md
|
85
|
-
post_install_message:
|
86
|
+
post_install_message:
|
86
87
|
rdoc_options: []
|
87
88
|
require_paths:
|
88
89
|
- lib
|
@@ -98,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
99
|
version: '0'
|
99
100
|
requirements: []
|
100
101
|
rubygems_version: 3.4.10
|
101
|
-
signing_key:
|
102
|
+
signing_key:
|
102
103
|
specification_version: 4
|
103
104
|
summary: ERP File operation framework
|
104
105
|
test_files: []
|
data/lib/luca_support/config.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'date'
|
4
|
-
require 'pathname'
|
5
|
-
require 'yaml'
|
6
|
-
|
7
|
-
# startup config
|
8
|
-
#
|
9
|
-
module LucaSupport
|
10
|
-
PJDIR = ENV['LUCA_TEST_DIR'] || Dir.pwd.freeze
|
11
|
-
CONFIG = begin
|
12
|
-
{
|
13
|
-
'decimal_separator' => '.',
|
14
|
-
'thousands_separator' => ','
|
15
|
-
}.merge(YAML.safe_load(File.read(Pathname(PJDIR) / 'config.yml'), permitted_classes: [Date]))
|
16
|
-
rescue Errno::ENOENT
|
17
|
-
{
|
18
|
-
'decimal_separator' => '.',
|
19
|
-
'thousands_separator' => ','
|
20
|
-
}
|
21
|
-
end
|
22
|
-
CONFIG['decimal_num'] ||= CONFIG['country'] == 'jp' ? 0 : 2
|
23
|
-
end
|