gren 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/History.txt +7 -0
  2. data/bin/gren +1 -1
  3. data/lib/gren.rb +1 -1
  4. data/lib/gren/findgrep.rb +37 -38
  5. metadata +3 -3
@@ -4,6 +4,13 @@
4
4
  英語にする
5
5
  文章を綺麗にする
6
6
 
7
+ === 0.1.2 2010/08/05
8
+
9
+ * Bug fix.
10
+ * 読み込み禁止ディレクトリがあるとハングアップする問題を修正
11
+
12
+ === 0.1.1 2010/08/04
13
+
7
14
  * --depth, --this で探索する階層数を指定出来るように
8
15
  * -sでサイレントモード、マッチした行のみを表示する
9
16
  * -f, --if, --idオプションを何個でも設定出来るように
data/bin/gren CHANGED
@@ -7,5 +7,5 @@ require 'rubygems'
7
7
  require File.expand_path(File.dirname(__FILE__) + "/../lib/gren")
8
8
  require "gren/cli"
9
9
 
10
- Version = "0.1.1"
10
+ Version = "0.1.2"
11
11
  Gren::CLI.execute(STDOUT, ARGV)
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module Gren
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
@@ -71,49 +71,35 @@ module Gren
71
71
  end
72
72
 
73
73
  def searchAndPrintIN(stdout, dir, depth)
74
- if (@option.depth == -1 || depth > @option.depth)
74
+ if (@option.depth != -1 && depth > @option.depth)
75
75
  return
76
76
  end
77
77
 
78
78
  Dir.foreach(dir) do |name|
79
- if name != '.' and name != '..' then
80
- fpath = File.join(dir,name)
81
- fpath_disp = fpath.gsub(/^.\//, "")
79
+ next if (name == '.' || name == '..')
82
80
 
83
- # 除外ディレクトリ
84
- if ignoreDir?(fpath)
85
- @result.prune_dirs << fpath_disp if (@option.debugMode)
86
- next;
87
- end
88
-
89
- # ファイルでなければ次のディレクトリへ
90
- unless FileTest.file?(fpath)
91
- searchAndPrintIN(stdout, fpath, depth + 1)
92
- next;
93
- end
94
-
95
- @result.count += 1
96
-
97
- # 読み込み不可ならば探索しない
98
- unless FileTest.readable?(fpath)
99
- @result.unreadable_files << fpath_disp if (@option.debugMode)
100
- next
101
- end
102
-
103
- @result.size += FileTest.size(fpath)
104
-
105
- # 除外ファイル
106
- if ignoreFile?(fpath)
107
- @result.ignore_files << fpath_disp if (@option.debugMode)
108
- next
109
- end
110
-
111
- @result.search_count += 1
112
- @result.search_size += FileTest.size(fpath)
81
+ fpath = File.join(dir,name)
82
+ fpath_disp = fpath.gsub(/^.\//, "")
83
+
84
+ # 除外ディレクトリならばパス
85
+ if ignoreDir?(fpath)
86
+ @result.prune_dirs << fpath_disp if (@option.debugMode)
87
+ next;
88
+ end
113
89
 
114
- # 検索
115
- searchMain(stdout, fpath, fpath_disp)
90
+ # 読み込み不可ならばパス
91
+ unless FileTest.readable?(fpath)
92
+ @result.unreadable_files << fpath_disp if (@option.debugMode)
93
+ next
116
94
  end
95
+
96
+ # ファイルならば中身を探索、ディレクトリならば再帰
97
+ case File.ftype(fpath)
98
+ when "directory"
99
+ searchAndPrintIN(stdout, fpath, depth + 1)
100
+ when "file"
101
+ searchFile(stdout, fpath, fpath_disp)
102
+ end
117
103
  end
118
104
  end
119
105
  private :searchAndPrintIN
@@ -161,7 +147,20 @@ module Gren
161
147
  return s.index("\x00")
162
148
  end
163
149
 
164
- def searchMain(stdout, fpath, fpath_disp)
150
+ def searchFile(stdout, fpath, fpath_disp)
151
+ @result.count += 1
152
+ @result.size += FileTest.size(fpath)
153
+
154
+ # 除外ファイル
155
+ if ignoreFile?(fpath)
156
+ @result.ignore_files << fpath_disp if (@option.debugMode)
157
+ return
158
+ end
159
+
160
+ @result.search_count += 1
161
+ @result.search_size += FileTest.size(fpath)
162
+
163
+ # 検索本体
165
164
  @result.search_files << fpath_disp if (@option.debugMode)
166
165
 
167
166
  open(fpath, "r") { |file|
@@ -195,7 +194,7 @@ module Gren
195
194
  }
196
195
  }
197
196
  end
198
- private :searchMain
197
+ private :searchFile
199
198
 
200
199
  def match?(line)
201
200
  match_datas = []
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - ongaeshi
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-05 00:00:00 +09:00
17
+ date: 2010-08-06 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency