tabulo 1.2.1 → 1.2.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
2
  SHA256:
3
- metadata.gz: 8583d9f66b9305bb91dc45079567e811c60e839389c468ac963b2e49d1edc6a1
4
- data.tar.gz: f89afda08a128532f113a7d36f1941ed638d745c7addf5761f068865eadbcdaa
3
+ metadata.gz: 2db6b288685b76e7cab29fc52f1f0d265cb77310392449681bd15950231fb3d7
4
+ data.tar.gz: 8a9477cc4c7f04a0219bac645c774bd5569f1cd2baff5bfb17ffba57e22b497b
5
5
  SHA512:
6
- metadata.gz: 0c0f4a420b0dfd4624afaa857f2ba03c28e5decab3c1fcb867b40662d277f8071a6c75a22b7f9bb72adf7595bbd8e6616a4103be1c92fee5e228e2bdacff07f7
7
- data.tar.gz: 86b81698a9bfa003ed01f80a314e0bf4c0c55569152ef326ef29a73091094c02d844b536e7729fb879bf2225c260d3640687d97d6bc08acf604863b3a08ee083
6
+ metadata.gz: 292313dfb4ec2e67e0f0f879c61f9b3797b407d9c8bf1a1e049126b509cedeca557b4cb0d0e4498658438ced29a0faf0aab868ee821cda92a9cea6959a81e75c
7
+ data.tar.gz: 8714b8dae9a6373d0953a496816e14264af2c78e680b8854866e513776f6aa81827d9beb4c29c190455b3911326495a4cfbe5b712175c54b5087e7927531737b
data/.travis.yml CHANGED
@@ -5,4 +5,5 @@ rvm:
5
5
  - 2.2.10
6
6
  - 2.3.8
7
7
  - 2.4.5
8
- - 2.5.3
8
+ - 2.5.5
9
+ - 2.6.2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### v1.2.2
4
+
5
+ * Improve documentation.
6
+
3
7
  ### v1.2.1
4
8
 
5
9
  * Improve documentation in README.
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Tabulo
2
2
 
3
3
  [![Gem Version][GV img]][Gem Version]
4
+ [![Documentation][DC img]][Documentation]
4
5
  [![Coverage Status][CS img]][Coverage Status]
5
6
  [![Build Status][BS img]][Build Status]
7
+ [![Code Climate][CC img]][Code Climate]
6
8
 
7
9
  ## Overview
8
10
 
@@ -29,9 +31,9 @@ end
29
31
 
30
32
  ## Features
31
33
 
