tabulo 2.3.2 → 2.3.3

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: 436c1fe445c0910e0084a47697d782f5910cd98b2840500804ef6120b33e6f7c
4
- data.tar.gz: 4964c641d3a806af82acee1b4192c6d4a8a4c229cbdd3a679c0b394fde5d4c1c
3
+ metadata.gz: 6104501fe177f52639fb3e05c12c5cd53d62d1388ad85e2abecaa58f15b3d39d
4
+ data.tar.gz: 35648de653973f20a5871a71bb2cd9340eb1b80196dc25f510477e7e8143a9db
5
5
  SHA512:
6
- metadata.gz: 82b090f560d056f9f9162d911b84db3a3b89b1761756f105fe3afd4b65361d56e17899f065bfc538e57ddc83546601e3de14853e33622913f474eb3a259afd7e
7
- data.tar.gz: f4767057ce09370700e3245de955c8733d4c4f3c4c86e5289707d4fcd5e9d614b2e6cf462f75e496e76d5894db044209f35623c1386ed533457bd095650ec185
6
+ metadata.gz: e5c158f65f97272c637bf37fab53f542001264f3e094ea07a67b4a5e6d583cfb315a40d0a51abad2135fa84169b1edce77420dc9fded8f619f842aa5087c7262
7
+ data.tar.gz: 0d0f2abb4a82098b4c4886926254f65c17c80b751509818927f8a237c2f4dce35f61d8fcdf028ba9d47640611d14349437eb767ffd2deaf92ebc5c8ee16eda8c
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### v2.3.3
4
+
5
+ * Fix styler option on Table initializer, which had no effect
6
+
3
7
  ### v2.3.2
4
8
 
5
9
  * Update Rake version to address vulnerability CVE-2020-8130
data/README.md CHANGED
@@ -798,7 +798,7 @@ a new table in which the rows and columns are swapped:
798
798
  By default, a header row is added to the new table, showing the string value of the element
799
799
  represented in that column. This can be configured, however, along with other aspects of
800
800
  `transpose`’s behaviour. For details, see the
