tty-table 0.10.0 → 0.11.0
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/CHANGELOG.md +13 -0
- data/README.md +67 -3
- data/Rakefile +2 -0
- data/lib/tty-table.rb +0 -3
- data/lib/tty/table.rb +35 -12
- data/lib/tty/table/alignment_set.rb +2 -2
- data/lib/tty/table/border.rb +6 -3
- data/lib/tty/table/border/ascii.rb +1 -1
- data/lib/tty/table/border/null.rb +3 -2
- data/lib/tty/table/border/row_line.rb +1 -1
- data/lib/tty/table/border/unicode.rb +1 -2
- data/lib/tty/table/border_dsl.rb +3 -3
- data/lib/tty/table/border_options.rb +21 -1
- data/lib/tty/table/column_constraint.rb +1 -1
- data/lib/tty/table/columns.rb +0 -1
- data/lib/tty/table/empty.rb +2 -0
- data/lib/tty/table/error.rb +1 -1
- data/lib/tty/table/field.rb +1 -1
- data/lib/tty/table/header.rb +1 -1
- data/lib/tty/table/indentation.rb +2 -3
- data/lib/tty/table/operation/alignment.rb +8 -6
- data/lib/tty/table/operation/escape.rb +1 -1
- data/lib/tty/table/operation/filter.rb +1 -1
- data/lib/tty/table/operation/padding.rb +1 -9
- data/lib/tty/table/operation/truncation.rb +1 -1
- data/lib/tty/table/operation/wrapped.rb +1 -1
- data/lib/tty/table/operations.rb +1 -1
- data/lib/tty/table/options.rb +1 -1
- data/lib/tty/table/orientation.rb +1 -1
- data/lib/tty/table/orientation/horizontal.rb +1 -1
- data/lib/tty/table/orientation/vertical.rb +1 -1
- data/lib/tty/table/renderer.rb +4 -4
- data/lib/tty/table/renderer/ascii.rb +1 -1
- data/lib/tty/table/renderer/basic.rb +19 -20
- data/lib/tty/table/renderer/unicode.rb +1 -1
- data/lib/tty/table/row.rb +2 -2
- data/lib/tty/table/transformation.rb +2 -2
- data/lib/tty/table/validatable.rb +1 -1
- data/lib/tty/table/version.rb +3 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/access_spec.rb +1 -3
- data/spec/unit/add_row_spec.rb +1 -3
- data/spec/unit/alignment_set/each_spec.rb +1 -3
- data/spec/unit/alignment_set/new_spec.rb +1 -3
- data/spec/unit/alignment_set/to_ary_spec.rb +1 -3
- data/spec/unit/alignment_spec.rb +1 -3
- data/spec/unit/border/ascii/rendering_spec.rb +1 -3
- data/spec/unit/border/new_spec.rb +1 -3
- data/spec/unit/border/null/rendering_spec.rb +1 -3
- data/spec/unit/border/options/from_spec.rb +1 -3
- data/spec/unit/border/options/new_spec.rb +1 -3
- data/spec/unit/border/unicode/rendering_spec.rb +1 -3
- data/spec/unit/border_options/new_spec.rb +1 -3
- data/spec/unit/border_options/update_spec.rb +1 -3
- data/spec/unit/column_constraint/enforce_spec.rb +1 -3
- data/spec/unit/column_constraint/widths_spec.rb +1 -3
- data/spec/unit/columns/extract_widths_spec.rb +1 -1
- data/spec/unit/columns/total_width_spec.rb +0 -1
- data/spec/unit/columns/widths_from_spec.rb +1 -1
- data/spec/unit/data_spec.rb +1 -3
- data/spec/unit/each_spec.rb +1 -3
- data/spec/unit/each_with_index_spec.rb +1 -3
- data/spec/unit/empty_spec.rb +1 -3
- data/spec/unit/eql_spec.rb +1 -3
- data/spec/unit/field/equality_spec.rb +1 -3
- data/spec/unit/field/length_spec.rb +1 -3
- data/spec/unit/field/lines_spec.rb +1 -3
- data/spec/unit/field/new_spec.rb +1 -3
- data/spec/unit/field/width_spec.rb +1 -3
- data/spec/unit/filter_spec.rb +1 -3
- data/spec/unit/header/call_spec.rb +1 -3
- data/spec/unit/header/color_spec.rb +1 -3
- data/spec/unit/header/equality_spec.rb +1 -3
- data/spec/unit/header/height_spec.rb +1 -3
- data/spec/unit/header/new_spec.rb +1 -4
- data/spec/unit/header/set_spec.rb +1 -3
- data/spec/unit/header/to_ary_spec.rb +1 -3
- data/spec/unit/header_spec.rb +1 -3
- data/spec/unit/indentation/indent_spec.rb +1 -3
- data/spec/unit/new_spec.rb +1 -3
- data/spec/unit/operation/alignment/call_spec.rb +1 -3
- data/spec/unit/operation/escape/call_spec.rb +1 -3
- data/spec/unit/operation/filter/call_spec.rb +1 -3
- data/spec/unit/operation/truncation/call_spec.rb +1 -3
- data/spec/unit/operation/wrapped/call_spec.rb +1 -3
- data/spec/unit/operations/new_spec.rb +1 -1
- data/spec/unit/options/access_spec.rb +1 -3
- data/spec/unit/options_spec.rb +1 -3
- data/spec/unit/orientation_spec.rb +1 -3
- data/spec/unit/padding_spec.rb +1 -3
- data/spec/unit/properties_spec.rb +1 -3
- data/spec/unit/render_repeat_spec.rb +1 -4
- data/spec/unit/render_spec.rb +1 -3
- data/spec/unit/render_with_spec.rb +1 -3
- data/spec/unit/renderer/ascii/coloring_spec.rb +16 -3
- data/spec/unit/renderer/ascii/indentation_spec.rb +1 -3
- data/spec/unit/renderer/ascii/multiline_spec.rb +1 -3
- data/spec/unit/renderer/ascii/padding_spec.rb +1 -3
- data/spec/unit/renderer/ascii/render_spec.rb +1 -3
- data/spec/unit/renderer/ascii/resizing_spec.rb +1 -3
- data/spec/unit/renderer/ascii/separator_spec.rb +14 -4
- data/spec/unit/renderer/basic/alignment_spec.rb +1 -3
- data/spec/unit/renderer/basic/coloring_spec.rb +1 -3
- data/spec/unit/renderer/basic/extract_column_widths_spec.rb +1 -3
- data/spec/unit/renderer/basic/filter_spec.rb +1 -3
- data/spec/unit/renderer/basic/indentation_spec.rb +1 -3
- data/spec/unit/renderer/basic/multiline_spec.rb +1 -3
- data/spec/unit/renderer/basic/new_spec.rb +1 -3
- data/spec/unit/renderer/basic/options_spec.rb +1 -3
- data/spec/unit/renderer/basic/padding_spec.rb +1 -3
- data/spec/unit/renderer/basic/render_spec.rb +1 -3
- data/spec/unit/renderer/basic/resizing_spec.rb +1 -3
- data/spec/unit/renderer/basic/separator_spec.rb +1 -3
- data/spec/unit/renderer/basic/single_row_separator_spec.rb +80 -0
- data/spec/unit/renderer/basic/truncation_spec.rb +1 -3
- data/spec/unit/renderer/basic/wrapping_spec.rb +1 -3
- data/spec/unit/renderer/border_spec.rb +1 -3
- data/spec/unit/renderer/render_spec.rb +1 -3
- data/spec/unit/renderer/select_spec.rb +1 -3
- data/spec/unit/renderer/unicode/coloring_spec.rb +1 -3
- data/spec/unit/renderer/unicode/indentation_spec.rb +1 -3
- data/spec/unit/renderer/unicode/padding_spec.rb +1 -3
- data/spec/unit/renderer/unicode/render_spec.rb +1 -3
- data/spec/unit/renderer/unicode/separator_spec.rb +13 -3
- data/spec/unit/renderer_spec.rb +1 -3
- data/spec/unit/rotate_spec.rb +1 -3
- data/spec/unit/row/access_spec.rb +1 -3
- data/spec/unit/row/call_spec.rb +1 -3
- data/spec/unit/row/data_spec.rb +1 -3
- data/spec/unit/row/each_spec.rb +1 -3
- data/spec/unit/row/equality_spec.rb +1 -3
- data/spec/unit/row/height_spec.rb +1 -3
- data/spec/unit/row/new_spec.rb +1 -3
- data/spec/unit/row/to_ary_spec.rb +1 -3
- data/spec/unit/to_s_spec.rb +1 -1
- data/spec/unit/transformation/extract_tuples_spec.rb +1 -3
- data/spec/unit/utf_spec.rb +1 -3
- data/spec/unit/validatable/validate_options_spec.rb +1 -3
- data/spec/unit/validatable_spec.rb +1 -3
- data/tasks/console.rake +1 -0
- data/tty-table.gemspec +19 -10
- metadata +21 -27
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.travis.yml +0 -26
- data/CODE_OF_CONDUCT.md +0 -49
- data/Gemfile +0 -17
- data/appveyor.yml +0 -21
- data/benchmarks/speed.rb +0 -39
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: 7e62b5af0c89b3acf1aa73598053bc5b5f364d9f346fc40e20129d2a639c3919
         | 
