flist 0.1.30 → 0.1.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/main.yml +31 -0
- data/.gitignore +5 -0
- data/.rubocop.yml +12 -0
- data/.rubocop_todo.yml +129 -0
- data/Gemfile +22 -0
- data/Rakefile +50 -3
- data/SECURITY.md +21 -0
- data/bin/console +4 -3
- data/bin/setup +2 -0
- data/config/.gitkeep +0 -0
- data/config/config.yml +14 -0
- data/config/config_sample.yml +15 -0
- data/config/config_yml.sample +15 -0
- data/config/db_scheme.yml +71 -0
- data/config/db_scheme.yml.sample +48 -0
- data/config/dbsetup.rb +56 -0
- data/config/opts.rb +9 -0
- data/config/opts.rb.sample +7 -0
- data/config/setting.yml +2 -0
- data/config/sqlite3.yml +26 -0
- data/config/tmp/db_scheme.yml +71 -0
- data/db/migrate/010_create_countdatetime.rb +11 -0
- data/db/migrate/020_create_flistz.rb +22 -0
- data/db/migrate/030_create_invalidflistz.rb +13 -0
- data/db/migrate/040_create_currentflistz.rb +15 -0
- data/db/migrate/050_create_dirz.rb +12 -0
- data/db/migrate/060_create_invaliddirz.rb +13 -0
- data/db/migrate/070_create_currentdirz.rb +15 -0
- data/exe/flist +80 -27
- data/flist.gemspec +33 -20
- data/lib/dbacrecord.rb +36 -0
- data/lib/flist/cli.rb +49 -0
- data/lib/flist/config.rb +16 -0
- data/lib/flist/csvx.rb +29 -0
- data/lib/flist/dbutil/dbmgr.rb +25 -24
- data/lib/flist/dbutil/dirzmgr.rb +75 -12
- data/lib/flist/dbutil/flistzmgr.rb +81 -34
- data/lib/flist/dbutil.rb +4 -4
- data/lib/flist/flist/filelist.rb +219 -168
- data/lib/flist/flist.rb +282 -101
- data/lib/flist/version.rb +3 -1
- data/lib/flist.rb +51 -5
- data/lib/template/config_yml.erb +15 -0
- metadata +128 -33
- data/exe/makemigrate +0 -52
- data/lib/flist/flist/store.rb +0 -79
@@ -1,65 +1,112 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'pp'
|
4
4
|
require 'flist/dbutil/dbmgr'
|
5
5
|
|
6
6
|
module Flist
|
7
7
|
module Dbutil
|
8
|
+
# ファイル情報マネージャ
|
8
9
|
class FlistzMgr
|
9
|
-
|
10
|
+
include Ykutils::DebugUtils
|
11
|
+
|
12
|
+
def initialize(encx, db_encoding, register_time)
|
13
|
+
# 指定エンコーディングの基づいたパス操作
|
10
14
|
@encx = encx
|
15
|
+
# DBのエンコーディング
|
11
16
|
@db_encoding = db_encoding
|
17
|
+
# DB接続時のタイムスタンプ
|
12
18
|
@register_time = register_time
|
19
|
+
# DBに登録・更新したファイル情報をのハッシュ
|
20
|
+
# キーはパス
|
13
21
|
@hs_by_path = {}
|
22
|
+
# DBに登録・更新したファイル情報のハッシュ
|
23
|
+
# キーはファイル情報のobject_id
|
14
24
|
@hs_by_id = {}
|
25
|
+
# DBに登録・更新したファイル情報に対応するディレクトリID
|
26
|
+
@set_of_dir_id = Set.new
|
15
27
|
end
|
16
28
|
|
17
|
-
|
18
|
-
|
19
|
-
|
29
|
+
# ファイル情報追加・更新
|
30
|
+
# DBに未登録の時は追加し、登録済みの時は更新する
|
31
|
+
def add(dir_id, level, kind, repo, path, project, desc, comment, atime, ctime, mtime)
|
32
|
+
d_puts 'Flist::Dbutil::FlistzMgr add'
|
33
|
+
# pathをDBのエンコーディングに変換する
|
34
|
+
path_conv = @encx.convert(path, @db_encoding)
|
35
|
+
# パスが表すファイル情報をハッシュから得る
|
36
|
+
flistz = @hs_by_path[path_conv]
|
37
|
+
# パスに対応するファイル情報が見つかれば何もしない
|
38
|
+
return flistz if flistz
|
20
39
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
40
|
+
# FlistzのViewから、dir_idとパスで指定したファイル情報を得る
|
41
|
+
cur_flistz = Currentflistz.where(dir_id: dir_id, path: path_conv).limit(1)
|
42
|
+
if cur_flistz.size.zero?
|
43
|
+
# 見つからなければ、新たにファイル情報をDBに登録する
|
44
|
+
begin
|
45
|
+
d_puts '#### FlistzMgr'
|
46
|
+
d_puts "dir_id=#{dir_id}"
|
47
|
+
d_puts "level=#{level}"
|
48
|
+
d_puts "kind=#{kind}"
|
49
|
+
d_puts "repo=#{repo}"
|
50
|
+
d_puts "path=#{path_conv}"
|
51
|
+
d_puts "project=#{project}"
|
52
|
+
d_puts "desc=#{desc}"
|
53
|
+
d_puts "comment=#{comment}"
|
54
|
+
d_puts "atime=#{atime}"
|
55
|
+
d_puts "ctime=#{ctime}"
|
56
|
+
d_puts "mtime=#{mtime}"
|
57
|
+
d_puts "@register_time=#{@register_time}"
|
58
|
+
d_puts '#### FlistzMgr End'
|
59
|
+
flistz = Flistz.create(dir_id: dir_id, level: level, kind: kind,
|
60
|
+
repo: repo, path: path_conv, project: project,
|
61
|
+
desc: desc, comment: comment,
|
62
|
+
atime: atime, ctime: ctime, mtime: mtime,
|
63
|
+
start_datetime: @register_time)
|
64
|
+
rescue StandardError => e
|
65
|
+
p e.class
|
66
|
+
p e.message
|
67
|
+
pp e.backtrace
|
30
68
|
|
31
|
-
|
32
|
-
end
|
33
|
-
else
|
34
|
-
current_flistz = cur_flistz.first.flistz
|
35
|
-
hs = {atime: atime, ctime: ctime , mtime: mtime , repo: repo, project: project, desc: desc , comment: comment}
|
36
|
-
value_hs = hs.reduce({}){ |hsx, item|
|
37
|
-
if current_flistz[ item[0] ] != item[1]
|
38
|
-
hsx[ item[0] ] = item[1]
|
39
|
-
end
|
40
|
-
hsx
|
41
|
-
}
|
42
|
-
current_flistz.update(value_hs) if value_hs.size > 0
|
69
|
+
flistz = nil
|
43
70
|
end
|
44
71
|
else
|
45
|
-
#
|
72
|
+
# DBから見つかれば、最初に見つけたファイル情報を更新する
|
73
|
+
# current_flistz = cur_flistz.first.flistz
|
74
|
+
current_flistz = cur_flistz[0].flistz
|
75
|
+
hs = { atime: atime, ctime: ctime, mtime: mtime, repo: repo,
|
76
|
+
project: project, desc: desc, comment: comment }
|
77
|
+
value_hs = hs.each_with_object({}) do |item, hsx|
|
78
|
+
hsx[item[0]] = item[1] if current_flistz[item[0]] != item[1]
|
79
|
+
end
|
80
|
+
current_flistz.update(value_hs) if value_hs.size.positive?
|
81
|
+
flistz = current_flistz
|
46
82
|
end
|
47
83
|
|
84
|
+
# DBに登録・更新したファイル情報をハッシュに格納
|
48
85
|
if flistz
|
49
86
|
@hs_by_path[path] = flistz
|
50
|
-
@hs_by_id[flistz.
|
87
|
+
@hs_by_id[flistz.object_id] = flistz
|
88
|
+
@set_of_dir_id.add(dir_id)
|
51
89
|
end
|
52
90
|
flistz
|
53
91
|
end
|
54
92
|
|
55
|
-
|
56
|
-
|
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)
|
101
|
+
# DBに登録済データのうち、ハッシュに存在しないデータをInvalidflistzに登録する
|
102
|
+
def post_process_for_dir_id(dir_id)
|
103
|
+
h_ids = Currentflistz.where(dir_id: dir_id).pluck(:org_id)
|
57
104
|
t_ids = @hs_by_id.keys
|
58
105
|
ids = h_ids - t_ids
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
106
|
+
return unless ids.size.positive?
|
107
|
+
|
108
|
+
ids.each do |idx|
|
109
|
+
Invalidflistz.create(org_id: idx, end_datetime: @register_time)
|
63
110
|
end
|
64
111
|
end
|
65
112
|
end
|
data/lib/flist/dbutil.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
require 'flist/dbutil/dbmgr'
|
3
|
-
require 'flist/dbutil/dirzmgr'
|
4
|
-
require 'flist/dbutil/flistzmgr'
|
1
|
+
# frozen_string_literal: true
|
5
2
|
|
3
|
+
require_relative 'dbutil/dbmgr'
|
4
|
+
require_relative 'dbutil/dirzmgr'
|
5
|
+
require_relative 'dbutil/flistzmgr'
|
data/lib/flist/flist/filelist.rb
CHANGED
@@ -1,75 +1,76 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'ykutils/debugutils'
|
3
4
|
|
4
5
|
module Flist
|
5
6
|
class Flist
|
7
|
+
# 詳細ファイルリストクラス
|
6
8
|
class Filelist
|
7
9
|
include Ykutils::DebugUtils
|
8
10
|
|
9
|
-
|
11
|
+
@fileinfo_class = Struct.new(:atime, :ctime, :mtime)
|
12
|
+
@item_class = Struct.new(:level, :kind, :repo, :path, :path_conv, :project,
|
13
|
+
:desc, :comment, :atime, :ctime, :mtime)
|
14
|
+
|
15
|
+
def self.make_instance_of_fileinfo_class(atime, ctime, mtime)
|
16
|
+
@fileinfo_class.new(atime, ctime, mtime)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.make_instance_of_item_class(level = nil, kind = nil, repo = nil, path = nil,
|
20
|
+
path_conv = nil, project = nil, desc = nil,
|
21
|
+
comment = nil,
|
22
|
+
atime = nil, ctime = nil, mtime = nil)
|
23
|
+
@item_class.new(level, kind, repo, path, path_conv, project, desc,
|
24
|
+
comment, atime, ctime, mtime)
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(dbmgr, csvx, encx, skip_dirs = {}, dir_id = 0, top_dir = '',
|
28
|
+
top_level = 0, mode = '')
|
29
|
+
@dbmgr = dbmgr
|
30
|
+
@csvx = csvx
|
10
31
|
@encx = encx
|
11
|
-
@store = store
|
12
32
|
@skip_dirs = skip_dirs
|
13
33
|
|
14
|
-
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
34
|
+
# パス名判別用正規表現
|
35
|
+
@hash = {}
|
36
|
+
@hash[:dot_directory] = @encx.make_regexp('^(\.|_).+')
|
37
|
+
@hash[:node_repository] = @encx.make_regexp('[^_]_packages')
|
38
|
+
@hash[:node_modules] = @encx.make_regexp('node_modules|bower_modules')
|
39
|
+
@hash[:temp] = @encx.make_regexp('te?mp', Regexp::IGNORECASE)
|
40
|
+
@hash[:cvs] = @encx.make_regexp('cvs', Regexp::IGNORECASE)
|
20
41
|
|
42
|
+
# 設定ファイルの"topdirhs"で定義されたグループに含まれるサブディレクトリを表すID
|
21
43
|
@dir_id = dir_id
|
22
|
-
|
23
|
-
set_debug(true)
|
44
|
+
raise InvalidDirIdError, "invalid @dir_id=#{@dir_id}" unless @dir_id
|
24
45
|
|
25
|
-
|
26
|
-
@@item_class ||= Struct.new("Itemfi" , :level , :kind, :repo, :path , :path_conv, :project, :comment , :atime, :ctime, :mtime )
|
27
|
-
@cur_item = @@item_class.new
|
46
|
+
# 全Itemを収めるハッシュ(キーはそのItemを指すパス)
|
28
47
|
@items = {}
|
48
|
+
# Itemのうち、ディレクトリを収めるハッシュ(キーはそのItemを指すパス)
|
29
49
|
@dirs = {}
|
50
|
+
# Itemのうち、ファイルを収めるハッシュ(キーはそのItemを指すパス)
|
30
51
|
@files = {}
|
31
52
|
|
53
|
+
# このFilelistのトップディレクトリ(トップディレクトリより下位のディレクトリ、ファイルの情報を持つ)
|
32
54
|
@top_dir = top_dir
|
55
|
+
# このFilelistのトップディレクトリの階層の深さ
|
33
56
|
@top_level = top_level
|
34
57
|
@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
58
|
end
|
39
59
|
|
40
60
|
def need_skip?(path_s)
|
41
61
|
ret = nil
|
42
|
-
if @skip_dirs
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
62
|
+
ret = @skip_dirs.keys.find { |x| @encx.compare(path_s, x) } if @skip_dirs
|
63
|
+
ret_value = !ret.nil?
|
64
|
+
d_puts "need_skip? path_s=#{path_s}|ret_value=#{ret_value}"
|
65
|
+
ret_value
|
65
66
|
end
|
66
67
|
|
67
|
-
def time2datetime_utc(
|
68
|
+
def time2datetime_utc(time)
|
68
69
|
# UTC
|
69
|
-
|
70
|
+
DateTime.new(time.year, time.month, time.day, time.hour, time.min, time.sec, time.utc_offset)
|
70
71
|
end
|
71
72
|
|
72
|
-
def update_item(kind, level, repo, path,
|
73
|
+
def update_item(kind, level, repo, path, _project = 0)
|
73
74
|
@items[path].kind = kind
|
74
75
|
@items[path].level = level
|
75
76
|
@items[path].repo = repo
|
@@ -77,213 +78,263 @@ module Flist
|
|
77
78
|
@items[path].project = preoject
|
78
79
|
end
|
79
80
|
|
81
|
+
# ハッシュ@itemsにpathをキーに登録する
|
80
82
|
def register_item(kind, level, repo, path, fileinfo, project = 0)
|
81
|
-
d_puts
|
83
|
+
d_puts 'register_item'
|
82
84
|
d_puts "path=#{path}"
|
83
|
-
|
84
|
-
@cur_item
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
85
|
+
cur_item = self.class.make_instance_of_item_class
|
86
|
+
# @cur_item = @@item_class.new
|
87
|
+
cur_item.kind = kind
|
88
|
+
cur_item.level = level
|
89
|
+
cur_item.repo = repo
|
90
|
+
cur_item.path_conv = @encx.convert(path)
|
91
|
+
cur_item.path = path
|
92
|
+
cur_item.project = project
|
93
|
+
cur_item.comment = ''
|
94
|
+
cur_item.atime = time2datetime_utc(fileinfo.atime)
|
95
|
+
cur_item.ctime = time2datetime_utc(fileinfo.ctime)
|
96
|
+
cur_item.mtime = time2datetime_utc(fileinfo.mtime)
|
97
|
+
|
98
|
+
@items[path] = cur_item
|
96
99
|
end
|
97
100
|
|
98
101
|
def get_config(path)
|
99
|
-
alist = File.open(path)
|
100
|
-
f.readlines.
|
102
|
+
alist = File.open(path) do |f|
|
103
|
+
f.readlines.grep_v(/^-/).collect do |x|
|
101
104
|
x.chomp.split(/:/)
|
102
|
-
|
103
|
-
|
105
|
+
end
|
106
|
+
end
|
104
107
|
Hash[*alist.flatten(1)]
|
105
108
|
end
|
106
109
|
|
107
110
|
def dot_directory?(basename)
|
108
|
-
d_puts "In dot_directory?
|
109
|
-
|
110
|
-
ret = @encx.compare(basename , @hs[:dot_directory])
|
111
|
+
d_puts "In dot_directory? basename=#{basename}"
|
112
|
+
ret = @encx.compare(basename, @hash[:dot_directory])
|
111
113
|
if ret
|
112
114
|
d_puts 'T'
|
113
115
|
else
|
114
116
|
d_puts 'F'
|
115
117
|
end
|
116
|
-
|
118
|
+
d_puts "In dot_directory? basename=#{basename}|ret=#{ret}"
|
117
119
|
ret
|
118
120
|
end
|
119
121
|
|
120
122
|
def node_repository?(basename)
|
121
123
|
d_puts "In node_repository? path=#{basename}"
|
122
|
-
|
123
|
-
ret = @encx.compare( basename , @hs[:node_modules] )
|
124
|
+
ret = @encx.compare(basename, @hash[:node_modules])
|
124
125
|
unless ret
|
125
|
-
|
126
|
-
ret = @encx.compare(basename
|
126
|
+
d_puts '# node_repository? 2'
|
127
|
+
ret = @encx.compare(basename, @hash[:node_repository])
|
127
128
|
end
|
128
|
-
|
129
|
+
d_puts "# node_repository? basename=#{basename}|ret=#{ret}"
|
129
130
|
ret
|
130
131
|
end
|
131
132
|
|
132
|
-
def repository?(basename
|
133
|
-
d_puts "In repository? basename=#{basename} bundle_repo=#{bundle_repo}"
|
133
|
+
def repository?(basename, bundle_repo)
|
134
134
|
ret = dot_directory?(basename) or bundle_repo == basename or node_repository?(basename)
|
135
|
-
|
135
|
+
d_puts "In repository? basename=#{basename} bundle_repo=#{bundle_repo}|ret=#{ret}"
|
136
136
|
ret
|
137
137
|
end
|
138
138
|
|
139
|
-
def
|
139
|
+
def bundle_repository
|
140
140
|
abs_path = nil
|
141
|
-
config_path =
|
141
|
+
config_path = '.bundle/config'
|
142
142
|
if Dir.exist?(config_path)
|
143
143
|
config = get_config(config_path)
|
144
|
-
if config
|
145
|
-
@skip_dirs[bundle_pn.to_s] = @encx.make_regexp( "^#{config}" )
|
146
|
-
end
|
144
|
+
@skip_dirs[bundle_pn.to_s] = @encx.make_regexp("^#{config}") if config
|
147
145
|
|
148
|
-
if config[
|
149
|
-
if Dir.exist?(config["BUNDLE_PATH"])
|
150
|
-
abs_path = Dir.open(config["BUNDLE_PATH"]){ |d| d.pwd}
|
151
|
-
end
|
152
|
-
end
|
146
|
+
abs_path = Dir.open(config['BUNDLE_PATH'], &:pwd) if config['BUNDLE_PATH'] && Dir.exist?(config['BUNDLE_PATH'])
|
153
147
|
end
|
154
148
|
abs_path
|
155
149
|
end
|
156
150
|
|
157
|
-
def project_directory?(
|
151
|
+
def project_directory?(_abs_path)
|
158
152
|
false
|
159
153
|
end
|
160
154
|
|
161
155
|
def ignore_directory?(basename)
|
162
|
-
|
163
|
-
ret = @encx.compare(basename , @hs[:temp])
|
156
|
+
ret = @encx.compare(basename, @hash[:temp])
|
164
157
|
unless ret
|
165
|
-
|
166
|
-
ret = @encx.compare(basename
|
158
|
+
d_puts '# ignore_directory? 2'
|
159
|
+
ret = @encx.compare(basename, @hash[:cvs])
|
167
160
|
end
|
168
|
-
|
161
|
+
d_puts "# ignore_directory? ret=#{ret}"
|
169
162
|
ret
|
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)
|
176
|
-
|
171
|
+
self.class.make_instance_of_fileinfo_class(atime, ctime, mtime)
|
172
|
+
# @@fileinfo_class.new( atime , ctime, mtime )
|
173
|
+
end
|
174
|
+
|
175
|
+
def repository_files(kind, level, repo, dir, fileinfo, path_s)
|
176
|
+
register_item(kind, level, repo, dir, fileinfo, 1)
|
177
|
+
|
178
|
+
@dirs[path_s] = @encx.make_regexp("^#{path_s}") unless @dirs[path_s]
|
179
|
+
@skip_dirs[path_s] = @encx.make_regexp("^#{path_s}") unless @skip_dirs[path_s]
|
180
|
+
|
181
|
+
[repo, dir]
|
177
182
|
end
|
178
183
|
|
179
|
-
def scanx_sub(
|
184
|
+
def scanx_sub(item, bundle_repo, level, _level_limit, repo)
|
180
185
|
dir = nil
|
181
|
-
if File.directory?(
|
182
|
-
kind =
|
186
|
+
if File.directory?(item)
|
187
|
+
kind = 'D'
|
183
188
|
dir = @encx.convert(@cur_dir)
|
184
|
-
|
185
|
-
|
186
|
-
|
189
|
+
unless item.instance_of?(String)
|
190
|
+
p item
|
191
|
+
raise InvalidSacnxSubArgumentError, "item=#{item}"
|
192
|
+
end
|
193
|
+
x_item = @encx.convert(item)
|
194
|
+
path_s = File.expand_path(File.join(dir, x_item))
|
195
|
+
if repository?(x_item, bundle_repo)
|
187
196
|
# カレントディレクトリの直下にリポジトリが存在すれば、カレントディレクトリをプロジェクトとして登録する。リポジトリ自体は登録しない(管理外とする)。
|
188
|
-
|
189
|
-
|
190
|
-
unless
|
191
|
-
|
192
|
-
|
193
|
-
unless @skip_dirs[path_s]
|
194
|
-
@skip_dirs[path_s] = @encx.make_regexp( "^#{path_s}" )
|
197
|
+
d_puts "REPOSITORY #{dir}|#{path_s}"
|
198
|
+
# return nil
|
199
|
+
unless x_item.instance_of?(String)
|
200
|
+
p x_item
|
201
|
+
raise InvalidSacnxSubArgumentError, "x_item=#{x_item}"
|
195
202
|
end
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
@skip_dirs[path_s] = @encx.make_regexp( "^#{path_s}" )
|
203
|
+
return repository_files(kind, level, x_item, dir, make_fileinfo(x_item), path_s)
|
204
|
+
elsif ignore_directory?(x_item)
|
205
|
+
d_puts "SKIP_DIRECTORY #{x_item}|#{path_s}"
|
206
|
+
@skip_dirs[path_s] = @encx.make_regexp("^#{path_s}")
|
201
207
|
else
|
202
|
-
|
208
|
+
d_puts "REGISTER_DIRECTORY #{x_item}|#{path_s}"
|
209
|
+
register_item(kind, level, '', path_s, make_fileinfo(x_item), 0)
|
203
210
|
dir = path_s
|
204
211
|
end
|
205
|
-
|
206
|
-
|
207
|
-
kind = "F"
|
212
|
+
elsif @mode == :simple
|
213
|
+
kind = 'F'
|
208
214
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
end
|
215
|
+
dir = @encx.convert(@cur_dir)
|
216
|
+
x_item = @encx.convert(item)
|
217
|
+
path_s = File.expand_path(File.join(dir, x_item))
|
218
|
+
register_item(kind, level, '', path_s, make_fileinfo(x_item), 0)
|
214
219
|
end
|
215
|
-
|
216
|
-
p repo
|
217
|
-
p dir
|
220
|
+
|
218
221
|
[repo, dir]
|
219
222
|
end
|
220
223
|
|
221
|
-
def
|
222
|
-
|
223
|
-
|
224
|
-
d_puts "
|
224
|
+
def project_directory_files
|
225
|
+
dir = @encx.convert(@cur_dir)
|
226
|
+
x_str = @encx.convert(x)
|
227
|
+
d_puts "1 #{dir}"
|
228
|
+
register_item(kind, level, '', dir, make_fileinfo(x_str), 1)
|
229
|
+
@dirs[dir] = @encx.make_regexp("^#{abs_dir_path}") unless @dirs[dir]
|
230
|
+
|
231
|
+
# プロジェクトを格納するディレクトリは、今後スキップさせる
|
232
|
+
@skip_dirs[dir] = @encx.make_regexp("^#{abs_dir_path}") unless skip_dirs[dir]
|
233
|
+
end
|
234
|
+
|
235
|
+
def non_skip_files(abs_dir_path, level, level_limit)
|
236
|
+
next_level = level + 1
|
237
|
+
next_level_limit = level_limit - 1
|
238
|
+
Dir.chdir(abs_dir_path) do
|
239
|
+
d_puts "non_skip_files chdir #{abs_dir_path}"
|
240
|
+
repo = nil
|
241
|
+
dirs = []
|
242
|
+
@cur_dir = Dir.getwd
|
243
|
+
bundle_repo = bundle_repository
|
244
|
+
|
245
|
+
if next_level_limit <= 0
|
246
|
+
Dir.foreach('.') do |x|
|
247
|
+
next if ['.', '..'].include?(x)
|
248
|
+
|
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
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
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
|
269
|
+
# d_puts "=scanx====#{Dir.pwd}"
|
270
|
+
# d_puts "abs_dir_path=#{abs_dir_path}"
|
271
|
+
# d_puts "abs_dir_path.encoding=#{abs_dir_path.encoding}"
|
225
272
|
|
226
273
|
# プロジェクトを格納するディレクトリであれば、
|
227
274
|
# (TO DO) project_directory?を実装する
|
228
275
|
if project_directory?(abs_dir_path)
|
229
|
-
|
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
|
276
|
+
project_directory_files
|
241
277
|
else
|
278
|
+
return if next_level_limit <= 0
|
279
|
+
|
242
280
|
# スッキプすべきとして登録されたディレクトリまたは、そのサブディレクトリであれば、スキップする
|
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
|
281
|
+
non_skip_files(abs_dir_path, next_level, next_level_limit) unless need_skip?(abs_dir_path)
|
267
282
|
end
|
268
283
|
end
|
269
284
|
|
270
285
|
def scan
|
271
|
-
d_puts(
|
286
|
+
d_puts('In scan')
|
272
287
|
# 調査対象のトップディレクトリ
|
273
288
|
# @top_dirはディレクトリ名(フルパスではない)である
|
274
|
-
Dir.chdir(@top_dir)
|
289
|
+
Dir.chdir(@top_dir) do
|
275
290
|
@topd_dir = Dir.getwd
|
276
|
-
|
291
|
+
end
|
277
292
|
# 調査対象のトップディレクトリが絶対パス、相対パスで指定された時を考慮して、
|
278
293
|
# トップディレクトリのbasename部分をとりだして調べる。
|
279
294
|
#
|
280
295
|
# 無視すべきディレクトリ名パターンにマッチすれば、@top_dir以下を調べない
|
281
|
-
|
282
|
-
|
283
|
-
|
296
|
+
return if ignore_directory?(File.basename(@top_dir))
|
297
|
+
|
298
|
+
Dir.chdir(File.join(@top_dir, '..')) do
|
299
|
+
@cur_dir = Dir.getwd
|
300
|
+
end
|
301
|
+
d_puts "scan @cur_dir=#{@cur_dir} call scanx @top_dir=#{@top_dir}"
|
302
|
+
next_level = 0
|
303
|
+
next_level_limit = 2
|
304
|
+
scanx(@top_dir, next_level, next_level_limit)
|
305
|
+
|
306
|
+
d_puts '########## scan End'
|
307
|
+
end
|
308
|
+
|
309
|
+
def output
|
310
|
+
d_puts 'In output'
|
311
|
+
|
312
|
+
@items.each do |_k, v|
|
313
|
+
d_puts "v.path.encoding=#{v.path.encoding}"
|
314
|
+
|
315
|
+
if @csv
|
316
|
+
@csvx.csv << [@dir_id, v.level, v.kind, v.repo, v.path, v.project, '', v.comment, v.atime, v.ctime,
|
317
|
+
v.mtime]
|
318
|
+
end
|
319
|
+
d_puts '#### Flielist'
|
320
|
+
d_puts "dir_id=#{@dir_id}"
|
321
|
+
d_puts "level=#{v.level}"
|
322
|
+
d_puts "kind=#{v.kind}"
|
323
|
+
d_puts "repo=#{v.repo}"
|
324
|
+
d_puts "path=#{v.path_conv}"
|
325
|
+
d_puts "project=#{v.project}"
|
326
|
+
d_puts "desc=#{v.desc}"
|
327
|
+
d_puts "comment=#{v.comment}"
|
328
|
+
d_puts "atime=#{v.atime}"
|
329
|
+
d_puts "ctime=#{v.ctime}"
|
330
|
+
d_puts "mtime=#{v.mtime}"
|
331
|
+
d_puts '#### Flilelist 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
|
284
335
|
|
285
|
-
|
286
|
-
|
336
|
+
@dbmgr.flistz_add(@dir_id, v.level, v.kind, v.repo, v.path, v.project,
|
337
|
+
v.desc, v.comment, v.atime, v.ctime, v.mtime)
|
287
338
|
end
|
288
339
|
end
|
289
340
|
end
|