milkode 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/VERSION +1 -1
  2. data/bin/gmilk +1 -1
  3. data/bin/milk +1 -1
  4. data/lib/milkode/cdstk/cdstk.rb +337 -117
  5. data/lib/milkode/cdstk/cli_cdstk.rb +27 -9
  6. data/lib/milkode/cdstk/cli_cdstksub.rb +44 -6
  7. data/lib/milkode/cdstk/milkode_yaml.rb +105 -0
  8. data/lib/milkode/cdstk/package.rb +83 -0
  9. data/lib/milkode/cdstk/yaml_file_wrapper.rb +94 -0
  10. data/lib/milkode/cdweb/app.rb +6 -28
  11. data/lib/milkode/cdweb/lib/database.rb +6 -0
  12. data/lib/milkode/cdweb/lib/grep.rb +28 -0
  13. data/lib/milkode/cdweb/lib/mkurl.rb +2 -0
  14. data/lib/milkode/cdweb/lib/search_contents.rb +49 -10
  15. data/lib/milkode/cdweb/views/filelist.haml +2 -6
  16. data/lib/milkode/cdweb/views/header_menu.haml +5 -0
  17. data/lib/milkode/cdweb/views/search.haml +4 -8
  18. data/lib/milkode/cdweb/views/search_form.haml +22 -0
  19. data/lib/milkode/cdweb/views/view.haml +2 -6
  20. data/lib/milkode/common/ignore_checker.rb +34 -0
  21. data/lib/milkode/common/ignore_setting.rb +62 -0
  22. data/lib/milkode/grep/cli_grep.rb +10 -9
  23. data/milkode.gemspec +18 -5
  24. data/test/data/.gitignore +42 -0
  25. data/test/data/no_auto_ignore/.gitignore +1 -0
  26. data/test/data/no_auto_ignore/a.txt +3 -0
  27. data/test/milkode_test_work.rb +2 -2
  28. data/test/test_cdstk.rb +17 -12
  29. data/test/test_database.rb +4 -4
  30. data/test/test_ignore_checker.rb +26 -0
  31. data/test/test_ignore_setting.rb +113 -0
  32. data/test/test_milkode_yaml.rb +149 -0
  33. data/test/test_package.rb +73 -0
  34. data/test/test_yaml_file_wrapper.rb +97 -0
  35. metadata +19 -6
  36. data/lib/milkode/cdstk/cdstk_yaml.rb +0 -140
  37. data/test/test_cdstk_yaml.rb +0 -167
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
data/bin/gmilk CHANGED
@@ -6,5 +6,5 @@
6
6
  require 'rubygems'
7
7
  require 'milkode/grep/cli_grep'
8
8
 
9
- Version = "0.4.0"
9
+ Version = "0.5.0"
10
10
  Milkode::CLI_Grep.execute(STDOUT, ARGV)
data/bin/milk CHANGED
@@ -6,5 +6,5 @@
6
6
  require 'rubygems'
7
7
  require 'milkode/cdstk/cli_cdstk'
8
8
 
9
- Version = "0.4.0"
9
+ Version = "0.5.0"
10
10
  Milkode::CLI_Cdstk.execute(STDOUT, ARGV)
@@ -6,7 +6,6 @@ require 'rubygems'
6
6
  require 'groonga'
7
7
  require 'fileutils'
8
8
  require 'pathname'
9
- require 'milkode/cdstk/cdstk_yaml'
10
9
  require 'milkode/common/grenfiletest'
11
10
  require 'milkode/common/util'
12
11
  require 'milkode/common/dir'
@@ -19,9 +18,16 @@ rescue LoadError
19
18
  end
20
19
  require 'milkode/cdweb/lib/database'
21
20
  require 'open-uri'
21
+
22
22
  require 'milkode/cdstk/cdstk_command'
23
23
 
