rbfind 1.5 → 1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rbfind +5 -0
- data/lib/rbfind.rb +21 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c046a612c3da3a05daa0de7853ebf36891dea0da
|
4
|
+
data.tar.gz: 279bdbadfef3185b025c02d6d1f84d7ddc9bda35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1cc146111ab1bd02e9978bbede94b063c61675f013ba72219385f04312b8a1a7641225e6a04c8bc4996d3516b17a503f11dc1c08b41da24601a75281541bea0
|
7
|
+
data.tar.gz: a887cfd06d7a547d881e450284a94d2f9079d4a802cfa10be1efc334391c05bd0266e7a8bbbae6a26aca09872da5f58d4573e08ac5541357a018f45bb100d2e6
|
data/bin/rbfind
CHANGED
@@ -35,6 +35,7 @@ OPTIONS = [
|
|
35
35
|
[ %w(--puts-path -p), nil, "do 'puts path/cpath' on true block"],
|
36
36
|
[ %w(--ls-l -P), nil, "do 'ls -l' style output on true block"],
|
37
37
|
[ %w(--wider -+), nil, "widen fields in long output format (--ls-l)"],
|
38
|
+
[ %w(--slash -/), nil, "append a slash to directory names"],
|
38
39
|
[ %w(--lines -l), :blk, "surround block by 'lines { |$_,$.| ... }'"],
|
39
40
|
[ %w(--reallines -L), :blk, "same as -l but stop at any null character"],
|
40
41
|
[ %w(--grep -g), :blk, "grep files (implies -pL)"],
|
@@ -268,6 +269,8 @@ end
|
|
268
269
|
|
269
270
|
@params = {}
|
270
271
|
|
272
|
+
envopts = ENV[ "RBFIND_OPTIONS"]
|
273
|
+
$*.unshift *envopts.split if envopts
|
271
274
|
opts = GetoptLong.new *OPTIONS.map { |(long,short),arg,|
|
272
275
|
[long,short,(arg ? GetoptLong::REQUIRED_ARGUMENT : GetoptLong::NO_ARGUMENT)]
|
273
276
|
}
|
@@ -294,6 +297,7 @@ begin
|
|
294
297
|
when '--puts-path' then @puts = true
|
295
298
|
when '--ls-l' then @puts = true ; @wd = 6
|
296
299
|
when '--wider' then @wd = @wd ? @wd.succ : 4
|
300
|
+
when '--slash' then @slash = true
|
297
301
|
when '--lines' then @lines = :plain ; @block = arg
|
298
302
|
when '--reallines' then @lines = :plain ; @real = true ; @block = arg
|
299
303
|
when '--grep' then @lines = :grep ; @block = arg
|
@@ -373,6 +377,7 @@ error_handle do
|
|
373
377
|
|
374
378
|
co = color_on $stdout
|
375
379
|
opath = co ? "cpath" : "path"
|
380
|
+
@slash and opath << "!"
|
376
381
|
case @lines
|
377
382
|
when :plain then
|
378
383
|
@puts and @block = "( #@block ) and colsep #{opath}, num, line"
|
data/lib/rbfind.rb
CHANGED
@@ -63,6 +63,8 @@ In Ruby programs, you may call:
|
|
63
63
|
f.name # file name (*)
|
64
64
|
f.path # file path relative to working directory (*)
|
65
65
|
f.fullpath # full file path (*)
|
66
|
+
f.path! # directories with a slash appended (*)
|
67
|
+
f.fullpath! # directories with a slash appended (*)
|
66
68
|
f.dirname # dirname of path
|
67
69
|
f.ext # file name extension
|
68
70
|
f.without_ext # file name without extension
|
@@ -153,7 +155,9 @@ Derivated from stat:
|
|
153
155
|
|
154
156
|
f.cname # colorized name
|
155
157
|
f.cpath # colorized path
|
158
|
+
f.cpath! # colorized path!
|
156
159
|
f.cfullpath # colorized fullpath
|
160
|
+
f.cfullpath! # colorized fullpath!
|
157
161
|
f.creadlink # colored symlink pointer
|
158
162
|
f.carrow # colored "-> symlink" suffix
|
159
163
|
|
@@ -249,7 +253,7 @@ Sort without case sensitivity and preceding dot:
|
|
249
253
|
|
250
254
|
class RbFind
|
251
255
|
|
252
|
-
VERSION = "1.
|
256
|
+
VERSION = "1.6".freeze
|
253
257
|
|
254
258
|
class <<self
|
255
259
|
private :new
|
@@ -305,9 +309,17 @@ class RbFind
|
|
305
309
|
end
|
306
310
|
end
|
307
311
|
|
308
|
-
|
309
|
-
|
310
|
-
def
|
312
|
+
private
|
313
|
+
|
314
|
+
def append_slash s ; (File.directory? s) ? (File.join s, "") : s ; end
|
315
|
+
|
316
|
+
public
|
317
|
+
|
318
|
+
def name ; @levels.last ; end
|
319
|
+
def path ; @path ; end
|
320
|
+
def fullpath ; @fullpath ; end
|
321
|
+
def path! ; append_slash @path ; end
|
322
|
+
def fullpath! ; append_slash @fullpath ; end
|
311
323
|
|
312
324
|
def dirname
|
313
325
|
d = File.dirname @fullpath
|
@@ -446,9 +458,11 @@ class RbFind
|
|
446
458
|
end
|
447
459
|
|
448
460
|
|
449
|
-
def cname
|
450
|
-
def cpath
|
451
|
-
def cfullpath
|
461
|
+
def cname ; color name ; end
|
462
|
+
def cpath ; color path ; end
|
463
|
+
def cfullpath ; color fullpath ; end
|
464
|
+
def cpath! ; color path! ; end
|
465
|
+
def cfullpath! ; color fullpath! ; end
|
452
466
|
|
453
467
|
def color arg
|
454
468
|
col_stat arg, stat
|