rbfind 2.8.1 → 2.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rbfind +8 -8
- data/lib/rbfind/table.rb +8 -1
- data/lib/rbfind.rb +28 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47ca00aba0ae8524f5387884b0709ebf9ed3ab432747796bd0d2ec169af74cd0
|
4
|
+
data.tar.gz: 6f3251bd4d89bb2f63afbe0384959fb0877cd0bffe2b6436e776af757d93c81c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3eb71d77d938432ec563bfed26ffa969d386e9a98512b8453e2df7f1cd968599f1f9a1be8d7c81e018c10dcf00d9adbf12758f6ef940442c31c1e2072efe7126
|
7
|
+
data.tar.gz: ae0b19c287053a09e1c2a9c96fa0b877668bd8534d20a8cf3efa0ebdff95dd32e9b2ab9d06ac391308ee7d9d120ada5a6590dc5a3409a3f54b7af903072cffe8
|
data/bin/rbfind
CHANGED
@@ -31,8 +31,8 @@ module RbFind
|
|
31
31
|
[ %w(--bw -w), nil, "black and white on -p or default output"],
|
32
32
|
[ %w(--colored -c), nil, "force color on -p or default output"],
|
33
33
|
[ %w(--depth -d), nil, "yield directory after its contents"],
|
34
|
-
[ %w(--maxdepth -m), :num, "maxium step depth"],
|
35
|
-
[ %w(--
|
34
|
+
[ %w(--maxdepth -m), :num, "maxium step depth (0 = any)"],
|
35
|
+
[ %w(--argsdepth -A), nil, "args have depth 1 (not 0)"],
|
36
36
|
[ %w(--follow -y), nil, "follow symbolic links"],
|
37
37
|
[ %w(--nosort -U), nil, "unsorted"],
|
38
38
|
[ %w(--sort-by -s), :str, "sort expression"],
|
@@ -85,15 +85,15 @@ module RbFind
|
|
85
85
|
when '--bw' then @color = false
|
86
86
|
when '--colored' then @color = true
|
87
87
|
when '--depth' then @params[ :depth_first] = true
|
88
|
-
when '--maxdepth' then @params[ :max_depth] = arg.to_i
|
89
|
-
when '--
|
88
|
+
when '--maxdepth' then @params[ :max_depth] = arg.to_i.nonzero?
|
89
|
+
when '--argsdepth' then @params[ :args_depth] = true
|
90
90
|
when '--follow' then @params[ :follow] = true
|
91
91
|
when '--nosort' then @params[ :sort] = false
|
92
92
|
when '--sort-by' then @params[ :sort] = instance_eval "proc { #{arg} }"
|
93
93
|
when '--time' then @params[ :sort] = proc { mtime } ; @params[ :reverse] = true
|
94
94
|
when '--size' then @params[ :sort] = proc { size } ; @params[ :reverse] = true
|
95
95
|
when '--dirs' then @params[ :dirs] = true
|
96
|
-
when '--reverse' then @params[ :reverse] =
|
96
|
+
when '--reverse' then @params[ :reverse] = !@params[ :reverse]
|
97
97
|
when '--require' then require arg
|
98
98
|
when '--puts-path' then @puts = true
|
99
99
|
when '--ls-l' then @puts = :ls ; @wds = 6 ; @wd = 6
|
@@ -240,10 +240,10 @@ module RbFind
|
|
240
240
|
"--" stops option processing.
|
241
241
|
|
242
242
|
The last argument is a block that will be executed on every found
|
243
|
-
file object. It may be omitted; then "puts path" is assumed or
|
244
|
-
in case the output is a terminal.
|
243
|
+
file object. It may be omitted; then "puts path" is assumed, or
|
244
|
+
"puts cpath" in case the output is a terminal.
|
245
245
|
|
246
|
-
Default sort order is
|
246
|
+
Default sort order is by name.
|
247
247
|
EOT
|
248
248
|
end
|
249
249
|
|
data/lib/rbfind/table.rb
CHANGED
@@ -56,6 +56,7 @@ module RbFind
|
|
56
56
|
w = calc_widths
|
57
57
|
rs.each { |r|
|
58
58
|
j = (w.zip @heads, r).map { |v,(_,a),c|
|
59
|
+
v ||= ""
|
59
60
|
case a
|
60
61
|
when -1 then c.ljust v
|
61
62
|
when 0 then c.center v
|
@@ -95,7 +96,13 @@ module RbFind
|
|
95
96
|
def calc_widths
|
96
97
|
w = @heads.map { 0 }
|
97
98
|
@rows.each { |r|
|
98
|
-
w = (w.zip r).map { |i,c|
|
99
|
+
w = (w.zip r).map { |i,c|
|
100
|
+
if c then
|
101
|
+
j = c.length
|
102
|
+
i = j if j > i
|
103
|
+
end
|
104
|
+
i
|
105
|
+
}
|
99
106
|
}
|
100
107
|
w
|
101
108
|
end
|
data/lib/rbfind.rb
CHANGED
@@ -8,7 +8,7 @@ require "rbfind/csv"
|
|
8
8
|
|
9
9
|
module RbFind
|
10
10
|
|
11
|
-
VERSION = "2.8.
|
11
|
+
VERSION = "2.8.5".freeze
|
12
12
|
|
13
13
|
=begin rdoc
|
14
14
|
|
@@ -270,12 +270,12 @@ Sort without case sensitivity and preceding dot:
|
|
270
270
|
|
271
271
|
private
|
272
272
|
|
273
|
-
Params = Struct.new :max_depth, :depth_first, :follow,
|
273
|
+
Params = Struct.new :max_depth, :args_depth, :depth_first, :follow,
|
274
274
|
:sort, :dirs, :reverse, :error, :block
|
275
275
|
|
276
|
-
def initialize max_depth: nil, depth_first: nil, follow: nil,
|
276
|
+
def initialize max_depth: nil, args_depth: false, depth_first: nil, follow: nil,
|
277
277
|
sort: true, dirs: false, reverse: false, error: nil, &block
|
278
|
-
@params = Params.new max_depth, depth_first, follow,
|
278
|
+
@params = Params.new max_depth, args_depth, depth_first, follow,
|
279
279
|
(sort_parser sort), dirs, reverse, error, block
|
280
280
|
@start = Time.instance_eval { @start = Time.now }
|
281
281
|
Time.instance_eval { @start = Time.now }
|
@@ -299,10 +299,12 @@ Sort without case sensitivity and preceding dot:
|
|
299
299
|
if args.empty? then
|
300
300
|
visit_dir Dir::CUR_DIR
|
301
301
|
else
|
302
|
-
args.
|
303
|
-
|
304
|
-
|
305
|
-
|
302
|
+
list = args.map { |base| Entry.new base, self }
|
303
|
+
list.select! { |e| handle_error do e.stat end }
|
304
|
+
sort_entries list
|
305
|
+
step_depth_args do
|
306
|
+
list.each { |e| enter e }
|
307
|
+
end
|
306
308
|
end
|
307
309
|
end
|
308
310
|
|
@@ -319,6 +321,16 @@ Sort without case sensitivity and preceding dot:
|
|
319
321
|
@depth -= 1
|
320
322
|
end
|
321
323
|
|
324
|
+
def step_depth_args
|
325
|
+
if @params[ :args_depth] then
|
326
|
+
step_depth do
|
327
|
+
yield
|
328
|
+
end
|
329
|
+
else
|
330
|
+
yield
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
322
334
|
def enter elem
|
323
335
|
c_, @current = @current, elem
|
324
336
|
@count += 1
|
@@ -345,16 +357,20 @@ Sort without case sensitivity and preceding dot:
|
|
345
357
|
def visit_dir dir
|
346
358
|
return if @params.max_depth and @params.max_depth <= @depth
|
347
359
|
list = (Dir.new dir).children.map { |f| Entry.new f, self }
|
360
|
+
sort_entries list
|
361
|
+
step_depth do
|
362
|
+
list.each { |e| enter e }
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
def sort_entries list
|
348
367
|
@params.sort.call list
|
349
368
|
list.reverse! if @params.reverse
|
350
369
|
if @params.dirs then
|
351
|
-
list
|
370
|
+
list.replace list.partition { |e| e.rstat.directory? rescue nil }
|
352
371
|
list.reverse! if @params.depth_first
|
353
372
|
list.flatten!
|
354
373
|
end
|
355
|
-
step_depth do
|
356
|
-
list.each { |e| enter e }
|
357
|
-
end
|
358
374
|
end
|
359
375
|
|
360
376
|
def enter_dir
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbfind
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.8.
|
4
|
+
version: 2.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bertram Scharpf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
A replacement for the standard UNIX command find.
|