801
- [documentation](https://www.rubydoc.info/gems/tabulo/2.3.2/Tabulo/Table#transpose-instance_method).
801
+ [documentation](https://www.rubydoc.info/gems/tabulo/2.3.3/Tabulo/Table#transpose-instance_method).
802
802
 
803
803
  <a name="borders"></a>
804
804
  ### Configuring borders
@@ -1107,14 +1107,14 @@ The gem is available as open source under the terms of the [MIT
1107
1107
  License](http://opensource.org/licenses/MIT).
1108
1108
 
1109
1109
  [Gem Version]: https://rubygems.org/gems/tabulo
1110
- [Documentation]: http://www.rubydoc.info/gems/tabulo/2.3.2
1110
+ [Documentation]: http://www.rubydoc.info/gems/tabulo/2.3.3
1111
1111
  [Build Status]: https://travis-ci.org/matt-harvey/tabulo
1112
1112
  [Coverage Status]: https://coveralls.io/r/matt-harvey/tabulo
1113
1113
  [Code Climate]: https://codeclimate.com/github/matt-harvey/tabulo
1114
1114
  [Awesome Ruby]: https://github.com/markets/awesome-ruby#cli-utilities
1115
1115
 
1116
1116
  [GV img]: https://img.shields.io/gem/v/tabulo.svg
1117
- [DC img]: https://img.shields.io/badge/documentation-v2.3.2-blue.svg
1117
+ [DC img]: https://img.shields.io/badge/documentation-v2.3.3-blue.svg
1118
1118
  [BS img]: https://img.shields.io/travis/matt-harvey/tabulo.svg
1119
1119
  [CS img]: https://img.shields.io/coveralls/matt-harvey/tabulo.svg
1120
1120
  [CC img]: https://codeclimate.com/github/matt-harvey/tabulo/badges/gpa.svg
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.2
1
+ 2.3.3
@@ -87,7 +87,7 @@ module Tabulo
87
87
  end
88
88
 
89
89
  def style_and_align_cell_content(content)
90
- padding = [@width - Unicode::DisplayWidth.of(content), 0].max
90
+ padding = Util.max(@width - Unicode::DisplayWidth.of(content), 0)
91
91
  left_padding, right_padding =
92
92
  case real_alignment
93
93
  when :center
@@ -129,6 +129,7 @@ module Tabulo
129
129
  @header_frequency = header_frequency
130
130
  @header_styler = header_styler
131
131
  @row_divider_frequency = row_divider_frequency
132
+ @styler = styler
132
133
  @truncation_indicator = validate_character(truncation_indicator,
133
134
  DEFAULT_TRUNCATION_INDICATOR, InvalidTruncationIndicatorError, "truncation indicator")
134
135
  @wrap_body_cells_to = wrap_body_cells_to
@@ -286,17 +287,15 @@ module Tabulo
286
287
  # Note that when printed, the first row will visually include the headers (assuming these
287
288
  # were not disabled when the Table was initialized).
288
289
  def each
289
- header_frequency_is_integer = (Integer === @header_frequency)
290
290
  @sources.each_with_index do |source, index|
291
- is_first_row = (index == 0)
292
291
  header =
293
- if is_first_row && (@header_frequency == :start || header_frequency_is_integer)
292
+ if (index == 0) && @header_frequency
294
293
  :top
295
- elsif header_frequency_is_integer && (index % @header_frequency == 0)
294
+ elsif (Integer === @header_frequency) && Util.divides?(@header_frequency, index)
296
295
  :middle
297
296
  end
298
297
 
299
- show_divider = @row_divider_frequency && !is_first_row && (index % @row_divider_frequency == 0)
298
+ show_divider = @row_divider_frequency && (index != 0) && Util.divides?(@row_divider_frequency, index)
300
299
 
301
300
  yield Row.new(self, source, header: header, divider: show_divider)
302
301
  end
@@ -363,14 +362,13 @@ module Tabulo
363
362
 
364
363
  @sources.each do |source|
365
364
  get_columns.each do |column|
366
- width = wrapped_width(column.body_cell(source).formatted_content)
367
- column.width = [width, column.width].max
365
+ cell_width = wrapped_width(column.body_cell(source).formatted_content)
366
+ column.width = Util.max(column.width, cell_width)
368
367
  end
369
368
  end
370
369
 
371
370
  if max_table_width
372
- max_table_width = TTY::Screen.width if max_table_width == :auto
373
- shrink_to(max_table_width)
371
+ shrink_to(max_table_width == :auto ? TTY::Screen.width : max_table_width)
374
372
  end
375
373
 
376
374
  self
@@ -532,8 +530,8 @@ module Tabulo
532
530
  # Ensure max table width is at least wide enough to accommodate table borders and padding
533
531
  # and one character of content.
534
532
  min_table_width = total_padding + total_borders + column_registry.count
535
- max_table_width = min_table_width if min_table_width > max_table_width
536
- required_reduction = [unadjusted_table_width - max_table_width, 0].max
533
+ max_table_width = Util.max(min_table_width, max_table_width)
534
+ required_reduction = Util.max(unadjusted_table_width - max_table_width, 0)
537
535
 
538
536
  required_reduction.times do
539
537
  widest_column = columns.inject(columns.first) do |widest, column|
@@ -600,7 +598,7 @@ module Tabulo
600
598
  def wrapped_width(str)
601
599
  segments = str.split($/)
602
600
  segments.inject(1) do |longest_length_so_far, segment|
603
- [longest_length_so_far, Unicode::DisplayWidth.of(segment)].max
601
+ Util.max(longest_length_so_far, Unicode::DisplayWidth.of(segment))
604
602
  end
605
603
  end
606
604
  end
@@ -3,6 +3,16 @@ module Tabulo
3
3
  # @!visibility private
4
4
  module Util
5
5
 
6
+ # @!visibility private
7
+ def self.divides?(smaller, larger)
8
+ larger % smaller == 0
9
+ end
10
+
11
+ # @!visibility private
12
+ def self.max(x, y)
13
+ x > y ? x : y
14
+ end
15
+
6
16
  # @!visibility private
7
17
  def self.slice_hash(hash, *keys)
8
18
  new_hash = {}
@@ -1,3 +1,3 @@
1
1
  module Tabulo
2
- VERSION = "2.3.2"
2
+ VERSION = "2.3.3"
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: 2.3.2
4
+ version: 2.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Harvey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-01 00:00:00.000000000 Z
11
+ date: 2020-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-screen