rbfind 2.2 → 2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rbfind.rb +1 -1
  3. data/lib/rbfind/table.rb +30 -24
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75ec1222c8e64f36c9927aa96c1c4f2a737d624d142fea22bfce274637074a7b
4
- data.tar.gz: 6c34e268c249977c6c74dc3bf42d841ea63c2649274742be29918a1c19d592a0
3
+ metadata.gz: 0655e863af78b2081d7306e8823694ef7ad5c48625dbdd9c7f0f75fb8a85d4d7
4
+ data.tar.gz: 0ef05d8082c2487d7079176ea8373f31e392d41eb1dd269555c47832ff313689
5
5
  SHA512:
6
- metadata.gz: c71fdaa76238ddae6fcc6b887bf30280f7f48c97e92d324ad5a400f81de8038f4fbe1b10ff931e4cc8f80604d69e71e496a80f99544ff5ba5a37ad0beb1dc2ea
7
- data.tar.gz: b12aad69797682840b1a75b07b77f5474d5aab8e66b4b536dfe41e538e7f5fee493aaf5ad493db8419454532729600acc037e0936001b193d7911a44ac886f73
6
+ metadata.gz: 915e2359d8bb0c7814c682f8247e71eb7db8742a8095c2cdbb44194252df0ba2636602443ca916055a3f260cece8de837118c565c76ca2bfb470dd2409749a94
7
+ data.tar.gz: f72fdc455e7ac5eba31060f3c96176f47985f7a4f41fd55d089dc78d7b713838365c5b949f537b7089b223829e63ac5ed64935af9a80a90639e31aa7ade67474
@@ -8,7 +8,7 @@ require "rbfind/csv"
8
8
 
9
9
  module RbFind
10
10
 
11
- VERSION = "2.2".freeze
11
+ VERSION = "2.3".freeze
12
12
 
13
13
  =begin rdoc
14
14
 
@@ -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
- def spawn
17
- self.class.new *@heads
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[ 0, n] = row[ 0, n].map { |r| r.to_s }
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 heads_plain if head
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,h,c|
45
- case h
46
- when />\z/ then c.rjust v
47
- when /\^\z/ then c.center v
48
- when /<?\z/ then c.ljust v
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
- (@heads.zip heads_plain).each { |h,c|
63
- tag :td, c.downcase, align: (html_align h) do @html << c end
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 heads_plain, r).each { |h,g,c|
69
- tag :td, g.downcase, align: (html_align h) do @html << c end
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 h
105
- case h
106
- when />/ then "right"
107
- when /\^/ then "center"
108
- when /<?/ then "left"
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.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-19 00:00:00.000000000 Z
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.