table-formatter 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/table-formatter.rb +16 -20
- metadata +19 -17
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f48b45d64b37cf9717740bccbfcbe9f2b27461c6
|
4
|
+
data.tar.gz: 9d701c6f18c4d13bfde273231bf379d60adadd9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c55a34ec74104aa1a0e3d5acbfe685497d87c753ea3a094076c2a4df76582963f889e0f803bc32a4b0886d5853dc7e9740c5014535be9a5a95978b3b52a8798
|
7
|
+
data.tar.gz: f61e9e5a884e020296b45ed9c49a1f182779c56c7e6aef01f755f45dfda5b9d8a9a363dff8ba6900b540c8a3ac31de6d68bb1c6de3b9dcb555cb8fd46444d5df
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/table-formatter.rb
CHANGED
@@ -6,15 +6,14 @@ class TableFormatter
|
|
6
6
|
|
7
7
|
attr_accessor :source, :labels, :border, :divider
|
8
8
|
|
9
|
-
def initialize(
|
9
|
+
def initialize(source: nil, labels: nil, border: true, nowrap: false, divider: nil)
|
10
10
|
|
11
|
-
o = {source: nil, labels: nil, border: true, nowrap: false}.merge(opt)
|
12
11
|
super()
|
13
|
-
@source =
|
14
|
-
@raw_labels =
|
15
|
-
@border =
|
16
|
-
@nowrap =
|
17
|
-
@divider =
|
12
|
+
@source = source
|
13
|
+
@raw_labels = labels
|
14
|
+
@border = border
|
15
|
+
@nowrap = nowrap
|
16
|
+
@divider = divider
|
18
17
|
@maxwidth = 60
|
19
18
|
end
|
20
19
|
|
@@ -70,17 +69,19 @@ class TableFormatter
|
|
70
69
|
d.map{|x| x.max_by(&:length).length}
|
71
70
|
end
|
72
71
|
|
73
|
-
def format_cols(row, col_widths)
|
72
|
+
def format_cols(row, col_widths, bar='')
|
74
73
|
|
75
|
-
|
76
|
-
bar = '|' if border == true
|
77
|
-
|
78
|
-
|
74
|
+
outer_bar = ''
|
75
|
+
outer_bar = bar = '|' if border == true
|
76
|
+
col_spacer = @divider ? 1 : 2
|
77
|
+
|
78
|
+
buffer = outer_bar
|
79
79
|
|
80
80
|
row.each_with_index do |col, i|
|
81
81
|
|
82
82
|
align = @align_cols ? @align_cols[i] : :ljust
|
83
|
-
|
83
|
+
next_bar = (i < row.length - 1 || border) ? bar : ''
|
84
|
+
buffer += col.method(align).call(col_widths[i] + col_spacer) + next_bar
|
84
85
|
end
|
85
86
|
|
86
87
|
buffer
|
@@ -100,13 +101,8 @@ class TableFormatter
|
|
100
101
|
end
|
101
102
|
end
|
102
103
|
|
103
|
-
a.map
|
104
|
-
|
105
|
-
row.join(divider)
|
106
|
-
else
|
107
|
-
format_cols(row, col_widths)
|
108
|
-
end
|
109
|
-
end
|
104
|
+
a.map {|row| format_cols(row, col_widths, divider) }
|
105
|
+
|
110
106
|
end
|
111
107
|
|
112
108
|
def just(x)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table-formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,26 +10,28 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
14
|
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc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sRVEXpvqlYPBZioEzCn5f0
|
28
|
+
re+bscYJS5XmScGZHjTH9Gr5eahV6AWQTpBFdI5d416db4RuOtHZ8Ek+qr2us0VD
|
29
|
+
Kxqfb7yOCHMxQVNUD42DSBIsK+n2uX0++ltsnW8o8ZQvL4nrUdxMBUF28m3Z+V3o
|
30
|
+
ZWtCoj2zbSQLZzmPNIy9RAzn4Z64XB651zDe432QymDfLSEVi6n5YKixjsDOfa91
|
31
|
+
xMYZkElOttvQm8M6uUy483IxDueFvAWV/BnpYc9uzT6Rb9VtyMgUXX9pi/WwGjoF
|
32
|
+
0vXd6ZyRHRSlpQ==
|
31
33
|
-----END CERTIFICATE-----
|
32
|
-
date: 2014-
|
34
|
+
date: 2014-03-25 00:00:00.000000000 Z
|
33
35
|
dependencies: []
|
34
36
|
description:
|
35
37
|
email: james@r0bertson.co.uk
|
metadata.gz.sig
CHANGED
Binary file
|