flist 0.1.30 → 0.1.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +5 -0
  3. data/.rubocop.yml +9 -0
  4. data/.rubocop_todo.yml +110 -0
  5. data/Gemfile +21 -0
  6. data/Rakefile +22 -3
  7. data/SECURITY.md +21 -0
  8. data/bin/console +4 -3
  9. data/config/.gitkeep +0 -0
  10. data/config/db_scheme.yml +71 -0
  11. data/config/db_scheme.yml.sample +48 -0
  12. data/config/dbsetup.rb +55 -0
  13. data/config/opts.rb +9 -0
  14. data/config/opts.rb.sample +7 -0
  15. data/config/setting.yml +2 -0
  16. data/config/sqlite3.yml +26 -0
  17. data/config/tmp/db_scheme.yml +71 -0
  18. data/db/migrate/010_create_countdatetime.rb +13 -0
  19. data/db/migrate/020_create_dirz.rb +12 -0
  20. data/db/migrate/020_create_flistz.rb +24 -0
  21. data/db/migrate/030_create_flistz.rb +22 -0
  22. data/db/migrate/030_create_invalidflistz.rb +14 -0
  23. data/db/migrate/040_create_currentflistz.rb +17 -0
  24. data/db/migrate/040_create_invalidflistz.rb +12 -0
  25. data/db/migrate/050_create_currentflistz.rb +15 -0
  26. data/db/migrate/050_create_dirz.rb +14 -0
  27. data/db/migrate/060_create_invaliddirz.rb +14 -0
  28. data/db/migrate/070_create_currentdirz.rb +17 -0
  29. data/exe/flist +36 -27
  30. data/flist.gemspec +33 -20
  31. data/lib/dbacrecord.rb +37 -0
  32. data/lib/flist/cli.rb +30 -0
  33. data/lib/flist/csvx.rb +26 -0
  34. data/lib/flist/dbutil/dbmgr.rb +17 -24
  35. data/lib/flist/dbutil/dirzmgr.rb +63 -12
  36. data/lib/flist/dbutil/flistzmgr.rb +69 -34
  37. data/lib/flist/dbutil.rb +4 -4
  38. data/lib/flist/flist/filelist.rb +217 -168
  39. data/lib/flist/flist/store.rb +29 -33
  40. data/lib/flist/flist.rb +239 -98
  41. data/lib/flist/version.rb +3 -1
  42. data/lib/flist.rb +16 -5
  43. metadata +126 -32
  44. data/exe/makemigrate +0 -52
@@ -1,4 +1,5 @@
1
- # -*- coding: utf-8 -*-
1
+ # frozen_string_literal: true
2
+
2
3
  require 'ykutils/debugutils'
3
4
 
4
5
  module Flist
@@ -6,70 +7,76 @@ module Flist
6
7
  class Filelist
7
8
  include Ykutils::DebugUtils
8
9
 
9
- def initialize( encx , skip_dirs = {} , store = nil , dir_id = 0, top_dir = "" , top_level = 0 , mode = "" )
10
+ @fileinfo_class = Struct.new(:atime, :ctime, :mtime)
11
+ @item_class = Struct.new(:level, :kind, :repo, :path, :path_conv, :project,
12
+ :desc, :comment, :atime, :ctime, :mtime)
13
+
14
+ def self.make_instance_of_fileinfo_class(atime, ctime, mtime)
15
+ @fileinfo_class.new(atime, ctime, mtime)
16
+ end
17
+
18
+ def self.make_instance_of_item_class(level = nil, kind = nil, repo = nil, path = nil,
19
+ path_conv = nil, project = nil, desc = nil,
20
+ comment = nil,
21
+ atime = nil, ctime = nil, mtime = nil)
22
+ @item_class.new(level, kind, repo, path, path_conv, project, desc,
23
+ comment, atime, ctime, mtime)
24
+ end
25
+
26
+ def initialize(dbmgr, csvx, encx, skip_dirs = {}, dir_id = 0, top_dir = '',
27
+ top_level = 0, mode = '')
28
+ @dbmgr = dbmgr
29
+ @csvx = csvx
10
30
  @encx = encx
11
- @store = store
12
31
  @skip_dirs = skip_dirs
13
32
 