24
+ require 'milkode/cdstk/yaml_file_wrapper'
25
+ require 'milkode/cdstk/package'
26
+ require 'milkode/common/ignore_checker'
27
+
24
28
  module Milkode
29
+ class IgnoreError < RuntimeError ; end
30
+
25
31
  class Cdstk
26
32
  # バイグラムでトークナイズする。連続する記号・アルファベット・数字は一語として扱う。
27
33
  # DEFAULT_TOKENIZER = "TokenBigram"
@@ -36,7 +42,9 @@ module Milkode
36
42
  Database.setup(@db_dir)
37
43
  @out = io
38
44
  # @out = $stdout # 強制出力
45
+ @is_display_info = false # alert_info の表示
39
46
  clear_count
47
+ @yaml = YamlFileWrapper.load_if(@db_dir)
40
48
  end
41
49
 
42
50
  def clear_count
@@ -47,11 +55,12 @@ module Milkode
47
55
  @start_time = Time.now
48
56
  end
49
57
 
50
- def init
58
+ def init(options)
51
59
  if Dir.emptydir?(@db_dir)
52
- CdstkYaml.create(@db_dir)
60
+ @yaml = YamlFileWrapper.create(@db_dir)
53
61
  @out.puts "create : #{yaml_file}"
54
62
  db_create(db_file)
63
+ setdb([@db_dir], {}) if (options[:setdb])
55
64
  else
56
65
  @out.puts "Can't create milkode db (Because not empty in #{db_dir_expand})"
57
66
  end
@@ -63,38 +72,43 @@ module Milkode
63
72
 
64
73
  def update_all
65
74
  print_result do
66
- yaml = yaml_load
67
-
68
75
  db_open(db_file)
69
76
 
70
- yaml.list.each do |content|
71
- update_dir_in(content["directory"])
77
+ @yaml.contents.each do |package|
78
+ update_dir_in(package.directory)
72
79
  end
73
80
  end
74
81
  end
75
82
 
76
83
  def update(args, options)
84
+ update_display_info(options)
85
+
77
86
  if (options[:all])
78
87
  update_all
79
88
  else
80
89
  if (args.empty?)
81
90
  path = File.expand_path('.')
82
- package = yaml_load.package_root( path )
91
+ package = @yaml.package_root(path)
83
92
 
84
93
  if (package)
85
94
  print_result do
86
95
  db_open(db_file)
87
- update_dir_in(package["directory"])
96
+ update_dir_in(package.directory)
88
97
  end
89
98
  else
90
99
  @out.puts "Not registered. If you want to add, 'milk add #{path}'."
91
100
  end
92
101
  else
93
102
  print_result do
94
- update_list = yaml_load.list CdstkYaml::Query.new(args)
95
103
  db_open(db_file)
96
- update_list.each do |content|
97
- update_dir_in(content["directory"])
104
+ args.each do |name|
105
+ package = @yaml.find_name(name)
106
+ if (package)
107
+ update_dir_in(package.directory)
108
+ else
109
+ @out.puts "Not found package '#{name}'."
110
+ return
111
+ end
98
112
  end
99
113
  end
100
114
  end
@@ -110,45 +124,81 @@ module Milkode
110
124
  update_dir_in(dir)
111
125
  end
112
126
 
113
- def add(contents)
114
- # YAMLを読み込み
115
- yaml = yaml_load
127
+ def add(dirs, options)
128
+ update_display_info(options)
116
129
 
117
- # コンテンツを読み込める形に変換
118
- begin
119
- contents.map!{|v|convert_content(v)}
120
- rescue ConvetError
121
- return
122
- end
130
+ print_result do
131
+ # データベースを開く
132
+ db_open(db_file)
123
133
 
124
- # 存在しないコンテンツがあった場合はその場で終了
125
- contents.each do |v|
126
- shortname = File.basename v
134
+ # メイン処理
135
+ begin
136
+ dirs.each do |v|
137
+ # コンテンツを読み込める形に変換
138
+ dir = convert_content(v)
127
139
 
