tty-table 0.1.0 → 0.2.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 +4 -4
 - data/CHANGELOG.md +24 -0
 - data/README.md +458 -142
 - data/lib/tty-table.rb +6 -6
 - data/lib/tty/table.rb +34 -34
 - data/lib/tty/table/alignment_set.rb +73 -0
 - data/lib/tty/table/border.rb +54 -36
 - data/lib/tty/table/border/null.rb +4 -4
 - data/lib/tty/table/{columns.rb → column_constraint.rb} +30 -32
 - data/lib/tty/table/column_set.rb +18 -17
 - data/lib/tty/table/field.rb +50 -25
 - data/lib/tty/table/header.rb +6 -2
 - data/lib/tty/table/indentation.rb +7 -12
 - data/lib/tty/table/operation/alignment.rb +59 -0
 - 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 +12 -61
 - data/lib/tty/table/operation/truncation.rb +2 -2
 - data/lib/tty/table/operation/wrapped.rb +2 -5
 - data/lib/tty/table/operations.rb +35 -17
 - data/lib/tty/table/orientation/vertical.rb +4 -4
 - data/lib/tty/table/renderer.rb +1 -7
 - data/lib/tty/table/renderer/basic.rb +69 -63
 - data/lib/tty/table/version.rb +1 -1
 - data/spec/spec_helper.rb +3 -4
 - data/spec/unit/access_spec.rb +8 -8
 - data/spec/unit/{operation/alignment_set → alignment_set}/each_spec.rb +1 -1
 - data/spec/unit/{operation/alignment_set → alignment_set}/new_spec.rb +4 -4
 - data/spec/unit/{operation/alignment_set → alignment_set}/to_ary_spec.rb +1 -1
 - data/spec/unit/alignment_spec.rb +71 -0
 - data/spec/unit/border/ascii/rendering_spec.rb +12 -12
 - data/spec/unit/border/new_spec.rb +2 -2
 - data/spec/unit/border/null/rendering_spec.rb +2 -2
 - data/spec/unit/border/unicode/rendering_spec.rb +10 -10
 - data/spec/unit/{columns → column_constraint}/enforce_spec.rb +15 -12
 - data/spec/unit/{columns → column_constraint}/widths_spec.rb +6 -6
 - data/spec/unit/column_set/extract_widths_spec.rb +39 -6
 - data/spec/unit/data_spec.rb +4 -6
 - data/spec/unit/each_spec.rb +8 -23
 - data/spec/unit/each_with_index_spec.rb +27 -33
 - data/spec/unit/field/length_spec.rb +23 -9
 - data/spec/unit/field/width_spec.rb +1 -1
 - data/spec/unit/filter_spec.rb +7 -8
 - data/spec/unit/header/new_spec.rb +6 -15
 - data/spec/unit/indentation/indent_spec.rb +21 -0
 - data/spec/unit/new_spec.rb +73 -0
 - data/spec/unit/operation/{alignment_set → alignment}/call_spec.rb +1 -1
 - data/spec/unit/operation/escape/call_spec.rb +2 -3
 - data/spec/unit/operation/filter/call_spec.rb +2 -3
 - data/spec/unit/operation/truncation/call_spec.rb +6 -8
 - data/spec/unit/operation/wrapped/call_spec.rb +15 -8
 - data/spec/unit/operations/new_spec.rb +1 -1
 - data/spec/unit/orientation_spec.rb +6 -6
 - data/spec/unit/padding_spec.rb +29 -32
 - data/spec/unit/properties_spec.rb +4 -4
 - data/spec/unit/render_repeat_spec.rb +42 -0
 - data/spec/unit/render_spec.rb +1 -1
 - data/spec/unit/render_with_spec.rb +3 -3
 - data/spec/unit/renderer/ascii/coloring_spec.rb +70 -0
 - data/spec/unit/renderer/ascii/multiline_spec.rb +101 -0
 - data/spec/unit/renderer/ascii/padding_spec.rb +37 -10
 - data/spec/unit/renderer/ascii/render_spec.rb +4 -4
 - data/spec/unit/renderer/ascii/resizing_spec.rb +22 -22
 - data/spec/unit/renderer/ascii/separator_spec.rb +1 -1
 - data/spec/unit/renderer/basic/alignment_spec.rb +20 -20
 - data/spec/unit/renderer/basic/coloring_spec.rb +43 -28
 - data/spec/unit/renderer/basic/filter_spec.rb +3 -3
 - data/spec/unit/renderer/basic/multiline_spec.rb +74 -0
 - data/spec/unit/renderer/basic/options_spec.rb +9 -9
 - data/spec/unit/renderer/basic/padding_spec.rb +26 -2
 - data/spec/unit/renderer/basic/render_spec.rb +4 -4
 - data/spec/unit/renderer/basic/resizing_spec.rb +18 -18
 - data/spec/unit/renderer/basic/separator_spec.rb +1 -1
 - data/spec/unit/renderer/basic/truncation_spec.rb +6 -6
 - data/spec/unit/renderer/basic/wrapping_spec.rb +3 -3
 - data/spec/unit/renderer/border_spec.rb +4 -4
 - data/spec/unit/renderer/unicode/coloring_spec.rb +70 -0
 - data/spec/unit/renderer/unicode/indentation_spec.rb +1 -1
 - data/spec/unit/renderer/unicode/padding_spec.rb +26 -26
 - data/spec/unit/renderer/unicode/render_spec.rb +4 -4
 - data/spec/unit/renderer/unicode/separator_spec.rb +1 -1
 - data/spec/unit/to_s_spec.rb +4 -11
 - data/spec/unit/utf_spec.rb +33 -0
 - data/tty-table.gemspec +2 -1
 - metadata +52 -32
 - data/lib/tty/table/operation/alignment_set.rb +0 -103
 - data/lib/tty/table/padder.rb +0 -180
 - data/lib/tty/table/renderer/color.rb +0 -12
 - data/spec/unit/indentation/insert_indent_spec.rb +0 -27
 - data/spec/unit/initialize_spec.rb +0 -88
 - data/spec/unit/padder/parse_spec.rb +0 -45
 - data/spec/unit/padder/to_s_spec.rb +0 -14
 - data/spec/unit/renderer/basic/multiline_content_spec.rb +0 -135
 - data/spec/unit/renderer/style_spec.rb +0 -72
 
