tabulo 2.7.2 → 2.8.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: f2419c20288ae285e4fcbfefd5627f6dac370ab3940969093216283407df6ee4
4
- data.tar.gz: '08ee67482f630a3f185319fcc7fec4844b3a64d70042f3afc9abb993e4a65260'
3
+ metadata.gz: '0967716cb8ae0364c51187023e9515933615d25de080d95b08c931cbf17a11a0'
4
+ data.tar.gz: e6497d0121eefcb8960370a5ee9d3884143b89a0a45336aaa30814095be3794d
5
5
  SHA512:
6
- metadata.gz: 97f9cc96273afdc2fb30f341cc7dede4440cc2198209035bdbb65bf4872628a0db6a42f29287a7f9a2aa08c0fd2495bd7cdf189529ef1ce93f62797a5cfdb8dd
7
- data.tar.gz: 96e4fd149487e51a49bb3935ec4341c0a327f101d028019b8bf73279b3e239cf3d8deb0fd5efda92c8d10d79c5bf1973b16344e45e753695b6920c6c4111f852
6
+ metadata.gz: 9d49aeccc15b496344ae03b93ca10cce1b3c02d706f43e68f30285f7c0bf9c6a81bbcbec68768791b5cb37b0f75dcec33ce45999e87b33ee39a01eb8997217ca
7
+ data.tar.gz: 846cfe4796836b485848b6f9fdcd1b1e8f0907587b5c32debb50734ded99e6992e56a4b62d6d755740e03d5831182fb4e7f0c9fe67e04bad636baac2cc090deb
@@ -23,9 +23,10 @@ jobs:
23
23
  '2.3.8',
24
24
  '2.4.10',
25
25
  '2.5.9',
26
- '2.6.9',
27
- '2.7.5',
28
- '3.0.3',
26
+ '2.6.10',
27
+ '2.7.6',
28
+ '3.0.4',
29
+ '3.1.2',
29
30
  ]
30
31
  steps:
31
32
  - uses: actions/checkout@v2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ### v2.8.0
4
+
5
+ * Add `except:` param to `Tabulo::Table#pack` method, allowing specific
6
+ columns to be excluded from the action of `.pack`
7
+ * Provide method `Tabulo::Table#autosize_columns`, allowing columns to be auto-sized
8
+ to fit their contents' widths, without having to call `.pack` (which also has
9
+ other effects on the table). This method also has an `except:` param allowing columns
10
+ to be excluded from its action.
11
+ * Provide method `Tabulo::Table#shrink_to`, allowing the table's width to be reduced
12
+ so as not to exceed a given target number of characters (or the argument `:screen`
13
+ meaning "width of terminal"), independently of the `.pack` method.
14
+ This method also has an `except:` param allowing columns to be excluded from its action.
15
+ * Fix `max_table_width:` param to `.pack` not being respected if table title was
16
+ wider than terminal.
17
+ * Documentation improvements
18
+ * Fix broken documentation links
19
+ * Add Ruby 3.1 to CI config
20
+
21
+ ### v2.7.3
22
+
23
+ * Fix malformed YARD documentation for `Tabulo::Table#initialize` method
24
+
3
25
  ### v2.7.2
4
26
 
5
27
  * Minor documentation improvements and tweaks
data/README.md CHANGED
@@ -6,7 +6,8 @@
6
6
  [![Coverage Status][CS img]][Coverage Status]
7
7
  [![Awesome][AR img]][Awesome Ruby]
8
8
 
9
- Tabulo is a Ruby library for generating plain text tables. It is both highly configurable and very easy to use.
9
+ Tabulo is a Ruby library for generating plain text tables, also known as “ASCII tables”. It is
10
+ both highly configurable and very easy to use.
10
11
 
11
12
  <a name="overview"></a>
12
13
  ## Overview
