tabulo 2.7.0 → 2.7.1

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: 632d2d2d3b7d0120410d0afd2b8f1d1b341fd1b6daa7802b15b6f791640d409e
4
- data.tar.gz: f5720b528f1c4384118196619ea923b317ec3ff7d374fa87d79808361031e7cc
3
+ metadata.gz: 63054578d0f667075a8e2888d3fc0a2572ec9b8a93e3f74468f058613a7c2f19
4
+ data.tar.gz: 3d0b8bad1b9ad7fa2949037ec6de683f7b43c7ecc73ca02c53bbb14f926139fe
5
5
  SHA512:
6
- metadata.gz: 283e3ac39971cfdf9df9968fe0e40b00d049865fe7f49ef0403d71e35ea8f49a43d85579cb9f12d080e0bacafa48c943d2e57176309be99809272983cd9db2d7
7
- data.tar.gz: 32256e95de32d81a65d64e49a6f1eb42c33d7ccca2c76a5d6ce5cb6d0beee8c9d5588aa6d5df2c68a59ac8805e5b5048851a0959ddf281eaf891771ee162158c
6
+ metadata.gz: d8626993288417bdd75b581819ea4ef9ef79bfcdfb5d18e7469ac2699e303096405f6155b690a289f5bbc27a8235cc80fb4cb0ad8e62146c664f198fefce9a7e
7
+ data.tar.gz: 9a306fb542677778f3e6998ee83352f87802bf6d07b422846b61d1fe42acdd8b40a914daa87a10e5abe2f84e6d4b8cd5ddc5711e49d9b5d066113b167b4cf4a9
@@ -23,9 +23,9 @@ jobs:
23
23
  '2.3.8',
24
24
  '2.4.10',
25
25
  '2.5.9',
26
- '2.6.7',
27
- '2.7.3',
28
- '3.0.1',
26
+ '2.6.8',
27
+ '2.7.4',
28
+ '3.0.2',
29
29
  ]
30
30
  steps:
31
31
  - uses: actions/checkout@v2
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  **/.*.swp
11
11
  coverage
12
12
  gh-md-toc
13
+ .ruby-version
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ### v2.7.1
4
+
5
+ * Dependency version upgrades
6
+ * Minor documentation improvements and tweaks
7
+
3
8
  ### v2.7.0
4
9
 
5
10
  * Add `wrap_preserve` option, allowing whole words to be preserved when wrapping.
data/README.md CHANGED
@@ -4,7 +4,6 @@
4
4
  [![Documentation][DC img]][Documentation]
5
5
  [![Build Status][BS img]][Build Status]
6
6
  [![Coverage Status][CS img]][Coverage Status]
7
- [![Code Climate][CC img]][Code Climate]
8
7
  [![Awesome][AR img]][Awesome Ruby]
9
8
 