128
- if (yaml.cant_add_directory? v)
129
- error_alert("already exist '#{shortname}'.")
130
- return
131
- end
132
-
133
- unless (File.exist? v)
134
- error_alert("not found '#{v}'.")
140
+ # YAMLに追加
141
+ package = Package.create(dir, options[:ignore])
142
+ add_yaml(package)
143
+ set_yaml_options(package, options)
144
+
145
+ # アップデート
146
+ update_dir(dir)
147
+ end
148
+ rescue ConvetError
135
149
  return
136
150
  end
137
151
  end
152
+ end
138
153
 
139
- # YAML更新
140
- yaml.add(contents)
141
- yaml.save
154
+ def set_yaml_options(package, src)
155
+ is_dirty = false
156
+
157
+ if src[:no_auto_ignore]
158
+ dst = package.options
159
+ dst[:no_auto_ignore] = true
160
+ package.set_options(dst)
161
+ is_dirty = true
162
+ end
142
163
 
143
- # 部分アップデート
144
- print_result do
145
- db_open(db_file)
146
- contents.each do |dir|
147
- update_dir(dir)
148
- end
164
+ if src[:name]
165
+ dst = package.options
166
+ dst[:name] = src[:name]
167
+ package.set_options(dst)
168
+ is_dirty = true
169
+ end
170
+
171
+ if is_dirty
172
+ @yaml.update(package)
173
+ @yaml.save
149
174
  end
150
175
  end
151
176
 
177
+ def add_dir(dir, no_yaml = false)
178
+ add_yaml(Package.create(dir)) unless no_yaml
179
+ db_open(db_file)
180
+ update_dir(dir)
181
+ end
182
+
183
+ # yamlにパッケージを追加
184
+ def add_yaml(package)
185
+ # すでに同名パッケージがある
186
+ if @yaml.find_name(package.name)
187
+ error_alert("already exist '#{package.name}'.")
188
+ return
189
+ end
190
+
191
+ # ファイルが存在しない
192
+ unless File.exist?(package.directory)
193
+ error_alert("not found '#{package.directory}'.")
194
+ return
195
+ end
196
+
197
+ # YAML更新
198
+ @yaml.add(package)
199
+ @yaml.save
200
+ end
201
+
152
202
  def convert_content(src)
153
203
  # httpファイルならダウンロード
154
204
  begin
@@ -208,34 +258,51 @@ module Milkode
208
258
  filename
209
259
  end
210
260
 
211
- def remove(args, options)
212
- print_result do
213
- db_open(db_file)
214
-
215
- yaml = yaml_load
216
- query = CdstkYaml::Query.new(args)
217
-
218
- remove_list = yaml_load.list(query)
219
- return if remove_list.empty?
261
+ def remove_all
262
+ print_result do
263
+ list([], {:verbose => true})
220
264
 
221
- list(args, {:verbose => true})
222
-
223
- if options[:force] or yes_or_no("Remove #{remove_list.size} contents? (yes/no)")
224
- # yamlから削除
225
- yaml.remove(query)
226
- yaml.save
227
-
228
- # データベースからも削除
229
- packages = remove_list.map{|v| File.basename v['directory']}
265
+ if yes_or_no("Remove #{@yaml.contents.size} contents? (yes/no)")
266
+ db_open(db_file)
230
267
 