14
- @hs = {}
15
- @hs[:dot_directory] = @encx.make_regexp( '^(\.|_).+' )
16
- @hs[:node_repository] = @encx.make_regexp( '[^_]_packages' )
17
- @hs[:node_modules] = @encx.make_regexp( 'node_modules|bower_modules' )
18
- @hs[:temp] = @encx.make_regexp( 'te?mp' , Regexp::IGNORECASE )
19
- @hs[:cvs] = @encx.make_regexp( 'cvs' , Regexp::IGNORECASE )
33
+ # パス名判別用正規表現
34
+ @hash = {}
35
+ @hash[:dot_directory] = @encx.make_regexp('^(\.|_).+')
36
+ @hash[:node_repository] = @encx.make_regexp('[^_]_packages')
37
+ @hash[:node_modules] = @encx.make_regexp('node_modules|bower_modules')
38
+ @hash[:temp] = @encx.make_regexp('te?mp', Regexp::IGNORECASE)
39
+ @hash[:cvs] = @encx.make_regexp('cvs', Regexp::IGNORECASE)
20
40
 
41
+ # 設定ファイルの"topdirhs"で定義されたグループに含まれるサブディレクトリを表すID
21
42
  @dir_id = dir_id
22
- debug_utils_init
23
- set_debug(true)
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
24
51
 
25
- @@fileinfo_class ||= Struct.new("Fileinfo" , :atime, :ctime, :mtime )
26
- @@item_class ||= Struct.new("Itemfi" , :level , :kind, :repo, :path , :path_conv, :project, :comment , :atime, :ctime, :mtime )
27
- @cur_item = @@item_class.new
52
+ # 全Itemを収めるハッシュ(キーはそのItemを指すパス)
28
53
  @items = {}
54
+ # Itemのうち、ディレクトリを収めるハッシュ(キーはそのItemを指すパス)
29
55
  @dirs = {}
56
+ # Itemのうち、ファイルを収めるハッシュ(キーはそのItemを指すパス)
30
57
  @files = {}
31
58
 
59
+ # このFilelistのトップディレクトリ(トップディレクトリより下位のディレクトリ、ファイルの情報を持つ)
32
60
  @top_dir = top_dir
61
+ # このFilelistのトップディレクトリの階層の深さ
33
62
  @top_level = top_level
34
63
  @mode = mode
35
- @headers_sym = [:level , :kind, :repo, :path , :project, :comment , :atime, :ctime, :mtime]
36
- @items = {}
37
- @headers_s = @headers_sym.map{ |x| x.to_s }
38
64
  end
39
65
 
40
66
  def need_skip?(path_s)
41
67
  ret = nil
42
- if @skip_dirs
43
- ret = @skip_dirs.keys.find { |x| @encx.compare( path_s , x ) }
44
- end
45
- ret != nil
46
- =begin
47
- d_puts "need_skip? path_s=#{path_s}"
48
- ret = false
49
- if @skip_dirs
50
- # p "=@skip_dirs="
51
- # @skip_dirs.each do |x| puts x end
52
- @skip_dirs.each do |k,v|
53
- # p v
54
- puts "# need_skip?"
55
- ret = @encx.compare( path_s , v)
56
- if ret
57
- break
58
- end
59
- end
60
- end
61
- d_puts "need_skip? ret=#{ret}"
62
-
63
- ret
64
- =end
68
+ ret = @skip_dirs.keys.find { |x| @encx.compare(path_s, x) } if @skip_dirs
69
+ ret_value = !ret.nil?
70
+ d_puts "need_skip? path_s=#{path_s}|ret_value=#{ret_value}"
71
+ ret_value
65
72
  end
66
73
 
67
- def time2datetime_utc( time )
74
+ def time2datetime_utc(time)
68
75
  # UTC
69
- datetiem = DateTime.new( time.year, time.month, time.day, time.hour, time.min, time.sec , time.utc_offset )
76
+ DateTime.new(time.year, time.month, time.day, time.hour, time.min, time.sec, time.utc_offset)
70
77
  end
71
78
 
72
- def update_item(kind, level, repo, path, project = 0)
79
+ def update_item(kind, level, repo, path, _project = 0)
73
80
  @items[path].kind = kind
74
81
  @items[path].level = level
75
82
  @items[path].repo = repo