| 
         @@ -13,7 +13,7 @@ RSpec.describe TTY::Table::Renderer::Unicode, '#render' do 
     | 
|
| 
       13 
13 
     | 
    
         
             
                let(:table) { TTY::Table.new rows }
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                it 'display table rows' do
         
     | 
| 
       16 
     | 
    
         
            -
                  expect(renderer.render).to eq <<-EOS 
     | 
| 
      
 16 
     | 
    
         
            +
                  expect(renderer.render).to eq unindent(<<-EOS)
         
     | 
| 
       17 
17 
     | 
    
         
             
                    ┌──┬──┬──┐
         
     | 
| 
       18 
18 
     | 
    
         
             
                    │a1│a2│a3│
         
     | 
| 
       19 
19 
     | 
    
         
             
                    │b1│b2│b3│
         
     | 
| 
         @@ -24,7 +24,7 @@ RSpec.describe TTY::Table::Renderer::Unicode, '#render' do 
     | 
|
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
              context 'with header' do
         
     | 
| 
       26 
26 
     | 
    
         
             
                it 'displays table with header' do
         
     | 
| 
       27 
     | 
    
         
            -
                  expect(renderer.render).to eq <<-EOS 
     | 
| 
      
 27 
     | 
    
         
            +
                  expect(renderer.render).to eq unindent(<<-EOS)
         
     | 
| 
       28 
28 
     | 
    
         
             
                    ┌──┬──┬──┐
         
     | 
| 
       29 
29 
     | 
    
         
             
                    │h1│h2│h3│
         
     | 
| 
       30 
30 
     | 
    
         
             
                    ├──┼──┼──┤
         
     | 
| 
         @@ -40,7 +40,7 @@ RSpec.describe TTY::Table::Renderer::Unicode, '#render' do 
     | 
|
| 
       40 
40 
     | 
    
         
             
                let(:rows)   { [['aaa1', 'a2'], ['b1', 'bb1']] }
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
42 
     | 
    
         
             
                it 'displays table according to widths' do
         
     | 
| 
       43 
     | 
    
         
            -
                  expect(renderer.render).to eq <<-EOS 
     | 
| 
      
 43 
     | 
    
         
            +
                  expect(renderer.render).to eq unindent(<<-EOS)
         
     | 
| 
       44 
44 
     | 
    
         
             
                    ┌────┬───┐
         
     | 
| 
       45 
45 
     | 
    
         
             
                    │h1  │h2 │
         
     | 
| 
       46 
46 
     | 
    
         
             
                    ├────┼───┤
         
     | 
| 
         @@ -55,7 +55,7 @@ RSpec.describe TTY::Table::Renderer::Unicode, '#render' do 
     | 
|
| 
       55 
55 
     | 
    
         
             
                let(:header) { ['header1', 'header2', 'header3'] }
         
     | 
| 
       56 
56 
     | 
    
         | 
| 
       57 
57 
     | 
    
         
             
                it 'header greater than row sizes' do
         
     | 
| 
       58 
     | 
    
         
            -
                  expect(renderer.render).to eq <<-EOS 
     | 
| 
      
 58 
     | 
    
         
            +
                  expect(renderer.render).to eq unindent(<<-EOS)
         
     | 
| 
       59 
59 
     | 
    
         
             
                    ┌───────┬───────┬───────┐
         
     | 
| 
       60 
60 
     | 
    
         
             
                    │header1│header2│header3│
         
     | 
| 
       61 
61 
     | 
    
         
             
                    ├───────┼───────┼───────┤
         
     | 
| 
         @@ -13,7 +13,7 @@ RSpec.describe TTY::Table::Renderer::Unicode, 'with separator' do 
     | 
|
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
              it "renders each row" do
         
     | 
| 
       15 
15 
     | 
    
         
             
                renderer.border.separator= :each_row
         
     | 
| 
       16 
     | 
    
         
            -
                expect(renderer.render).to eq <<-EOS 
     | 
| 
      
 16 
     | 
    
         
            +
                expect(renderer.render).to eq unindent(<<-EOS)
         
     | 
| 
       17 
17 
     | 
    
         
             
                  ┌──┬──┬──┐
         
     | 
| 
       18 
18 
     | 
    
         
             
                  │h1│h2│h3│
         
     | 
| 
       19 
19 
     | 
    
         
             
                  ├──┼──┼──┤
         
     | 
    
        data/spec/unit/to_s_spec.rb
    CHANGED
    
    | 
         @@ -5,15 +5,12 @@ require 'spec_helper' 
     | 
|
| 
       5 
5 
     | 
    
         
             
            RSpec.describe TTY::Table, '#to_s' do
         
     | 
| 
       6 
6 
     | 
    
         
             
              let(:header)   { ['h1', 'h2', 'h3'] }
         
     | 
| 
       7 
7 
     | 
    
         
             
              let(:rows)     { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] }
         
     | 
| 
       8 
     | 
    
         
            -
              let(:renderer) { :basic }
         
     | 
| 
       9 
8 
     | 
    
         | 
| 
       10 
9 
     | 
    
         
             
              subject(:table) { described_class.new(header, rows) }
         
     | 
| 
       11 
10 
     | 
    
         | 
| 
       12 
11 
     | 
    
         
             
              context 'without renderer' do
         
     | 
| 
       13 
     | 
    
         
            -
                let(:renderer) { nil }
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
12 
     | 
    
         
             
                it 'displayes basic table' do
         
     | 