@@ -74,13 +75,13 @@ Tabulo has also been ported to Crystal (with some modifications): see [Tablo](ht
74
75
 
75
76
  * [Overview](#overview)
76
77
  * [Features](#features)
77
- * [Table of contents](#table-of-contents)
78
+ * [Table of contents](#contents)
78
79
  * [Installation](#installation)
79
80
  * [Detailed usage](#detailed-usage)
80
81
  * [Creating a table](#table-initialization)
81
82
  * [Adding columns](#adding-columns)
82
83
  * [Quick API](#quick-api)
83
- * [Full API](#quick-api)
84
+ * [Full API](#full-api)
84
85
  * [Column labels _vs_ headers](#labels-headers)
85
86
  * [Positioning columns](#column-positioning)
86
87
  * [Extracting column content from a hash or array](#from-arrays-hashes)
@@ -113,6 +114,7 @@ Tabulo has also been ported to Crystal (with some modifications): see [Tablo](ht
113
114
  * [Contributing](#contributing)
114
115
  * [License](#license)
115
116
 
117
+ <a name="installation"></a>
116
118
  ## Installation [&#x2191;](#contents)
117
119
 
118
120
  Add this line to your application&#8217;s Gemfile:
@@ -135,6 +137,9 @@ To use the gem, you need to require it in your source code as follows:
135
137
  require 'tabulo'
136
138
  ```
137
139
 
140
+ <a name="detailed-usage"></a>
141
+ ## Detailed usage [&#x2191;](#contents)
142
+
138
143
  <a name="table-initialization"></a>
139
144
  ### Creating a table [&#x2191;](#contents)
140
145
 
@@ -408,9 +413,11 @@ If a table title is present, it is center-aligned by default. This can be change
408
413
  table = Tabulo::Table.new([1, 2], :itself, :even?, title: "Numbers", align_title: :left)
409
414
  ```
410
415
 
416
+ <a name="column-width-wrapping-and-truncation"></a>
411
417
  ### Column width, wrapping and truncation [&#x2191;](#contents)
412
418
 
413
419
  <a name="fixed-column-widths"></a>
420
+ <a name="configuring-fixed-widths"></a>
414
421
  #### Configuring fixed widths [&#x2191;](#contents)
415
422
 
416
423
  By default, column width is fixed at 12 characters, plus 1 character of padding on either side.
@@ -453,6 +460,7 @@ table = Tabulo::Table.new([1, 2], :itself, :even?, column_width: 6)
453
460
  Widths set for individual columns always override the default column width for the table.
454
461
 
455
462
  <a name="pack"></a>
463
+ <a name="automating-column-widths"></a>
456
464
  #### Automating column widths [&#x2191;](#contents)
457
465
 
458
466
  Instead of setting column widths &ldquo;manually&rdquo;, you can tell the table to sort out the widths
@@ -529,6 +537,16 @@ necessary (see [Overflow handling](#overflow-handling)). Under the hood, a chara
529
537
  is deducted column by column&mdash;the widest column being targetted each time&mdash;until
530
538
  the table will fit.
531
539
 
540
+ To resize only specific columns, `pack` takes an `except:` argument, which can be a single column
541
+ label or an Array of column labels. E.g. `pack(except: :id)` will exclude the `id` column from
542
+ resizing and let it keep its current width. This is useful if you want to prevent the addition of
543
+ linebreaks in your data. When using this option, other columns might be shrunk more to still make
544
+ the table fit within the `max_table_width`.
545
+
546
+ For even finer-grained control over column and table resizing, see the
547
+ for the [`#autosize_columns`](https://www.rubydoc.info/gems/tabulo/2.8.1/Tabulo/Table#autosize_columns-instance_method)
548
+ and [`#shrink_to`](https://www.rubydoc.info/gems/tabulo/2.8.1/Tabulo/Table#shrink_to-instance_method) methods.
549
+
532
550
  Note that `pack`ing the table necessarily involves traversing the entire collection up front as
533
551
  the maximum cell width needs to be calculated for each column. You may not want to do this
534
552
  if the collection is very large.
@@ -792,7 +810,7 @@ the table.
792
810
  The `formatter` callback also has an alternative, 2-parameter version. If `formatter` is passed
793
811
  a 2-parameter callable, the second parameter will be given a `CellData` instance,
794
812
  containing additional information about the cell that may be useful in determining how to format
795
- it&mdash;see the [documentation](https://www.rubydoc.info/gems/tabulo/2.7.2/Tabulo/CellData.html)
813
+ it&mdash;see the [documentation](https://www.rubydoc.info/gems/tabulo/2.8.1/Tabulo/CellData.html)
796
814
  for details.
797
815
 
798
816
  <a name="colours-and-styling"></a>
@@ -838,7 +856,7 @@ number is even). The second parameter represents the formatted string value of t
838
856
  content after any processing by the [formatter](#formatting-cell-values). The third and fourth
839
857
  parameters are optional, and contain further information about the cell and its contents that may be useful in
840
858
  determining how to style it. See the
841
- [documentation](https://www.rubydoc.info/gems/tabulo/2.7.2/Tabulo/Table#add_column-instance_method) for details.
859
+ [documentation](https://www.rubydoc.info/gems/tabulo/2.8.1/Tabulo/Table#add_column-instance_method) for details.
842
860
 
843
861
  If the content of a cell is wrapped over multiple lines, then the `styler` will be called once
844
862
  per line, so that each line of the cell will have the escape sequence applied to it separately
@@ -858,7 +876,7 @@ table.add_column(:even?, header_styler: -> (s) { "\033[32m#{s}\033[0m" })
858
876
  ```
859
877
 
860
878
  The `header_styler` option accepts a 1-, 2- or 3-parameter callable. See the
861
- [documentation](https://www.rubydoc.info/gems/tabulo/2.7.2/Tabulo/Table#add_column-instance_method)
879
+ [documentation](https://www.rubydoc.info/gems/tabulo/2.8.1/Tabulo/Table#add_column-instance_method)
862
880
  for details.
863
881
 
864
882
  <a name="styling-title"></a>
@@ -872,7 +890,7 @@ table = Tabulo::Table.new(1..5, :itself, :even?, :odd?, title: "Numbers", title_
872
890
  ```
873
891
 
874
892
  The `title_styler` option accepts a 1- or 2-parameter callable. See the
875
- [documentation](https://www.rubydoc.info/gems/tabulo/2.7.2/Tabulo/Table#initialize-instance_method)
893
+ [documentation](https://www.rubydoc.info/gems/tabulo/2.8.1/Tabulo/Table#initialize-instance_method)
876
894
  for details.
877
895
 
878
896
  <a name="styling-borders"></a>
@@ -1073,7 +1091,7 @@ a new table in which the rows and columns are swapped:
1073
1091
  By default, a header row is added to the new table, showing the string value of the element
1074
1092
  represented in that column. This can be configured, however, along with other aspects of
1075
1093
  `transpose`&#8217;s behaviour. For details, see the
1076
- [documentation](https://www.rubydoc.info/gems/tabulo/2.7.2/Tabulo/Table#transpose-instance_method).
1094
+ [documentation](https://www.rubydoc.info/gems/tabulo/2.8.1/Tabulo/Table#transpose-instance_method).
1077
1095
 
1078
1096
  <a name="borders"></a>
1079
1097
  ### Configuring borders [&#x2191;](#contents)
@@ -1463,6 +1481,7 @@ install dependencies.
1463
1481
  `bundle exec rake spec` will run the test suite. For a list of other Rake tasks that are available in
1464
1482
  the development environment, run `bundle exec rake -T`.
1465
1483
 
1484
+ <a name="license"></a>
1466
1485
  ## License [&#x2191;](#contents)
1467
1486
 
1468
1487
  The gem is available as open source under the terms of the [MIT
@@ -1475,7 +1494,7 @@ License](http://opensource.org/licenses/MIT).
1475
1494
  [Awesome Ruby]: https://github.com/markets/awesome-ruby#cli-utilities
1476
1495
 
1477
1496
  [GV img]: https://img.shields.io/gem/v/tabulo.svg
1478
- [DC img]: https://img.shields.io/badge/documentation-v2.7.2-blue.svg
1497
+ [DC img]: https://img.shields.io/badge/documentation-v2.8.1-blue.svg
1479
1498
  [BS img]: https://github.com/matt-harvey/tabulo/actions/workflows/tests.yml/badge.svg
1480
1499
  [CS img]: https://img.shields.io/coveralls/matt-harvey/tabulo.svg
1481
1500
  [AR img]: https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.7.2
1
+ 2.8.1
data/lib/tabulo/table.rb CHANGED
@@ -125,7 +125,7 @@ module Tabulo
125
125
  # defaults to {DEFAULT_TRUNCATION_INDICATOR}. If passed something other than <tt>nil</tt> or
126
126
  # a single-character String, raises {InvalidTruncationIndicatorError}.
127
127
  # @param [Symbol] wrap_preserve Specifies what unit of text the wrapping mechanism will try to
128
- # preserve intact when wrapping column content when the column width is reached.
128
+ # preserve intact when wrapping column content when the column width is reached:
129
129
  # * If passed `:rune` (the default), then it will wrap at the "character" level (approximately
130
130
  # speaking, the Unicode grapheme cluster level). This means the maximum number of what
131
131
  # readers usually think of as "characters" will be fit on each line, within the column's allocated
@@ -207,11 +207,10 @@ module Tabulo
207
207
  # by the Table-level setting passed to the <tt>align_header</tt> (which itself defaults
208
208
  # to <tt>:center</tt>). Otherwise, this option determines the alignment of the header
209
209
  # content for this column.
210
- # @param [Symbol, String, Integer, nil] before The label of the column before (i.e. to
211
- # the left of) which the new column should inserted. If <tt>nil</tt> is passed, it will be
212
- # inserted after all other columns. If there is no column with the given label, then an
213
- # {InvalidColumnLabelError} will be raised. A non-Integer labelled column can be identified
214
- # in either String or Symbol form for this purpose.
210
+ # @param [Symbol, Integer, nil] before The label of the column before (i.e. to the left of) which the
211
+ # new column should inserted. If <tt>nil</tt> is passed, it will be inserted after all other columns.
212
+ # If there is no column with the given label, then an {InvalidColumnLabelError} will be raised.
213
+ # A non-Integer labelled column can be identified in Symbol form for this purpose.
215
214
  # @param [#to_proc] formatter A lambda or other callable object that
216
215
  # will be passed the calculated value of each cell to determine how it should be displayed. This
217
216
  # is distinct from the extractor and the styler (see below).
@@ -453,8 +452,10 @@ module Tabulo
453
452
 
454
453
  # Resets all the column widths so that each column is *just* wide enough to accommodate
455
454
  # its header text as well as the formatted content of each its cells for the entire
456
- # collection, together with a single character of padding on either side of the column,
457
- # without any wrapping. In addition, if the table has a title but is not wide enough to
455
+ # collection, together with padding (by default 1 character on either side of the column),
456
+ # without wrapping. Other adjustments may also be performed (see below).
457
+ #
458
+ # In addition, if the table has a title but is not wide enough to
458
459
  # accommodate (without wrapping) the title text (with a character of padding either side),
459
460
  # widens the columns roughly evenly until the table as a whole is just wide enough to
460
461
  # accommodate the title text.
@@ -468,7 +469,7 @@ module Tabulo
468
469
  # is called. If the source Enumerable changes between that point, and the point when
469
470
  # the Table is printed, then columns will *not* be resized yet again on printing.
470
471
  #
471
- # @param [nil, Numeric] max_table_width With no args, or if passed <tt>:auto</tt>,
472
+ # @param [nil, :auto, Numeric] max_table_width With no args, or if passed <tt>:auto</tt>,
472
473
  # stops the total table width (including padding and borders) from expanding beyond the
473
474
  # bounds of the terminal screen.
474
475
  # If passed <tt>nil</tt>, the table width will not be capped.
@@ -476,34 +477,104 @@ module Tabulo
476
477
  # deducted from the width of the widest column until the target is reached. When the
477
478
  # table is printed, wrapping or truncation will then occur in these columns as required
478
479
  # (depending on how they were configured).
479
- # Note that regardless of the value passed to max_table_width, the table will always be left wide
480
- # enough to accommodate at least 1 character's width of content, 1 character of left padding and
481
- # 1 character of right padding in each column, together with border characters (1 on each side
482
- # of the table and 1 between adjacent columns). I.e. there is a certain width below width the
480
+ # Note that regardless of the value passed to `max_table_width`, the table will always be left wide
481
+ # enough to accommodate at least 1 character's width of content for each column, and the padding
482
+ # configured for each column (by default 1 character either side), together with border characters
483
+ # (1 on each side of the table and 1 between adjacent columns). I.e. there is a certain width below width the
483
484
  # Table will refuse to shrink itself.
485
+ # @param [nil, Symbol, Integer, Array[Symbol|Integer]] except If passed one or multiple column labels,
486
+ # these columns will be excluded from resizing and will keep their current width.
487
+ # (Note if passing integers, these are not necessarily positional: only columns _explicitly_
488
+ # given an integer label will have these as labels.)
484
489
  # @return [Table] the Table itself
485
- def pack(max_table_width: :auto)
486
- get_columns.each { |column| column.width = Util.wrapped_width(column.header) }
490
+ def pack(max_table_width: :auto, except: nil)
491
+ autosize_columns(except: except)
492
+
493
+ max_width = nil
494
+ if max_table_width
495
+ max_width = (max_table_width == :auto ? TTY::Screen.width : max_table_width)
496
+ shrink_to(max_width, except: except)
497
+ end
498
+
499
+ if @title
500
+ border_edge_width = (@border == :blank ? 0 : 2)
501
+ all_columns = get_columns
502
+ min_width =
503
+ Unicode::DisplayWidth.of(@title) +
504
+ all_columns.first.left_padding +
505
+ all_columns.last.right_padding +
506
+ border_edge_width
487
507
 
508
+ min_width = max_width if max_width && max_width < min_width
509
+ expand_to(min_width, except: except)
510
+ end
511
+
512
+ self
513
+ end
514
+
515
+ # Resets all the column widths so that each column is *just* wide enough to accommodate
516
+ # its header text as well as the formatted content of each its cells for the entire
517
+ # collection, together with padding (by default 1 character either side), without wrapping.
518
+ #
519
+ # @param [nil, Symbol, Integer, Array[Symbol|Integer]] except If passed one or multiple column labels,
520
+ # these columns will be excluded from resizing and will keep their current width.
521
+ # (Note if using integers, these are not necessarily positional: only columns _explicitly_
522
+ # given an integer label will have these as labels.)
523
+ # @return [Table] the Table itself
524
+ def autosize_columns(except: nil)
525
+ columns = get_columns(except: except)
526
+ columns.each { |column| column.width = Util.wrapped_width(column.header) }
488
527
  @sources.each_with_index do |source, row_index|
489
- get_columns.each_with_index do |column, column_index|
528
+ columns.each_with_index do |column, column_index|
490
529
  cell = column.body_cell(source, row_index: row_index, column_index: column_index)
491
530
  cell_width = Util.wrapped_width(cell.formatted_content)
492
531
  column.width = Util.max(column.width, cell_width)
493
532
  end
494
533
  end
534
+ self
535
+ end
495
536
 
496
- shrink_to(max_table_width == :auto ? TTY::Screen.width : max_table_width) if max_table_width
537
+ # If `max_table_width` is passed an integer, then column widths will be adjusted downward so
538
+ # that the total table width is reduced to the passed target width. (If the total width of the
539
+ # table exceeds the passed `max_table_width`, then this method is a no-op.)
540
+ #
541
+ # Width is deducted from columns if required to achieve this, with one character progressively
542
+ # deducted from the width of the widest column until the target is reached. When the
543
+ # table is printed, wrapping or truncation will then occur in these columns as required
544
+ # (depending on how they were configured).
545
+ #
546
+ # Note that regardless of the value passed to `max_table_width`, the table will always be left wide
547
+ # enough to accommodate at least 1 character's width of content for each column, and the padding
548
+ # configured for each column (by default 1 character either side), together with border characters
549
+ # (1 on each side of the table and 1 between adjacent columns). I.e. there is a certain width below width the
550
+ # Table will refuse to shrink itself.
551
+ #
552
+ # If `max_table_width` is passed the symbol `:screen`, then this method will behave as if it
553
+ # were passed an integer, with that integer being the width of the terminal.
554
+ #
555
+ # @param [Integer, :screen] the desired maximum table width
556
+ # @param [nil, Symbol, Integer, Array[Symbol|Integer]] except If passed one or multiple column labels,
557
+ # these columns will be excluded from resizing and will keep their current width.
558
+ # (Note if passing integers, these are not necessarily positional: only columns _explicitly_
559
+ # given an integer label will have these as labels.)
560
+ # @return [Table] the Table itself
561
+ def shrink_to(max_table_width, except: nil)
562
+ min_content_width_per_column = 1
563
+ min_total_column_content_width = num_columns * min_content_width_per_column
564
+ min_table_width = total_padding_width + total_borders_width + min_total_column_content_width
497
565
 
498
- if @title
499
- border_edge_width = (@border == :blank ? 0 : 2)
500
- columns = get_columns
501
- expand_to(
502
- Unicode::DisplayWidth.of(@title) +
503
- columns.first.left_padding +
504
- columns.last.right_padding +
505
- border_edge_width
506
- )
566
+ max_table_width = (max_table_width == :screen ? TTY::Screen.width : max_table_width)
567
+ max_table_width = Util.max(min_table_width, max_table_width)
568
+
569
+ required_reduction = Util.max(total_table_width - max_table_width, 0)
570
+
571
+ shrinkable_columns = get_columns(except: except)
572
+ required_reduction.times do
573
+ widest_column = shrinkable_columns.inject(shrinkable_columns.first) do |widest, column|
574
+ column.width >= widest.width ? column : widest
575
+ end
576
+
577
+ widest_column.width -= 1
507
578
  end
508
579
 
509
580
  self
@@ -609,8 +680,13 @@ module Tabulo
609
680
  private
610
681
 
611
682
  # @!visibility private
612
- def get_columns
613
- column_registry.values
683
+ def get_columns(except: nil)
684
+ if except
685
+ column_labels = except ? column_registry.keys - Array(except) : column_registry.keys
686
+ column_labels.map { |label| column_registry[label] }
687
+ else
688
+ column_registry.values
689
+ end
614
690
  end
615
691
 
616
692
  # @!visibility private
@@ -695,16 +771,35 @@ module Tabulo
695
771
  end
696
772
 
697
773
  # @!visibility private
698
- def expand_to(min_table_width)
699
- columns = get_columns
700
- num_columns = columns.count
701
- total_columns_padded_width = columns.inject(0) { |sum, column| sum + column.padded_width }
702
- total_borders = num_columns + 1
703
- unadjusted_table_width = total_columns_padded_width + total_borders
704
- required_increase = Util.max(min_table_width - unadjusted_table_width, 0)
774
+ # @return [Integer] the total combined width of padding characters
775
+ def total_padding_width
776
+ get_columns.inject(0) { |sum, column| sum + column.total_padding }
777
+ end
705
778
 
779
+ # @!visibility private
780
+ # @return [Integer] the total combined width of vertical border characters
781
+ def total_borders_width
782
+ num_columns + 1
783
+ end
784
+
785
+ # @!visibility private
786
+ # @return [Integer] the total combined width of column contents (excludes borders and padding)
787
+ def total_column_content_width
788
+ get_columns.inject(0) { |sum, column| sum + column.width }
789
+ end
790
+
791
+ # @!visibility private
792
+ # @return [Integer] the total actual width of the table as a whole
793
+ def total_table_width
794
+ total_column_content_width + total_padding_width + total_borders_width
795
+ end
796
+
797
+ # @!visibility private
798
+ def expand_to(min_table_width, except: nil)
799
+ required_increase = Util.max(min_table_width - total_table_width, 0)
800
+ expandable_columns = get_columns(except: except)
706
801
  required_increase.times do
707
- narrowest_column = columns.inject(columns.first) do |narrowest, column|
802
+ narrowest_column = expandable_columns.inject(expandable_columns.first) do |narrowest, column|
708
803
  column.width <= narrowest.width ? column : narrowest
709
804
  end
710
805
 
@@ -713,27 +808,8 @@ module Tabulo
713
808
  end
714
809
 
715
810
  # @!visibility private
716
- def shrink_to(max_table_width)
717
- columns = get_columns
718
- num_columns = columns.count
719
- total_columns_padded_width = columns.inject(0) { |sum, column| sum + column.padded_width }
720
- total_padding = columns.inject(0) { |sum, column| sum + column.total_padding }
721
- total_borders = num_columns + 1
722
- unadjusted_table_width = total_columns_padded_width + total_borders
723
-
724
- # Ensure max table width is at least wide enough to accommodate table borders and padding
725
- # and one character of content.
726
- min_table_width = total_padding + total_borders + column_registry.count
727
- max_table_width = Util.max(min_table_width, max_table_width)
728
- required_reduction = Util.max(unadjusted_table_width - max_table_width, 0)
729
-
730
- required_reduction.times do
731
- widest_column = columns.inject(columns.first) do |widest, column|
732
- column.width >= widest.width ? column : widest
733
- end
734
-
735
- widest_column.width -= 1
736
- end
811
+ def num_columns
812
+ column_registry.count
737
813
  end
738
814
 
739
815
  # @!visibility private
@@ -1,3 +1,3 @@
1
1
  module Tabulo
2
- VERSION = "2.7.2"
2
+ VERSION = "2.8.1"
3
3
  end
data/tabulo.gemspec CHANGED
@@ -29,11 +29,11 @@ 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.1.0"
32
+ spec.add_runtime_dependency "unicode-display_width", "2.2.0"
33
33
 
34
34
  spec.add_development_dependency "bundler"
35
- spec.add_development_dependency "rake", "~> 12.3.3"
36
- spec.add_development_dependency "rspec", "~> 3.9"
35
+ spec.add_development_dependency "rake", "~> 13.0"
36
+ spec.add_development_dependency "rspec", "~> 3.11"
37
37
  spec.add_development_dependency "simplecov"
38
38
  spec.add_development_dependency "simplecov-lcov"
39
39
  spec.add_development_dependency "yard"
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.2
4
+ version: 2.8.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: 2021-12-11 00:00:00.000000000 Z
11
+ date: 2022-07-27 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.1.0
33
+ version: 2.2.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.1.0
40
+ version: 2.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 12.3.3
61
+ version: '13.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 12.3.3
68
+ version: '13.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '3.9'
75
+ version: '3.11'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '3.9'
82
+ version: '3.11'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement