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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55d7d117511c03581216fed4ed7b730af3dc2735
4
- data.tar.gz: b11665ac25129a1a455bce648b330ea715dedfdd
3
+ metadata.gz: f48b45d64b37cf9717740bccbfcbe9f2b27461c6
4
+ data.tar.gz: 9d701c6f18c4d13bfde273231bf379d60adadd9f
5
5
  SHA512:
6
- metadata.gz: d1f349c1b04c4eaf618b486d464d1bfdd48af3200a5d66403458700305ea1a1156024684db35daa230fd1eb2df468b241f4f253fdf98ed39b4f433d08351e049
7
- data.tar.gz: 48a4e9f34f2f5ba660ed19703c7f5f90c3fb3ce598886f05f0d4ae8869affba15bbbf164cb289d130dc453be6c29a5a40e24cbd7bd1c717b89f11274c95e6a25
6
+ metadata.gz: 4c55a34ec74104aa1a0e3d5acbfe685497d87c753ea3a094076c2a4df76582963f889e0f803bc32a4b0886d5853dc7e9740c5014535be9a5a95978b3b52a8798
7
+ data.tar.gz: f61e9e5a884e020296b45ed9c49a1f182779c56c7e6aef01f755f45dfda5b9d8a9a363dff8ba6900b540c8a3ac31de6d68bb1c6de3b9dcb555cb8fd46444d5df
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -6,15 +6,14 @@ class TableFormatter
6
6
 
7
7
  attr_accessor :source, :labels, :border, :divider
8
8
 
9
- def initialize(opt={})
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 = o[:source]
14
- @raw_labels = o[:labels] if o[:labels]
15
- @border = o[:border]
16
- @nowrap = o[:nowrap]
17
- @divider = o[:divider] if o[: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
- bar = ''
76
- bar = '|' if border == true
77
-
78
- buffer = bar
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
- buffer += col.method(align).call(col_widths[i] + 2) + bar
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 do |row|
104
- if divider then
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.9
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
- MIIDRDCCAiygAwIBAgIBADANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
14
  YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTEzMDIwNjIxMDY1MloXDTE0MDIwNjIxMDY1MlowSDESMBAG
15
+ 8ixkARkWAmV1MB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jaMKyhp+NrAreBd7rhk4gaA0tLVHXyFZBjGJItv7df4aXrWoVApeat5p
19
+ v4bvGWVL4mLfWETs5z+vtWDTvicz3qX+V1KDAZDDq+wQ4h1WSSZkGFfF3M7aJUNG
20
+ vAiGwDltwsWiY2AYlAdvfwk2GNW4tqX99+XzAzuGCdvInIUChviC2ai1BHcInPY9
21
+ xmc4ZA5oI4T59xMXsapT4jN8Wljy1IWcKlan1JDjY34TBJI9XC6IqHvJkkVcD9cr
22
+ uZpSRVAAFs/sKHBoE1037QTnECh6KSxKLxFel7zOoBcjOQDab2PyJpC5UNrdbF6R
23
+ t6PYTY5cjMOGKkNj2b4/kQ28A6UCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQUI97NPNbdiCYSclmyMqKJr7LtpEYwJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAswyKuUaQ
27
+ zaalcas2asWXnUh5T/zbKVmymHIEG9kvXH0rMA51P4sRVEXpvqlYPBZioEzCn5f0
28
+ re+bscYJS5XmScGZHjTH9Gr5eahV6AWQTpBFdI5d416db4RuOtHZ8Ek+qr2us0VD
29
+ Kxqfb7yOCHMxQVNUD42DSBIsK+n2uX0++ltsnW8o8ZQvL4nrUdxMBUF28m3Z+V3o
30
+ ZWtCoj2zbSQLZzmPNIy9RAzn4Z64XB651zDe432QymDfLSEVi6n5YKixjsDOfa91
31
+ xMYZkElOttvQm8M6uUy483IxDueFvAWV/BnpYc9uzT6Rb9VtyMgUXX9pi/WwGjoF
32
+ 0vXd6ZyRHRSlpQ==
31
33
  -----END CERTIFICATE-----
32
- date: 2014-01-05 00:00:00.000000000 Z
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