@@ -77,95 +84,88 @@ module Flist
77
84
  @items[path].project = preoject
78
85
  end
79
86
 
87
+ # ハッシュ@itemsにpathをキーに登録する
80
88
  def register_item(kind, level, repo, path, fileinfo, project = 0)
81
- d_puts "register_item"
89
+ d_puts 'register_item'
82
90
  d_puts "path=#{path}"
83
- @cur_item.kind = kind
84
- @cur_item.level = level
85
- @cur_item.repo = repo
86
- @cur_item.path_conv = @encx.convert(path)
87
- @cur_item.path = path
88
- @cur_item.project = project
89
- @cur_item.comment = ""
90
- @cur_item.atime = time2datetime_utc( fileinfo.atime )
91
- @cur_item.ctime = time2datetime_utc( fileinfo.ctime )
92
- @cur_item.mtime = time2datetime_utc( fileinfo.mtime )
93
-
94
- @items[path] = @cur_item
95
- @cur_item = @@item_class.new
91
+ cur_item = self.class.make_instance_of_item_class
92
+ # @cur_item = @@item_class.new
93
+ cur_item.kind = kind
94
+ cur_item.level = level
95
+ cur_item.repo = repo
96
+ cur_item.path_conv = @encx.convert(path)
97
+ cur_item.path = path
98
+ cur_item.project = project
99
+ cur_item.comment = ''
100
+ cur_item.atime = time2datetime_utc(fileinfo.atime)
101
+ cur_item.ctime = time2datetime_utc(fileinfo.ctime)
102
+ cur_item.mtime = time2datetime_utc(fileinfo.mtime)
103
+
104
+ @items[path] = cur_item
96
105
  end
97
106
 
98
107
  def get_config(path)
99
- alist = File.open(path){ |f|
100
- f.readlines.select{ |x| x !~ /^-/ }.collect{ |x|
108
+ alist = File.open(path) do |f|
109
+ f.readlines.grep_v(/^-/).collect do |x|
101
110
  x.chomp.split(/:/)
102
- }
103
- }
111
+ end
112
+ end
104
113
  Hash[*alist.flatten(1)]
105
114
  end
106
115
 
107
116
  def dot_directory?(basename)
108
- d_puts "In dot_directory? path=#{basename}"
109
- puts "# dot_directory?"
110
- ret = @encx.compare(basename , @hs[:dot_directory])
117
+ d_puts "In dot_directory? basename=#{basename}"
118
+ ret = @encx.compare(basename, @hash[:dot_directory])
111
119
  if ret
112
120
  d_puts 'T'
113
121
  else
114
122
  d_puts 'F'
115
123
  end
116
- p ret
124
+ # p ret
125
+ d_puts "In dot_directory? basename=#{basename}|ret=#{ret}"
117
126
  ret
118
127
  end
119
128
 
120
129
  def node_repository?(basename)
121
130
  d_puts "In node_repository? path=#{basename}"
122
- puts "# need_repository? 1"
123
- ret = @encx.compare( basename , @hs[:node_modules] )
131
+ ret = @encx.compare(basename, @hash[:node_modules])
124
132
  unless ret
125
- puts "# need_repository? 2"
126
- ret = @encx.compare(basename , @hs[:node_repository])
133
+ d_puts '# node_repository? 2'
134
+ ret = @encx.compare(basename, @hash[:node_repository])
127
135
  end
128
- p ret
136
+ d_puts "# node_repository? basename=#{basename}|ret=#{ret}"
129
137
  ret
130
138
  end
131
139
 
132
- def repository?(basename , bundle_repo)
133
- d_puts "In repository? basename=#{basename} bundle_repo=#{bundle_repo}"
140
+ def repository?(basename, bundle_repo)
134
141
  ret = dot_directory?(basename) or bundle_repo == basename or node_repository?(basename)
135
- p ret
142
+ d_puts "In repository? basename=#{basename} bundle_repo=#{bundle_repo}|ret=#{ret}"
136
143
  ret
137
144
  end
138
145
 
139
- def get_bundle_repository()
146
+ def bundle_repository
140
147
  abs_path = nil
141
- config_path = ".bundle/config"
148
+ config_path = '.bundle/config'
142
149
  if Dir.exist?(config_path)