10
9
  Tabulo is a Ruby library for generating plain text tables (also known as “terminal tables”
@@ -85,6 +84,7 @@ Tabulo has also been ported to Crystal (with some modifications): see [Tablo](ht
85
84
  * [Full API](#quick-api)
86
85
  * [Column labels _vs_ headers](#labels-headers)
87
86
  * [Positioning columns](#column-positioning)
87
+ * [Extracting column content from a hash or array](#from-arrays-hashes)
88
88
  * [Removing columns](#removing-columns)
89
89
  * [Adding a title](#title)
90
90
  * [Cell alignment](#cell-alignment)
@@ -93,6 +93,7 @@ Tabulo has also been ported to Crystal (with some modifications): see [Tablo](ht
93
93
  * [Automating column widths](#automating-column-widths)
94
94
  * [Configuring padding](#configuring-padding)
95
95
  * [Overflow handling](#overflow-handling)
96
+ * [Wrapping at word boundaries](#preserve-words)
96
97
  * [Manual cell wrapping](#manual-wrapping)
97
98
  * [Formatting cell values](#formatting-cell-values)
98
99
  * [Colours and other styling](#colours-and-styling)
@@ -281,6 +282,69 @@ table.add_column(:even?, before: :odd?)
281
282
  +--------------+--------------+--------------+
282
283
  ```
283
284
 
285
+ <a name="from-arrays-hashes"></a>
286
+ #### Extracting column content from a hash or array [&#x2191;](#contents)
287
+
288
+ Sometimes the data source for the table may be a collection of hashes or arrays. For example:
289
+
290
+ ```ruby
291
+ data = [
292
+ { english: "hello", portuguese: "bom dia" },
293
+ { english: "goodbye", portuguese: "adeus" },
294
+ ]
295
+ ```
296
+
297
+ or
298
+
299
+ ```ruby
300
+ data = [
301
+ ["hello", "bom dia"],
302
+ ["goodbye", "adeus"],
303
+ ]
304
+ ```
305
+
306
+ To tabulate such a collection, simply use the same mechanism as described above, passing a block to
307
+ the `add_column` method to tell Tabulo how to extract the data for each column from a row. For
308
+ example, to tabulate the first example above, you could do something like this:
309
+
310
+ ```ruby
311
+ table = Tabulo::Table.new(data) do |t|
312
+ t.add_column("English") { |h| h[:english] }
313
+ t.add_column("Portuguese") { |h| h[:portuguese] }
314
+ end
315
+
316
+ puts table
317
+ ```
318
+
319
+ For the second example, you could do the following:
320
+
321
+ ```ruby
322
+ table = Tabulo::Table.new(data) do |t|
323
+ t.add_column("English") { |a| a[0] }
324
+ t.add_column("Portuguese") { |a| a[1] }
325
+ end
326
+
327
+ puts table
328
+ ```
329
+
330
+ In both cases, the output will be as follows:
331
+
332
+ ```
333
+ +--------------+--------------+
334
+ | English | Portuguese |
335
+ +--------------+--------------+
336
+ | hello | bom dia |
337
+ | goodbye | adeus |
338
+ +--------------+--------------+
339
+ ```
340
+
341
+ If you have previously used other terminal tabulation libraries, you may be accustomed to being _required_
342
+ to place your data into an array of hashes or arrays before you can tabulate them. Tabulo, however,
343
+ offers an API that is more general and flexible than this; your data source can be _any_
344
+ enumerable collection (not just an array), and each item in that collection can be _any_ object (not
345
+ necessarily an array or a hash). However, as shown above, it is still straightforward to tabulate an
346
+ array of hashes or arrays, if your data source happens to take that form.
347
+
284
348
  <a name="removing-columns"></a>
285
349
  ### Removing columns [&#x2191;](#contents)
286
350
 
@@ -729,7 +793,7 @@ the table.
729
793
  The `formatter` callback also has an alternative, 2-parameter version. If `formatter` is passed
730
794
  a 2-parameter callable, the second parameter will be given a `CellData` instance,
731
795
  containing additional information about the cell that may be useful in determining how to format
732
- it&mdash;see the [documentation](https://www.rubydoc.info/gems/tabulo/2.7.0/Tabulo/CellData.html)
796
+ it&mdash;see the [documentation](https://www.rubydoc.info/gems/tabulo/2.7.1/Tabulo/CellData.html)
733
797
  for details.
734
798
 
735
799
  <a name="colours-and-styling"></a>
@@ -775,7 +839,7 @@ number is even). The second parameter represents the formatted string value of t
775
839
  content after any processing by the [formatter](#formatting-cell-values). The third and fourth
776
840
  parameters are optional, and contain further information about the cell and its contents that may be useful in
777
841
  determining how to style it. See the
778
- [documentation](https://www.rubydoc.info/gems/tabulo/2.7.0/Tabulo/Table#add_column-instance_method) for details.
842
+ [documentation](https://www.rubydoc.info/gems/tabulo/2.7.1/Tabulo/Table#add_column-instance_method) for details.
779
843
 
780
844
  If the content of a cell is wrapped over multiple lines, then the `styler` will be called once
781
845
  per line, so that each line of the cell will have the escape sequence applied to it separately
@@ -795,7 +859,7 @@ table.add_column(:even?, header_styler: -> (s) { "\033[32m#{s}\033[0m" })
795
859
  ```
796
860
 
797
861
  The `header_styler` option accepts a 1-, 2- or 3-parameter callable. See the
798
- [documentation](https://www.rubydoc.info/gems/tabulo/2.7.0/Tabulo/Table#add_column-instance_method)
862
+ [documentation](https://www.rubydoc.info/gems/tabulo/2.7.1/Tabulo/Table#add_column-instance_method)
799
863
  for details.
800
864
 
801
865
  <a name="styling-title"></a>
@@ -809,7 +873,7 @@ table = Tabulo::Table.new(1..5, :itself, :even?, :odd?, title: "Numbers", title_
809
873
  ```
810
874
 
811
875
  The `title_styler` option accepts a 1- or 2-parameter callable. See the
812
- [documentation](https://www.rubydoc.info/gems/tabulo/2.7.0/Tabulo/Table#initialize-instance_method)
876
+ [documentation](https://www.rubydoc.info/gems/tabulo/2.7.1/Tabulo/Table#initialize-instance_method)
813
877
  for details.
814
878
 
815
879
  <a name="styling-borders"></a>
@@ -1004,7 +1068,7 @@ a new table in which the rows and columns are swapped:
1004
1068
  By default, a header row is added to the new table, showing the string value of the element
1005
1069
  represented in that column. This can be configured, however, along with other aspects of
1006
1070
  `transpose`&#8217;s behaviour. For details, see the
1007
- [documentation](https://www.rubydoc.info/gems/tabulo/2.7.0/Tabulo/Table#transpose-instance_method).
1071
+ [documentation](https://www.rubydoc.info/gems/tabulo/2.7.1/Tabulo/Table#transpose-instance_method).
1008
1072
 
1009
1073
  <a name="borders"></a>
1010
1074
  ### Configuring borders [&#x2191;](#contents)
@@ -1395,15 +1459,13 @@ The gem is available as open source under the terms of the [MIT
1395
1459
  License](http://opensource.org/licenses/MIT).
1396
1460
 
1397
1461
  [Gem Version]: https://rubygems.org/gems/tabulo
1398
- [Documentation]: http://www.rubydoc.info/gems/tabulo/2.7.0
1462
+ [Documentation]: http://www.rubydoc.info/gems/tabulo/2.7.1
1399
1463
  [Build Status]: https://github.com/matt-harvey/tabulo/actions/workflows/tests.yml
1400
1464
  [Coverage Status]: https://coveralls.io/github/matt-harvey/tabulo
1401
- [Code Climate]: https://codeclimate.com/github/matt-harvey/tabulo
1402
1465
  [Awesome Ruby]: https://github.com/markets/awesome-ruby#cli-utilities
1403
1466
 
1404
1467
  [GV img]: https://img.shields.io/gem/v/tabulo.svg
1405
- [DC img]: https://img.shields.io/badge/documentation-v2.7.0-blue.svg
1468
+ [DC img]: https://img.shields.io/badge/documentation-v2.7.1-blue.svg
1406
1469
  [BS img]: https://github.com/matt-harvey/tabulo/actions/workflows/tests.yml/badge.svg
1407
1470
  [CS img]: https://img.shields.io/coveralls/matt-harvey/tabulo.svg
1408
- [CC img]: https://codeclimate.com/github/matt-harvey/tabulo/badges/gpa.svg
1409
1471
  [AR img]: https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.7.0
1
+ 2.7.1
@@ -1,3 +1,3 @@
1
1
  module Tabulo
2
- VERSION = "2.7.0"
2
+ VERSION = "2.7.1"
3
3
  end
data/tabulo.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  }
30
30
 
31
31
  spec.add_runtime_dependency "tty-screen", "0.8.1"
32
- spec.add_runtime_dependency "unicode-display_width", "2.0.0"
32
+ spec.add_runtime_dependency "unicode-display_width", "2.1.0"
33
33
 
34
34
  spec.add_development_dependency "bundler"
35
35
  spec.add_development_dependency "rake", "~> 12.3.3"
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: 2.7.0
4
+ version: 2.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Harvey
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-18 00:00:00.000000000 Z
11
+ date: 2021-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-screen
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 2.0.0
33
+ version: 2.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 2.0.0
40
+ version: 2.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -206,7 +206,7 @@ licenses:
206
206
  metadata:
207
207
  source_code_uri: https://github.com/matt-harvey/tabulo
208
208
  changelog_uri: https://raw.githubusercontent.com/matt-harvey/tabulo/master/CHANGELOG.md
209
- post_install_message:
209
+ post_install_message:
210
210
  rdoc_options: []
211
211
  require_paths:
212
212
  - lib
@@ -221,8 +221,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
223
  requirements: []
224
- rubygems_version: 3.1.2
225
- signing_key:
224
+ rubygems_version: 3.2.29
225
+ signing_key:
226
226
  specification_version: 4
227
227
  summary: Terminal table generator
228
228
  test_files: []