rbfind 2.2 → 2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbfind.rb +1 -1
- data/lib/rbfind/table.rb +30 -24
- 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: 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/lib/rbfind.rb
CHANGED
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-10-
|
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.
|