231
- # 本当はパッケージの配列をまとめて渡した方が効率が良いのだが、表示を綺麗にするため
232
- packages.each do |package|
233
- alert("rm_package", package)
234
- @package_count += 1
235
-
236
- Database.instance.remove([package]) do |record|
237
- alert("rm_record", record.path)
238
- @file_count += 1
268
+ @yaml.contents.each do |package|
269
+ remove_dir(package.directory)
270
+ end
271
+ else
272
+ return
273
+ end
274
+ end
275
+ end
276
+
277
+ def remove(args, options)
278
+ update_display_info(options)
279
+
280
+ if (options[:all])
281
+ remove_all
282
+ else
283
+ if (args.empty?)
284
+ path = File.expand_path('.')
285
+ package = @yaml.package_root(path)
286
+
287
+ if (package)
288
+ print_result do
289
+ db_open(db_file)
290
+ remove_dir(package.directory)
291
+ end
292
+ else
293
+ @out.puts "Not registered. '#{path}'."
294
+ end
295
+ else
296
+ print_result do
297
+ db_open(db_file)
298
+ args.each do |name|
299
+ package = @yaml.find_name(name)
300
+ if (package)
301
+ remove_dir(package.directory)
302
+ else
303
+ @out.puts "Not found package '#{name}'."
304
+ return
305
+ end
239
306
  end
240
307
  end
241
308
  end
@@ -261,17 +328,20 @@ module Milkode
261
328
  end
262
329
 
263
330
  def list(args, options)