143
150
  config = get_config(config_path)
144
- if config
145
- @skip_dirs[bundle_pn.to_s] = @encx.make_regexp( "^#{config}" )
146
- end
151
+ @skip_dirs[bundle_pn.to_s] = @encx.make_regexp("^#{config}") if config
147
152
 
148
- if config["BUNDLE_PATH"]
149
- if Dir.exist?(config["BUNDLE_PATH"])
150
- abs_path = Dir.open(config["BUNDLE_PATH"]){ |d| d.pwd}
151
- end
152
- end
153
+ abs_path = Dir.open(config['BUNDLE_PATH'], &:pwd) if config['BUNDLE_PATH'] && Dir.exist?(config['BUNDLE_PATH'])
153
154
  end
154
155
  abs_path
155
156
  end
156
157
 
157
- def project_directory?(abs_path)
158
+ def project_directory?(_abs_path)
158
159
  false
159
160
  end
160
161
 
161
162
  def ignore_directory?(basename)
162
- puts "# ignore_directory? 1"
163
- ret = @encx.compare(basename , @hs[:temp])
163
+ ret = @encx.compare(basename, @hash[:temp])
164
164
  unless ret
165
- puts "# ignore_directory? 2"
166
- ret = @encx.compare(basename , @hs[:cvs])
165
+ d_puts '# ignore_directory? 2'
166
+ ret = @encx.compare(basename, @hash[:cvs])
167
167
  end
168
- p ret
168
+ d_puts "# ignore_directory? ret=#{ret}"
169
169
  ret
170
170
  end
171
171
 
@@ -173,117 +173,166 @@ module Flist
173
173
  atime = File.atime(path)
174
174
  ctime = File.ctime(path)
175
175
  mtime = File.mtime(path)
176
- @@fileinfo_class.new( atime , ctime, mtime )
176
+ self.class.make_instance_of_fileinfo_class(atime, ctime, mtime)
177
+ # @@fileinfo_class.new( atime , ctime, mtime )
177
178
  end
178
179
 
179
- def scanx_sub(x , bundle_repo , level, repo )
180
+ def repository_files(kind, level, repo, dir, x_str, path_s)
181
+ register_item(kind, level, repo, dir, make_fileinfo(x_str), 1)
182
+
183
+ @dirs[path_s] = @encx.make_regexp("^#{path_s}") unless @dirs[path_s]
184
+ @skip_dirs[path_s] = @encx.make_regexp("^#{path_s}") unless @skip_dirs[path_s]
185
+
186
+ [repo, dir]
187
+ end
188
+
189
+ def scanx_sub(item, bundle_repo, level, repo)
180
190
  dir = nil
181
- if File.directory?(x)
182
- kind = "D"
191
+ if File.directory?(item)
192
+ kind = 'D'
183
193
  dir = @encx.convert(@cur_dir)
184
- x_str = @encx.convert(x)
185
- path_s = File.expand_path( File.join( dir , x_str ) )
186
- if repository?(x , bundle_repo)
194
+ x_item = @encx.convert(item)
195
+ path_s = File.expand_path(File.join(dir, x_item))
196
+ if repository?(x_item, bundle_repo)
187
197
  # カレントディレクトリの直下にリポジトリが存在すれば、カレントディレクトリをプロジェクトとして登録する。リポジトリ自体は登録しない(管理外とする)。
188
- register_item(kind, level, x , dir , make_fileinfo(x_str) , 1)
189
-
190
- unless @dirs[path_s]
191
- @dirs[path_s] = @encx.make_regexp( "^#{path_s}" )
192
- end
193
- unless @skip_dirs[path_s]
194
- @skip_dirs[path_s] = @encx.make_regexp( "^#{path_s}" )
195
- end
196
-
197
- repo = x
198
- return [repo , dir]
199
- elsif ignore_directory?(x)
200
- @skip_dirs[path_s] = @encx.make_regexp( "^#{path_s}" )
198
+ d_puts "REPOSITORY #{dir}|#{path_s}"
199
+ # return nil
200
+ return repository_files(kind, level, x_item, dir, make_fileinfo(x_item), path_s)
201
+ elsif ignore_directory?(x_item)
202
+ d_puts "SKIP_DIRECTORY #{x_item}|#{path_s}"
203
+ @skip_dirs[path_s] = @encx.make_regexp("^#{path_s}")
201
204
  else