| 4 | 
            +
              data.tar.gz: 812b92b6eccf2743f121bfd85c069f833e0e3d80507526a8c1cabfacb776df15
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: bdc6608e3633b35eaed9481e545732c6d55f9ec43823ca111b08b177edb03046e1710221d36e7e4b6df8980d8555ebfecfdfc07535786199ae04f37e18423228
         | 
| 7 | 
            +
              data.tar.gz: 1a77ffd2f0ef11427c5bb4769edb6ec41f691f0226f6f216c3988abd19519ce5ab84685de4b90d7a2f590023b3fedde2a075a4b80f7992b74a6160be909280a6
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,5 +1,17 @@ | |
| 1 1 | 
             
            # Change log
         | 
| 2 2 |  | 
| 3 | 
            +
            ## [v0.11.0] - 2019-08-01
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ### Add
         | 
| 6 | 
            +
            * Add ability to specify border separator as an Array, Proc value by Mitch VanDuyn(@catmando)
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            ### Changed
         | 
| 9 | 
            +
            * Change Indentation#indent to stop mutating input
         | 
| 10 | 
            +
            * Change gemspec to load files directly
         | 
| 11 | 
            +
            * Change to freeze strings
         | 
| 12 | 
            +
            * Change to relax constraints on tty-screen & equatable
         | 
| 13 | 
            +
            * Change to remove upper boundary on bundler dev dependency
         | 
| 14 | 
            +
             | 
| 3 15 | 
             
            ## [v0.10.0] - 2018-02-18
         | 
| 4 16 |  | 
| 5 17 | 
             
            ### Changed
         | 
| @@ -91,6 +103,7 @@ | |
| 91 103 |  | 
| 92 104 | 
             
            * Initial implementation and release
         | 
| 93 105 |  | 
| 106 | 
            +
            [v0.11.0]: https://github.com/piotrmurach/tty-table/compare/v0.10.0...v0.11.0
         | 
| 94 107 | 
             
            [v0.10.0]: https://github.com/piotrmurach/tty-table/compare/v0.9.0...v0.10.0
         | 
| 95 108 | 
             
            [v0.9.0]: https://github.com/piotrmurach/tty-table/compare/v0.8.0...v0.9.0
         | 
| 96 109 | 
             
            [v0.8.0]: https://github.com/piotrmurach/tty-table/compare/v0.7.0...v0.8.0
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,4 +1,9 @@ | |
| 1 | 
            +
            <div align="center">
         | 
| 2 | 
            +
              <a href="https://piotrmurach.github.io/tty" target="_blank"><img width="130" src="https://github.com/piotrmurach/tty/blob/master/images/tty.png" alt="tty logo" /></a>
         | 
