flist 0.1.32 → 0.1.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +31 -0
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +68 -49
- data/Gemfile +1 -0
- data/Rakefile +30 -2
- data/bin/setup +2 -0
- data/config/config.yml +14 -0
- data/config/config_sample.yml +15 -0
- data/config/config_yml.sample +15 -0
- data/config/dbsetup.rb +46 -45
- data/db/migrate/010_create_countdatetime.rb +1 -3
- data/db/migrate/020_create_flistz.rb +12 -14
- data/db/migrate/030_create_invalidflistz.rb +3 -4
- data/db/migrate/040_create_currentflistz.rb +4 -6
- data/db/migrate/050_create_dirz.rb +2 -4
- data/db/migrate/060_create_invaliddirz.rb +3 -4
- data/db/migrate/070_create_currentdirz.rb +4 -6
- data/exe/flist +72 -28
- data/lib/dbacrecord.rb +26 -27
- data/lib/flist/cli.rb +24 -5
- data/lib/flist/config.rb +16 -0
- data/lib/flist/csvx.rb +3 -0
- data/lib/flist/dbutil/dbmgr.rb +8 -0
- data/lib/flist/dbutil/dirzmgr.rb +21 -9
- data/lib/flist/dbutil/flistzmgr.rb +13 -1
- data/lib/flist/flist/filelist.rb +47 -45
- data/lib/flist/flist.rb +106 -66
- data/lib/flist/version.rb +1 -1
- data/lib/flist.rb +37 -2
- data/lib/template/config_yml.erb +15 -0
- metadata +8 -7
- data/db/migrate/020_create_dirz.rb +0 -12
- data/db/migrate/030_create_flistz.rb +0 -22
- data/db/migrate/040_create_invalidflistz.rb +0 -12
- data/db/migrate/050_create_currentflistz.rb +0 -15
- data/lib/flist/flist/store.rb +0 -75
data/lib/dbacrecord.rb
CHANGED
@@ -1,37 +1,36 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
module Flist
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
module Dbutil
|
3
|
+
class Count < ActiveRecord::Base
|
4
|
+
has_many :invalidFlistzs
|
5
|
+
has_many :invalidDirzs
|
6
|
+
end
|
9
7
|
|
10
|
-
|
11
|
-
|
8
|
+
class Countdatetime < ActiveRecord::Base
|
9
|
+
end
|
12
10
|
|
13
|
-
|
14
|
-
|
11
|
+
class Flistz < ActiveRecord::Base
|
12
|
+
end
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
class Invalidflistz < ActiveRecord::Base
|
15
|
+
belongs_to :flistz, foreign_key: 'org_id'
|
16
|
+
belongs_to :count, foreign_key: ''
|
17
|
+
end
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
class Currentflistz < ActiveRecord::Base
|
20
|
+
belongs_to :flistz, foreign_key: 'org_id'
|
21
|
+
end
|
24
22
|
|
25
|
-
|
26
|
-
|
23
|
+
class Dirz < ActiveRecord::Base
|
24
|
+
end
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
class Invaliddirz < ActiveRecord::Base
|
27
|
+
belongs_to :dirz, foreign_key: 'org_id'
|
28
|
+
belongs_to :count, foreign_key: ''
|
29
|
+
end
|
32
30
|
|
33
|
-
|
34
|
-
|
35
|
-
end
|
31
|
+
class Currentdirz < ActiveRecord::Base
|
32
|
+
belongs_to :dirz, foreign_key: 'org_id'
|
36
33
|
end
|
34
|
+
|
35
|
+
end
|
37
36
|
end
|
data/lib/flist/cli.rb
CHANGED
@@ -1,18 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Flist
|
4
|
+
# コマンドライン処理クラス
|
4
5
|
class Cli
|
5
6
|
include Ykutils::DebugUtils
|
6
7
|
|
7
|
-
def
|
8
|
+
def initialize(verbose)
|
8
9
|
debug_utils_init
|
9
|
-
set_debug(
|
10
|
+
set_debug(verbose)
|
11
|
+
end
|
12
|
+
|
13
|
+
# 構成情報設定
|
14
|
+
def setup
|
15
|
+
setup_config
|
10
16
|
|
11
17
|
env = ENV.fetch('ENV', nil)
|
12
18
|
# env ||= "development"
|
13
19
|
env ||= 'production'
|
14
20
|
|
15
|
-
|
21
|
+
{
|
16
22
|
'db_dir' => Arxutils_Sqlite3::Config::DB_DIR,
|
17
23
|
'migrate_dir' => Arxutils_Sqlite3::Config::MIGRATE_DIR,
|
18
24
|
'config_dir' => Arxutils_Sqlite3::Config::CONFIG_DIR,
|
@@ -22,9 +28,22 @@ module Flist
|
|
22
28
|
'output_dir' => ::Flist::OUTPUT_DIR,
|
23
29
|
'pstore_dir' => ::Flist::PSTORE_DIR
|
24
30
|
}
|
25
|
-
|
31
|
+
end
|
32
|
+
|
33
|
+
def setup_config
|
34
|
+
scope = {}
|
35
|
+
value_hash = {}
|
36
|
+
content = Ykutils::Erubyx.erubi_render_with_template_file(::Flist::ERB_CONFIG_YAML_FILE, scope, value_hash)
|
37
|
+
File.write(::Flist::SAMPLE_CONFIG_YAML_FILE, content)
|
38
|
+
Ykxutils.yaml_load_compati(content)
|
39
|
+
end
|
26
40
|
|
27
|
-
|
41
|
+
# setting.ymlのロード
|
42
|
+
def load_config_yaml_file
|
43
|
+
# settingファイル
|
44
|
+
config_yaml_file = ::Flist::CONFIG_YAML_FILE
|
45
|
+
config = Ykxutils.yaml_load_compati(config_yaml_file) if config_yaml_file.exist?
|
46
|
+
config
|
28
47
|
end
|
29
48
|
end
|
30
49
|
end
|
data/lib/flist/config.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Flist
|
4
|
+
# 構成情報クラス
|
5
|
+
class Config
|
6
|
+
include Ykutils::DebugUtils
|
7
|
+
|
8
|
+
def setup_config
|
9
|
+
scope = {}
|
10
|
+
value_hash = {}
|
11
|
+
content = Ykutils::Erubyx.erubi_render_with_template_file(ERB_CONFIG_YAML_FILE, scope, value_hash)
|
12
|
+
Ykxutils.yaml_load_comati(content)
|
13
|
+
File.write(SAMPLE_CONFIG_YAML_FILE, content)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/flist/csvx.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Flist
|
4
|
+
# CSV操作用クラス
|
4
5
|
class Csvx
|
5
6
|
attr_reader :headers_s
|
6
7
|
attr_accessor :csv
|
7
8
|
|
9
|
+
# 初期化
|
8
10
|
def initialize(fname)
|
9
11
|
@headers_sym = %i[level kind repo path project comment atime ctime mtime]
|
10
12
|
@headers_s = @headers_sym.map(&:to_s)
|
@@ -19,6 +21,7 @@ module Flist
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
24
|
+
# 終了処理
|
22
25
|
def finish
|
23
26
|
@csv&.close
|
24
27
|
end
|
data/lib/flist/dbutil/dbmgr.rb
CHANGED
@@ -8,6 +8,7 @@ require 'encx'
|
|
8
8
|
|
9
9
|
module Flist
|
10
10
|
module Dbutil
|
11
|
+
# DBマネージャクラス
|
11
12
|
class DbMgr
|
12
13
|
extend Forwardable
|
13
14
|
|
@@ -16,6 +17,7 @@ module Flist
|
|
16
17
|
def_delegator(:@flistzmgr, :add, :flistz_add)
|
17
18
|
def_delegator(:@flistzmgr, :post_process, :flistz_post_process)
|
18
19
|
|
20
|
+
# 初期化
|
19
21
|
def initialize(register_time)
|
20
22
|
# DB接続タイムスタンプ
|
21
23
|
@register_time = register_time
|
@@ -27,6 +29,12 @@ module Flist
|
|
27
29
|
@flistzmgr = FlistzMgr.new(@encx, @db_encoding, @register_time)
|
28
30
|
@dirzmgr = DirzMgr.new(@encx, @db_encoding, @register_time)
|
29
31
|
end
|
32
|
+
|
33
|
+
# 後処理
|
34
|
+
def post_process
|
35
|
+
dirz_post_process
|
36
|
+
flistz_post_process
|
37
|
+
end
|
30
38
|
end
|
31
39
|
end
|
32
40
|
end
|
data/lib/flist/dbutil/dirzmgr.rb
CHANGED
@@ -5,9 +5,11 @@ require 'flist/dbutil/dbmgr'
|
|
5
5
|
|
6
6
|
module Flist
|
7
7
|
module Dbutil
|
8
|
+
# ディレクトリ情報マネージャ
|
8
9
|
class DirzMgr
|
9
10
|
include Ykutils::DebugUtils
|
10
11
|
|
12
|
+
# 初期化
|
11
13
|
def initialize(encx, db_encoding, register_time)
|
12
14
|
# 指定エンコーディングの基づいたパス操作
|
13
15
|
@encx = encx
|
@@ -21,6 +23,8 @@ module Flist
|
|
21
23
|
# DBに登録・更新したファイル情報のハッシュ
|
22
24
|
# キーはファイル情報のobject_id
|
23
25
|
@hs_by_id = {}
|
26
|
+
# DBに登録・更新したディレクトリ情報に対応するパス
|
27
|
+
@set_of_dir_path = Set.new
|
24
28
|
end
|
25
29
|
|
26
30
|
# ディレクトリ情報追加・更新
|
@@ -65,20 +69,28 @@ module Flist
|
|
65
69
|
if dirz
|
66
70
|
@hs_by_path[path] = dirz
|
67
71
|
@hs_by_id[dirz.object_id] = dirz
|
72
|
+
@set_of_dir_path.add(path)
|
68
73
|
end
|
69
74
|
dirz
|
70
75
|
end
|
71
76
|
|
72
|
-
#
|
77
|
+
# 後処理
|
73
78
|
def post_process
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
@set_of_dir_path.each do |path|
|
80
|
+
post_process_for_dir_path(path)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# 後処理(パス指定)
|
85
|
+
def post_process_for_dir_path(path)
|
86
|
+
h_ids = Currentdirz.where(path: path).pluck(:org_id)
|
87
|
+
t_ids = @hs_by_id.keys
|
88
|
+
ids = h_ids - t_ids
|
89
|
+
return unless ids.size.positive?
|
90
|
+
|
91
|
+
ids.each do |idx|
|
92
|
+
Invaliddirz.create(org_id: idx, end_datetime: @register_time)
|
93
|
+
end
|
82
94
|
end
|
83
95
|
end
|
84
96
|
end
|
@@ -5,6 +5,7 @@ require 'flist/dbutil/dbmgr'
|
|
5
5
|
|
6
6
|
module Flist
|
7
7
|
module Dbutil
|
8
|
+
# ファイル情報マネージャ
|
8
9
|
class FlistzMgr
|
9
10
|
include Ykutils::DebugUtils
|
10
11
|
|
@@ -21,6 +22,8 @@ module Flist
|
|
21
22
|
# DBに登録・更新したファイル情報のハッシュ
|
22
23
|
# キーはファイル情報のobject_id
|
23
24
|
@hs_by_id = {}
|
25
|
+
# DBに登録・更新したファイル情報に対応するディレクトリID
|
26
|
+
@set_of_dir_id = Set.new
|
24
27
|
end
|
25
28
|
|
26
29
|
# ファイル情報追加・更新
|
@@ -82,12 +85,21 @@ module Flist
|
|
82
85
|
if flistz
|
83
86
|
@hs_by_path[path] = flistz
|
84
87
|
@hs_by_id[flistz.object_id] = flistz
|
88
|
+
@set_of_dir_id.add(dir_id)
|
85
89
|
end
|
86
90
|
flistz
|
87
91
|
end
|
88
92
|
|
93
|
+
# 後処理
|
94
|
+
def post_process
|
95
|
+
@set_of_dir_id.each do |dir_id|
|
96
|
+
post_process_for_dir_id(dir_id)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# 後処理(ディレクトリID)
|
89
101
|
# DBに登録済データのうち、ハッシュに存在しないデータをInvalidflistzに登録する
|
90
|
-
def
|
102
|
+
def post_process_for_dir_id(dir_id)
|
91
103
|
h_ids = Currentflistz.where(dir_id: dir_id).pluck(:org_id)
|
92
104
|
t_ids = @hs_by_id.keys
|
93
105
|
ids = h_ids - t_ids
|
data/lib/flist/flist/filelist.rb
CHANGED
@@ -4,6 +4,7 @@ require 'ykutils/debugutils'
|
|
4
4
|
|
5
5
|
module Flist
|
6
6
|
class Flist
|
7
|
+
# 詳細ファイルリストクラス
|
7
8
|
class Filelist
|
8
9
|
include Ykutils::DebugUtils
|
9
10
|
|
@@ -40,14 +41,7 @@ module Flist
|
|
40
41
|
|
41
42
|
# 設定ファイルの"topdirhs"で定義されたグループに含まれるサブディレクトリを表すID
|
42
43
|
@dir_id = dir_id
|
43
|
-
unless @dir_id
|
44
|
-
p "invalid @dir_id=#{@dir_id}"
|
45
|
-
exit
|
46
|
-
end
|
47
|
-
# debug_utils_init
|
48
|
-
# set_debug(true)
|
49
|
-
|
50
|
-
# @cur_item = self.class.make_instance_of_item_class
|
44
|
+
raise InvalidDirIdError, "invalid @dir_id=#{@dir_id}" unless @dir_id
|
51
45
|
|
52
46
|
# 全Itemを収めるハッシュ(キーはそのItemを指すパス)
|
53
47
|
@items = {}
|
@@ -121,7 +115,6 @@ module Flist
|
|
121
115
|
else
|
122
116
|
d_puts 'F'
|
123
117
|
end
|
124
|
-
# p ret
|
125
118
|
d_puts "In dot_directory? basename=#{basename}|ret=#{ret}"
|
126
119
|
ret
|
127
120
|
end
|
@@ -170,6 +163,8 @@ module Flist
|
|
170
163
|
end
|
171
164
|
|
172
165
|
def make_fileinfo(path)
|
166
|
+
raise InvalidMakeItemArgsError, "path=#{path}" unless path.instance_of?(String)
|
167
|
+
|
173
168
|
atime = File.atime(path)
|
174
169
|
ctime = File.ctime(path)
|
175
170
|
mtime = File.mtime(path)
|
@@ -177,8 +172,8 @@ module Flist
|
|
177
172
|
# @@fileinfo_class.new( atime , ctime, mtime )
|
178
173
|
end
|
179
174
|
|
180
|
-
def repository_files(kind, level, repo, dir,
|
181
|
-
register_item(kind, level, repo, dir,
|
175
|
+
def repository_files(kind, level, repo, dir, fileinfo, path_s)
|
176
|
+
register_item(kind, level, repo, dir, fileinfo, 1)
|
182
177
|
|
183
178
|
@dirs[path_s] = @encx.make_regexp("^#{path_s}") unless @dirs[path_s]
|
184
179
|
@skip_dirs[path_s] = @encx.make_regexp("^#{path_s}") unless @skip_dirs[path_s]
|
@@ -186,17 +181,25 @@ module Flist
|
|
186
181
|
[repo, dir]
|
187
182
|
end
|
188
183
|
|
189
|
-
def scanx_sub(item, bundle_repo, level, repo)
|
184
|
+
def scanx_sub(item, bundle_repo, level, _level_limit, repo)
|
190
185
|
dir = nil
|
191
186
|
if File.directory?(item)
|
192
187
|
kind = 'D'
|
193
188
|
dir = @encx.convert(@cur_dir)
|
189
|
+
unless item.instance_of?(String)
|
190
|
+
p item
|
191
|
+
raise InvalidSacnxSubArgumentError, "item=#{item}"
|
192
|
+
end
|
194
193
|
x_item = @encx.convert(item)
|
195
194
|
path_s = File.expand_path(File.join(dir, x_item))
|
196
195
|
if repository?(x_item, bundle_repo)
|
197
196
|
# カレントディレクトリの直下にリポジトリが存在すれば、カレントディレクトリをプロジェクトとして登録する。リポジトリ自体は登録しない(管理外とする)。
|
198
197
|
d_puts "REPOSITORY #{dir}|#{path_s}"
|
199
198
|
# return nil
|
199
|
+
unless x_item.instance_of?(String)
|
200
|
+
p x_item
|
201
|
+
raise InvalidSacnxSubArgumentError, "x_item=#{x_item}"
|
202
|
+
end
|
200
203
|
return repository_files(kind, level, x_item, dir, make_fileinfo(x_item), path_s)
|
201
204
|
elsif ignore_directory?(x_item)
|
202
205
|
d_puts "SKIP_DIRECTORY #{x_item}|#{path_s}"
|
@@ -214,9 +217,7 @@ module Flist
|
|
214
217
|
path_s = File.expand_path(File.join(dir, x_item))
|
215
218
|
register_item(kind, level, '', path_s, make_fileinfo(x_item), 0)
|
216
219
|
end
|
217
|
-
|
218
|
-
# p repo
|
219
|
-
# p dir
|
220
|
+
|
220
221
|
[repo, dir]
|
221
222
|
end
|
222
223
|
|
@@ -231,7 +232,9 @@ module Flist
|
|
231
232
|
@skip_dirs[dir] = @encx.make_regexp("^#{abs_dir_path}") unless skip_dirs[dir]
|
232
233
|
end
|
233
234
|
|
234
|
-
def non_skip_files(abs_dir_path, level)
|
235
|
+
def non_skip_files(abs_dir_path, level, level_limit)
|
236
|
+
next_level = level + 1
|
237
|
+
next_level_limit = level_limit - 1
|
235
238
|
Dir.chdir(abs_dir_path) do
|
236
239
|
d_puts "non_skip_files chdir #{abs_dir_path}"
|
237
240
|
repo = nil
|
@@ -239,26 +242,30 @@ module Flist
|
|
239
242
|
@cur_dir = Dir.getwd
|
240
243
|
bundle_repo = bundle_repository
|
241
244
|
|
242
|
-
|
243
|
-
|
245
|
+
if next_level_limit <= 0
|
246
|
+
Dir.foreach('.') do |x|
|
247
|
+
next if ['.', '..'].include?(x)
|
244
248
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
249
|
+
# d_puts "scanx x=#{x}"
|
250
|
+
# d_puts "=========#{x.encoding}"
|
251
|
+
# d_puts "@cur_dir=#{@cur_dir}"
|
252
|
+
x_str = @encx.convert(x)
|
253
|
+
repo, dir = scanx_sub(x_str, bundle_repo, next_level, next_level_limit, repo)
|
254
|
+
dirs << dir if dir
|
255
|
+
end
|
256
|
+
unless repo.nil?
|
257
|
+
dirs.each do |d|
|
258
|
+
scanx(d, next_level, next_level_limit)
|
259
|
+
end
|
255
260
|
end
|
256
261
|
end
|
257
262
|
end
|
258
263
|
end
|
259
264
|
|
260
|
-
def scanx(abs_dir_path, level)
|
261
|
-
d_puts "######### scanx abs_dir_path=#{abs_dir_path}"
|
265
|
+
def scanx(abs_dir_path, level, level_limit)
|
266
|
+
d_puts "######### scanx abs_dir_path=#{abs_dir_path} level=#{level} level_limit=#{level_limit}"
|
267
|
+
next_level = level + 1
|
268
|
+
next_level_limit = level_limit - 1
|
262
269
|
# d_puts "=scanx====#{Dir.pwd}"
|
263
270
|
# d_puts "abs_dir_path=#{abs_dir_path}"
|
264
271
|
# d_puts "abs_dir_path.encoding=#{abs_dir_path.encoding}"
|
@@ -268,8 +275,10 @@ module Flist
|
|
268
275
|
if project_directory?(abs_dir_path)
|
269
276
|
project_directory_files
|
270
277
|
else
|
278
|
+
return if next_level_limit <= 0
|
279
|
+
|
271
280
|
# スッキプすべきとして登録されたディレクトリまたは、そのサブディレクトリであれば、スキップする
|
272
|
-
non_skip_files(abs_dir_path,
|
281
|
+
non_skip_files(abs_dir_path, next_level, next_level_limit) unless need_skip?(abs_dir_path)
|
273
282
|
end
|
274
283
|
end
|
275
284
|
|
@@ -290,7 +299,10 @@ module Flist
|
|
290
299
|
@cur_dir = Dir.getwd
|
291
300
|
end
|
292
301
|
d_puts "scan @cur_dir=#{@cur_dir} call scanx @top_dir=#{@top_dir}"
|
293
|
-
|
302
|
+
next_level = 0
|
303
|
+
next_level_limit = 2
|
304
|
+
scanx(@top_dir, next_level, next_level_limit)
|
305
|
+
|
294
306
|
d_puts '########## scan End'
|
295
307
|
end
|
296
308
|
|
@@ -317,19 +329,9 @@ module Flist
|
|
317
329
|
d_puts "ctime=#{v.ctime}"
|
318
330
|
d_puts "mtime=#{v.mtime}"
|
319
331
|
d_puts '#### Flilelist End'
|
320
|
-
unless @dir_id
|
321
|
-
|
322
|
-
|
323
|
-
end
|
324
|
-
unless v.repo
|
325
|
-
puts "invalid v.repo=#{v.repo}"
|
326
|
-
exit
|
327
|
-
end
|
328
|
-
|
329
|
-
unless v.comment
|
330
|
-
puts "invalid v.comment=#{v.comment}"
|
331
|
-
exit
|
332
|
-
end
|
332
|
+
raise InvalidDirIdError, "invalid @dir_id=#{@dir_id}" unless @dir_id
|
333
|
+
raise InvalidRepoError, "invalid v.repo=#{v.repo}" unless v.repo
|
334
|
+
raise InvalidCommitError, "invalid v.comment=#{v.comment}" unless v.comment
|
333
335
|
|
334
336
|
@dbmgr.flistz_add(@dir_id, v.level, v.kind, v.repo, v.path, v.project,
|
335
337
|
v.desc, v.comment, v.atime, v.ctime, v.mtime)
|