32
- * A [DRY interface](#configuring-columns) that relieves the developer of maintaining a correspondence between an array
33
- of column headers on the one hand, and an array of rows of cell values on the other
34
- * Set [fixed column widths](#fixed-column-widths), then either [wrap](#overflow-handling) or
34
+ * A [DRY interface](#configuring-columns): by being "column based", it is designed to spare the
35
+ developer the burden of syncing the ordering within the header row with that of the body rows.
36
+ * Lets you set [fixed column widths](#fixed-column-widths), then either [wrap](#overflow-handling) or
35
37
  [truncate](#overflow-handling) the overflow.
36
38
  * Alternatively, [shrinkwrap](#shrinkwrap) the table so that each column is just wide enough for its contents.
37
39
  * Put an upper limit on total table width when shrinkwrapping, to
@@ -44,10 +46,11 @@ end
44
46
  printing as you go, without waiting for the entire underlying collection to load.
45
47
  * Each `Tabulo::Row` is also an `Enumerable`, [providing access](#accessing-cell-values) to the underlying cell values.
46
48
  * Tabulate any `Enumerable`: the underlying collection need not be an array.
49
+ * [Customize](#additional-configuration-options) border and divider characters.
47
50
 
48
51
  Tabulo has also been ported to Crystal (with some modifications): see [Tablo](https://github.com/hutou/tablo).
49
52
 
50
- ## Table of Contents
53
+ ## Contents
51
54
 
52
55
  * [Overview](#overview)
53
56
  * [Features](#features)
@@ -59,12 +62,13 @@ Tabulo has also been ported to Crystal (with some modifications): see [Tablo](ht
59
62
  * [Cell alignment](#cell-alignment)
60
63
  * [Column width, wrapping and truncation](#column-width-wrapping-and-truncation)
61
64
  * [Configuring fixed widths](#configuring-fixed-widths)
65
+ * [Configuring padding](#configuring-padding)
62
66
  * [Automating column widths](#automating-column-widths)
63
67
  * [Overflow handling](#overflow-handling)
64
68
  * [Formatting cell values](#formatting-cell-values)
65
69
  * [Repeating headers](#repeating-headers)
66
70
  * [Using a Table Enumerator](#using-a-table-enumerator)
67
- * [Accessing cell values)(#accessing-cell-values)
71
+ * [Accessing cell values](#accessing-cell-values)
68
72
  * [Additional configuration options](#additional-configuration-options)
69
73
  * [Development](#development)
70
74
  * [Contributing](#contributing)
@@ -202,7 +206,10 @@ table = Tabulo::Table.new([1, 2], columns: %i[itself even?], column_width: 6)
202
206
 
203
207
  Widths set for individual columns always override the default column width for the table.
204
208
 
205
- Note the single character of padding either side of each column is not counted in the column width.
209
+ <a name="configuring-padding"></a>
210
+ #### Configuring padding
211
+
212
+ The single character of padding either side of each column is not counted in the column width.
206
213
  The amount of this padding can be configured for the table as a whole, using the `column_padding`
207
214
  option passed to `Table.new`.
208
215
 
@@ -329,7 +336,7 @@ end
329
336
  ```
330
337
 
331
338
  ```
332
- puts table
339
+ > puts table
333
340
  +--------------+--------------+
334
341
  | N | Reciprocal |
335
342
  +--------------+--------------+
@@ -423,6 +430,25 @@ table.each do |row|
423
430
  end
424
431
  ```
425
432
 
433
+ The first argument to `add_column`, considered as a `Symbol`, always provides the key
434
+ for the purpose of accessing the `Hash` form of a `Tabulo::Row`. This key serves as
435
+ a sort of "logical label" for the column; and it need not be the same as the column
436
+ header. If we want the header to be different to the label, we can achieve this
437
+ using the `header` option to `add_column`:
438
+
439
+ ```ruby
440
+ table = Tabulo::Table.new(1..5) do |t|
441
+ t.add_column("Number") { |n| n }
442
+ t.add_column(:doubled, header: "Number X 2") { |n| n * 2 }
443
+ end
444
+
445
+ table.each do |row|
446
+ cells = row.to_h
447
+ puts cells[:Number] # 1...2...3...4...5
448
+ puts cells[:doubled] # 2...4...6...8...10
449
+ end
450
+ ```
451
+
426
452
  ### Additional configuration options
427
453
 
428
454
  The characters used for horizontal dividers, vertical dividers and corners, which default to `-`,
@@ -432,15 +458,44 @@ The characters used for horizontal dividers, vertical dividers and corners, whic
432
458
  The character used to indicate truncation, which defaults to `~`, can be configured using the
433
459
  `truncation_indicator` option passed to `Table.new`.
434
460
 
435
- ## Development
461
+ A bottom border can be added to the table when printing, as follows:
462
+
463
+ ```ruby
464
+ puts table
465
+ puts table.horizontal_rule
466
+ ```
467
+
468
+ This will output a bottom border that's appropriately sized for the table.
436
469
 
437
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run
438
- the tests. You can also run `bin/console` for an interactive prompt that will allow you to
439
- experiment.
470
+ This mechanism can also be used to output a horizontal divider after each row:
471
+
472
+ ```ruby
473
+ table = Tabulo::Table.new(1..3, columns: %i[itself even?])
474
+ ```
475
+
476
+ ```
477
+ > table.each { |row| puts row ; puts table.horizontal_rule }
478
+ +--------------+--------------+
479
+ | itself | even? |
480
+ +--------------+--------------+
481
+ | 1 | false |
482
+ +--------------+--------------+
483
+ | 2 | true |
484
+ +--------------+--------------+
485
+ | 3 | false |
486
+ +--------------+--------------+
487
+ ```
440
488
 
441
489
  ## Contributing
442
490
 
443
- Bug reports and pull requests are welcome on GitHub at https://github.com/matt-harvey/tabulo.
491
+ Issues and pull requests are welcome on GitHub at https://github.com/matt-harvey/tabulo.
492
+
493
+ To start working on Tabulo, `git clone` and `cd` into your fork of the repo, then run `bin/setup` to
494
+ install dependencies.
495
+
496
+ `bin/console` will give you an interactive prompt that will allow you to experiment; and `rake spec`
497
+ will run the test suite. For a list of other Rake tasks that are available in the development
498
+ environment, run `rake -T`.
444
499
 
445
500
  ## License
446
501
 
@@ -448,9 +503,13 @@ The gem is available as open source under the terms of the [MIT
448
503
  License](http://opensource.org/licenses/MIT).
449
504
 
450
505
  [Gem Version]: https://rubygems.org/gems/tabulo
506
+ [Documentation]: http://www.rubydoc.info/gems/tabulo/1.2.2
451
507
  [Build Status]: https://travis-ci.org/matt-harvey/tabulo
452
508
  [Coverage Status]: https://coveralls.io/r/matt-harvey/tabulo
509
+ [Code Climate]: https://codeclimate.com/github/matt-harvey/tabulo
453
510
 
454
- [GV img]: https://img.shields.io/gem/v/tabulo.svg?style=plastic
455
- [BS img]: https://img.shields.io/travis/matt-harvey/tabulo.svg?style=plastic
456
- [CS img]: https://img.shields.io/coveralls/matt-harvey/tabulo.svg?style=plastic
511
+ [GV img]: https://img.shields.io/gem/v/tabulo.svg
512
+ [DC img]: https://img.shields.io/badge/documentation-v1.2.2-blue.svg
513
+ [BS img]: https://img.shields.io/travis/matt-harvey/tabulo.svg
514
+ [CS img]: https://img.shields.io/coveralls/matt-harvey/tabulo.svg
515
+ [CC img]: https://codeclimate.com/github/matt-harvey/tabulo/badges/gpa.svg
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 1.2.2
data/lib/tabulo/table.rb CHANGED
@@ -237,9 +237,7 @@ module Tabulo
237
237
  return self if column_registry.none?
238
238
  columns = column_registry.values
239
239
 
240
- columns.each do |column|
241
- column.width = wrapped_width(column.header)
242
- end
240
+ columns.each { |column| column.width = wrapped_width(column.header) }
243
241
 
244
242
  @sources.each do |source|
245
243
  columns.each do |column|
@@ -1,3 +1,3 @@
1
1
  module Tabulo
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabulo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Harvey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-17 00:00:00.000000000 Z
11
+ date: 2019-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler