tabulo 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +35 -9
- data/VERSION +1 -1
- data/lib/tabulo/border.rb +34 -0
- data/lib/tabulo/table.rb +12 -8
- data/lib/tabulo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f88dea9e9986d3d6483bb082ff61131192f8c347f5a8ef8d9bb1db020d327ce
|
4
|
+
data.tar.gz: 5fac068d5c1966a942246bf5ca404d0d21e9169337d024873b4d20c83c563a49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6979e838018800f81ca9fb062d34fdd4c19068efac1b5442998ec1f9b9808ec4d43a9aa5f91306abdc7535016bc1efd947af3b394bb93fd1be2b3979dd65c523
|
7
|
+
data.tar.gz: f764c67975c9409ab0b3646af6f396cb76407490940179e16071527ab6bf00a08a87a8aa62c1b7b8f4d21ada8ae1d25bdb34ed6eebdec4d22f22910331e01f60
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### v2.1.0
|
4
|
+
|
5
|
+
* New `:reduced_ascii` and `:reduced_modern` border options
|
6
|
+
* Fix `column_width` option not properly inherited from original table by the new table created
|
7
|
+
by calling #transpose.
|
8
|
+
|
3
9
|
### v2.0.2
|
4
10
|
|
5
11
|
* Minor documentation fixes
|
data/README.md
CHANGED
@@ -560,11 +560,11 @@ A `Tabulo::Row` can also
|
|
560
560
|
be converted to a `Hash` for keyed access. For example:
|
561
561
|
|
562
562
|
```ruby
|
563
|
-
table = Tabulo::Table.new(1..
|
563
|
+
table = Tabulo::Table.new(1..3, :itself, :even?, :odd?)
|
564
564
|
|
565
565
|
table.each do |row|
|
566
|
-
row.each { |cell| puts cell.value } # 1...2...3
|
567
|
-
puts row.to_h[:even?].value # false...true...false
|
566
|
+
row.each { |cell| puts cell.value } # 1, false, true...2, true, false...3, false, true
|
567
|
+
puts row.to_h[:even?].value # false...true...false
|
568
568
|
end
|
569
569
|
```
|
570
570
|
|
@@ -575,15 +575,15 @@ the column; and it need not be the same as the column header. If we want the hea
|
|
575
575
|
to the label, we can achieve this using the `header` option to `add_column`:
|
576
576
|
|
577
577
|
```ruby
|
578
|
-
table = Tabulo::Table.new(1..
|
578
|
+
table = Tabulo::Table.new(1..3) do |t|
|
579
579
|
t.add_column("Number") { |n| n }
|
580
580
|
t.add_column(:doubled, header: "Number X 2") { |n| n * 2 }
|
581
581
|
end
|
582
582
|
|
583
583
|
table.each do |row|
|
584
584
|
cells = row.to_h
|
585
|
-
puts cells[:Number].value # 1...2...3...
|
586
|
-
puts cells[:doubled].value # 2...4...6...
|
585
|
+
puts cells[:Number].value # 1...2...3...
|
586
|
+
puts cells[:doubled].value # 2...4...6...
|
587
587
|
end
|
588
588
|
```
|
589
589
|
|
@@ -651,7 +651,7 @@ a new table in which the rows and columns are swapped:
|
|
651
651
|
By default, a header row is added to the new table, showing the string value of the element
|
652
652
|
represented in that column. This can be configured, however, along with other aspects of
|
653
653
|
`transpose`'s behaviour. For details, see the
|
654
|
-
[documentation](https://www.rubydoc.info/gems/tabulo/2.0
|
654
|
+
[documentation](https://www.rubydoc.info/gems/tabulo/2.1.0/Tabulo/Table#transpose-instance_method).
|
655
655
|
|
656
656
|
<a name="borders"></a>
|
657
657
|
### Configuring borders
|
@@ -706,6 +706,32 @@ This is done using the `border` option passed to `Table.new`. The options are as
|
|
706
706
|
3 false true
|
707
707
|
```
|
708
708
|
|
709
|
+
`:reduced_ascii`—similar to `:ascii`, but without vertical lines:
|
710
|
+
|
711
|
+
```
|
712
|
+
> puts Tabulo::Table.new(1...3, :itself, :even?, :odd?, border: :reduced_modern)
|
713
|
+
-------------- -------------- --------------
|
714
|
+
itself even? odd?
|
715
|
+
-------------- -------------- --------------
|
716
|
+
1 false true
|
717
|
+
2 true false
|
718
|
+
3 false true
|
719
|
+
-------------- -------------- --------------
|
720
|
+
```
|
721
|
+
|
722
|
+
`:reduced_modern`—similar to `:modern`, but without vertical lines:
|
723
|
+
|
724
|
+
```
|
725
|
+
> puts Tabulo::Table.new(1...3, :itself, :even?, :odd?, border: :reduced_ascii)
|
726
|
+
────────────── ────────────── ──────────────
|
727
|
+
itself even? odd?
|
728
|
+
────────────── ────────────── ──────────────
|
729
|
+
1 false true
|
730
|
+
2 true false
|
731
|
+
3 false true
|
732
|
+
────────────── ────────────── ──────────────
|
733
|
+
```
|
734
|
+
|
709
735
|
`:classic`—reproduces the default behaviour in Tabulo v1; this is like the `:ascii` option,
|
710
736
|
but without a bottom border:
|
711
737
|
|
@@ -821,14 +847,14 @@ The gem is available as open source under the terms of the [MIT
|
|
821
847
|
License](http://opensource.org/licenses/MIT).
|
822
848
|
|
823
849
|
[Gem Version]: https://rubygems.org/gems/tabulo
|
824
|
-
[Documentation]: http://www.rubydoc.info/gems/tabulo/2.0
|
850
|
+
[Documentation]: http://www.rubydoc.info/gems/tabulo/2.1.0
|
825
851
|
[Build Status]: https://travis-ci.org/matt-harvey/tabulo
|
826
852
|
[Coverage Status]: https://coveralls.io/r/matt-harvey/tabulo
|
827
853
|
[Code Climate]: https://codeclimate.com/github/matt-harvey/tabulo
|
828
854
|
[Awesome Ruby]: https://github.com/markets/awesome-ruby#cli-utilities
|
829
855
|
|
830
856
|
[GV img]: https://img.shields.io/gem/v/tabulo.svg
|
831
|
-
[DC img]: https://img.shields.io/badge/documentation-v2.0
|
857
|
+
[DC img]: https://img.shields.io/badge/documentation-v2.1.0-blue.svg
|
832
858
|
[BS img]: https://img.shields.io/travis/matt-harvey/tabulo.svg
|
833
859
|
[CS img]: https://img.shields.io/coveralls/matt-harvey/tabulo.svg
|
834
860
|
[CC img]: https://codeclimate.com/github/matt-harvey/tabulo/badges/gpa.svg
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0
|
1
|
+
2.1.0
|
data/lib/tabulo/border.rb
CHANGED
@@ -34,6 +34,40 @@ module Tabulo
|
|
34
34
|
divider_horizontal: "-",
|
35
35
|
intersection: "+",
|
36
36
|
},
|
37
|
+
reduced_ascii: {
|
38
|
+
corner_top_left: "",
|
39
|
+
corner_top_right: "",
|
40
|
+
corner_bottom_right: "",
|
41
|
+
corner_bottom_left: "",
|
42
|
+
edge_top: "-",
|
43
|
+
edge_right: "",
|
44
|
+
edge_bottom: "-",
|
45
|
+
edge_left: "",
|
46
|
+
tee_top: " ",
|
47
|
+
tee_right: "",
|
48
|
+
tee_bottom: " ",
|
49
|
+
tee_left: "",
|
50
|
+
divider_vertical: " ",
|
51
|
+
divider_horizontal: "-",
|
52
|
+
intersection: " ",
|
53
|
+
},
|
54
|
+
reduced_modern: {
|
55
|
+
corner_top_left: "",
|
56
|
+
corner_top_right: "",
|
57
|
+
corner_bottom_right: "",
|
58
|
+
corner_bottom_left: "",
|
59
|
+
edge_top: "─",
|
60
|
+
edge_right: "",
|
61
|
+
edge_bottom: "─",
|
62
|
+
edge_left: "",
|
63
|
+
tee_top: " ",
|
64
|
+
tee_right: "",
|
65
|
+
tee_bottom: " ",
|
66
|
+
tee_left: "",
|
67
|
+
divider_vertical: " ",
|
68
|
+
divider_horizontal: "─",
|
69
|
+
intersection: " ",
|
70
|
+
},
|
37
71
|
markdown: {
|
38
72
|
corner_top_left: "",
|
39
73
|
corner_top_right: "",
|
data/lib/tabulo/table.rb
CHANGED
@@ -74,12 +74,16 @@ module Tabulo
|
|
74
74
|
# within the table to separate columns from each other and the header row from the Table body.
|
75
75
|
# If <tt>nil</tt>, then the value of {DEFAULT_BORDER} will be used.
|
76
76
|
# Possible values are:
|
77
|
-
# - `:ascii`
|
78
|
-
# - `:markdown`
|
79
|
-
# - `:modern`
|
80
|
-
# - `:blank`
|
81
|
-
# - `:
|
82
|
-
#
|
77
|
+
# - `:ascii` Uses ASCII characters only
|
78
|
+
# - `:markdown` Produces a GitHub-flavoured Markdown table
|
79
|
+
# - `:modern` Uses non-ASCII Unicode characters to render a border with smooth continuous lines
|
80
|
+
# - `:blank` No border characters are rendered
|
81
|
+
# - `:reduced_ascii` Like `:ascii`, but without left or right borders, and with internal vertical
|
82
|
+
# borders and intersection characters consisting of whitespace only
|
83
|
+
# - `:reduced_modern` Like `:modern`, but without left or right borders, and with internal vertical
|
84
|
+
# borders and intersection characters consisting of whitespace only
|
85
|
+
# - `:classic` Like `:ascii`, but does not have a horizontal line at the bottom of the
|
86
|
+
# table. This reproduces the default behaviour in `tabulo` v1.
|
83
87
|
# @param [nil, #to_proc] border_styler (nil) A lambda or other callable object taking
|
84
88
|
# a single parameter, representing a section of the table's borders (which for this purpose
|
85
89
|
# include any horizontal and vertical lines inside the table), and returning a string.
|
@@ -100,7 +104,7 @@ module Tabulo
|
|
100
104
|
@header_frequency = header_frequency
|
101
105
|
@wrap_header_cells_to = wrap_header_cells_to
|
102
106
|
@wrap_body_cells_to = wrap_body_cells_to
|
103
|
-
@
|
107
|
+
@column_width = (column_width || DEFAULT_COLUMN_WIDTH)
|
104
108
|
@align_header = align_header
|
105
109
|
@align_body = align_body
|
106
110
|
|
@@ -212,7 +216,7 @@ module Tabulo
|
|
212
216
|
header: (header || label).to_s,
|
213
217
|
align_header: align_header || @align_header,
|
214
218
|
align_body: align_body || @align_body,
|
215
|
-
width: (width || @
|
219
|
+
width: (width || @column_width),
|
216
220
|
formatter: formatter,
|
217
221
|
extractor: (extractor || label.to_proc),
|
218
222
|
styler: styler,
|
data/lib/tabulo/version.rb
CHANGED
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.0
|
4
|
+
version: 2.1.0
|
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-
|
11
|
+
date: 2019-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-screen
|