rbfind 2.1 → 2.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 +2 -1
- data/lib/rbfind.rb +9 -4
- data/lib/rbfind/humansiz.rb +10 -0
- data/lib/rbfind/table.rb +35 -25
- 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: cc576c9c24d5acd2c31b95e55bfd40b306c1510060c06c2a5d00140c1fca77dd
|
4
|
+
data.tar.gz: e2a95604bf31b4290d71b0c93da8bff1cde417407cf6c22c79872cf4132c6de3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 671c10d123f2a025f4ee3b0f0b08cbe2a74ef830a0b8f56cd7485470c68051902db9ace56b00a5f479d36ceefb802d133ddd43aa5cc025286a49405ce4860e79
|
7
|
+
data.tar.gz: 39a4b9cd0565455b010228a68fefd7d021e81953cdd23c150555a83fef577a342282f42b6476c6f1e97287d9e99b659349284eae55244fbfff01edf40a2d724c
|
data/bin/rbfind
CHANGED
@@ -142,7 +142,7 @@ module RbFind
|
|
142
142
|
@binary or @block = "not binary? and (#@block)"
|
143
143
|
|
144
144
|
else
|
145
|
-
@block ||= if @args.last and not (File.
|
145
|
+
@block ||= if @args.last and not (File.lstat @args.last rescue false) then
|
146
146
|
@args.pop.dup
|
147
147
|
else
|
148
148
|
@puts ||= true
|
@@ -369,6 +369,7 @@ module RbFind
|
|
369
369
|
alias hidden hidden?
|
370
370
|
alias visible visible?
|
371
371
|
alias broken_link broken_link?
|
372
|
+
alias broken broken?
|
372
373
|
alias dir dir?
|
373
374
|
alias binary binary?
|
374
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.4".freeze
|
12
12
|
|
13
13
|
=begin rdoc
|
14
14
|
|
@@ -307,7 +307,7 @@ Sort without case sensitivity and preceding dot:
|
|
307
307
|
else
|
308
308
|
args.each { |base|
|
309
309
|
handle_error do
|
310
|
-
File.
|
310
|
+
File.lstat base rescue raise "`#{base}` doesn't exist."
|
311
311
|
visit_depth base
|
312
312
|
end
|
313
313
|
}
|
@@ -519,12 +519,13 @@ Sort without case sensitivity and preceding dot:
|
|
519
519
|
def readlink ; File.readlink @path if stat.symlink? ; end
|
520
520
|
|
521
521
|
def broken_link?
|
522
|
-
return
|
522
|
+
return unless stat.symlink?
|
523
523
|
rstat
|
524
524
|
false
|
525
525
|
rescue
|
526
526
|
true
|
527
527
|
end
|
528
|
+
alias broken? broken_link?
|
528
529
|
|
529
530
|
ARROW = " -> "
|
530
531
|
def arrow
|
@@ -551,7 +552,11 @@ Sort without case sensitivity and preceding dot:
|
|
551
552
|
# Check whether a directory contains an entry.
|
552
553
|
#
|
553
554
|
def contains? name
|
554
|
-
|
555
|
+
p = File.join @path, name
|
556
|
+
File.lstat p
|
557
|
+
true
|
558
|
+
rescue
|
559
|
+
false
|
555
560
|
end
|
556
561
|
|
557
562
|
# :call-seq:
|
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
|
|
@@ -32,20 +42,24 @@ module RbFind
|
|
32
42
|
@rows.empty?
|
33
43
|
end
|
34
44
|
|
35
|
-
def output head: false
|
45
|
+
def output head: false, ifempty: nil
|
46
|
+
if empty? and ifempty then
|
47
|
+
puts ifempty
|
48
|
+
return
|
49
|
+
end
|
36
50
|
make_lines head: head do |l| puts l end
|
37
51
|
end
|
38
52
|
|
39
53
|
def make_lines head: false
|
40
54
|
rs = @rows
|
41
|
-
rs.unshift
|
55
|
+
rs.unshift @heads.map { |(h,a)| h } if head
|
42
56
|
w = calc_widths
|
43
57
|
rs.each { |r|
|
44
|
-
j = (w.zip @heads, r).map { |v,
|
45
|
-
case
|
46
|
-
when
|
47
|
-
when
|
48
|
-
when
|
58
|
+
j = (w.zip @heads, r).map { |v,(_,a),c|
|
59
|
+
case a
|
60
|
+
when -1 then c.ljust v
|
61
|
+
when 0 then c.center v
|
62
|
+
when +1 then c.rjust v
|
49
63
|
end
|
50
64
|
}
|
51
65
|
l = j.join " "
|
@@ -59,14 +73,14 @@ module RbFind
|
|
59
73
|
@html = ""
|
60
74
|
tag :table, table, nl: 2 do
|
61
75
|
tag :tr, row, nl: 1 do
|
62
|
-
|
63
|
-
tag :td,
|
76
|
+
@heads.each { |(h,a)|
|
77
|
+
tag :td, h.downcase, align: a do @html << h end
|
64
78
|
}
|
65
79
|
end
|
66
80
|
@rows.each { |r|
|
67
81
|
tag :tr, table, nl: 1 do
|
68
|
-
(@heads.zip
|
69
|
-
tag :td, g.downcase, align:
|
82
|
+
(@heads.zip r).each { |(g,a),c|
|
83
|
+
tag :td, g.downcase, align: a do @html << c end
|
70
84
|
}
|
71
85
|
end
|
72
86
|
}
|
@@ -86,13 +100,9 @@ module RbFind
|
|
86
100
|
w
|
87
101
|
end
|
88
102
|
|
89
|
-
def heads_plain
|
90
|
-
@heads.map { |h| h.sub /\W\z/, "" }
|
91
|
-
end
|
92
|
-
|
93
103
|
def tag name, cls, nl: 0, align: nil
|
94
104
|
@html << "<#{name}"
|
95
|
-
@html << " style=\"text-align: " << align << ";\"" if align
|
105
|
+
@html << " style=\"text-align: " << (html_align align) << ";\"" if align
|
96
106
|
@html << " class=\"" << cls << "\"" if cls
|
97
107
|
@html << ">"
|
98
108
|
@html << $/ if nl > 1
|
@@ -101,11 +111,11 @@ module RbFind
|
|
101
111
|
@html << $/ if nl > 0
|
102
112
|
end
|
103
113
|
|
104
|
-
def html_align
|
105
|
-
case
|
106
|
-
when
|
107
|
-
when
|
108
|
-
when
|
114
|
+
def html_align a
|
115
|
+
case a
|
116
|
+
when -1 then "left"
|
117
|
+
when 0 then "center"
|
118
|
+
when +1 then "right"
|
109
119
|
end
|
110
120
|
end
|
111
121
|
|
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.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: 2020-07
|
11
|
+
date: 2020-11-07 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
|