tabulo 1.2.0 → 1.2.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/.gitignore +1 -0
- data/.travis.yml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +49 -4
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/tabulo/version.rb +1 -1
- data/tabulo.gemspec +2 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8583d9f66b9305bb91dc45079567e811c60e839389c468ac963b2e49d1edc6a1
|
4
|
+
data.tar.gz: f89afda08a128532f113a7d36f1941ed638d745c7addf5761f068865eadbcdaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c0f4a420b0dfd4624afaa857f2ba03c28e5decab3c1fcb867b40662d277f8071a6c75a22b7f9bb72adf7595bbd8e6616a4103be1c92fee5e228e2bdacff07f7
|
7
|
+
data.tar.gz: 86b81698a9bfa003ed01f80a314e0bf4c0c55569152ef326ef29a73091094c02d844b536e7729fb879bf2225c260d3640687d97d6bc08acf604863b3a08ee083
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -6,11 +6,13 @@
|
|
6
6
|
|
7
7
|
## Overview
|
8
8
|
|
9
|
-
Tabulo
|
9
|
+
Tabulo is a Ruby library for generating ASCII tables.
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
|
13
|
-
|
12
|
+
underyling_enumerable = [1, 2, 50000000] # need not be an array
|
13
|
+
|
14
|
+
table = Tabulo::Table.new(underlying_enumerable) do |t|
|
15
|
+
t.add_column("N") { |n| n }
|
14
16
|
t.add_column("Doubled") { |n| n * 2 }
|
15
17
|
end
|
16
18
|
```
|
@@ -27,6 +29,8 @@ end
|
|
27
29
|
|
28
30
|
## Features
|
29
31
|
|
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
|
30
34
|
* Set [fixed column widths](#fixed-column-widths), then either [wrap](#overflow-handling) or
|
31
35
|
[truncate](#overflow-handling) the overflow.
|
32
36
|
* Alternatively, [shrinkwrap](#shrinkwrap) the table so that each column is just wide enough for its contents.
|
@@ -38,7 +42,33 @@ end
|
|
38
42
|
* Newlines within cell content are correctly handled.
|
39
43
|
* A `Tabulo::Table` is an `Enumerable`, so you can [step through it](#enumerator) a row at a time,
|
40
44
|
printing as you go, without waiting for the entire underlying collection to load.
|
41
|
-
* Each `Tabulo::Row` is also an `Enumerable`, providing access to the underlying cell values.
|
45
|
+
* Each `Tabulo::Row` is also an `Enumerable`, [providing access](#accessing-cell-values) to the underlying cell values.
|
46
|
+
* Tabulate any `Enumerable`: the underlying collection need not be an array.
|
47
|
+
|
48
|
+
Tabulo has also been ported to Crystal (with some modifications): see [Tablo](https://github.com/hutou/tablo).
|
49
|
+
|
50
|
+
## Table of Contents
|
51
|
+
|
52
|
+
* [Overview](#overview)
|
53
|
+
* [Features](#features)
|
54
|
+
* [Table of Contents](#table-of-contents)
|
55
|
+
* [Installation](#installation)
|
56
|
+
* [Detailed usage](#detailed-usage)
|
57
|
+
* [Requiring the gem](#requiring-the-gem)
|
58
|
+
* [Configuring columns](#configuring-columns)
|
59
|
+
* [Cell alignment](#cell-alignment)
|
60
|
+
* [Column width, wrapping and truncation](#column-width-wrapping-and-truncation)
|
61
|
+
* [Configuring fixed widths](#configuring-fixed-widths)
|
62
|
+
* [Automating column widths](#automating-column-widths)
|
63
|
+
* [Overflow handling](#overflow-handling)
|
64
|
+
* [Formatting cell values](#formatting-cell-values)
|
65
|
+
* [Repeating headers](#repeating-headers)
|
66
|
+
* [Using a Table Enumerator](#using-a-table-enumerator)
|
67
|
+
* [Accessing cell values)(#accessing-cell-values)
|
68
|
+
* [Additional configuration options](#additional-configuration-options)
|
69
|
+
* [Development](#development)
|
70
|
+
* [Contributing](#contributing)
|
71
|
+
* [License](#license)
|
42
72
|
|
43
73
|
## Installation
|
44
74
|
|
@@ -378,6 +408,21 @@ underlying collection. (This is negated if we [shrinkwrap](#shrinkwrap) the tabl
|
|
378
408
|
in that case the entire collection must be traversed up front in order for column widths to be
|
379
409
|
calculated.)
|
380
410
|
|
411
|
+
<a name="accessing-cell-values"></a>
|
412
|
+
### Accessing cell values
|
413
|
+
Each `Tabulo::Table` is an `Enumerable` of which each element is a `Tabulo::Row`. Each `Tabulo::Row`
|
414
|
+
is itself an `Enumerable` comprising the underlying the values of each cell. A `Tabulo::Row` can
|
415
|
+
also be converted to a `Hash` for keyed access. For example:
|
416
|
+
|
417
|
+
```ruby
|
418
|
+
table = Tabulo::Table.new(1..5, columns: %i[itself even? odd?])
|
419
|
+
|
420
|
+
table.each do |row|
|
421
|
+
row.each { |cell| puts cell } # 1...2...3...4...5
|
422
|
+
puts row.to_h[:even?] # false...true...false...true...false
|
423
|
+
end
|
424
|
+
```
|
425
|
+
|
381
426
|
### Additional configuration options
|
382
427
|
|
383
428
|
The characters used for horizontal dividers, vertical dividers and corners, which default to `-`,
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.1
|
data/lib/tabulo/version.rb
CHANGED
data/tabulo.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = "Enumerable ASCII table"
|
13
13
|
spec.description = "Enumerable ASCII table"
|
14
|
-
spec.homepage = "https://matt-harvey
|
14
|
+
spec.homepage = "https://github.com/matt-harvey/tabulo"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
"changelog_uri" => "https://raw.githubusercontent.com/matt-harvey/tabulo/master/CHANGELOG.md"
|
29
29
|
}
|
30
30
|
|
31
|
-
spec.add_development_dependency "bundler"
|
31
|
+
spec.add_development_dependency "bundler"
|
32
32
|
spec.add_development_dependency "rake", "~> 11.0"
|
33
33
|
spec.add_development_dependency "rspec", "~> 3.0"
|
34
34
|
spec.add_development_dependency "simplecov"
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tabulo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Harvey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,7 +165,7 @@ files:
|
|
165
165
|
- lib/tabulo/table.rb
|
166
166
|
- lib/tabulo/version.rb
|
167
167
|
- tabulo.gemspec
|
168
|
-
homepage: https://matt-harvey
|
168
|
+
homepage: https://github.com/matt-harvey/tabulo
|
169
169
|
licenses:
|
170
170
|
- MIT
|
171
171
|
metadata:
|
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
189
189
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.
|
190
|
+
rubygems_version: 2.7.6
|
191
191
|
signing_key:
|
192
192
|
specification_version: 4
|
193
193
|
summary: Enumerable ASCII table
|