terminal-table 1.7.2 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +28 -0
- data/.gitignore +5 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +49 -0
- data/History.rdoc +66 -0
- data/LICENSE.txt +21 -0
- data/README.md +417 -0
- data/Rakefile +10 -4
- data/examples/data.csv +4 -0
- data/examples/examples.rb +0 -0
- data/examples/examples_unicode.rb +89 -0
- data/examples/issue100.rb +34 -0
- data/examples/issue111.rb +4 -0
- data/examples/issue118.rb +36 -0
- data/examples/issue95.rb +42 -0
- data/examples/show_csv_table.rb +34 -0
- data/examples/strong_separator.rb +23 -0
- data/lib/terminal-table.rb +2 -2
- data/lib/terminal-table/cell.rb +8 -8
- data/lib/terminal-table/row.rb +18 -4
- data/lib/terminal-table/separator.rb +56 -4
- data/lib/terminal-table/style.rb +218 -10
- data/lib/terminal-table/table.rb +49 -18
- data/lib/terminal-table/util.rb +13 -0
- data/lib/terminal-table/version.rb +1 -1
- data/terminal-table.gemspec +3 -3
- metadata +32 -15
- data/README.rdoc +0 -238
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminal-table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TJ Holowaychuk
|
8
8
|
- Scott J. Goldman
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-05-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -17,28 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '2'
|
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
|
-
version: '
|
27
|
+
version: '2'
|
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
|
-
version: '
|
34
|
+
version: '13.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
|
-
version: '
|
41
|
+
version: '13.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,31 +85,48 @@ dependencies:
|
|
85
85
|
name: unicode-display_width
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - "
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: 1.1.1
|
91
|
+
- - "<"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '3'
|
91
94
|
type: :runtime
|
92
95
|
prerelease: false
|
93
96
|
version_requirements: !ruby/object:Gem::Requirement
|
94
97
|
requirements:
|
95
|
-
- - "
|
98
|
+
- - ">="
|
96
99
|
- !ruby/object:Gem::Version
|
97
100
|
version: 1.1.1
|
98
|
-
|
101
|
+
- - "<"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3'
|
104
|
+
description:
|
99
105
|
email:
|
100
106
|
- tj@vision-media.ca
|
101
107
|
executables: []
|
102
108
|
extensions: []
|
103
109
|
extra_rdoc_files: []
|
104
110
|
files:
|
111
|
+
- ".github/workflows/ci.yml"
|
105
112
|
- ".gitignore"
|
106
113
|
- Gemfile
|
114
|
+
- Gemfile.lock
|
107
115
|
- History.rdoc
|
116
|
+
- LICENSE.txt
|
108
117
|
- Manifest
|
109
|
-
- README.
|
118
|
+
- README.md
|
110
119
|
- Rakefile
|
111
120
|
- Todo.rdoc
|
121
|
+
- examples/data.csv
|
112
122
|
- examples/examples.rb
|
123
|
+
- examples/examples_unicode.rb
|
124
|
+
- examples/issue100.rb
|
125
|
+
- examples/issue111.rb
|
126
|
+
- examples/issue118.rb
|
127
|
+
- examples/issue95.rb
|
128
|
+
- examples/show_csv_table.rb
|
129
|
+
- examples/strong_separator.rb
|
113
130
|
- lib/terminal-table.rb
|
114
131
|
- lib/terminal-table/cell.rb
|
115
132
|
- lib/terminal-table/import.rb
|
@@ -118,13 +135,14 @@ files:
|
|
118
135
|
- lib/terminal-table/style.rb
|
119
136
|
- lib/terminal-table/table.rb
|
120
137
|
- lib/terminal-table/table_helper.rb
|
138
|
+
- lib/terminal-table/util.rb
|
121
139
|
- lib/terminal-table/version.rb
|
122
140
|
- terminal-table.gemspec
|
123
141
|
homepage: https://github.com/tj/terminal-table
|
124
142
|
licenses:
|
125
143
|
- MIT
|
126
144
|
metadata: {}
|
127
|
-
post_install_message:
|
145
|
+
post_install_message:
|
128
146
|
rdoc_options: []
|
129
147
|
require_paths:
|
130
148
|
- lib
|
@@ -139,9 +157,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
157
|
- !ruby/object:Gem::Version
|
140
158
|
version: '0'
|
141
159
|
requirements: []
|
142
|
-
|
143
|
-
|
144
|
-
signing_key:
|
160
|
+
rubygems_version: 3.2.3
|
161
|
+
signing_key:
|
145
162
|
specification_version: 4
|
146
163
|
summary: Simple, feature rich ascii table generation library
|
147
164
|
test_files: []
|
data/README.rdoc
DELETED
@@ -1,238 +0,0 @@
|
|
1
|
-
= Terminal Table
|
2
|
-
|
3
|
-
== Description
|
4
|
-
|
5
|
-
Terminal Table is a fast and simple, yet feature rich ASCII table generator written in Ruby.
|
6
|
-
|
7
|
-
== Installation
|
8
|
-
|
9
|
-
$ gem install terminal-table
|
10
|
-
|
11
|
-
== Usage
|
12
|
-
|
13
|
-
=== Basics
|
14
|
-
|
15
|
-
To use Terminal Table:
|
16
|
-
|
17
|
-
require 'terminal-table'
|
18
|
-
|
19
|
-
To generate a table, provide an array of arrays (which are interpreted as rows):
|
20
|
-
|
21
|
-
rows = []
|
22
|
-
rows << ['One', 1]
|
23
|
-
rows << ['Two', 2]
|
24
|
-
rows << ['Three', 3]
|
25
|
-
table = Terminal::Table.new :rows => rows
|
26
|
-
|
27
|
-
# > puts table
|
28
|
-
#
|
29
|
-
# +-------+---+
|
30
|
-
# | One | 1 |
|
31
|
-
# | Two | 2 |
|
32
|
-
# | Three | 3 |
|
33
|
-
# +-------+---+
|
34
|
-
|
35
|
-
|
36
|
-
The constructor can also be given a block which is either yielded the Table object or instance evaluated:
|
37
|
-
|
38
|
-
table = Terminal::Table.new do |t|
|
39
|
-
t.rows = rows
|
40
|
-
end
|
41
|
-
|
42
|
-
table = Terminal::Table.new do
|
43
|
-
self.rows = rows
|
44
|
-
end
|
45
|
-
|
46
|
-
Adding rows one by one:
|
47
|
-
|
48
|
-
table = Terminal::Table.new do |t|
|
49
|
-
t << ['One', 1]
|
50
|
-
t.add_row ['Two', 2]
|
51
|
-
end
|
52
|
-
|
53
|
-
To add separators between rows:
|
54
|
-
|
55
|
-
table = Terminal::Table.new do |t|
|
56
|
-
t << ['One', 1]
|
57
|
-
t << :separator
|
58
|
-
t.add_row ['Two', 2]
|
59
|
-
t.add_separator
|
60
|
-
t.add_row ['Three', 3]
|
61
|
-
end
|
62
|
-
|
63
|
-
# > puts table
|
64
|
-
#
|
65
|
-
# +-------+---+
|
66
|
-
# | One | 1 |
|
67
|
-
# +-------+---+
|
68
|
-
# | Two | 2 |
|
69
|
-
# +-------+---+
|
70
|
-
# | Three | 3 |
|
71
|
-
# +-------+---+
|
72
|
-
|
73
|
-
Cells can handle multiline content:
|
74
|
-
|
75
|
-
table = Terminal::Table.new do |t|
|
76
|
-
t << ['One', 1]
|
77
|
-
t << :separator
|
78
|
-
t.add_row ["Two\nDouble", 2]
|
79
|
-
t.add_separator
|
80
|
-
t.add_row ['Three', 3]
|
81
|
-
end
|
82
|
-
|
83
|
-
# > puts table
|
84
|
-
#
|
85
|
-
# +--------+---+
|
86
|
-
# | One | 1 |
|
87
|
-
# +--------+---+
|
88
|
-
# | Two | 2 |
|
89
|
-
# | Double | |
|
90
|
-
# +--------+---+
|
91
|
-
# | Three | 3 |
|
92
|
-
# +--------+---+
|
93
|
-
|
94
|
-
=== Head
|
95
|
-
|
96
|
-
To add a head to the table:
|
97
|
-
|
98
|
-
table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows
|
99
|
-
|
100
|
-
# > puts table
|
101
|
-
#
|
102
|
-
# +-------+--------+
|
103
|
-
# | Word | Number |
|
104
|
-
# +-------+--------+
|
105
|
-
# | One | 1 |
|
106
|
-
# | Two | 2 |
|
107
|
-
# | Three | 3 |
|
108
|
-
# +-------+--------+
|
109
|
-
|
110
|
-
=== Title
|
111
|
-
|
112
|
-
To add a title to the table:
|
113
|
-
|
114
|
-
table = Terminal::Table.new :title => "Cheatsheet", :headings => ['Word', 'Number'], :rows => rows
|
115
|
-
|
116
|
-
# > puts table
|
117
|
-
#
|
118
|
-
# +------------+--------+
|
119
|
-
# | Cheatsheet |
|
120
|
-
# +------------+--------+
|
121
|
-
# | Word | Number |
|
122
|
-
# +------------+--------+
|
123
|
-
# | One | 1 |
|
124
|
-
# | Two | 2 |
|
125
|
-
# | Three | 3 |
|
126
|
-
# +------------+--------+
|
127
|
-
|
128
|
-
=== Alignment
|
129
|
-
|
130
|
-
To align the second column to the right:
|
131
|
-
|
132
|
-
table.align_column(1, :right)
|
133
|
-
|
134
|
-
# > puts table
|
135
|
-
#
|
136
|
-
# +-------+--------+
|
137
|
-
# | Word | Number |
|
138
|
-
# +-------+--------+
|
139
|
-
# | One | 1 |
|
140
|
-
# | Two | 2 |
|
141
|
-
# | Three | 3 |
|
142
|
-
# +-------+--------+
|
143
|
-
|
144
|
-
To align an individual cell, you specify the cell value in a hash along the alignment:
|
145
|
-
|
146
|
-
table << ["Four", {:value => 4.0, :alignment => :center}]
|
147
|
-
|
148
|
-
# > puts table
|
149
|
-
#
|
150
|
-
# +-------+--------+
|
151
|
-
# | Word | Number |
|
152
|
-
# +-------+--------+
|
153
|
-
# | One | 1 |
|
154
|
-
# | Two | 2 |
|
155
|
-
# | Three | 3 |
|
156
|
-
# | Four | 4.0 |
|
157
|
-
# +-------+--------+
|
158
|
-
|
159
|
-
=== Style
|
160
|
-
|
161
|
-
To specify style options:
|
162
|
-
|
163
|
-
table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows, :style => {:width => 80}
|
164
|
-
|
165
|
-
# > puts table
|
166
|
-
#
|
167
|
-
# +--------------------------------------+---------------------------------------+
|
168
|
-
# | Word | Number |
|
169
|
-
# +--------------------------------------+---------------------------------------+
|
170
|
-
# | One | 1 |
|
171
|
-
# | Two | 2 |
|
172
|
-
# | Three | 3 |
|
173
|
-
# +--------------------------------------+---------------------------------------+
|
174
|
-
|
175
|
-
And change styles on the fly:
|
176
|
-
|
177
|
-
table.style = {:width => 40, :padding_left => 3, :border_x => "=", :border_i => "x"}
|
178
|
-
|
179
|
-
# > puts table
|
180
|
-
#
|
181
|
-
# x====================x=================x
|
182
|
-
# | Cheatsheet |
|
183
|
-
# x====================x=================x
|
184
|
-
# | Word | Number |
|
185
|
-
# x====================x=================x
|
186
|
-
# | One | 1 |
|
187
|
-
# | Two | 2 |
|
188
|
-
# | Three | 3 |
|
189
|
-
# x====================x=================x
|
190
|
-
|
191
|
-
To change the default style options:
|
192
|
-
|
193
|
-
Terminal::Table::Style.defaults = {:width => 80}
|
194
|
-
|
195
|
-
All Table objects created afterwards will inherit these defaults.
|
196
|
-
|
197
|
-
=== Constructor options and setter methods
|
198
|
-
|
199
|
-
Valid options for the constructor are :rows, :headings, :style and :title - and all options can also be set on the created table object by their setter method:
|
200
|
-
|
201
|
-
table = Terminal::Table.new
|
202
|
-
table.title = "Cheatsheet"
|
203
|
-
table.headings = ['Word', 'Number']
|
204
|
-
table.rows = rows
|
205
|
-
table.style = {:width => 40}
|
206
|
-
|
207
|
-
== More examples
|
208
|
-
|
209
|
-
For more examples, please see the examples/examples.rb file included in the source distribution.
|
210
|
-
|
211
|
-
== Author
|
212
|
-
|
213
|
-
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.
|