| 3 | 
            +
            </div>
         | 
| 4 | 
            +
             | 
| 1 5 | 
             
            # TTY::Table [][gitter]
         | 
| 6 | 
            +
             | 
| 2 7 | 
             
            [][gem]
         | 
| 3 8 | 
             
            [][travis]
         | 
| 4 9 | 
             
            [][appveyor]
         | 
| @@ -152,7 +157,7 @@ table.each_with_index  { |row, index| ... }    # iterate over rows with an index | |
| 152 157 |  | 
| 153 158 | 
             
            ### 2.3 Access
         | 
| 154 159 |  | 
| 155 | 
            -
            In order to  | 
| 160 | 
            +
            In order to reference the row at `index` do:
         | 
| 156 161 |  | 
| 157 162 | 
             
            ```ruby
         | 
| 158 163 | 
             
            table = TTY::Table.new [['a1','a2'], ['b1','b2']]
         | 
| @@ -520,7 +525,7 @@ table.render_with MyBorder | |
| 520 525 |  | 
| 521 526 | 
             
            #### 3.5.3 Separator
         | 
| 522 527 |  | 
| 523 | 
            -
            In addition to specifying border characters you can force table to render separator line on each row like:
         | 
| 528 | 
            +
            In addition to specifying border characters you can force the table to render a separator line on each row like:
         | 
| 524 529 |  | 
| 525 530 | 
             
            ```ruby
         | 
| 526 531 | 
             
            table = TTY::Table.new ['header1', 'header2'], [['a1', 'a2'], ['b1', 'b2']]
         | 
| @@ -537,6 +542,65 @@ end | |
| 537 542 | 
             
            #  +-------+-------+
         | 
| 538 543 | 
             
            ```
         | 
| 539 544 |  | 
| 545 | 
            +
            If you want more control you can provide an array of rows *after* which a separator will be added:
         | 
| 546 | 
            +
             | 
| 547 | 
            +
            ```ruby
         | 
| 548 | 
            +
            table = TTY::Table.new ['header1', 'header2'], [['a1', 'a2'], ['b1', 'b2'], ['c1', 'c2']]
         | 
| 549 | 
            +
            table.render do |renderer|
         | 
| 550 | 
            +
              renderer.border.separator = [0, 2]
         | 
| 551 | 
            +
            end
         | 
| 552 | 
            +
            # =>
         | 
| 553 | 
            +
            #  +-------+-------+
         | 
| 554 | 
            +
            #  |header1|header2|
         | 
| 555 | 
            +
            #  +-------+-------+
         | 
| 556 | 
            +
            #  |a1     |a2     |
         | 
| 557 | 
            +
            #  |b1     |b2     |
         | 
| 558 | 
            +
            #  +-------+-------+
         | 
| 559 | 
            +
            #  |c1     |c2     |
         | 
| 560 | 
            +
            #  +-------+-------+
         | 
| 561 | 
            +
            ```
         | 
| 562 | 
            +
             | 
| 563 | 
            +
            **Note:** if you supply a detailed list of rows to separate, then the separator between the header and the rows
         | 
| 564 | 
            +
            will not be automatically added.
         | 
| 565 | 
            +
             | 
| 566 | 
            +
            You can also give the separator option a proc to control where the separators are:
         | 
| 567 | 
            +
             | 
| 568 | 
            +
            ```ruby
         | 