264
- query = (args.empty?) ? nil : CdstkYaml::Query.new(args)
265
- a = yaml_load.list(query).map {|v| [File.basename(v['directory']), v['directory']] }
266
- max = a.map{|v|v[0].length}.max
267
- str = a.sort_by {|v|
268
- v[0]
269
- }.map {|v|
270
- h = File.exist?(v[1]) ? '' : '? '
331
+ match_p = @yaml.contents.find_all do |p|
332
+ args.all? {|k| p.name.include? k }
333
+ end
334
+
335
+ max = match_p.map{|p| p.name.length}.max
336
+
337
+ str = match_p.sort_by {|p|
338
+ p.name
339
+ }.map {|p|
340
+ h = File.exist?(p.directory) ? '' : '? '
271
341
  if (options[:verbose])
272
- "#{(h + v[0]).ljust(max+2)} #{v[1]}"
342
+ "#{(h + p.name).ljust(max+2)} #{p.directory}"
273
343
  else
274
- "#{h}#{v[0]}"
344
+ "#{h}#{p.name}"
275
345
  end
276
346
  }.join("\n")
277
347
 
@@ -281,7 +351,7 @@ module Milkode
281
351
  if args.empty?
282
352
  milkode_info
283
353
  else
284
- list_info(a) unless a.empty?
354
+ list_info(match_p) unless match_p.empty?
285
355
  end
286
356
  end
287
357
 
@@ -289,7 +359,13 @@ module Milkode
289
359
  dir = options[:default] ? Dbdir.default_dir : db_dir_expand
290
360
 
291
361
  if File.exist? dir
292
- @out.puts dir
362
+ if options[:default]
363
+ @out.puts dir
364
+ else
365
+ package = @yaml.package_root(File.expand_path('.'))
366
+ name = package ? package.name : "'not_package_dir'"
367
+ @out.puts "#{name} in #{dir}"
368
+ end
293
369
  else
294
370
  @out.puts "Not found db in #{Dir.pwd}"
295
371
  end
@@ -303,14 +379,12 @@ module Milkode
303
379
  if (options[:force] or yes_or_no("cleanup contents? (yes/no)"))
304
380
  print_result do
305
381
  # yamlファイルのクリーンアップ
306
- yaml = yaml_load
307
-
308
- yaml.cleanup do |v|
309
- alert("rm_package", v['directory'])
382
+ @yaml.contents.find_all {|v| !File.exist? v.directory }.each do |p|
383
+ @yaml.remove(p)
384
+ alert("rm_package", p.directory)
310
385
  @package_count += 1
311
386
  end
312
-
313
- yaml.save
387
+ @yaml.save
314
388
 
315
389
  # データベースのクリーンアップ
316
390
  Database.instance.cleanup do |record|
@@ -321,10 +395,43 @@ module Milkode
321
395
  end
322
396
  end
323
397
 
324
- def rebuild
325
- db_delete(db_file)
326
- db_create(db_file)
327
- update_all
398
+ def rebuild(args, options)
399
+ update_display_info(options)
400
+
401
+ if (options[:all])
402
+ db_delete(db_file)
403
+ db_create(db_file)
404
+ update_all
405
+ else
406
+ if (args.empty?)
407
+ path = File.expand_path('.')
408
+ package = @yaml.package_root(path)
409
+
410
+ if (package)
411
+ print_result do
412
+ db_open(db_file)
413
+ remove_dir(package.directory, true)
414
+ add_dir(package.directory, true)
415
+ end
416
+ else
417
+ @out.puts "Not registered. '#{path}'."
418
+ end
419
+ else
420
+ print_result do
421
+ args.each do |name|
422
+ package = @yaml.find_name(name)
423
+ if (package)
424
+ db_open(db_file)
425
+ remove_dir(package.directory, true)
426
+ add_dir(package.directory, true)
427
+ else
428
+ @out.puts "Not found package '#{name}'."
429
+ return
430
+ end
431
+ end
432
+ end
433
+ end
434
+ end
328
435
  end
329
436
 
330
437
  def dump
@@ -345,20 +452,22 @@ module Milkode
345
452
  end
346
453
 
347
454
  def dir(args, options)
348
- yaml = yaml_load
349
-
350
455
  if args.empty?
351
456
  path = File.expand_path('.')
352
- package = yaml.package_root(path)
457
+ package = @yaml.package_root(path)
353
458
 
354
459
  if (package)
355
- @out.print package['directory'] + (options[:top] ? "" : "\n")
460
+ @out.print package.directory + (options[:top] ? "" : "\n")
356
461
  else
357
462
  # Use mcd.
358
463
  @out.print "Not registered." + (options[:top] ? "" : "\n")
359
464
  end
360
465
  else
361
- dirs = yaml.list(CdstkYaml::Query.new(args)).map{|v|v['directory']}.reverse
466
+ match_p = @yaml.contents.find_all do |p|
467
+ args.all? {|k| p.name.include? k }
468
+ end
469
+
470
+ dirs = match_p.map{|v|v.directory}.reverse
362
471
 
363
472
  if options[:top]
364
473
  unless (dirs.empty?)
@@ -427,6 +536,61 @@ EOF
427
536
  milkode_info
428
537
  end
429
538
 
539
+ def ignore(args, options)
540
+ current_dir = File.expand_path('.')
541
+
542
+ if (options[:package])
543
+ package = @yaml.find_name(options[:package])
544
+ raise IgnoreError, "Not found package '#{options[:package]}'." unless package
545
+ else
546
+ package = @yaml.package_root(current_dir)
547
+ raise IgnoreError, "Not a package dir: '#{current_dir}'" unless package
548
+ end
549
+
550
+ if options[:test]
551
+ # Test mode
552
+ db_open(db_file)
553
+ @is_display_info = true
554
+ @is_silent = true
555
+ update_dir(package.directory)
556
+ elsif options[:delete_all]
557
+ # Delete all
558
+ package.set_ignore([])
559
+ @yaml.update(package)
560
+ @yaml.save
561
+ elsif args.empty?
562
+ # Display ignore settting
563
+ @out.puts package.ignore
564
+ else
565
+ # Add or Delete
566
+ if options[:package]
567
+ add_ignore = args.map {|v| v.sub(/^.\//, "") }
568
+ else
569
+ path = Util::relative_path(File.expand_path('.'), package.directory).to_s
570
+ add_ignore = args.map {|v| File.join(path, v).sub(/^.\//, "") }
571
+ end
572
+
573
+ ignore = package.ignore
574
+
575
+ if options[:delete]
576
+ ignore -= add_ignore
577
+ else
578
+ ignore += add_ignore
579
+ end
580
+ ignore.uniq!
581
+ package.set_ignore(ignore)
582
+
583
+ @yaml.update(package)
584
+ @yaml.save
585
+
586
+ if options[:delete]
587
+ @out.puts add_ignore.map{|v| "Delete : #{v}"}
588
+ else
589
+ @out.puts add_ignore.map{|v| "Add : #{v}"}
590
+ end
591
+ end
592
+ end
593
+
430
594
  private
431
595
 
432
596
  def db_file
@@ -446,11 +610,7 @@ EOF
446
610
  end
447
611
 
448
612
  def yaml_file
449
- CdstkYaml.yaml_file @db_dir
450
- end
451
-
452
- def yaml_load
453
- CdstkYaml.load(@db_dir)
613
+ YamlFileWrapper.yaml_file @db_dir
454
614
  end
455
615
 
456
616
  def update_dir_in(dir)
@@ -468,6 +628,25 @@ EOF
468
628
  end
469
629
  end
470
630
 
631
+ def remove_dir(dir, no_yaml = false)
632
+ # yamlから削除
633
+ unless (no_yaml)
634
+ @yaml.remove(@yaml.find_dir(dir))
635
+ @yaml.save
636
+ end
637
+
638
+ # データベースからも削除
639
+ dir = File.expand_path(dir)
640
+
641
+ alert("rm_package", dir)
642
+ @package_count += 1
643
+
644
+ Database.instance.remove([File.basename(dir)]) do |record|
645
+ alert_info("rm_record", record.path)
646
+ @file_count += 1
647
+ end
648
+ end
649
+
471
650
  def time
472
651
  @end_time - @start_time
473
652
  end
@@ -492,7 +671,7 @@ EOF
492
671
  end
493
672
 
494
673
  def milkode_info
495
- alert('*milkode*', "#{yaml_load.package_num} packages, #{Database.instance.totalRecords} records in #{db_file}.")
674
+ alert('*milkode*', "#{@yaml.contents.size} packages, #{Database.instance.totalRecords} records in #{db_file}.")
496
675
  end
497
676
 
498
677
  def db_create(filename)
@@ -513,7 +692,7 @@ EOF
513
692
  option = FindGrep::FindGrep::DEFAULT_OPTION.dup
514
693
  option.dbFile = Dbdir.groonga_path(Dbdir.default_dir)
515
694
  option.isSilent = true
516
- option.packages = packages.map{|v| v[1]}
695
+ option.packages = packages.map{|p| p.directory}
517
696
  findGrep = FindGrep::FindGrep.new([], option)
518
697
  records = findGrep.pickupRecords
519
698
 
@@ -565,12 +744,18 @@ EOF
565
744
  end
566
745
  private :db_delete
567
746
 
568
- def db_add_dir(dirname)
569
- searchDirectory(STDOUT, dirname, File.basename(dirname), 0)
747
+ def db_add_dir(dir)
748
+ @current_package = @yaml.package_root(dir)
749
+ @current_ignore = IgnoreChecker.new
750
+ @current_ignore.add IgnoreSetting.new("/", @current_package.ignore) # 手動設定
751
+ searchDirectory(STDOUT, dir, @current_package.name, "/", 0)
570
752
  end
571
753
  private :db_add_dir
572
754
 
573
755
  def db_add_file(stdout, filename, shortpath)
756
+ # サイレントモード
757
+ return if @is_silent
758
+
574
759
  # ファイル名を全てUTF-8に変換
575
760
  filename_utf8 = Util::filename_to_utf8(filename)
576
761
  shortpath_utf8 = Util::filename_to_utf8(shortpath)
@@ -610,27 +795,31 @@ EOF
610
795
  if (key == :path)
611
796
  if (isNewFile)
612
797
  @add_count += 1
613
- alert("add_record", value)
798
+ alert_info("add_record", value)
614
799
  else
615
800
  @update_count += 1
616
- alert("update", value)
801
+ alert_info("update", value)
617
802
  end
618
803
  end
619
804
  document[key] = value
620
805
  end
621
806
  end
622
-
623
807
  end
624
808
 
625
- def searchDirectory(stdout, dir, shortdir, depth)
626
- Dir.foreach(dir) do |name|
809
+ def searchDirectory(stdout, dirname, packname, path, depth)
810
+ # 現在位置に.gitignoreがあれば無視設定に加える
811
+ add_current_gitignore(dirname, path) unless @current_package.options[:no_auto_ignore]
812
+
813
+ # 子の要素を追加
814
+ Dir.foreach(File.join(dirname, path)) do |name|
627
815
  next if (name == '.' || name == '..')
628
-
629
- fpath = File.join(dir,name)
630
- shortpath = File.join(shortdir,name)
631
-
816
+
817
+ next_path = File.join(path, name)
818
+ fpath = File.join(dirname, next_path)
819
+ shortpath = File.join(packname, next_path)
820
+
632
821
  # 除外ディレクトリならばパス
633
- next if ignoreDir?(fpath)
822
+ next if ignoreDir?(fpath, next_path)
634
823
 
635
824
  # 読み込み不可ならばパス
636
825
  next unless FileTest.readable?(fpath)
@@ -638,9 +827,9 @@ EOF
638
827
  # ファイルならば中身を探索、ディレクトリならば再帰
639
828
  case File.ftype(fpath)
640
829
  when "directory"
641
- searchDirectory(stdout, fpath, shortpath, depth + 1)
830
+ searchDirectory(stdout, dirname, packname, next_path, depth + 1)
642
831
  when "file"
643
- unless ignoreFile?(fpath)
832
+ unless ignoreFile?(fpath, next_path)
644
833
  db_add_file(stdout, fpath, shortpath)
645
834
  @file_count += 1
646
835
  # @out.puts "file_count : #{@file_count}" if (@file_count % 100 == 0)
@@ -649,15 +838,38 @@ EOF
649
838
  end
650
839
  end
651
840
 
652
- def ignoreDir?(fpath)
841
+ def add_current_gitignore(dirname, path)
842
+ git_ignore = File.join(dirname, path, ".gitignore")
843
+
844
+ if File.exist? git_ignore
845
+ alert_info("add_ignore", git_ignore)
846
+
847
+ open(git_ignore) do |f|
848
+ @current_ignore.add IgnoreSetting.create_from_gitignore(path, f.read)
849
+ end
850
+ end
851
+ end
852
+
853
+ def package_ignore?(fpath, mini_path)
854
+ if @current_ignore.ignore?(mini_path)
855
+ alert_info("ignore", fpath)
856
+ true
857
+ else
858
+ false
859
+ end
860
+ end
861
+
862
+ def ignoreDir?(fpath, mini_path)
653
863
  FileTest.directory?(fpath) &&
654
- GrenFileTest::ignoreDir?(fpath)
864
+ (GrenFileTest::ignoreDir?(fpath) ||
865
+ package_ignore?(fpath, mini_path))
655
866
  end
656
867
  private :ignoreDir?
657
868
 
658
- def ignoreFile?(fpath)
869
+ def ignoreFile?(fpath, mini_path)
659
870
  GrenFileTest::ignoreFile?(fpath) ||
660
- GrenFileTest::binary?(fpath)
871
+ GrenFileTest::binary?(fpath) ||
872
+ package_ignore?(fpath, mini_path)
661
873
  end
662
874
  private :ignoreFile?
663
875
 
@@ -669,6 +881,10 @@ EOF
669
881
  end
670
882
  end
671
883
 
884
+ def alert_info(title, msg)
885
+ alert(title, msg) if @is_display_info
886
+ end
887
+
672
888
  def error_alert(msg)
673
889
  @out.puts "[fatal] #{msg}"
674
890
  end
@@ -688,5 +904,9 @@ EOF
688
904
  exit -1
689
905
  end
690
906
  end
907
+
908
+ def update_display_info(options)
909
+ @is_display_info = true if (options[:verbose])
910
+ end
691
911
  end
692
912
  end