rbfind 2.8 → 2.8.4
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.
- checksums.yaml +4 -4
- data/bin/rbfind +8 -11
- data/lib/rbfind/table.rb +7 -1
- data/lib/rbfind.rb +29 -13
- 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: c48f9b56403a1985bc80039a8f3cecf636cd4613cb641e9a3708e65bc5790500
|
|
4
|
+
data.tar.gz: 77dd4d10810a8c1492460a118d67d5d82951306146ef9db516ef0eb929fdf4cf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8333d71ff3fc7158418d54a3ce117b08b9459abe189ebdc2c5fa2ed66fe7b34baed1ec6ef0e7b624cbf3404c5637bbc6aa7f1a2e6c8583772e2883dfb738c8ef
|
|
7
|
+
data.tar.gz: 7b3eda841f6ca23bc21b3f5a5c48fb2ce7c4c0065fac58e9c8cd630cd94bb8da6ee029af17a4456d67339fa41b90bcd4b32b6107e2dd192c8e4fd0a8990b7b74
|
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
|
|
|
@@ -358,9 +358,6 @@ module RbFind
|
|
|
358
358
|
error_handle do
|
|
359
359
|
eval @blkbegin if @blkbegin
|
|
360
360
|
b = @block
|
|
361
|
-
if not @args.empty? and @params[ :max_depth] then
|
|
362
|
-
@params[ :max_depth] -= 1
|
|
363
|
-
end
|
|
364
361
|
Walk.run *@args, **@params do instance_eval b end
|
|
365
362
|
eval @blkend if @blkend
|
|
366
363
|
end
|
data/lib/rbfind/table.rb
CHANGED
|
@@ -95,7 +95,13 @@ module RbFind
|
|
|
95
95
|
def calc_widths
|
|
96
96
|
w = @heads.map { 0 }
|
|
97
97
|
@rows.each { |r|
|
|
98
|
-
w = (w.zip r).map { |i,c|
|
|
98
|
+
w = (w.zip r).map { |i,c|
|
|
99
|
+
if c then
|
|
100
|
+
j = c.length
|
|
101
|
+
i = j if j > i
|
|
102
|
+
end
|
|
103
|
+
i
|
|
104
|
+
}
|
|
99
105
|
}
|
|
100
106
|
w
|
|
101
107
|
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".freeze
|
|
11
|
+
VERSION = "2.8.4".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
|
|
@@ -343,18 +355,22 @@ Sort without case sensitivity and preceding dot:
|
|
|
343
355
|
end
|
|
344
356
|
|
|
345
357
|
def visit_dir dir
|
|
346
|
-
return if @params.max_depth and @params.max_depth
|
|
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:
|
|
4
|
+
version: 2.8.4
|
|
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.
|