| 569 | 
            +
            table = TTY::Table.new ['header1', 'header2'],
         | 
| 570 | 
            +
                                   [['a1', 'a2'], ['b1', 'b2'], ['c1', 'c2'], ['d1', 'd2']]
         | 
| 571 | 
            +
            table.render do |renderer|
         | 
| 572 | 
            +
              renderer.border.separator = ->(row) { row == 0 || (row+1) % 2 == 0} # separate every two rows
         | 
| 573 | 
            +
            end
         | 
| 574 | 
            +
            # =>
         | 
| 575 | 
            +
            #  +-------+-------+
         | 
| 576 | 
            +
            #  |header1|header2|
         | 
| 577 | 
            +
            #  +-------+-------+
         | 
| 578 | 
            +
            #  |a1     |a2     |
         | 
| 579 | 
            +
            #  |b1     |b2     |
         | 
| 580 | 
            +
            #  +-------+-------+
         | 
| 581 | 
            +
            #  |c1     |c2     |
         | 
| 582 | 
            +
            #  |d1     |d2     |
         | 
| 583 | 
            +
            #  +-------+-------+
         | 
| 584 | 
            +
            ```
         | 
| 585 | 
            +
             | 
| 586 | 
            +
            Finally you can also position a separator using the `:separator` key word in place of a row:
         | 
| 587 | 
            +
             | 
| 588 | 
            +
            ```ruby
         | 
| 589 | 
            +
            table = TTY::Table.new ['header1', 'header2'],
         | 
| 590 | 
            +
                                   [:separator, ['a1', 'a2'], ['b1', 'b2']]
         | 
| 591 | 
            +
            table << :separator << ['c1', 'c2']  # you can push separators on too!
         | 
| 592 | 
            +
            table.render
         | 
| 593 | 
            +
            # =>
         | 
| 594 | 
            +
            #  +-------+-------+
         | 
| 595 | 
            +
            #  |header1|header2|
         | 
| 596 | 
            +
            #  +-------+-------+
         | 
| 597 | 
            +
            #  |a1     |a2     |
         | 
| 598 | 
            +
            #  |b1     |b2     |
         | 
| 599 | 
            +
            #  +-------+-------+
         | 
| 600 | 
            +
            #  |c1     |c2     |
         | 
| 601 | 
            +
            #  +-------+-------+
         | 
