terminal-table 1.7.3 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +9 -0
- data/LICENSE.txt +21 -0
- data/README.rdoc +49 -40
- data/lib/terminal-table/style.rb +3 -0
- data/lib/terminal-table/table.rb +3 -3
- data/lib/terminal-table/version.rb +1 -1
- data/terminal-table.gemspec +1 -1
- metadata +25 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fbefc4babd3ccb3e9e7caca474bec488cf6f234
|
4
|
+
data.tar.gz: 1ed67b9091ccce0e7d1d4782e7d7a9d0d59359c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b5b405dc6afba3a3388c2f4d70c61a01130946b050c94e33414822868d432809f4cde2c1c4a724995d862a763664dc2f6cfeeffa6339f468e9c1a34aa111d63
|
7
|
+
data.tar.gz: 9418542619af83d894a50f9a5a8e0e564f86382f378fe5ea15adc8a4331eaf3ffb7e7c11d86f945239aff2d758962f359a1acff9e60fa46a3b622ef9aaeaaceb
|
data/History.rdoc
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
1.8.0 / 2017-05-16
|
2
|
+
==================
|
3
|
+
|
4
|
+
* Top and bottom borders can be disabled (@kubakrzempek, #83)
|
5
|
+
* `unicode-display-width` dependency relaxes (@mvz, #88)
|
6
|
+
|
7
|
+
* Readme and docs fixes (@loualrid, #82 and @leoarnold, #86)
|
8
|
+
* Fixed some test-related warnings (@juanitofatas, #81 and @mvz, #89)
|
9
|
+
|
1
10
|
1.7.3 / 2016-09-21
|
2
11
|
==================
|
3
12
|
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2008-2017 TJ Holowaychuk <tj@vision-media.ca>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -23,7 +23,7 @@ To generate a table, provide an array of arrays (which are interpreted as rows):
|
|
23
23
|
rows << ['Two', 2]
|
24
24
|
rows << ['Three', 3]
|
25
25
|
table = Terminal::Table.new :rows => rows
|
26
|
-
|
26
|
+
|
27
27
|
# > puts table
|
28
28
|
#
|
29
29
|
# +-------+---+
|
@@ -51,7 +51,7 @@ Adding rows one by one:
|
|
51
51
|
end
|
52
52
|
|
53
53
|
To add separators between rows:
|
54
|
-
|
54
|
+
|
55
55
|
table = Terminal::Table.new do |t|
|
56
56
|
t << ['One', 1]
|
57
57
|
t << :separator
|
@@ -59,7 +59,7 @@ To add separators between rows:
|
|
59
59
|
t.add_separator
|
60
60
|
t.add_row ['Three', 3]
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
# > puts table
|
64
64
|
#
|
65
65
|
# +-------+---+
|
@@ -71,7 +71,7 @@ To add separators between rows:
|
|
71
71
|
# +-------+---+
|
72
72
|
|
73
73
|
Cells can handle multiline content:
|
74
|
-
|
74
|
+
|
75
75
|
table = Terminal::Table.new do |t|
|
76
76
|
t << ['One', 1]
|
77
77
|
t << :separator
|
@@ -79,7 +79,7 @@ Cells can handle multiline content:
|
|
79
79
|
t.add_separator
|
80
80
|
t.add_row ['Three', 3]
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
# > puts table
|
84
84
|
#
|
85
85
|
# +--------+---+
|
@@ -96,7 +96,7 @@ Cells can handle multiline content:
|
|
96
96
|
To add a head to the table:
|
97
97
|
|
98
98
|
table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows
|
99
|
-
|
99
|
+
|
100
100
|
# > puts table
|
101
101
|
#
|
102
102
|
# +-------+--------+
|
@@ -112,7 +112,7 @@ To add a head to the table:
|
|
112
112
|
To add a title to the table:
|
113
113
|
|
114
114
|
table = Terminal::Table.new :title => "Cheatsheet", :headings => ['Word', 'Number'], :rows => rows
|
115
|
-
|
115
|
+
|
116
116
|
# > puts table
|
117
117
|
#
|
118
118
|
# +------------+--------+
|
@@ -130,7 +130,7 @@ To add a title to the table:
|
|
130
130
|
To align the second column to the right:
|
131
131
|
|
132
132
|
table.align_column(1, :right)
|
133
|
-
|
133
|
+
|
134
134
|
# > puts table
|
135
135
|
#
|
136
136
|
# +-------+--------+
|
@@ -144,7 +144,7 @@ To align the second column to the right:
|
|
144
144
|
To align an individual cell, you specify the cell value in a hash along the alignment:
|
145
145
|
|
146
146
|
table << ["Four", {:value => 4.0, :alignment => :center}]
|
147
|
-
|
147
|
+
|
148
148
|
# > puts table
|
149
149
|
#
|
150
150
|
# +-------+--------+
|
@@ -155,13 +155,13 @@ To align an individual cell, you specify the cell value in a hash along the alig
|
|
155
155
|
# | Three | 3 |
|
156
156
|
# | Four | 4.0 |
|
157
157
|
# +-------+--------+
|
158
|
-
|
158
|
+
|
159
159
|
=== Style
|
160
160
|
|
161
161
|
To specify style options:
|
162
|
-
|
162
|
+
|
163
163
|
table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows, :style => {:width => 80}
|
164
|
-
|
164
|
+
|
165
165
|
# > puts table
|
166
166
|
#
|
167
167
|
# +--------------------------------------+---------------------------------------+
|
@@ -173,9 +173,9 @@ To specify style options:
|
|
173
173
|
# +--------------------------------------+---------------------------------------+
|
174
174
|
|
175
175
|
And change styles on the fly:
|
176
|
-
|
176
|
+
|
177
177
|
table.style = {:width => 40, :padding_left => 3, :border_x => "=", :border_i => "x"}
|
178
|
-
|
178
|
+
|
179
179
|
# > puts table
|
180
180
|
#
|
181
181
|
# x====================x=================x
|
@@ -187,7 +187,41 @@ And change styles on the fly:
|
|
187
187
|
# | Two | 2 |
|
188
188
|
# | Three | 3 |
|
189
189
|
# x====================x=================x
|
190
|
-
|
190
|
+
|
191
|
+
You can also use styles to add a separator after every row:
|
192
|
+
|
193
|
+
table = Terminal::Table.new do |t|
|
194
|
+
t.add_row [1, 'One']
|
195
|
+
t.add_row [2, 'Two']
|
196
|
+
t.add_row [3, 'Three']
|
197
|
+
t.style = {:all_separators => true}
|
198
|
+
end
|
199
|
+
|
200
|
+
# > puts table
|
201
|
+
#
|
202
|
+
# +---+-------+
|
203
|
+
# | 1 | One |
|
204
|
+
# +---+-------+
|
205
|
+
# | 2 | Two |
|
206
|
+
# +---+-------+
|
207
|
+
# | 3 | Three |
|
208
|
+
# +---+-------+
|
209
|
+
|
210
|
+
You can also use styles to disable top and bottom borders of the table
|
211
|
+
|
212
|
+
table = Terminal::Table.new do |t|
|
213
|
+
t.headings = ['id', 'name']
|
214
|
+
t.rows = [[1, 'One'], [2, 'Two'], [3, 'Three']]
|
215
|
+
t.style = { :border_top => false, :border_bottom => false }
|
216
|
+
end
|
217
|
+
|
218
|
+
# > puts table
|
219
|
+
# | id | name |
|
220
|
+
# +----+-------+
|
221
|
+
# | 1 | One |
|
222
|
+
# | 2 | Two |
|
223
|
+
# | 3 | Three |
|
224
|
+
|
191
225
|
To change the default style options:
|
192
226
|
|
193
227
|
Terminal::Table::Style.defaults = {:width => 80}
|
@@ -211,28 +245,3 @@ For more examples, please see the examples/examples.rb file included in the sour
|
|
211
245
|
== Author
|
212
246
|
|
213
247
|
TJ Holowaychuk <tj@vision-media.ca>
|
214
|
-
|
215
|
-
== License
|
216
|
-
|
217
|
-
(The MIT License)
|
218
|
-
|
219
|
-
Copyright (c) 2008-2009 TJ Holowaychuk <tj@vision-media.ca>
|
220
|
-
|
221
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
222
|
-
a copy of this software and associated documentation files (the
|
223
|
-
'Software'), to deal in the Software without restriction, including
|
224
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
225
|
-
distribute, sublicense, an d/or sell copies of the Software, and to
|
226
|
-
permit persons to whom the Software is furnished to do so, subject to
|
227
|
-
the following conditions:
|
228
|
-
|
229
|
-
The above copyright notice and this permission notice shall be
|
230
|
-
included in all copies or substantial portions of the Software.
|
231
|
-
|
232
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
233
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
234
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
235
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
236
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
237
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
238
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/terminal-table/style.rb
CHANGED
@@ -24,6 +24,7 @@ module Terminal
|
|
24
24
|
class Style
|
25
25
|
@@defaults = {
|
26
26
|
:border_x => "-", :border_y => "|", :border_i => "+",
|
27
|
+
:border_top => true, :border_bottom => true,
|
27
28
|
:padding_left => 1, :padding_right => 1,
|
28
29
|
:margin_left => '',
|
29
30
|
:width => nil, :alignment => nil,
|
@@ -33,6 +34,8 @@ module Terminal
|
|
33
34
|
attr_accessor :border_x
|
34
35
|
attr_accessor :border_y
|
35
36
|
attr_accessor :border_i
|
37
|
+
attr_accessor :border_top
|
38
|
+
attr_accessor :border_bottom
|
36
39
|
|
37
40
|
attr_accessor :padding_left
|
38
41
|
attr_accessor :padding_right
|
data/lib/terminal-table/table.rb
CHANGED
@@ -94,7 +94,7 @@ module Terminal
|
|
94
94
|
# Return length of column _n_.
|
95
95
|
|
96
96
|
def column_width n
|
97
|
-
|
97
|
+
column_widths[n] || 0
|
98
98
|
end
|
99
99
|
alias length_of_column column_width # for legacy support
|
100
100
|
|
@@ -122,7 +122,7 @@ module Terminal
|
|
122
122
|
|
123
123
|
def render
|
124
124
|
separator = Separator.new(self)
|
125
|
-
buffer = [separator]
|
125
|
+
buffer = style.border_top ? [separator] : []
|
126
126
|
unless @title.nil?
|
127
127
|
buffer << Row.new(self, [title_cell_options])
|
128
128
|
buffer << separator
|
@@ -137,7 +137,7 @@ module Terminal
|
|
137
137
|
buffer += @rows.product([separator]).flatten
|
138
138
|
else
|
139
139
|
buffer += @rows
|
140
|
-
buffer << separator
|
140
|
+
buffer << separator if style.border_bottom
|
141
141
|
end
|
142
142
|
buffer.map { |r| style.margin_left + r.render.rstrip }.join("\n")
|
143
143
|
end
|
data/terminal-table.gemspec
CHANGED
@@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "term-ansicolor"
|
23
23
|
spec.add_development_dependency "pry"
|
24
24
|
|
25
|
-
spec.add_runtime_dependency "unicode-display_width", "~> 1.1.1"
|
25
|
+
spec.add_runtime_dependency "unicode-display_width", ["~> 1.1", ">= 1.1.1"]
|
26
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminal-table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TJ Holowaychuk
|
@@ -9,90 +9,96 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-05-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '1.10'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.10'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - ~>
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '10.0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - ~>
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '10.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '3.0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '3.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: term-ansicolor
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: pry
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: unicode-display_width
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - ~>
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '1.1'
|
91
|
+
- - ">="
|
89
92
|
- !ruby/object:Gem::Version
|
90
93
|
version: 1.1.1
|
91
94
|
type: :runtime
|
92
95
|
prerelease: false
|
93
96
|
version_requirements: !ruby/object:Gem::Requirement
|
94
97
|
requirements:
|
95
|
-
- - ~>
|
98
|
+
- - "~>"
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '1.1'
|
101
|
+
- - ">="
|
96
102
|
- !ruby/object:Gem::Version
|
97
103
|
version: 1.1.1
|
98
104
|
description:
|
@@ -102,9 +108,10 @@ executables: []
|
|
102
108
|
extensions: []
|
103
109
|
extra_rdoc_files: []
|
104
110
|
files:
|
105
|
-
- .gitignore
|
111
|
+
- ".gitignore"
|
106
112
|
- Gemfile
|
107
113
|
- History.rdoc
|
114
|
+
- LICENSE.txt
|
108
115
|
- Manifest
|
109
116
|
- README.rdoc
|
110
117
|
- Rakefile
|
@@ -130,17 +137,17 @@ require_paths:
|
|
130
137
|
- lib
|
131
138
|
required_ruby_version: !ruby/object:Gem::Requirement
|
132
139
|
requirements:
|
133
|
-
- -
|
140
|
+
- - ">="
|
134
141
|
- !ruby/object:Gem::Version
|
135
142
|
version: '0'
|
136
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
144
|
requirements:
|
138
|
-
- -
|
145
|
+
- - ">="
|
139
146
|
- !ruby/object:Gem::Version
|
140
147
|
version: '0'
|
141
148
|
requirements: []
|
142
149
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
150
|
+
rubygems_version: 2.6.11
|
144
151
|
signing_key:
|
145
152
|
specification_version: 4
|
146
153
|
summary: Simple, feature rich ascii table generation library
|