202
- register_item(kind, level, "" , path_s , make_fileinfo(x) , 0)
205
+ d_puts "REGISTER_DIRECTORY #{x_item}|#{path_s}"
206
+ register_item(kind, level, '', path_s, make_fileinfo(x_item), 0)
203
207
  dir = path_s
204
208
  end
205
- else
206
- if @mode == :simple
207
- kind = "F"
209
+ elsif @mode == :simple
210
+ kind = 'F'
208
211
 
209
- dir = @encx.convert(@cur_dir)
212
+ dir = @encx.convert(@cur_dir)
213
+ x_item = @encx.convert(item)
214
+ path_s = File.expand_path(File.join(dir, x_item))
215
+ register_item(kind, level, '', path_s, make_fileinfo(x_item), 0)
216
+ end
217
+ # p "scan_sub"
218
+ # p repo
219
+ # p dir
220
+ [repo, dir]
221
+ end
222
+
223
+ def project_directory_files
224
+ dir = @encx.convert(@cur_dir)
225
+ x_str = @encx.convert(x)
226
+ d_puts "1 #{dir}"
227
+ register_item(kind, level, '', dir, make_fileinfo(x_str), 1)
228
+ @dirs[dir] = @encx.make_regexp("^#{abs_dir_path}") unless @dirs[dir]
229
+
230
+ # プロジェクトを格納するディレクトリは、今後スキップさせる
231
+ @skip_dirs[dir] = @encx.make_regexp("^#{abs_dir_path}") unless skip_dirs[dir]
232
+ end
233
+
234
+ def non_skip_files(abs_dir_path, level)
235
+ Dir.chdir(abs_dir_path) do
236
+ d_puts "non_skip_files chdir #{abs_dir_path}"
237
+ repo = nil
238
+ dirs = []
239
+ @cur_dir = Dir.getwd
240
+ bundle_repo = bundle_repository
241
+
242
+ Dir.foreach('.') do |x|
243
+ next if ['.', '..'].include?(x)
244
+
245
+ # d_puts "scanx x=#{x}"
246
+ # d_puts "=========#{x.encoding}"
247
+ # d_puts "@cur_dir=#{@cur_dir}"
210
248
  x_str = @encx.convert(x)
211
- path_s = File.expand_path( File.join( dir , x_str) )
212
- register_item(kind, level, "" , path_s , make_fileinfo(x_str) , 0)
249
+ repo, dir = scanx_sub(x_str, bundle_repo, level, repo)
250
+ dirs << dir if dir
251
+ end
252
+ unless repo.nil?
253
+ dirs.each do |d|
254
+ scanx(d, level + 1)
255
+ end
213
256
  end
214
257
  end
215
- p "scan_sub"
216
- p repo
217
- p dir
218
- [repo, dir]
219
258
  end
220
259
 
221
- def scanx(abs_dir_path , level)
222
- d_puts "=scanx====#{Dir.pwd}"
223
- d_puts "abs_dir_path=#{abs_dir_path}"
224
- d_puts "abs_dir_path.encoding=#{abs_dir_path.encoding}"
260
+ def scanx(abs_dir_path, level)
261
+ d_puts "######### scanx abs_dir_path=#{abs_dir_path}"
262
+ # d_puts "=scanx====#{Dir.pwd}"
263
+ # d_puts "abs_dir_path=#{abs_dir_path}"
264
+ # d_puts "abs_dir_path.encoding=#{abs_dir_path.encoding}"
225
265
 
226
266
  # プロジェクトを格納するディレクトリであれば、
227
267
  # (TO DO) project_directory?を実装する
228
268
  if project_directory?(abs_dir_path)
229
- dir = @encx.convert(@cur_dir)
230
- x_str = @encx.convert(x)
231
- d_puts "1 #{dir}"
232
- register_item(kind, level, "" , dir , make_fileinfo(x_str) , 1)
233
- unless @dirs[dir]
234
- @dirs[dir] = @encx.make_regexp( "^#{abs_dir_path}" )
235
- end
236
-
237
- # プロジェクトを格納するディレクトリは、今後スキップさせる
238
- unless skip_dirs[dir]
239
- @skip_dirs[dir] = @encx.make_regexp( "^#{abs_dir_path}" )
240
- end
269
+ project_directory_files
241
270
  else