| 
       16 
     | 
    
         
            -
                  expect(table. 
     | 
| 
      
 13 
     | 
    
         
            +
                  expect(table.render(:basic)).to eq unindent(<<-EOS)
         
     | 
| 
       17 
14 
     | 
    
         
             
                    h1 h2 h3
         
     | 
| 
       18 
15 
     | 
    
         
             
                    a1 a2 a3
         
     | 
| 
       19 
16 
     | 
    
         
             
                    b1 b2 b3
         
     | 
| 
         @@ -23,7 +20,7 @@ RSpec.describe TTY::Table, '#to_s' do 
     | 
|
| 
       23 
20 
     | 
    
         | 
| 
       24 
21 
     | 
    
         
             
              context 'without border' do
         
     | 
| 
       25 
22 
     | 
    
         
             
                it 'displays table' do
         
     | 
| 
       26 
     | 
    
         
            -
                  expect(table.to_s).to eq <<-EOS 
     | 
| 
      
 23 
     | 
    
         
            +
                  expect(table.to_s).to eq unindent(<<-EOS)
         
     | 
| 
       27 
24 
     | 
    
         
             
                    h1 h2 h3
         
     | 
| 
       28 
25 
     | 
    
         
             
                    a1 a2 a3
         
     | 
| 
       29 
26 
     | 
    
         
             
                    b1 b2 b3
         
     | 
| 
         @@ -32,10 +29,8 @@ RSpec.describe TTY::Table, '#to_s' do 
     | 
|
| 
       32 
29 
     | 
    
         
             
              end
         
     | 
| 
       33 
30 
     | 
    
         | 
| 
       34 
31 
     | 
    
         
             
              context 'with ascii border' do
         
     | 
| 
       35 
     | 
    
         
            -
                let(:renderer) { :ascii }
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
32 
     | 
    
         
             
                it 'displays table' do
         
     | 
| 
       38 
     | 
    
         
            -
                  expect(table.render( 
     | 
| 
      
 33 
     | 
    
         
            +
                  expect(table.render(:ascii)).to eq unindent(<<-EOS)
         
     | 
| 
       39 
34 
     | 
    
         
             
                    +--+--+--+
         
     | 
| 
       40 
35 
     | 
    
         
             
                    |h1|h2|h3|
         
     | 
| 
       41 
36 
     | 
    
         
             
                    +--+--+--+
         
     | 
| 
         @@ -47,10 +42,8 @@ RSpec.describe TTY::Table, '#to_s' do 
     | 
|
| 
       47 
42 
     | 
    
         
             
              end
         
     | 
| 
       48 
43 
     | 
    
         | 
| 
       49 
44 
     | 
    
         
             
              context 'with unicode border' do
         
     | 
| 
       50 
     | 
    
         
            -
                let(:renderer) { :unicode}
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
45 
     | 
    
         
             
                it 'displays table' do
         
     | 
| 
       53 
     | 
    
         
            -
                  expect(table.render( 
     | 
| 
      
 46 
     | 
    
         
            +
                  expect(table.render(:unicode)).to eq unindent(<<-EOS)
         
     | 
| 
       54 
47 
     | 
    
         
             
                    ┌──┬──┬──┐
         
     | 
| 
       55 
48 
     | 
    
         
             
                    │h1│h2│h3│
         
     | 
| 
       56 
49 
     | 
    
         
             
                    ├──┼──┼──┤
         
     | 
| 
         @@ -0,0 +1,33 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            RSpec.describe TTY::Table, 'unicode support' do
         
     | 
| 
      
 6 
     | 
    
         
            +
              it "measures utf characters correctly for :basic" do
         
     | 
| 
      
 7 
     | 
    
         
            +
                table = TTY::Table[['こんにちは', 'a2'], ['b1','選択']]
         
     | 
| 
      
 8 
     | 
    
         
            +
                expect(table.render(:basic)).to eq unindent(<<-EOS)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  こんにちは a2  
         
     | 
| 
      
 10 
     | 
    
         
            +
                  b1         選択
         
     | 
| 
      
 11 
     | 
    
         
            +
                EOS
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              it "measure utf characters correctly for :ascii" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                table = TTY::Table[['こんにちは', 'a2'], ['b1','選択']]
         
     | 
| 
      
 16 
     | 
    
         
            +
                expect(table.render(:ascii)).to eq unindent(<<-EOS)
         
     | 
| 
      
 17 
     | 
    
         
            +
                 +----------+----+
         
     | 
| 
      
 18 
     | 
    
         
            +
                 |こんにちは|a2  |
         
     | 
| 
      
 19 
     | 
    
         
            +
                 |b1        |選択|
         
     | 
| 
      
 20 
     | 
    
         
            +
                 +----------+----+
         
     | 
| 
      
 21 
     | 
    
         
            +
                EOS
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              it "measure utf characters correctly for :unicode" do
         
     | 
| 
      
 25 
     | 
    
         
            +
                table = TTY::Table[['こんにちは', 'a2'], ['b1','選択']]
         
     | 
| 
      
 26 
     | 
    
         
            +
                expect(table.render(:unicode)).to eq unindent(<<-EOS)
         
     | 
| 
      
 27 
     | 
    
         
            +
                 ┌──────────┬────┐
         
     | 
| 
      
 28 
     | 
    
         
            +
                 │こんにちは│a2  │
         
     | 
| 
      
 29 
     | 
    
         
            +
                 │b1        │選択│
         
     | 
| 
      
 30 
     | 
    
         
            +
                 └──────────┴────┘
         
     | 
| 
      
 31 
     | 
    
         
            +
                EOS
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
            end
         
     | 
    
        data/tty-table.gemspec
    CHANGED
    
    | 
         @@ -22,7 +22,8 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       22 
22 
     | 
    
         
             
              spec.add_dependency 'necromancer', '~> 0.3'
         
     | 
| 
       23 
23 
     | 
    
         
             
              spec.add_dependency 'pastel',      '~> 0.4'
         
     | 
| 
       24 
24 
     | 
    
         
             
              spec.add_dependency 'tty-screen',  '~> 0.1'
         
     | 
| 
       25 
     | 
    
         
            -
              spec.add_dependency 'verse',       '~> 0. 
     | 
| 
      
 25 
     | 
    
         
            +
              spec.add_dependency 'verse',       '~> 0.4'
         
     | 
| 
      
 26 
     | 
    
         
            +
              spec.add_dependency 'unicode_utils','~> 1.4.0'
         
     | 
| 
       26 
27 
     | 
    
         | 
| 
       27 
28 
     | 
    
         
             
              spec.add_development_dependency 'bundler', '~> 1.5'
         
     | 
| 
       28 
29 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: tty-table
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Piotr Murach
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-03-30 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: equatable
         
     | 
| 
         @@ -72,14 +72,28 @@ dependencies: 
     | 
|
| 
       72 
72 
     | 
    
         
             
                requirements:
         
     | 
| 
       73 
73 
     | 
    
         
             
                - - ~>
         
     | 
| 
       74 
74 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       75 
     | 
    
         
            -
                    version: '0. 
     | 
| 
      
 75 
     | 
    
         
            +
                    version: '0.4'
         
     | 
| 
       76 
76 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       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: '0. 
     | 
| 
      
 82 
     | 
    
         
            +
                    version: '0.4'
         
     | 
| 
      
 83 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 84 
     | 
    
         
            +
              name: unicode_utils
         
     | 
| 
      
 85 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 86 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 87 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 88 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 89 
     | 
    
         
            +
                    version: 1.4.0
         
     | 
| 
      
 90 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 91 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 92 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 93 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 94 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 95 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 96 
     | 
    
         
            +
                    version: 1.4.0
         
     | 
| 
       83 
97 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       84 
98 
     | 
    
         
             
              name: bundler
         
     | 
| 
       85 
99 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -105,6 +119,7 @@ files: 
     | 
|
| 
       105 
119 
     | 
    
         
             
            - .rspec
         
     | 
| 
       106 
120 
     | 
    
         
             
            - .ruby-version
         
     | 
| 
       107 
121 
     | 
    
         
             
            - .travis.yml
         
     | 
| 
      
 122 
     | 
    
         
            +
            - CHANGELOG.md
         
     | 
| 
       108 
123 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       109 
124 
     | 
    
         
             
            - LICENSE.txt
         
     | 
| 
       110 
125 
     | 
    
         
             
            - README.md
         
     | 
| 
         @@ -112,6 +127,7 @@ files: 
     | 
|
| 
       112 
127 
     | 
    
         
             
            - benchmarks/speed.rb
         
     | 
| 
       113 
128 
     | 
    
         
             
            - lib/tty-table.rb
         
     | 
| 
       114 
129 
     | 
    
         
             
            - lib/tty/table.rb
         
     | 
| 
      
 130 
     | 
    
         
            +
            - lib/tty/table/alignment_set.rb
         
     | 
| 
       115 
131 
     | 
    
         
             
            - lib/tty/table/border.rb
         
     | 
| 
       116 
132 
     | 
    
         
             
            - lib/tty/table/border/ascii.rb
         
     | 
| 
       117 
133 
     | 
    
         
             
            - lib/tty/table/border/null.rb
         
     | 
| 
         @@ -119,14 +135,14 @@ files: 
     | 
|
| 
       119 
135 
     | 
    
         
             
            - lib/tty/table/border/unicode.rb
         
     | 
| 
       120 
136 
     | 
    
         
             
            - lib/tty/table/border_dsl.rb
         
     | 
| 
       121 
137 
     | 
    
         
             
            - lib/tty/table/border_options.rb
         
     | 
| 
      
 138 
     | 
    
         
            +
            - lib/tty/table/column_constraint.rb
         
     | 
| 
       122 
139 
     | 
    
         
             
            - lib/tty/table/column_set.rb
         
     | 
| 
       123 
     | 
    
         
            -
            - lib/tty/table/columns.rb
         
     | 
| 
       124 
140 
     | 
    
         
             
            - lib/tty/table/empty.rb
         
     | 
| 
       125 
141 
     | 
    
         
             
            - lib/tty/table/error.rb
         
     | 
| 
       126 
142 
     | 
    
         
             
            - lib/tty/table/field.rb
         
     | 
| 
       127 
143 
     | 
    
         
             
            - lib/tty/table/header.rb
         
     | 
| 
       128 
144 
     | 
    
         
             
            - lib/tty/table/indentation.rb
         
     | 
| 
       129 
     | 
    
         
            -
            - lib/tty/table/operation/ 
     | 
| 
      
 145 
     | 
    
         
            +
            - lib/tty/table/operation/alignment.rb
         
     | 
| 
       130 
146 
     | 
    
         
             
            - lib/tty/table/operation/escape.rb
         
     | 
| 
       131 
147 
     | 
    
         
             
            - lib/tty/table/operation/filter.rb
         
     | 
| 
       132 
148 
     | 
    
         
             
            - lib/tty/table/operation/padding.rb
         
     | 
| 
         @@ -137,11 +153,9 @@ files: 
     | 
|
| 
       137 
153 
     | 
    
         
             
            - lib/tty/table/orientation.rb
         
     | 
| 
       138 
154 
     | 
    
         
             
            - lib/tty/table/orientation/horizontal.rb
         
     | 
| 
       139 
155 
     | 
    
         
             
            - lib/tty/table/orientation/vertical.rb
         
     | 
| 
       140 
     | 
    
         
            -
            - lib/tty/table/padder.rb
         
     | 
| 
       141 
156 
     | 
    
         
             
            - lib/tty/table/renderer.rb
         
     | 
| 
       142 
157 
     | 
    
         
             
            - lib/tty/table/renderer/ascii.rb
         
     | 
| 
       143 
158 
     | 
    
         
             
            - lib/tty/table/renderer/basic.rb
         
     | 
| 
       144 
     | 
    
         
            -
            - lib/tty/table/renderer/color.rb
         
     | 
| 
       145 
159 
     | 
    
         
             
            - lib/tty/table/renderer/unicode.rb
         
     | 
| 
       146 
160 
     | 
    
         
             
            - lib/tty/table/row.rb
         
     | 
| 
       147 
161 
     | 
    
         
             
            - lib/tty/table/transformation.rb
         
     | 
| 
         @@ -150,6 +164,10 @@ files: 
     | 
|
| 
       150 
164 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       151 
165 
     | 
    
         
             
            - spec/unit/access_spec.rb
         
     | 
| 
       152 
166 
     | 
    
         
             
            - spec/unit/add_row_spec.rb
         
     | 
| 
      
 167 
     | 
    
         
            +
            - spec/unit/alignment_set/each_spec.rb
         
     | 
| 
      
 168 
     | 
    
         
            +
            - spec/unit/alignment_set/new_spec.rb
         
     | 
| 
      
 169 
     | 
    
         
            +
            - spec/unit/alignment_set/to_ary_spec.rb
         
     | 
| 
      
 170 
     | 
    
         
            +
            - spec/unit/alignment_spec.rb
         
     | 
| 
       153 
171 
     | 
    
         
             
            - spec/unit/border/ascii/rendering_spec.rb
         
     | 
| 
       154 
172 
     | 
    
         
             
            - spec/unit/border/new_spec.rb
         
     | 
| 
       155 
173 
     | 
    
         
             
            - spec/unit/border/null/rendering_spec.rb
         
     | 
| 
         @@ -158,11 +176,11 @@ files: 
     | 
|
| 
       158 
176 
     | 
    
         
             
            - spec/unit/border/unicode/rendering_spec.rb
         
     | 
| 
       159 
177 
     | 
    
         
             
            - spec/unit/border_options/new_spec.rb
         
     | 
| 
       160 
178 
     | 
    
         
             
            - spec/unit/border_options/update_spec.rb
         
     | 
| 
      
 179 
     | 
    
         
            +
            - spec/unit/column_constraint/enforce_spec.rb
         
     | 
| 
      
 180 
     | 
    
         
            +
            - spec/unit/column_constraint/widths_spec.rb
         
     | 
| 
       161 
181 
     | 
    
         
             
            - spec/unit/column_set/extract_widths_spec.rb
         
     | 
| 
       162 
182 
     | 
    
         
             
            - spec/unit/column_set/total_width_spec.rb
         
     | 
| 
       163 
183 
     | 
    
         
             
            - spec/unit/column_set/widths_from_spec.rb
         
     | 
| 
       164 
     | 
    
         
            -
            - spec/unit/columns/enforce_spec.rb
         
     | 
| 
       165 
     | 
    
         
            -
            - spec/unit/columns/widths_spec.rb
         
     | 
| 
       166 
184 
     | 
    
         
             
            - spec/unit/data_spec.rb
         
     | 
| 
       167 
185 
     | 
    
         
             
            - spec/unit/each_spec.rb
         
     | 
| 
       168 
186 
     | 
    
         
             
            - spec/unit/each_with_index_spec.rb
         
     | 
| 
         @@ -182,12 +200,9 @@ files: 
     | 
|
| 
       182 
200 
     | 
    
         
             
            - spec/unit/header/set_spec.rb
         
     | 
| 
       183 
201 
     | 
    
         
             
            - spec/unit/header/to_ary_spec.rb
         
     | 
| 
       184 
202 
     | 
    
         
             
            - spec/unit/header_spec.rb
         
     | 
| 
       185 
     | 
    
         
            -
            - spec/unit/indentation/ 
     | 
| 
       186 
     | 
    
         
            -
            - spec/unit/ 
     | 
| 
       187 
     | 
    
         
            -
            - spec/unit/operation/ 
     | 
| 
       188 
     | 
    
         
            -
            - spec/unit/operation/alignment_set/each_spec.rb
         
     | 
| 
       189 
     | 
    
         
            -
            - spec/unit/operation/alignment_set/new_spec.rb
         
     | 
| 
       190 
     | 
    
         
            -
            - spec/unit/operation/alignment_set/to_ary_spec.rb
         
     | 
| 
      
 203 
     | 
    
         
            +
            - spec/unit/indentation/indent_spec.rb
         
     | 
| 
      
 204 
     | 
    
         
            +
            - spec/unit/new_spec.rb
         
     | 
| 
      
 205 
     | 
    
         
            +
            - spec/unit/operation/alignment/call_spec.rb
         
     | 
| 
       191 
206 
     | 
    
         
             
            - spec/unit/operation/escape/call_spec.rb
         
     | 
| 
       192 
207 
     | 
    
         
             
            - spec/unit/operation/filter/call_spec.rb
         
     | 
| 
       193 
208 
     | 
    
         
             
            - spec/unit/operation/truncation/call_spec.rb
         
     | 
| 
         @@ -196,13 +211,14 @@ files: 
     | 
|
| 
       196 
211 
     | 
    
         
             
            - spec/unit/options/access_spec.rb
         
     | 
| 
       197 
212 
     | 
    
         
             
            - spec/unit/options_spec.rb
         
     | 
| 
       198 
213 
     | 
    
         
             
            - spec/unit/orientation_spec.rb
         
     | 
| 
       199 
     | 
    
         
            -
            - spec/unit/padder/parse_spec.rb
         
     | 
| 
       200 
     | 
    
         
            -
            - spec/unit/padder/to_s_spec.rb
         
     | 
| 
       201 
214 
     | 
    
         
             
            - spec/unit/padding_spec.rb
         
     | 
| 
       202 
215 
     | 
    
         
             
            - spec/unit/properties_spec.rb
         
     | 
| 
      
 216 
     | 
    
         
            +
            - spec/unit/render_repeat_spec.rb
         
     | 
| 
       203 
217 
     | 
    
         
             
            - spec/unit/render_spec.rb
         
     | 
| 
       204 
218 
     | 
    
         
             
            - spec/unit/render_with_spec.rb
         
     | 
| 
      
 219 
     | 
    
         
            +
            - spec/unit/renderer/ascii/coloring_spec.rb
         
     | 
| 
       205 
220 
     | 
    
         
             
            - spec/unit/renderer/ascii/indentation_spec.rb
         
     | 
| 
      
 221 
     | 
    
         
            +
            - spec/unit/renderer/ascii/multiline_spec.rb
         
     | 
| 
       206 
222 
     | 
    
         
             
            - spec/unit/renderer/ascii/padding_spec.rb
         
     | 
| 
       207 
223 
     | 
    
         
             
            - spec/unit/renderer/ascii/render_spec.rb
         
     | 
| 
       208 
224 
     | 
    
         
             
            - spec/unit/renderer/ascii/resizing_spec.rb
         
     | 
| 
         @@ -212,7 +228,7 @@ files: 
     | 
|
| 
       212 
228 
     | 
    
         
             
            - spec/unit/renderer/basic/extract_column_widths_spec.rb
         
     | 
| 
       213 
229 
     | 
    
         
             
            - spec/unit/renderer/basic/filter_spec.rb
         
     | 
| 
       214 
230 
     | 
    
         
             
            - spec/unit/renderer/basic/indentation_spec.rb
         
     | 
| 
       215 
     | 
    
         
            -
            - spec/unit/renderer/basic/ 
     | 
| 
      
 231 
     | 
    
         
            +
            - spec/unit/renderer/basic/multiline_spec.rb
         
     | 
| 
       216 
232 
     | 
    
         
             
            - spec/unit/renderer/basic/new_spec.rb
         
     | 
| 
       217 
233 
     | 
    
         
             
            - spec/unit/renderer/basic/options_spec.rb
         
     | 
| 
       218 
234 
     | 
    
         
             
            - spec/unit/renderer/basic/padding_spec.rb
         
     | 
| 
         @@ -224,7 +240,7 @@ files: 
     | 
|
| 
       224 
240 
     | 
    
         
             
            - spec/unit/renderer/border_spec.rb
         
     | 
| 
       225 
241 
     | 
    
         
             
            - spec/unit/renderer/render_spec.rb
         
     | 
| 
       226 
242 
     | 
    
         
             
            - spec/unit/renderer/select_spec.rb
         
     | 
| 
       227 
     | 
    
         
            -
            - spec/unit/renderer/ 
     | 
| 
      
 243 
     | 
    
         
            +
            - spec/unit/renderer/unicode/coloring_spec.rb
         
     | 
| 
       228 
244 
     | 
    
         
             
            - spec/unit/renderer/unicode/indentation_spec.rb
         
     | 
| 
       229 
245 
     | 
    
         
             
            - spec/unit/renderer/unicode/padding_spec.rb
         
     | 
| 
       230 
246 
     | 
    
         
             
            - spec/unit/renderer/unicode/render_spec.rb
         
     | 
| 
         @@ -241,6 +257,7 @@ files: 
     | 
|
| 
       241 
257 
     | 
    
         
             
            - spec/unit/row/to_ary_spec.rb
         
     | 
| 
       242 
258 
     | 
    
         
             
            - spec/unit/to_s_spec.rb
         
     | 
| 
       243 
259 
     | 
    
         
             
            - spec/unit/transformation/extract_tuples_spec.rb
         
     | 
| 
      
 260 
     | 
    
         
            +
            - spec/unit/utf_spec.rb
         
     | 
| 
       244 
261 
     | 
    
         
             
            - spec/unit/validatable/validate_options_spec.rb
         
     | 
| 
       245 
262 
     | 
    
         
             
            - spec/unit/validatable_spec.rb
         
     | 
| 
       246 
263 
     | 
    
         
             
            - tasks/console.rake
         
     | 
| 
         @@ -275,6 +292,10 @@ test_files: 
     | 
|
| 
       275 
292 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       276 
293 
     | 
    
         
             
            - spec/unit/access_spec.rb
         
     | 
| 
       277 
294 
     | 
    
         
             
            - spec/unit/add_row_spec.rb
         
     | 
| 
      
 295 
     | 
    
         
            +
            - spec/unit/alignment_set/each_spec.rb
         
     | 
| 
      
 296 
     | 
    
         
            +
            - spec/unit/alignment_set/new_spec.rb
         
     | 
| 
      
 297 
     | 
    
         
            +
            - spec/unit/alignment_set/to_ary_spec.rb
         
     | 
| 
      
 298 
     | 
    
         
            +
            - spec/unit/alignment_spec.rb
         
     | 
| 
       278 
299 
     | 
    
         
             
            - spec/unit/border/ascii/rendering_spec.rb
         
     | 
| 
       279 
300 
     | 
    
         
             
            - spec/unit/border/new_spec.rb
         
     | 
| 
       280 
301 
     | 
    
         
             
            - spec/unit/border/null/rendering_spec.rb
         
     | 
| 
         @@ -283,11 +304,11 @@ test_files: 
     | 
|
| 
       283 
304 
     | 
    
         
             
            - spec/unit/border/unicode/rendering_spec.rb
         
     | 
| 
       284 
305 
     | 
    
         
             
            - spec/unit/border_options/new_spec.rb
         
     | 
| 
       285 
306 
     | 
    
         
             
            - spec/unit/border_options/update_spec.rb
         
     | 
| 
      
 307 
     | 
    
         
            +
            - spec/unit/column_constraint/enforce_spec.rb
         
     | 
| 
      
 308 
     | 
    
         
            +
            - spec/unit/column_constraint/widths_spec.rb
         
     | 
| 
       286 
309 
     | 
    
         
             
            - spec/unit/column_set/extract_widths_spec.rb
         
     | 
| 
       287 
310 
     | 
    
         
             
            - spec/unit/column_set/total_width_spec.rb
         
     | 
| 
       288 
311 
     | 
    
         
             
            - spec/unit/column_set/widths_from_spec.rb
         
     | 
| 
       289 
     | 
    
         
            -
            - spec/unit/columns/enforce_spec.rb
         
     | 
| 
       290 
     | 
    
         
            -
            - spec/unit/columns/widths_spec.rb
         
     | 
| 
       291 
312 
     | 
    
         
             
            - spec/unit/data_spec.rb
         
     | 
| 
       292 
313 
     | 
    
         
             
            - spec/unit/each_spec.rb
         
     | 
| 
       293 
314 
     | 
    
         
             
            - spec/unit/each_with_index_spec.rb
         
     | 
| 
         @@ -307,12 +328,9 @@ test_files: 
     | 
|
| 
       307 
328 
     | 
    
         
             
            - spec/unit/header/set_spec.rb
         
     | 
| 
       308 
329 
     | 
    
         
             
            - spec/unit/header/to_ary_spec.rb
         
     | 
| 
       309 
330 
     | 
    
         
             
            - spec/unit/header_spec.rb
         
     | 
| 
       310 
     | 
    
         
            -
            - spec/unit/indentation/ 
     | 
| 
       311 
     | 
    
         
            -
            - spec/unit/ 
     | 
| 
       312 
     | 
    
         
            -
            - spec/unit/operation/ 
     | 
| 
       313 
     | 
    
         
            -
            - spec/unit/operation/alignment_set/each_spec.rb
         
     | 
| 
       314 
     | 
    
         
            -
            - spec/unit/operation/alignment_set/new_spec.rb
         
     | 
| 
       315 
     | 
    
         
            -
            - spec/unit/operation/alignment_set/to_ary_spec.rb
         
     | 
| 
      
 331 
     | 
    
         
            +
            - spec/unit/indentation/indent_spec.rb
         
     | 
| 
      
 332 
     | 
    
         
            +
            - spec/unit/new_spec.rb
         
     | 
| 
      
 333 
     | 
    
         
            +
            - spec/unit/operation/alignment/call_spec.rb
         
     | 
| 
       316 
334 
     | 
    
         
             
            - spec/unit/operation/escape/call_spec.rb
         
     | 
| 
       317 
335 
     | 
    
         
             
            - spec/unit/operation/filter/call_spec.rb
         
     | 
| 
       318 
336 
     | 
    
         
             
            - spec/unit/operation/truncation/call_spec.rb
         
     | 
| 
         @@ -321,13 +339,14 @@ test_files: 
     | 
|
| 
       321 
339 
     | 
    
         
             
            - spec/unit/options/access_spec.rb
         
     | 
| 
       322 
340 
     | 
    
         
             
            - spec/unit/options_spec.rb
         
     | 
| 
       323 
341 
     | 
    
         
             
            - spec/unit/orientation_spec.rb
         
     | 
| 
       324 
     | 
    
         
            -
            - spec/unit/padder/parse_spec.rb
         
     | 
| 
       325 
     | 
    
         
            -
            - spec/unit/padder/to_s_spec.rb
         
     | 
| 
       326 
342 
     | 
    
         
             
            - spec/unit/padding_spec.rb
         
     | 
| 
       327 
343 
     | 
    
         
             
            - spec/unit/properties_spec.rb
         
     | 
| 
      
 344 
     | 
    
         
            +
            - spec/unit/render_repeat_spec.rb
         
     | 
| 
       328 
345 
     | 
    
         
             
            - spec/unit/render_spec.rb
         
     | 
| 
       329 
346 
     | 
    
         
             
            - spec/unit/render_with_spec.rb
         
     | 
| 
      
 347 
     | 
    
         
            +
            - spec/unit/renderer/ascii/coloring_spec.rb
         
     | 
| 
       330 
348 
     | 
    
         
             
            - spec/unit/renderer/ascii/indentation_spec.rb
         
     | 
| 
      
 349 
     | 
    
         
            +
            - spec/unit/renderer/ascii/multiline_spec.rb
         
     | 
| 
       331 
350 
     | 
    
         
             
            - spec/unit/renderer/ascii/padding_spec.rb
         
     | 
| 
       332 
351 
     | 
    
         
             
            - spec/unit/renderer/ascii/render_spec.rb
         
     | 
| 
       333 
352 
     | 
    
         
             
            - spec/unit/renderer/ascii/resizing_spec.rb
         
     | 
| 
         @@ -337,7 +356,7 @@ test_files: 
     | 
|
| 
       337 
356 
     | 
    
         
             
            - spec/unit/renderer/basic/extract_column_widths_spec.rb
         
     | 
| 
       338 
357 
     | 
    
         
             
            - spec/unit/renderer/basic/filter_spec.rb
         
     | 
| 
       339 
358 
     | 
    
         
             
            - spec/unit/renderer/basic/indentation_spec.rb
         
     | 
| 
       340 
     | 
    
         
            -
            - spec/unit/renderer/basic/ 
     | 
| 
      
 359 
     | 
    
         
            +
            - spec/unit/renderer/basic/multiline_spec.rb
         
     | 
| 
       341 
360 
     | 
    
         
             
            - spec/unit/renderer/basic/new_spec.rb
         
     | 
| 
       342 
361 
     | 
    
         
             
            - spec/unit/renderer/basic/options_spec.rb
         
     | 
| 
       343 
362 
     | 
    
         
             
            - spec/unit/renderer/basic/padding_spec.rb
         
     | 
| 
         @@ -349,7 +368,7 @@ test_files: 
     | 
|
| 
       349 
368 
     | 
    
         
             
            - spec/unit/renderer/border_spec.rb
         
     | 
| 
       350 
369 
     | 
    
         
             
            - spec/unit/renderer/render_spec.rb
         
     | 
| 
       351 
370 
     | 
    
         
             
            - spec/unit/renderer/select_spec.rb
         
     | 
| 
       352 
     | 
    
         
            -
            - spec/unit/renderer/ 
     | 
| 
      
 371 
     | 
    
         
            +
            - spec/unit/renderer/unicode/coloring_spec.rb
         
     | 
| 
       353 
372 
     | 
    
         
             
            - spec/unit/renderer/unicode/indentation_spec.rb
         
     | 
| 
       354 
373 
     | 
    
         
             
            - spec/unit/renderer/unicode/padding_spec.rb
         
     | 
| 
       355 
374 
     | 
    
         
             
            - spec/unit/renderer/unicode/render_spec.rb
         
     | 
| 
         @@ -366,6 +385,7 @@ test_files: 
     | 
|
| 
       366 
385 
     | 
    
         
             
            - spec/unit/row/to_ary_spec.rb
         
     | 
| 
       367 
386 
     | 
    
         
             
            - spec/unit/to_s_spec.rb
         
     | 
| 
       368 
387 
     | 
    
         
             
            - spec/unit/transformation/extract_tuples_spec.rb
         
     | 
| 
      
 388 
     | 
    
         
            +
            - spec/unit/utf_spec.rb
         
     | 
| 
       369 
389 
     | 
    
         
             
            - spec/unit/validatable/validate_options_spec.rb
         
     | 
| 
       370 
390 
     | 
    
         
             
            - spec/unit/validatable_spec.rb
         
     | 
| 
       371 
391 
     | 
    
         
             
            has_rdoc: 
         
     | 
| 
         @@ -1,103 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # encoding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            module TTY
         
     | 
| 
       4 
     | 
    
         
            -
              class Table
         
     | 
| 
       5 
     | 
    
         
            -
                module Operation
         
     | 
| 
       6 
     | 
    
         
            -
                  # A class which responsiblity is to align table rows and header.
         
     | 
| 
       7 
     | 
    
         
            -
                  class AlignmentSet
         
     | 
| 
       8 
     | 
    
         
            -
                    include Enumerable
         
     | 
| 
       9 
     | 
    
         
            -
                    # Initialize an AlignmentSet
         
     | 
| 
       10 
     | 
    
         
            -
                    #
         
     | 
| 
       11 
     | 
    
         
            -
                    # @api private
         
     | 
| 
       12 
     | 
    
         
            -
                    def initialize(aligns, widths = nil)
         
     | 
| 
       13 
     | 
    
         
            -
                      @converter = Necromancer.new
         
     | 
| 
       14 
     | 
    
         
            -
                      @elements = @converter.convert(aligns).to(:array)
         
     | 
| 
       15 
     | 
    
         
            -
                      @widths   = widths
         
     | 
| 
       16 
     | 
    
         
            -
                    end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                    # Iterate over each element in the alignment set
         
     | 
| 
       19 
     | 
    
         
            -
                    #
         
     | 
| 
       20 
     | 
    
         
            -
                    # @example
         
     | 
| 
       21 
     | 
    
         
            -
                    #   alignment = AlignmentSet.new [1,2,3]
         
     | 
| 
       22 
     | 
    
         
            -
                    #   alignment.each { |element| ... }
         
     | 
| 
       23 
     | 
    
         
            -
                    #
         
     | 
| 
       24 
     | 
    
         
            -
                    # @return [self]
         
     | 
| 
       25 
     | 
    
         
            -
                    #
         
     | 
| 
       26 
     | 
    
         
            -
                    # @api public
         
     | 
| 
       27 
     | 
    
         
            -
                    def each
         
     | 
| 
       28 
     | 
    
         
            -
                      return to_enum unless block_given?
         
     | 
| 
       29 
     | 
    
         
            -
                      to_ary.each { |element| yield element }
         
     | 
| 
       30 
     | 
    
         
            -
                      self
         
     | 
| 
       31 
     | 
    
         
            -
                    end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                    # Lookup an alignment by index
         
     | 
| 
       34 
     | 
    
         
            -
                    #
         
     | 
| 
       35 
     | 
    
         
            -
                    # @param [Integer]
         
     | 
| 
       36 
     | 
    
         
            -
                    #
         
     | 
| 
       37 
     | 
    
         
            -
                    # @return [Symbol] alignment
         
     | 
| 
       38 
     | 
    
         
            -
                    #
         
     | 
| 
       39 
     | 
    
         
            -
                    # @api public
         
     | 
| 
       40 
     | 
    
         
            -
                    def [](index)
         
     | 
| 
       41 
     | 
    
         
            -
                      elements.fetch(index, :left)
         
     | 
| 
       42 
     | 
    
         
            -
                    end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                    # Return each alignment in an Array
         
     | 
| 
       45 
     | 
    
         
            -
                    #
         
     | 
| 
       46 
     | 
    
         
            -
                    # @return [Array]
         
     | 
| 
       47 
     | 
    
         
            -
                    #
         
     | 
| 
       48 
     | 
    
         
            -
                    # @api private
         
     | 
| 
       49 
     | 
    
         
            -
                    def alignments
         
     | 
| 
       50 
     | 
    
         
            -
                      map { |alignment| alignment }
         
     | 
| 
       51 
     | 
    
         
            -
                    end
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                    # Evaluate alignment of the provided row
         
     | 
| 
       54 
     | 
    
         
            -
                    #
         
     | 
| 
       55 
     | 
    
         
            -
                    # @param [Array] row
         
     | 
| 
       56 
     | 
    
         
            -
                    #  the table row
         
     | 
| 
       57 
     | 
    
         
            -
                    # @param [Hash] options
         
     | 
| 
       58 
     | 
    
         
            -
                    #  the table options
         
     | 
| 
       59 
     | 
    
         
            -
                    #
         
     | 
| 
       60 
     | 
    
         
            -
                    # @return [TTY::Table::Field]
         
     | 
| 
       61 
     | 
    
         
            -
                    #
         
     | 
| 
       62 
     | 
    
         
            -
                    # @api public
         
     | 
| 
       63 
     | 
    
         
            -
                    def call(field, row, col)
         
     | 
| 
       64 
     | 
    
         
            -
                      align_field(field, col)
         
     | 
| 
       65 
     | 
    
         
            -
                    end
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
                    # Convert to array
         
     | 
| 
       68 
     | 
    
         
            -
                    #
         
     | 
| 
       69 
     | 
    
         
            -
                    #  @return [Array]
         
     | 
| 
       70 
     | 
    
         
            -
                    #
         
     | 
| 
       71 
     | 
    
         
            -
                    # @api public
         
     | 
| 
       72 
     | 
    
         
            -
                    def to_ary
         
     | 
| 
       73 
     | 
    
         
            -
                      @elements
         
     | 
| 
       74 
     | 
    
         
            -
                    end
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
                    protected
         
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
                    attr_reader :widths
         
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
                    attr_reader :elements
         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
                    # Align each field in a row
         
     | 
| 
       83 
     | 
    
         
            -
                    #
         
     | 
| 
       84 
     | 
    
         
            -
                    # @param [TTY::Table::Field] field
         
     | 
| 
       85 
     | 
    
         
            -
                    #   the table field
         
     | 
| 
       86 
     | 
    
         
            -
                    #
         
     | 
| 
       87 
     | 
    
         
            -
                    # @param [Integer] col
         
     | 
| 
       88 
     | 
    
         
            -
                    #   the table column index
         
     | 
| 
       89 
     | 
    
         
            -
                    #
         
     | 
| 
       90 
     | 
    
         
            -
                    # @param [Hash] options
         
     | 
| 
       91 
     | 
    
         
            -
                    #
         
     | 
| 
       92 
     | 
    
         
            -
                    # @return [TTY::Table::Field]
         
     | 
| 
       93 
     | 
    
         
            -
                    #
         
     | 
| 
       94 
     | 
    
         
            -
                    # @api private
         
     | 
| 
       95 
     | 
    
         
            -
                    def align_field(field, col)
         
     | 
| 
       96 
     | 
    
         
            -
                      column_width = widths[col]
         
     | 
| 
       97 
     | 
    
         
            -
                      direction    = field.align || self[col]
         
     | 
| 
       98 
     | 
    
         
            -
                      field.value = Verse.align(field.to_s, column_width, direction)
         
     | 
| 
       99 
     | 
    
         
            -
                    end
         
     | 
| 
       100 
     | 
    
         
            -
                  end # AlignmentSet
         
     | 
| 
       101 
     | 
    
         
            -
                end # Operation
         
     | 
| 
       102 
     | 
    
         
            -
              end # Table
         
     | 
| 
       103 
     | 
    
         
            -
            end # TTY
         
     |