lucarecord 0.2.14 → 0.2.15

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: 1b2e7e80da19b8c0adaebc6272a05e26f66c2e6a989fa416bfd77951ac5f88a0
4
- data.tar.gz: 699708346c68e5fa32105eec0d8a82aae8fd85c452f005a402f80a9ff7b19b95
3
+ metadata.gz: 3d7ac838f340b86b71208f40357ebbe7c4217b1ed6b69dcf012b773d8fa0a532
4
+ data.tar.gz: c0e706fe9e1eef4abbb5d9600a5100931cd9384d45459481142fb3c594dbfd32
5
5
  SHA512:
6
- metadata.gz: 59217fdab9258c37ceab07e35118961ae3ac6d6d1587f84235b31169dacf8a82f968a2e8b00f0710c0f7e587836d7d4834f4bf8d2f51e5fbd6f30d1a3100ea7b
7
- data.tar.gz: edbc54ec5c66e422a6975c8e53a33b32a063304d5c582ebf4f22596151d141de7d90404eaff8cdd7e8b10264f195da67803ba48a2e4426c6629d995f6cc03507
6
+ metadata.gz: 56f2f5575afb0a5e204a94ed66fa7b6ded3831316e9d71be17a02270f464b57551701c3938a447f479a4512255800d49bdc545e8f970f8d81f00c1be8caf5316
7
+ data.tar.gz: be5bf831649fb6d6ad74ca44ae18c9cbb4eabf26193926979776fb99f843c687a8dead90917dafeaa3e9289c2ec8eb83e78a2082fad50305df1f4b8bcaab96a9
@@ -1,4 +1,7 @@
1
1
  # frozen_string_literal: true
2
+
3
+ require 'luca_support'
4
+ require 'luca_support/config'
2
5
  require 'luca_record/version'
3
6
 
4
7
  module LucaRecord
@@ -14,8 +14,8 @@ module LucaRecord
14
14
  include LucaSupport::Code
15
15
 
16
16
  def initialize(file = @filename)
17
- @path = file
18
- #@path = dict_path(file)
17
+ #@path = file
18
+ @path = self.class.dict_path(file)
19
19
  set_driver
20
20
  end
21
21
 
@@ -20,12 +20,12 @@ module LucaRecord # :nodoc:
20
20
  end
21
21
 
22
22
  module ClassMethods
23
- #-----------------------------------------------------------------
23
+ # ----------------------------------------------------------------
24
24
  # :section: Query Methods
25
25
  # Provide sematic search interfaces.
26
26
  # <tt>basedir</tt> is set by class instance variable <tt>@dirname</tt>
27
27
  # of each concrete class.
28
- #-----------------------------------------------------------------
28
+ # ----------------------------------------------------------------
29
29
 
30
30
  # find ID based record. Support uuid and encoded date.
31
31
  def find(id, basedir = @dirname)
@@ -78,16 +78,16 @@ module LucaRecord # :nodoc:
78
78
  def all(basedir = @dirname)
79
79
  return enum_for(:all, basedir) unless block_given?
80
80
 
81
- open_all(basedir) do |f|
81
+ open_all(basedir) do |f|
82
82
  yield load_data(f)
83
83
  end
84
84
  end
85
85
 
86
- #-----------------------------------------------------------------
86
+ # ----------------------------------------------------------------
87
87
  # :section: Write Methods
88
88
  # <tt>basedir</tt> is set by class instance variable <tt>@dirname</tt>
89
89
  # of each concrete class.
90
- #-----------------------------------------------------------------
90
+ # ----------------------------------------------------------------
91
91
 
92
92
  # create hash based record
93
93
  def create(obj, basedir = @dirname)
@@ -114,29 +114,40 @@ module LucaRecord # :nodoc:
114
114
 
115
115
  def add_status!(id, status, basedir = @dirname)
116
116
  path = abs_path(basedir) / id2path(id)
117
- origin = YAML.load_file(path, {})
117
+ origin = YAML.load_file(path, **{})
118
118
  newline = { status => DateTime.now.to_s }