| 602 | 
            +
            ```
         | 
| 603 | 
            +
             | 
| 540 604 | 
             
            #### 3.5.4 Style
         | 
| 541 605 |  | 
| 542 606 | 
             
            If you want to change the display color of your border do:
         | 
| @@ -710,4 +774,4 @@ This project is intended to be a safe, welcoming space for collaboration, and co | |
| 710 774 |  | 
| 711 775 | 
             
            ## Copyright
         | 
| 712 776 |  | 
| 713 | 
            -
            Copyright (c) 2015 | 
| 777 | 
            +
            Copyright (c) 2015 Piotr Murach. See LICENSE for further details.
         | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/lib/tty-table.rb
    CHANGED
    
    
    
        data/lib/tty/table.rb
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            #  | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            require 'equatable'
         | 
| 4 4 | 
             
            require 'forwardable'
         | 
| @@ -11,6 +11,7 @@ require_relative 'table/row' | |
| 11 11 | 
             
            require_relative 'table/renderer'
         | 
| 12 12 | 
             
            require_relative 'table/transformation'
         | 
| 13 13 | 
             
            require_relative 'table/validatable'
         | 
| 14 | 
            +
            require_relative 'table/version'
         | 
| 14 15 |  | 
| 15 16 | 
             
            module TTY
         | 
| 16 17 | 
             
              # A core class intended for storing data in a structured, tabular form.
         | 
| @@ -37,21 +38,21 @@ module TTY | |
| 37 38 |  | 
| 38 39 | 
             
                # The table orientation out of :horizontal and :vertical
         | 
| 39 40 | 
             
                #
         | 
| 40 | 
            -
                # @ | 
| 41 | 
            +
                # @return [TTY::Table::Orientation]
         | 
| 41 42 | 
             
                #
         | 
| 42 43 | 
             
                # @api public
         | 
| 43 44 | 
             
                attr_reader :orientation
         | 
| 44 45 |  | 
| 45 46 | 
             
                # The table original row count
         | 
| 46 47 | 
             
                #
         | 
| 47 | 
            -
                # @ | 
| 48 | 
            +
                # @return [Integer]
         | 
| 48 49 | 
             
                #
         | 
| 49 50 | 
             
                # @api public
         | 
| 50 51 | 
             
                attr_reader :original_rows
         | 
| 51 52 |  | 
| 52 53 | 
             
                # The table original column count
         | 
| 53 54 | 
             
                #
         | 
| 54 | 
            -
                # @ | 
| 55 | 
            +
                # @return [Integer]
         | 
| 55 56 | 
             
                #
         | 
| 56 57 | 
             
                # @api public
         | 
| 57 58 | 
             
                attr_reader :original_columns
         | 
| @@ -86,7 +87,7 @@ module TTY | |
| 86 87 | 
             
                # @example of parameters passed as hash
         | 
| 87 88 | 
             
                #   Table.new [{'Header1' => ['a1','a2'], 'Header2' => ['b1', 'b2'] }]}
         | 
| 88 89 | 
             
                #
         | 
| 89 | 
            -
                # @param [Array[Symbol], Hash]  | 
| 90 | 
            +
                # @param [Array[Symbol], Hash] args
         | 
| 90 91 | 
             
                #
         | 
| 91 92 | 
             
                # @api public
         | 
| 92 93 | 
             
                def self.new(*args, &block)
         | 
| @@ -126,6 +127,15 @@ module TTY | |
| 126 127 | 
             
                  yield_or_eval(&block) if block_given?
         | 
| 127 128 | 
             
                end
         | 
| 128 129 |  | 
| 130 | 
            +
                # Provides a list of rows to have separations applied
         | 
| 131 | 
            +
                #
         | 
| 132 | 
            +
                # @return [Array]
         | 
| 133 | 
            +
                #
         | 
| 134 | 
            +
                # @api public
         | 
| 135 | 
            +
                def separators
         | 
| 136 | 
            +
                  @separators ||= []
         | 
| 137 | 
            +
                end
         | 
| 138 | 
            +
             | 
| 129 139 | 
             
                # Provides access to all table data
         | 
| 130 140 | 
             
                #
         | 
| 131 141 | 
             
                # @return [Array]
         | 
| @@ -285,9 +295,13 @@ module TTY | |
| 285 295 | 
             
                #
         | 
| 286 296 | 
             
                # @api public
         | 
| 287 297 | 
             
                def <<(row)
         | 
| 288 | 
            -
                   | 
| 289 | 
            -
             | 
| 290 | 
            -
                   | 
| 298 | 
            +
                  if row == Border::SEPARATOR
         | 
| 299 | 
            +
                    separators << columns_size - (header ? 0 : 2)
         | 
| 300 | 
            +
                  else
         | 
| 301 | 
            +
                    rows_copy = rows.dup
         | 
| 302 | 
            +
                    assert_row_sizes rows_copy << row
         | 
| 303 | 
            +
                    rows << to_row(row)
         | 
| 304 | 
            +
                  end
         | 
| 291 305 | 
             
                  self
         | 
| 292 306 | 
             
                end
         | 
| 293 307 |  | 
| @@ -428,10 +442,12 @@ module TTY | |
| 428 442 |  | 
| 429 443 | 
             
                # Render a given table using custom border class.
         | 
| 430 444 | 
             
                #
         | 
| 431 | 
            -
                # @param [TTY::Table::Border]
         | 
| 445 | 
            +
                # @param [TTY::Table::Border] border_class
         | 
| 432 446 | 
             
                #
         | 
| 433 447 | 
             
                # @param [Symbol] renderer_type
         | 
| 434 448 | 
             
                #
         | 
| 449 | 
            +
                # @param [Hash] options
         | 
| 450 | 
            +
                #
         | 
| 435 451 | 
             
                # @yield [renderer]
         | 
| 436 452 | 
             
                #
         | 
| 437 453 | 
             
                # @yieldparam [TTY::Table::Renderer] renderer
         | 
| @@ -456,15 +472,22 @@ module TTY | |
| 456 472 | 
             
                # This coercion mechanism is used by Table to handle Enumerable types
         | 
| 457 473 | 
             
                # and force them into array type.
         | 
| 458 474 | 
             
                #
         | 
| 459 | 
            -
                # @param [Enumerable]  | 
| 475 | 
            +
                # @param [Enumerable] rows
         | 
| 460 476 | 
             
                #    the object to coerce
         | 
| 461 477 | 
             
                #
         | 
| 462 478 | 
             
                # @return [Array]
         | 
| 463 479 | 
             
                #
         | 
| 464 480 | 
             
                # @api public
         | 
| 465 481 | 
             
                def coerce(rows)
         | 
| 466 | 
            -
                   | 
| 467 | 
            -
                  rows. | 
| 482 | 
            +
                  coerced_rows = []
         | 
| 483 | 
            +
                  @converter.convert(rows).to(:array).each do |row|
         | 
| 484 | 
            +
                    if row == Border::SEPARATOR
         | 
| 485 | 
            +
                      separators << coerced_rows.length - (header ? 0 : 1)
         | 
| 486 | 
            +
                    else
         | 
| 487 | 
            +
                      coerced_rows << to_row(row, header)
         | 
| 488 | 
            +
                    end
         | 
| 489 | 
            +
                  end
         | 
| 490 | 
            +
                  coerced_rows
         | 
| 468 491 | 
             
                end
         | 
| 469 492 |  | 
| 470 493 | 
             
                private
         | 
    
        data/lib/tty/table/border.rb
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            #  | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            require 'equatable'
         | 
| 4 4 | 
             
            require 'pastel'
         | 
| @@ -22,6 +22,9 @@ module TTY | |
| 22 22 | 
             
                  # Represent a separtor on each row
         | 
| 23 23 | 
             
                  EACH_ROW = :each_row
         | 
| 24 24 |  | 
| 25 | 
            +
                  # specify a separator as a row
         | 
| 26 | 
            +
                  SEPARATOR = :separator
         | 
| 27 | 
            +
             | 
| 25 28 | 
             
                  class << self
         | 
| 26 29 | 
             
                    # Store characters for border
         | 
| 27 30 | 
             
                    #
         | 
| @@ -138,7 +141,7 @@ module TTY | |
| 138 141 | 
             
                  #
         | 
| 139 142 | 
             
                  # @param [Symbol] color
         | 
| 140 143 | 
             
                  #
         | 
| 141 | 
            -
                  # @param [Array[String]] array of strings
         | 
| 144 | 
            +
                  # @param [Array[String]] strings array of strings
         | 
| 142 145 | 
             
                  #
         | 
| 143 146 | 
             
                  # @return [Array[String]]
         | 
| 144 147 | 
             
                  #
         | 
| @@ -188,7 +191,7 @@ module TTY | |
| 188 191 | 
             
                  # @param [TTY::Table::Row] row
         | 
| 189 192 | 
             
                  #   the table row
         | 
| 190 193 | 
             
                  #
         | 
| 191 | 
            -
                  # @param [Integer]  | 
| 194 | 
            +
                  # @param [Integer] line_index
         | 
| 192 195 | 
             
                  #  the index for current line inside multiline
         | 
| 193 196 | 
             
                  #
         | 
| 194 197 | 
             
                  # @param [TTY::Table::Border::RowLine] line
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            #  | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            require_relative '../border'
         | 
| 4 4 |  | 
| @@ -23,7 +23,8 @@ module TTY | |
| 23 23 | 
             
                    #
         | 
| 24 24 | 
             
                    # @api private
         | 
| 25 25 | 
             
                    def separator
         | 
| 26 | 
            -
                      return [] if border_options.separator == EACH_ROW
         | 
| 26 | 
            +
                      return [] if border_options.separator # == EACH_ROW #TODO ask about this looks broken.
         | 
| 27 | 
            +
                      # how could border_options ever be nil, if we just did border_options.separator
         | 
| 27 28 | 
             
                      border_options ? super : nil
         | 
| 28 29 | 
             
                    end
         | 
| 29 30 |  | 
    
        data/lib/tty/table/border_dsl.rb
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            #  | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            require 'forwardable'
         | 
| 4 4 |  | 
| @@ -37,7 +37,7 @@ module TTY | |
| 37 37 |  | 
| 38 38 | 
             
                  # Apply style color to the border
         | 
| 39 39 | 
             
                  #
         | 
| 40 | 
            -
                  # @param [Symbol]  | 
| 40 | 
            +
                  # @param [Symbol] value
         | 
| 41 41 | 
             
                  #   the style color for the border
         | 
| 42 42 | 
             
                  #
         | 
| 43 43 | 
             
                  # @return [undefined]
         | 
| @@ -50,7 +50,7 @@ module TTY | |
| 50 50 |  | 
| 51 51 | 
             
                  # Apply table tuple separator
         | 
| 52 52 | 
             
                  #
         | 
| 53 | 
            -
                  # @param [Symbol]  | 
| 53 | 
            +
                  # @param [Symbol] value
         | 
| 54 54 | 
             
                  #   the table tuple separator
         | 
| 55 55 | 
             
                  #
         | 
| 56 56 | 
             
                  # @return [undefined]
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            #  | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            module TTY
         | 
| 4 4 | 
             
              class Table
         | 
| @@ -48,6 +48,26 @@ module TTY | |
| 48 48 | 
             
                    end
         | 
| 49 49 | 
             
                    hash
         | 
| 50 50 | 
             
                  end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  # return true if there should be a separator AFTER this line
         | 
| 53 | 
            +
                  #
         | 
| 54 | 
            +
                  # @param [Integer] line
         | 
| 55 | 
            +
                  #
         | 
| 56 | 
            +
                  # @return [Boolean]
         | 
| 57 | 
            +
                  #
         | 
| 58 | 
            +
                  # @api public
         | 
| 59 | 
            +
                  def separator?(line)
         | 
| 60 | 
            +
                    case separator
         | 
| 61 | 
            +
                    when TTY::Table::Border::EACH_ROW
         | 
| 62 | 
            +
                      true
         | 
| 63 | 
            +
                    when Array
         | 
| 64 | 
            +
                      separator.include?(line)
         | 
| 65 | 
            +
                    when Proc
         | 
| 66 | 
            +
                      separator.call(line)
         | 
| 67 | 
            +
                    else
         | 
| 68 | 
            +
                      false
         | 
| 69 | 
            +
                    end
         | 
| 70 | 
            +
                  end
         | 
| 51 71 | 
             
                end # BorderOptions
         | 
| 52 72 | 
             
              end # Table
         | 
| 53 73 | 
             
            end # TTY
         | 
    
        data/lib/tty/table/columns.rb
    CHANGED
    
    
    
        data/lib/tty/table/empty.rb
    CHANGED
    
    
    
        data/lib/tty/table/error.rb
    CHANGED
    
    
    
        data/lib/tty/table/field.rb
    CHANGED
    
    
    
        data/lib/tty/table/header.rb
    CHANGED