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.
- data/History.txt +7 -0
- data/bin/gren +1 -1
- data/lib/gren.rb +1 -1
- data/lib/gren/findgrep.rb +37 -38
- metadata +3 -3
data/History.txt
CHANGED
data/bin/gren
CHANGED
data/lib/gren.rb
CHANGED
data/lib/gren/findgrep.rb
CHANGED
@@ -71,49 +71,35 @@ module Gren
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def searchAndPrintIN(stdout, dir, depth)
|
74
|
-
if (@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
|
80
|
-
fpath = File.join(dir,name)
|
81
|
-
fpath_disp = fpath.gsub(/^.\//, "")
|
79
|
+
next if (name == '.' || name == '..')
|
82
80
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
-
|
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
|
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 :
|
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
|
-
-
|
9
|
-
version: 0.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-
|
17
|
+
date: 2010-08-06 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|