242
271
  # スッキプすべきとして登録されたディレクトリまたは、そのサブディレクトリであれば、スキップする
243
- unless need_skip?(abs_dir_path)
244
- Dir.chdir(abs_dir_path) do
245
- repo = nil
246
- dirs = []
247
- kind = nil
248
- @cur_dir = Dir.getwd
249
- bundle_repo = get_bundle_repository( )
250
-
251
- Dir.foreach('.') do |x|
252
- next if x == '.' or x == '..'
253
- d_puts "scanx x=#{x}"
254
- d_puts "=========#{x.encoding}"
255
- d_puts "@cur_dir=#{@cur_dir}"
256
- x_str = @encx.convert(x)
257
- repo , dir = scanx_sub(x_str , bundle_repo , level, repo )
258
- dirs << dir if dir
259
- end
260
- if repo != nil
261
- dirs.each do |d|
262
- scanx(d , level + 1)
263
- end
264
- end
265
- end
266
- end
272
+ non_skip_files(abs_dir_path, level) unless need_skip?(abs_dir_path)
267
273
  end
268
274
  end
269
275
 
270
276
  def scan
271
- d_puts("In scan")
277
+ d_puts('In scan')
272
278
  # 調査対象のトップディレクトリ
273
279
  # @top_dirはディレクトリ名(フルパスではない)である
274
- Dir.chdir(@top_dir){
280
+ Dir.chdir(@top_dir) do
275
281
  @topd_dir = Dir.getwd
276
- }
282
+ end
277
283
  # 調査対象のトップディレクトリが絶対パス、相対パスで指定された時を考慮して、
278
284
  # トップディレクトリのbasename部分をとりだして調べる。
279
285
  #
280
286
  # 無視すべきディレクトリ名パターンにマッチすれば、@top_dir以下を調べない
281
- unless ignore_directory?( File.basename(@top_dir))
282
- Dir.chdir( File.join(@top_dir , "..") ){
283
- @cur_dir = Dir.getwd
287
+ return if ignore_directory?(File.basename(@top_dir))
288
+
289
+ Dir.chdir(File.join(@top_dir, '..')) do
290
+ @cur_dir = Dir.getwd
291
+ end
292
+ d_puts "scan @cur_dir=#{@cur_dir} call scanx @top_dir=#{@top_dir}"
293
+ scanx(@top_dir, 0)
294
+ d_puts '########## scan End'
295
+ end
296
+
297
+ def output
298
+ d_puts 'In output'
299
+
300
+ @items.each do |_k, v|
301
+ d_puts "v.path.encoding=#{v.path.encoding}"
302
+
303
+ if @csv
304
+ @csvx.csv << [@dir_id, v.level, v.kind, v.repo, v.path, v.project, '', v.comment, v.atime, v.ctime,
305
+ v.mtime]
306
+ end
307
+ d_puts '#### Flielist'
308
+ d_puts "dir_id=#{@dir_id}"
309
+ d_puts "level=#{v.level}"
310
+ d_puts "kind=#{v.kind}"
311
+ d_puts "repo=#{v.repo}"
312
+ d_puts "path=#{v.path_conv}"
313
+ d_puts "project=#{v.project}"
314
+ d_puts "desc=#{v.desc}"
315
+ d_puts "comment=#{v.comment}"
316
+ d_puts "atime=#{v.atime}"
317
+ d_puts "ctime=#{v.ctime}"
318
+ d_puts "mtime=#{v.mtime}"
319
+ d_puts '#### Flilelist End'
320
+ unless @dir_id
321
+ puts "invalid @dir_id=#{@dir_id}"
322
+ exit
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
284
333
 
285
- }
286
- scanx(@top_dir , 0)
334
+ @dbmgr.flistz_add(@dir_id, v.level, v.kind, v.repo, v.path, v.project,
335
+ v.desc, v.comment, v.atime, v.ctime, v.mtime)
287
336
  end
288
337
  end
289
338
  end
@@ -1,8 +1,9 @@
1
- # -*- coding: utf-8 -*-
1
+ # frozen_string_literal: true
2
+
2
3
  require 'forwardable'
3
4
  require 'csv'
4
5
 
5
- require 'arxutils'
6
+ require 'arxutils_sqlite3'
6
7
  require 'flist/dbutil/dbmgr'
7
8
  require 'ykutils/debugutils'
8
9
 
@@ -13,65 +14,60 @@ module Flist
13
14
 
14
15
  include Ykutils::DebugUtils
15
16
 
16
- def_delegators( :@dbmgr, :dirz_add )
17
-
18
- def initialize( kind, hs )
19
-
20
- debug=false
17
+ # def_delegators( :@dbmgr, :dirz_add )
21
18
 
22
- @dbmgr = Arxutils::Store.init(kind , hs ){ | register_time |
23
- Dbutil::DbMgr.new( register_time )
24
- }
19
+ def initialize(_kind, hash, _opts)
20
+ # @dbmgr = Arxutils_Sqlite3::Store.init(kind , hs , opts ){ | register_time |
21
+ # Dbutil::DbMgr.new( register_time )
22
+ # }
23
+ Dbutil::DbMgr.new(register_time)
25
24
 
26
- @csv_fname = hs["csv_fname"]
27
- @csvin_fname = hs["csvin_fname"]
25
+ @csv_fname = hash['csv_fname']
26
+ @csvin_fname = hash['csvin_fname']
28
27
 
29
28
  debug_utils_init
30
29
  d_puts("csv_fname=#{@csv_fname}")
31
30
 
32
31
  if @csv_fname
33
- @csv = CSV.open( @csv_fname , "w" ,
34
- { :encoding => 'UTF-8',
35
- :headers => @headers_s,
36
- :force_quotes => true,
37
- :write_headers => true,
38
-
39
- } )
32
+ @csv = CSV.open(@csv_fname, 'w',
33
+ { encoding: 'UTF-8',
34
+ headers: @headers_s,
35
+ force_quotes: true,
36
+ write_headers: true })
40
37
  end
41
38
 
42
39
  if @csvin_fname
43
- @csvin = CSV.open( @csvin_fname , "r" ,
44
- { :encoding => 'UTF-8',
45
- :headers => @headers_s,
46
- } )
40
+ @csvin = CSV.open(@csvin_fname, 'r',
41
+ { encoding: 'UTF-8',
42
+ headers: @headers_s })
47
43
  end
48
44
 
49
45
  d_puts "default_external=#{Encoding.default_external}"
50
- Encoding.default_external=Encoding::UTF_8
46
+ Encoding.default_external = Encoding::UTF_8
51
47
  d_puts "default_external=#{Encoding.default_external}"
52
48
  d_puts "default_internal=#{Encoding.default_internal}"
53
- Encoding.default_internal=Encoding::UTF_8
49
+ Encoding.default_internal = Encoding::UTF_8
54
50
  d_puts "default_internal=#{Encoding.default_internal}"
55
51
  end
56
52
 
57
53
  def finish
58
- @csv.close if @csv
59
- @csv_in.close if @csv_in
54
+ @csv&.close
55
+ @csv_in&.close
60
56
  end
61
57
 
62
58
  def post_process
63
- @dbmgr.flistz_post_process(@dir_id) if @dbmgr
59
+ @dbmgr&.flistz_post_process(@dir_id)
64
60
  end
65
61
 
66
- def output(items , dir_id)
67
- d_puts "In output"
62
+ def output(items, dir_id)
63
+ d_puts 'In output'
68
64
 
69
- items.each do |k,v|
65
+ items.each do |_k, v|
70
66
  d_puts "v.path.encoding=#{v.path.encoding}"
71
67
 
72
68
  @csv << [v.level, v.kind, v.repo, v.path, v.project, v.comment, v.atime, v.ctime, v.mtime] if @csv
73
- @dbmgr.flistz_add( dir_id, v.level, v.kind, v.repo, v.path, v.project, "", v.comment, v.atime, v.ctime, v.mtime) if @dbmgr
74
-
69
+ @dbmgr&.flistz_add(dir_id, v.level, v.kind, v.repo, v.path, v.project, '', v.comment, v.atime, v.ctime,
70
+ v.mtime)
75
71
  end
76
72
  end
77
73
  end