119
119
  origin['status'] = [] if origin['status'].nil?
120
120
  origin['status'] << newline
121
121
  File.write(path, YAML.dump(origin.sort.to_h))
122
122
  end
123
123
 
124
- #-----------------------------------------------------------------
124
+ # ----------------------------------------------------------------
125
125
  # :section: Path Utilities
126
- #-----------------------------------------------------------------
126
+ # ----------------------------------------------------------------
127
127
 
128
- # convert ID to file path. Normal argument is as follows:
128
+ # Convert ID to file directory/filename path.
129
+ # 1st element of Array is used as directory, the others as filename.
130
+ # String without '/' is converted as git-like structure.
131
+ # Normal argument is as follows:
129
132
  #
130
- # [2020H, V001]
131
- # "2020H/V001"
132
- # "a7b806d04a044c6dbc4ce72932867719"
133
+ # ['2020H', 'V001', 'a7b806d04a044c6dbc4ce72932867719']
134
+ # => '2020H/V001-a7b806d04a044c6dbc4ce72932867719'
135
+ # 'a7b806d04a044c6dbc4ce72932867719'
136
+ # => 'a7b/806d04a044c6dbc4ce72932867719'
137
+ # '2020H/V001'
138
+ # => '2020H/V001'
133
139
  def id2path(id)
134
140
  if id.is_a?(Array)
135
- id.join('/')
141
+ case id.length
142
+ when 0..2
143
+ id.join('/')
144
+ else
145
+ [id[0], id[1..-1].join('-')].join('/')
146
+ end
136
147
  elsif id.include?('/')
137
148
  id
138
149
  else
139
- encode_hashed_path(id)
150
+ encode_hashed_path(id).join('/')
140
151
  end
141
152
  end
142
153
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LucaRecord
4
- VERSION = '0.2.14'
4
+ VERSION = '0.2.15'
5
5
  end
@@ -12,7 +12,7 @@ module LucaSupport
12
12
  def encode_txid(num)
13
13
  txmap = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
14
14
  l = txmap.length
15
- txmap[num / (l**2)] + txmap[(num%(l**2)) / l] + txmap[num % l]
15
+ txmap[num / (l**2)] + txmap[(num % (l**2)) / l] + txmap[num % l]
16
16
  end
17
17
 
18
18
  def decode_txid(id)
@@ -73,7 +73,8 @@ module LucaSupport
73
73
  end
74
74
 
75
75
  #
76
- # convert effective/defunct data into current hash on @date
76
+ # convert effective/defunct data into current hash on @date.
77
+ # not parse nested children.
77
78
  #
78
79
  def parse_current(dat)
79
80
  {}.tap do |processed|
@@ -92,7 +93,7 @@ module LucaSupport
92
93
  # - effective: 2020-1-1
93
94
  # rank: 5
94
95
  # point: 1000
95
- # => { 'effective' => 2020-1-1, 'rank' => 5, '' => 'point' => 1000 }
96
+ # => { 'effective' => 2020-1-1, 'rank' => 5, 'point' => 1000 }
96
97
  #
97
98
  def take_current(dat, item)
98
99
  target = dat.dig(item)
@@ -6,6 +6,6 @@
6
6
  module LucaSupport
7
7
  module Config
8
8
  # Project top directory.
9
- Pjdir = Dir.pwd.freeze
9
+ Pjdir = ENV['LUCA_TEST_DIR'] || Dir.pwd.freeze
10
10
  end
11
11
  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.14
4
+ version: 0.2.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chuma Takahiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-07 00:00:00.000000000 Z
11
+ date: 2020-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
@@ -28,44 +28,44 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.17'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.17'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 12.3.3
47
+ version: '5.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 12.3.3
54
+ version: '5.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: minitest
56
+ name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '5.0'
61
+ version: 12.3.3
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '5.0'
68
+ version: 12.3.3
69
69
  description: 'ERP File operation framework
70
70
 
71
71
  '