terminal-table 1.8.0 → 3.0.2

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
- SHA1:
3
- metadata.gz: 8fbefc4babd3ccb3e9e7caca474bec488cf6f234
4
- data.tar.gz: 1ed67b9091ccce0e7d1d4782e7d7a9d0d59359c4
2
+ SHA256:
3
+ metadata.gz: 6213eea6e6bf691a9594f64660d97e3c56503c43bf2a95075f62aafca2b4d130
4
+ data.tar.gz: a3511ef514b25731d1753bc695e7066ac04c76d9ce5da62ac5d8d3f6208daa3a
5
5
  SHA512:
6
- metadata.gz: 6b5b405dc6afba3a3388c2f4d70c61a01130946b050c94e33414822868d432809f4cde2c1c4a724995d862a763664dc2f6cfeeffa6339f468e9c1a34aa111d63
7
- data.tar.gz: 9418542619af83d894a50f9a5a8e0e564f86382f378fe5ea15adc8a4331eaf3ffb7e7c11d86f945239aff2d758962f359a1acff9e60fa46a3b622ef9aaeaaceb
6
+ metadata.gz: bb49c90ce6d6edbfe07c2c335b2c5bf25df41f67a3d31b4d413febebc597ce47906575e738dd05be742d948bd854948c605414ad581ea033b36099c52dd1cf36
7
+ data.tar.gz: f49a1837097b5417887ba6eddd2deaad9e3dab933a67d22b23fd6028255dfd56d0e2d327dd80c87b6a99da94a5d00e2147feed2155b37590b72284610c3b408d
@@ -0,0 +1,28 @@
1
+ name: CI
2
+ on: [push]
3
+
4
+ jobs:
5
+ test:
6
+ if: "!contains(github.event.head_commit.message, 'ci skip')"
7
+
8
+ continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
9
+
10
+ strategy:
11
+ fail-fast: false
12
+
13
+ matrix:
14
+ os: [ubuntu]
15
+ ruby: [2.4, 2.5, 2.6, 2.7]
16
+
17
+ runs-on: ${{ matrix.os }}-latest
18
+
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ bundler-cache: true
25
+ ruby-version: ${{ matrix.ruby }}
26
+
27
+ - run: bundle install
28
+ - run: bundle exec rspec
data/.gitignore CHANGED
@@ -3,4 +3,9 @@ pkg
3
3
  tmp
4
4
  *.cache
5
5
  doc
6
+ vendor
7
+ /.bundle
6
8
  Gemfile.lock
9
+
10
+ # tempfiles
11
+ *~
data/History.rdoc CHANGED
@@ -1,3 +1,60 @@
1
+ 3.0.2 / 2021-09-19
2
+ ==================
3
+
4
+ - fix align_column for nil values and colspan
5
+
6
+ 3.0.1 / 2021-05-10
7
+ ==================
8
+
9
+ - Support for unicode-display_width 2.0
10
+ - Fix issue where last row of an empty table changed format
11
+
12
+ 3.0.0 / 2020-01-27
13
+ ==================
14
+
15
+ - Support for (optional) Unicode border styles on tables. In order to support decent looking Unicode borders, different types of intersections get different types of intersection characters. This has the side effect of subtle formatting differences even for the ASCII table border case due to removal of certain intersections near colspans.
16
+
17
+ For example, previously the output of a table may be:
18
+ +------+-----+
19
+ | Title |
20
+ +------+-----+
21
+ | Char | Num |
22
+ +------+-----+
23
+ | a | 1 |
24
+ | b | 2 |
25
+ | c | 3 |
26
+ +------+-----+
27
+
28
+ And now the `+` character above the word Title is removed, as it is no longer considered an intersection:
29
+
30
+ +------------+
31
+ | Title |
32
+ +------+-----+
33
+ | Char | Num |
34
+ +------+-----+
35
+ | a | 1 |
36
+ | b | 2 |
37
+ +------+-----+
38
+
39
+ - The default border remains an ASCII border for backwards compatibility, however multiple border classes are included / documented, and user defined border types can be applied as needed.
40
+
41
+ In support of this update, the following issues were addressed:
42
+ - colspan creates conflict with colorize (#95)
43
+ - Use nice UTF box-drawing characters by default (#99)
44
+ - Note that `AsciiBorder` is stll the default
45
+ - Border-left and border-right style (#100)
46
+ - Helper function to style as Markdown (#111)
47
+ - Achieved using `MarkdownBorder`
48
+
49
+ 2.0.0 / 2020-10-28
50
+ ==================
51
+
52
+ - Drops official support for Ruby 1.9.x with and of life on 2015-02-23
53
+ - Drops official support for Ruby 2.0.x with and of life on 2016-02-24
54
+ - Drops official support for Ruby 2.1.x with and of life on 2017-03-31
55
+ - Drops official support for Ruby 2.2.x with and of life on 2018-03-31
56
+ - Drops official support for Ruby 2.3.x with and of life on 2019-03-31
57
+
1
58
  1.8.0 / 2017-05-16
2
59
  ==================
3
60
 
data/README.md ADDED
@@ -0,0 +1,417 @@
1
+ [![CI status](https://github.com/tj/terminal-table/workflows/CI/badge.svg)](https://github.com/tj/terminal-table/actions)
2
+ [![Gem Version](https://badge.fury.io/rb/terminal-table.svg)](https://badge.fury.io/rb/terminal-table)
3
+
4
+ # Terminal Table
5
+
6
+ ## Description
7
+
8
+ Terminal Table is a fast and simple, yet feature rich table generator
9
+ written in Ruby. It supports ASCII and Unicode formatted tables.
10
+
11
+ ## Installation
12
+
13
+ ```
14
+ $ gem install terminal-table
15
+ ```
16
+ ## Usage
17
+
18
+ ### Basics
19
+
20
+ To use Terminal Table:
21
+
22
+ ```ruby
23
+ require 'terminal-table'
24
+ ```
25
+ To generate a table, provide an array of arrays (which are interpreted as
26
+ rows):
27
+
28
+ ```ruby
29
+ rows = []
30
+ rows << ['One', 1]
31
+ rows << ['Two', 2]
32
+ rows << ['Three', 3]
33
+ table = Terminal::Table.new :rows => rows
34
+
35
+ # > puts table
36
+ #
37
+ # +-------+---+
38
+ # | One | 1 |
39
+ # | Two | 2 |
40
+ # | Three | 3 |
41
+ # +-------+---+
42
+ ```
43
+ The constructor can also be given a block which is either yielded the Table
44
+ object or instance evaluated:
45
+
46
+ ```ruby
47
+ table = Terminal::Table.new do |t|
48
+ t.rows = rows
49
+ end
50
+
51
+ table = Terminal::Table.new do
52
+ self.rows = rows
53
+ end
54
+ ```
55
+ Adding rows one by one:
56
+
57
+ ```ruby
58
+ table = Terminal::Table.new do |t|
59
+ t << ['One', 1]
60
+ t.add_row ['Two', 2]
61
+ end
62
+ ```
63
+ To add separators between rows:
64
+
65
+ ```ruby
66
+ table = Terminal::Table.new do |t|
67
+ t << ['One', 1] # Using << (push) as an alias for add_row
68
+ t << :separator # Using << with :separator as an alias for add_separator
69
+ t.add_row ['Two', 2]
70
+ t.add_separator # Note - this version allows setting the separator's border_type
71
+ t.add_row ['Three', 3]
72
+ end
73
+
74
+ # > puts table
75
+ #
76
+ # +-------+---+
77
+ # | One | 1 |
78
+ # +-------+---+
79
+ # | Two | 2 |
80
+ # +-------+---+
81
+ # | Three | 3 |
82
+ # +-------+---+
83
+ ```
84
+ Cells can handle multiline content:
85
+
86
+ ```ruby
87
+ table = Terminal::Table.new do |t|
88
+ t << ['One', 1]
89
+ t << :separator
90
+ t.add_row ["Two\nDouble", 2]
91
+ t.add_separator
92
+ t.add_row ['Three', 3]
93
+ end
94
+
95
+ # > puts table
96
+ #
97
+ # +--------+---+
98
+ # | One | 1 |
99
+ # +--------+---+
100
+ # | Two | 2 |
101
+ # | Double | |
102
+ # +--------+---+
103
+ # | Three | 3 |
104
+ # +--------+---+
105
+ ```
106
+ ### Head
107
+
108
+ To add a head to the table:
109
+
110
+ ```ruby
111
+ table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows
112
+
113
+ # > puts table
114
+ #
115
+ # +-------+--------+
116
+ # | Word | Number |
117
+ # +-------+--------+
118
+ # | One | 1 |
119
+ # | Two | 2 |
120
+ # | Three | 3 |
121
+ # +-------+--------+
122
+ ```
123
+ ### Title
124
+
125
+ To add a title to the table:
126
+
127
+ ```ruby
128
+ table = Terminal::Table.new :title => "Cheatsheet", :headings => ['Word', 'Number'], :rows => rows
129
+
130
+ # > puts table
131
+ #
132
+ # +---------------------+
133
+ # | Cheatsheet |
134
+ # +------------+--------+
135
+ # | Word | Number |
136
+ # +------------+--------+
137
+ # | One | 1 |
138
+ # | Two | 2 |
139
+ # | Three | 3 |
140
+ # +------------+--------+
141
+ ```
142
+ ### Alignment
143
+
144
+ To align the second column to the right:
145
+
146
+ ```ruby
147
+ table.align_column(1, :right)
148
+
149
+ # > puts table
150
+ #
151
+ # +-------+--------+
152
+ # | Word | Number |
153
+ # +-------+--------+
154
+ # | One | 1 |
155
+ # | Two | 2 |
156
+ # | Three | 3 |
157
+ # +-------+--------+
158
+ ```
159
+ To align an individual cell, you specify the cell value in a hash along the
160
+ alignment:
161
+
162
+ ```ruby
163
+ table << ["Four", {:value => 4.0, :alignment => :center}]
164
+
165
+ # > puts table
166
+ #
167
+ # +-------+--------+
168
+ # | Word | Number |
169
+ # +-------+--------+
170
+ # | One | 1 |
171
+ # | Two | 2 |
172
+ # | Three | 3 |
173
+ # | Four | 4.0 |
174
+ # +-------+--------+
175
+ ```
176
+ ### Style
177
+
178
+ To specify style options:
179
+
180
+ ```ruby
181
+ table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows, :style => {:width => 80}
182
+
183
+ # > puts table
184
+ #
185
+ # +--------------------------------------+---------------------------------------+
186
+ # | Word | Number |
187
+ # +--------------------------------------+---------------------------------------+
188
+ # | One | 1 |
189
+ # | Two | 2 |
190
+ # | Three | 3 |
191
+ # +--------------------------------------+---------------------------------------+
192
+ ```
193
+ And change styles on the fly:
194
+
195
+ ```ruby
196
+ table.style = {:width => 40, :padding_left => 3, :border_x => "=", :border_i => "x"}
197
+
198
+ # > puts table
199
+ #
200
+ # x======================================x
201
+ # | Cheatsheet |
202
+ # x====================x=================x
203
+ # | Word | Number |
204
+ # x====================x=================x
205
+ # | One | 1 |
206
+ # | Two | 2 |
207
+ # | Three | 3 |
208
+ # x====================x=================x
209
+ ```
210
+ You can also use styles to add a separator after every row:
211
+
212
+ ```ruby
213
+ table = Terminal::Table.new do |t|
214
+ t.add_row [1, 'One']
215
+ t.add_row [2, 'Two']
216
+ t.add_row [3, 'Three']
217
+ t.style = {:all_separators => true}
218
+ end
219
+
220
+ # > puts table
221
+ #
222
+ # +---+-------+
223
+ # | 1 | One |
224
+ # +---+-------+
225
+ # | 2 | Two |
226
+ # +---+-------+
227
+ # | 3 | Three |
228
+ # +---+-------+
229
+ ```
230
+ You can also use styles to disable top and bottom borders of the table.
231
+
232
+ ```ruby
233
+ table = Terminal::Table.new do |t|
234
+ t.headings = ['id', 'name']
235
+ t.rows = [[1, 'One'], [2, 'Two'], [3, 'Three']]
236
+ t.style = { :border_top => false, :border_bottom => false }
237
+ end
238
+
239
+ # > puts table
240
+ # | id | name |
241
+ # +----+-------+
242
+ # | 1 | One |
243
+ # | 2 | Two |
244
+ # | 3 | Three |
245
+ ```
246
+
247
+ And also to disable left and right borders of the table.
248
+
249
+ ```ruby
250
+ table = Terminal::Table.new do |t|
251
+ t.headings = ['id', 'name']
252
+ t.rows = [[1, 'One'], [2, 'Two'], [3, 'Three']]
253
+ t.style = { :border_left => false, :border_right => false }
254
+ end
255
+
256
+ # > puts table
257
+ # ----+-------
258
+ # id | name
259
+ # ----+-------
260
+ # 1 | One
261
+ # 2 | Two
262
+ # 3 | Three
263
+ # ----+-------
264
+ ```
265
+
266
+ To change the default style options:
267
+
268
+ ```ruby
269
+ Terminal::Table::Style.defaults = {:width => 80}
270
+ ```
271
+ All Table objects created afterwards will inherit these defaults.
272
+
273
+ ### Constructor options and setter methods
274
+
275
+ Valid options for the constructor are `:rows`, `:headings`, `:style` and `:title` -
276
+ and all options can also be set on the created table object by their setter
277
+ method:
278
+
279
+ ```ruby
280
+ table = Terminal::Table.new
281
+ table.title = "Cheatsheet"
282
+ table.headings = ['Word', 'Number']
283
+ table.rows = rows
284
+ table.style = {:width => 40}
285
+ ```
286
+
287
+ ## New Formatting
288
+
289
+ ### Unicode Table Borders
290
+ Support for Unicode 'box art' borders presented a challenge, as the original terminal-table only handled three border types: horizontal (x), vertical (y), and intersection (i). For proper box-art, it became necessary to enable different types of corners/edges for multiple intersection types.
291
+
292
+ For the sake of backward compatiblity, the previous interface is still supported, as this gem has been around a long time and making breaking changes would have been inconvenient. The new interface is required for any complex and/or Unicode style bordering. A few variations on border style are supported via some new classes and creation of additional classes (or modification of characters used in existing ones) will allow for customized border types.
293
+
294
+ The simplest way to use an alternate border is one of the following:
295
+ ```
296
+ table.style = { :border => :unicode }
297
+ table.style = { :border => :unicode_round }
298
+ table.style = { :border => :unicode_thick_edge }
299
+ ```
300
+
301
+ These are a convenience wrapper around setting border using an instance of a class that inherits from Table::Terminal::Border
302
+ ```
303
+ table.style = { :border => Terminal::Table::UnicodeBorder.new() }
304
+ table.style = { :border => Terminal::Table::UnicodeRoundBorder.new() }
305
+ table.style = { :border => Terminal::Table::UnicodeThickEdgeBorder.new() }
306
+ ```
307
+
308
+ If you define a custom class and wish to use the symbol shortcut, you must namespace within `Terminal::Table` and end your class name with `Border`.
309
+
310
+ ### Markdown Compatiblity
311
+ Per popular request, Markdown formatted tables can be generated by using the following border style:
312
+
313
+ ```
314
+ table.style = { :border => :markdown }
315
+ ```
316
+
317
+ ### Ascii Borders
318
+ Ascii borders are default, but can be explicitly set with:
319
+ ```
320
+ table.style = { :border => :ascii }
321
+ ```
322
+
323
+ ### Customizing Borders
324
+ Inside the `UnicodeBorder` class, there are definitions for a variety of corner/intersection and divider types.
325
+
326
+ ```ruby
327
+ @data = {
328
+ nil => nil,
329
+ nw: "┌", nx: "─", n: "┬", ne: "┐",
330
+ yw: "│", y: "│", ye: "│",
331
+ aw: "╞", ax: "═", ai: "╪", ae: "╡", ad: '╤', au: "╧", # double
332
+ bw: "┝", bx: "━", bi: "┿", be: "┥", bd: '┯', bu: "┷", # heavy/bold/thick
333
+ w: "├", x: "─", i: "┼", e: "┤", dn: "┬", up: "┴", # normal div
334
+ sw: "└", sx: "─", s: "┴", se: "┘",
335
+ # alternative dots/dashes
336
+ x_dot4: '┈', x_dot3: '┄', x_dash: '╌',
337
+ bx_dot4: '┉', bx_dot3: '┅', bx_dash: '╍',
338
+ }
339
+ ```
340
+
341
+ Note that many are defined as directional (:nw == north-west), others defined in terms of 'x' or 'y'.
342
+ The border that separates headings (below each heading) is of type `:double` and is defined with `a*` entries.
343
+ Alternate `:heavy` types that can be applied to separators can be defined with `b*` entries.
344
+
345
+ When defining a new set of borders, it's probably easiest to define a new class that inherits from UnicodeBorder and replaces the `@data` Hash.
346
+ However, these elements can be these can be overridden by poking setting the Hash, should the need arise:
347
+
348
+ ```
349
+ table.style = {border: :unicode}
350
+ table.style.border[:nw] = '*' # Override the north-west corner of the table
351
+ ```
352
+
353
+ ### Customizing row separators
354
+
355
+ Row-separators can now be customized in a variety of ways. The default separator's border_type is referred to as `:div`. Additional separator border types (e.g. `:double`, `:heavy`, `:dash` - see full list below) can be applied to separate the sections (e.g. header/footer/title).
356
+
357
+ The separator's `border_type` may be specified when a user-defined separator is added. Alternatively, borders may be adjusted after the table's rows are elaborated, but before the table is rendered.
358
+
359
+ Separator `border_type`s can be adjusted to be heavy, use double-lines, and different dash/dot styles. The border type should be one of:
360
+
361
+ div dash dot3 dot4
362
+ thick thick_dash thick_dot3 thick_dot4
363
+ heavy heavy_dash heavy_dot3 heavy_dot4
364
+ bold bold_dash bold_dot3 bold_dot4
365
+ double
366
+
367
+ To manually set the separator border_type, the `add_separator` method may be called.
368
+ ```ruby
369
+ add_separator(border_type: :heavy_dash)
370
+ ```
371
+
372
+ Alternatively, if `style: :all_separators` is used at the table level, it may be necessary to elaborate the implicit Separator rows prior to rendering.
373
+ ```ruby
374
+ table = Terminal::Table.new do |t|
375
+ t.add_row [1, 'One']
376
+ t.add_row [2, 'Two']
377
+ t.add_row [3, 'Three']
378
+ t.style = {:all_separators => true}
379
+ end
380
+ rows = table.elaborate_rows
381
+ rows[2].border_type = :heavy # modify separator row: emphasize below title
382
+ puts table.render
383
+ ```
384
+
385
+ ## Example: Displaying a small CSV spreadsheet
386
+
387
+ This example code demonstrates using Terminal-table and CSV to display a small spreadsheet.
388
+
389
+ ```ruby
390
+ #!/usr/bin/env ruby
391
+ require "csv"
392
+ require "terminal-table"
393
+ use_stdin = ARGV[0].nil? || (ARGV[0] == '-')
394
+ io_object = use_stdin ? $stdin : File.open(ARGV[0], 'r')
395
+ csv = CSV.new(io_object)
396
+ csv_array = csv.to_a
397
+ user_table = Terminal::Table.new do |v|
398
+ v.style = { :border => :unicode_round } # >= v3.0.0
399
+ v.title = "Some Title"
400
+ v.headings = csv_array[0]
401
+ v.rows = csv_array[1..-1]
402
+ end
403
+ puts user_table
404
+ ```
405
+
406
+ See also `examples/show_csv_table.rb` in the source distribution.
407
+
408
+ ## More examples
409
+
410
+ For more examples, please see the `examples` directory included in the
411
+ source distribution.
412
+
413
+ ## Author
414
+
415
+ TJ Holowaychuk <tj@vision-media.ca>
416
+
417
+ Unicode table support by Ben Bowers https://github.com/nanobowers
data/examples/data.csv ADDED
@@ -0,0 +1,4 @@
1
+ First Name,Last Name,Email
2
+ TJ,Holowaychuk,tj@vision-media.ca
3
+ Bob,Someone,bob@vision-media.ca
4
+ Joe,Whatever,joe@vision-media.ca
data/examples/examples.rb CHANGED
File without changes
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.dirname(__FILE__) + '/../lib'
4
+ require 'terminal-table/import'
5
+
6
+ Terminal::Table::Style.defaults = { :border => :unicode_round }
7
+ # Terminal::Table::UnicodeThickEdgeBorder.new()
8
+
9
+ puts
10
+ puts table(['a', 'b'], [1, 2], [3, 4])
11
+
12
+ puts
13
+ puts table(['name', 'content'], ['ftp.example.com', '1.1.1.1'], ['www.example.com', '|lalalala|lalala|'])
14
+
15
+ puts
16
+ t = table ['a', 'b']
17
+ t.style = {:padding_left => 2, :width => 80}
18
+ t << [1, 2]
19
+ t << [3, 4]
20
+ t << :separator
21
+ t << [4, 6]
22
+ puts t
23
+
24
+ puts
25
+ user_table = table do |v|
26
+ v.title = "Contact Information"
27
+ v.headings = 'First Name', 'Last Name', 'Email'
28
+ v << %w( TJ Holowaychuk tj@vision-media.ca )
29
+ v << %w( Bob Someone bob@vision-media.ca )
30
+ v << %w( Joe Whatever bob@vision-media.ca )
31
+ end
32
+ puts user_table
33
+
34
+ puts
35
+ user_table = table do |v|
36
+ v.style.width = 80
37
+ v.headings = 'First Name', 'Last Name', 'Email'
38
+ v << %w( TJ Holowaychuk tj@vision-media.ca )
39
+ v << %w( Bob Someone bob@vision-media.ca )
40
+ v << %w( Joe Whatever bob@vision-media.ca )
41
+ end
42
+ puts user_table
43
+
44
+ puts
45
+ user_table = table do
46
+ self.headings = 'First Name', 'Last Name', 'Email'
47
+ add_row ['TJ', 'Holowaychuk', 'tj@vision-media.ca']
48
+ add_row ['Bob', 'Someone', 'bob@vision-media.ca']
49
+ add_row ['Joe', 'Whatever', 'joe@vision-media.ca']
50
+ add_separator
51
+ add_row ['Total', { :value => '3', :colspan => 2, :alignment => :right }]
52
+ align_column 1, :center
53
+ end
54
+ puts user_table
55
+
56
+ puts
57
+ user_table = table do
58
+ self.headings = ['First Name', 'Last Name', {:value => 'Phones', :colspan => 2, :alignment => :center}]
59
+ #add_row ['Bob', 'Someone', '123', '456']
60
+ add_row [{:value => "Bob Someone", :colspan => 3, :alignment => :center}, '123456']
61
+ add_row :separator
62
+ add_row ['TJ', 'Holowaychuk', {:value => "No phones\navaiable", :colspan => 2, :alignment => :center}]
63
+ add_row :separator
64
+ add_row ['Joe', 'Whatever', '4324', '343242']
65
+ end
66
+ puts user_table
67
+
68
+ rows = []
69
+ rows << ['Lines', 100]
70
+ rows << ['Comments', 20]
71
+ rows << ['Ruby', 70]
72
+ rows << ['JavaScript', 30]
73
+ puts table([nil, 'Lines'], *rows)
74
+
75
+ rows = []
76
+ rows << ['Lines', 100]
77
+ rows << ['Comments', 20]
78
+ rows << ['Ruby', 70]
79
+ rows << ['JavaScript', 30]
80
+ puts table(nil, *rows)
81
+
82
+ rows = []
83
+ rows << ['Lines', 100]
84
+ rows << ['Comments', 20]
85
+ rows << ['Ruby', 70]
86
+ rows << ['JavaScript', 30]
87
+ table = table([{ :value => 'Stats', :colspan => 2, :alignment => :center }], *rows)
88
+ table.align_column 1, :right
89
+ puts table
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Methods to suppress left/right borders using border_left & border_right
4
+
5
+ require_relative "../lib/terminal-table"
6
+ table = Terminal::Table.new do |t|
7
+ t.headings = ['id', 'name']
8
+ t.rows = [[1, 'One'], [2, 'Two'], [3, 'Three']]
9
+ t.style = { :border_left => false, :border_top => false, :border_bottom => false }
10
+ end
11
+
12
+ puts table
13
+ puts
14
+
15
+ # no right
16
+ table.style = {:border_right => false }
17
+ puts table
18
+ puts
19
+
20
+ # no right
21
+ table.style = {:border_left => true }
22
+ puts table
23
+ puts
24
+
25
+ table.style.border = Terminal::Table::UnicodeBorder.new
26
+ puts table
27
+
28
+
29
+ table.style = {:border_right => false, :border_left => true }
30
+ puts table
31
+
32
+ table.style = {:border_right => true, :border_left => false }
33
+ puts table
34
+
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../lib/terminal-table"
3
+ puts Terminal::Table.new(headings: ['heading A', 'heading B'], rows: [['a', 'b'], ['a', 'b']], style: {border: Terminal::Table::MarkdownBorder.new})
4
+
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/terminal-table'
4
+
5
+ puts Terminal::Table.new(headings: ['a', 'b', 'c', 'd'], style: { border: :unicode })
6
+
7
+ puts
8
+
9
+ tbl = Terminal::Table.new do |t|
10
+ t.style = { border: :unicode }
11
+ t.add_separator
12
+ t.add_separator
13
+ t.add_row ['x','y','z']
14
+ t.add_separator
15
+ t.add_separator
16
+ end
17
+ puts tbl
18
+
19
+ puts
20
+
21
+ puts Terminal::Table.new(headings: [['a', 'b', 'c', 'd'], ['cat','dog','frog','mouse']], style: { border: :unicode })
22
+
23
+ puts
24
+
25
+ puts Terminal::Table.new(headings: ['a', 'b', 'c', 'd'])
26
+
27
+ puts
28
+
29
+ tbl = Terminal::Table.new do |t|
30
+ t.add_separator
31
+ t.add_separator
32
+ t.add_row ['x','y','z']
33
+ t.add_separator
34
+ t.add_separator
35
+ end
36
+ puts tbl