rbfind 2.0.1 → 2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rbfind +2 -3
- data/lib/rbfind.rb +17 -6
- data/lib/rbfind/humansiz.rb +10 -0
- data/lib/rbfind/table.rb +30 -24
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0655e863af78b2081d7306e8823694ef7ad5c48625dbdd9c7f0f75fb8a85d4d7
|
4
|
+
data.tar.gz: 0ef05d8082c2487d7079176ea8373f31e392d41eb1dd269555c47832ff313689
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 915e2359d8bb0c7814c682f8247e71eb7db8742a8095c2cdbb44194252df0ba2636602443ca916055a3f260cece8de837118c565c76ca2bfb470dd2409749a94
|
7
|
+
data.tar.gz: f72fdc455e7ac5eba31060f3c96176f47985f7a4f41fd55d089dc78d7b713838365c5b949f537b7089b223829e63ac5ed64935af9a80a90639e31aa7ade67474
|
data/bin/rbfind
CHANGED
@@ -37,7 +37,6 @@ module RbFind
|
|
37
37
|
[ %w(--sort-by -s), :str, "sort expression ('n' is name)"],
|
38
38
|
[ %w(--reverse -R), :str, "reverse sort"],
|
39
39
|
[ %w(--require -r), :rb, "require library"],
|
40
|
-
[ %w(--fileutils -U), nil, "include FileUtils module"],
|
41
40
|
[ %w(--puts-path -p), nil, "do 'puts path/cpath' on true block"],
|
42
41
|
[ %w(--ls-l -P), nil, "do 'ls -l' style output on true block"],
|
43
42
|
[ %w(--wider -+), nil, "widen fields in long output format (--ls-l)"],
|
@@ -85,7 +84,6 @@ module RbFind
|
|
85
84
|
when '--sort-by' then @params[ :sort] = instance_eval "proc { |n| #{arg} }"
|
86
85
|
when '--reverse' then @params[ :reverse] = true
|
87
86
|
when '--require' then require arg
|
88
|
-
when '--fileutils' then require "fileutils" ; include FileUtils
|
89
87
|
when '--puts-path' then @puts = true
|
90
88
|
when '--ls-l' then @puts = true ; @wd = 6
|
91
89
|
when '--wider' then @wd = @wd ? @wd.succ : 4
|
@@ -138,7 +136,7 @@ module RbFind
|
|
138
136
|
|
139
137
|
when :grep then
|
140
138
|
re = Regexp.new @block, @icase && Regexp::IGNORECASE
|
141
|
-
@block = "grep #{re.inspect}"
|
139
|
+
@block = "grep %r#{re.inspect}"
|
142
140
|
@block << ", true" if co
|
143
141
|
@block << " ; $stdout.flush" unless $stdout.tty?
|
144
142
|
@binary or @block = "not binary? and (#@block)"
|
@@ -371,6 +369,7 @@ module RbFind
|
|
371
369
|
alias hidden hidden?
|
372
370
|
alias visible visible?
|
373
371
|
alias broken_link broken_link?
|
372
|
+
alias broken broken?
|
374
373
|
alias dir dir?
|
375
374
|
alias binary binary?
|
376
375
|
alias bin bin?
|
data/lib/rbfind.rb
CHANGED
@@ -8,7 +8,7 @@ require "rbfind/csv"
|
|
8
8
|
|
9
9
|
module RbFind
|
10
10
|
|
11
|
-
VERSION = "2.
|
11
|
+
VERSION = "2.3".freeze
|
12
12
|
|
13
13
|
=begin rdoc
|
14
14
|
|
@@ -119,6 +119,8 @@ Derivated from stat:
|
|
119
119
|
csv sep, path, ... # separate by user-defined separator
|
120
120
|
|
121
121
|
rename newname # rename, but leave it in the same directory
|
122
|
+
mv newname # dto.
|
123
|
+
rm # remove
|
122
124
|
|
123
125
|
|
124
126
|
== Color support
|
@@ -374,16 +376,22 @@ Sort without case sensitivity and preceding dot:
|
|
374
376
|
begin
|
375
377
|
e.instance_eval &@block
|
376
378
|
rescue Done
|
377
|
-
|
378
|
-
|
379
|
-
|
379
|
+
end
|
380
|
+
if !(e.name.equal? @levels.last) && e.name != @levels.last then
|
381
|
+
if e.name then
|
380
382
|
e.name == (File.basename e.name) or
|
381
383
|
raise "#{self.class}: rename to `#{e.name}' may not be a path."
|
382
384
|
e.name.freeze
|
383
385
|
@levels.pop
|
384
386
|
@levels.push e.name
|
385
|
-
@path = join_path
|
387
|
+
p, @path = @path, join_path
|
386
388
|
File.rename p, @path
|
389
|
+
else
|
390
|
+
if e.dir? then
|
391
|
+
Dir.rmdir @path
|
392
|
+
else
|
393
|
+
File.unlink @path
|
394
|
+
end
|
387
395
|
end
|
388
396
|
end
|
389
397
|
true
|
@@ -511,12 +519,13 @@ Sort without case sensitivity and preceding dot:
|
|
511
519
|
def readlink ; File.readlink @path if stat.symlink? ; end
|
512
520
|
|
513
521
|
def broken_link?
|
514
|
-
return
|
522
|
+
return unless stat.symlink?
|
515
523
|
rstat
|
516
524
|
false
|
517
525
|
rescue
|
518
526
|
true
|
519
527
|
end
|
528
|
+
alias broken? broken_link?
|
520
529
|
|
521
530
|
ARROW = " -> "
|
522
531
|
def arrow
|
@@ -682,7 +691,9 @@ Sort without case sensitivity and preceding dot:
|
|
682
691
|
|
683
692
|
|
684
693
|
def rename newname ; @name = newname ; end
|
694
|
+
alias mv rename
|
685
695
|
|
696
|
+
def rm ; @name = nil ; end
|
686
697
|
|
687
698
|
|
688
699
|
def cname ; color name ; end
|
data/lib/rbfind/humansiz.rb
CHANGED
@@ -83,6 +83,16 @@ class Numeric # sizes in bytes
|
|
83
83
|
end
|
84
84
|
|
85
85
|
|
86
|
+
class Integer
|
87
|
+
def to_g
|
88
|
+
s = to_s
|
89
|
+
l = []
|
90
|
+
while (t = s.slice! /\d{1,3}\z/) do l.unshift t end
|
91
|
+
l.join "_"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
86
96
|
class Numeric
|
87
97
|
"smhdw".each_char { |c|
|
88
98
|
define_method c do Time.to_sec self, c end
|
data/lib/rbfind/table.rb
CHANGED
@@ -9,18 +9,28 @@ module RbFind
|
|
9
9
|
|
10
10
|
def initialize *heads
|
11
11
|
heads.flatten!
|
12
|
-
@heads = heads
|
12
|
+
@heads = heads.map { |h|
|
13
|
+
a = case h
|
14
|
+
when />\z/ then +1
|
15
|
+
when /\^\z/ then 0
|
16
|
+
when /<?\z/ then -1
|
17
|
+
end
|
18
|
+
[ $`, a]
|
19
|
+
}
|
13
20
|
@rows = []
|
14
21
|
end
|
15
22
|
|
16
|
-
|
17
|
-
|
23
|
+
attr_reader :heads
|
24
|
+
protected :heads
|
25
|
+
def initialize_copy oth
|
26
|
+
@heads = oth.heads
|
27
|
+
@rows = []
|
18
28
|
end
|
19
29
|
|
20
30
|
def add *row
|
21
31
|
row.flatten!
|
22
32
|
n = @heads.size
|
23
|
-
row
|
33
|
+
row.map! { |r| break if n.zero? ; n -= 1 ; r.to_s }
|
24
34
|
@rows.push row
|
25
35
|
end
|
26
36
|
|
@@ -38,14 +48,14 @@ module RbFind
|
|
38
48
|
|
39
49
|
def make_lines head: false
|
40
50
|
rs = @rows
|
41
|
-
rs.unshift
|
51
|
+
rs.unshift @heads.map { |(h,a)| h } if head
|
42
52
|
w = calc_widths
|
43
53
|
rs.each { |r|
|
44
|
-
j = (w.zip @heads, r).map { |v,
|
45
|
-
case
|
46
|
-
when
|
47
|
-
when
|
48
|
-
when
|
54
|
+
j = (w.zip @heads, r).map { |v,(_,a),c|
|
55
|
+
case a
|
56
|
+
when -1 then c.ljust v
|
57
|
+
when 0 then c.center v
|
58
|
+
when +1 then c.rjust v
|
49
59
|
end
|
50
60
|
}
|
51
61
|
l = j.join " "
|
@@ -59,14 +69,14 @@ module RbFind
|
|
59
69
|
@html = ""
|
60
70
|
tag :table, table, nl: 2 do
|
61
71
|
tag :tr, row, nl: 1 do
|
62
|
-
|
63
|
-
tag :td,
|
72
|
+
@heads.each { |(h,a)|
|
73
|
+
tag :td, h.downcase, align: a do @html << h end
|
64
74
|
}
|
65
75
|
end
|
66
76
|
@rows.each { |r|
|
67
77
|
tag :tr, table, nl: 1 do
|
68
|
-
(@heads.zip
|
69
|
-
tag :td, g.downcase, align:
|
78
|
+
(@heads.zip r).each { |(g,a),c|
|
79
|
+
tag :td, g.downcase, align: a do @html << c end
|
70
80
|
}
|
71
81
|
end
|
72
82
|
}
|
@@ -86,13 +96,9 @@ module RbFind
|
|
86
96
|
w
|
87
97
|
end
|
88
98
|
|
89
|
-
def heads_plain
|
90
|
-
@heads.map { |h| h.sub /\W\z/, "" }
|
91
|
-
end
|
92
|
-
|
93
99
|
def tag name, cls, nl: 0, align: nil
|
94
100
|
@html << "<#{name}"
|
95
|
-
@html << " style=\"text-align: " << align << ";\"" if align
|
101
|
+
@html << " style=\"text-align: " << (html_align align) << ";\"" if align
|
96
102
|
@html << " class=\"" << cls << "\"" if cls
|
97
103
|
@html << ">"
|
98
104
|
@html << $/ if nl > 1
|
@@ -101,11 +107,11 @@ module RbFind
|
|
101
107
|
@html << $/ if nl > 0
|
102
108
|
end
|
103
109
|
|
104
|
-
def html_align
|
105
|
-
case
|
106
|
-
when
|
107
|
-
when
|
108
|
-
when
|
110
|
+
def html_align a
|
111
|
+
case a
|
112
|
+
when -1 then "left"
|
113
|
+
when 0 then "center"
|
114
|
+
when +1 then "right"
|
109
115
|
end
|
110
116
|
end
|
111
117
|
|
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.
|
4
|
+
version: '2.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bertram Scharpf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
A replacement for the standard UNIX command find.
|
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
version: '0'
|
55
55
|
requirements:
|
56
56
|
- just Ruby
|
57
|
-
rubygems_version: 3.0.
|
57
|
+
rubygems_version: 3.0.8
|
58
58
|
signing_key:
|
59
59
|
specification_version: 4
|
60
60
|
summary: Ruby replacement for the standard Unix find tool
|