tty-table 0.7.0 → 0.12.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.
Files changed (151) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +57 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +165 -94
  5. data/lib/tty-table.rb +1 -5
  6. data/lib/tty/table.rb +102 -42
  7. data/lib/tty/table/alignment_set.rb +3 -6
  8. data/lib/tty/table/border.rb +57 -68
  9. data/lib/tty/table/border/ascii.rb +17 -17
  10. data/lib/tty/table/border/null.rb +20 -22
  11. data/lib/tty/table/border/row_line.rb +4 -3
  12. data/lib/tty/table/border/unicode.rb +17 -17
  13. data/lib/tty/table/border_dsl.rb +28 -25
  14. data/lib/tty/table/border_options.rb +50 -25
  15. data/lib/tty/table/column_constraint.rb +29 -17
  16. data/lib/tty/table/{column_set.rb → columns.rb} +44 -69
  17. data/lib/tty/table/empty.rb +2 -0
  18. data/lib/tty/table/error.rb +1 -1
  19. data/lib/tty/table/field.rb +43 -35
  20. data/lib/tty/table/header.rb +7 -5
  21. data/lib/tty/table/indentation.rb +16 -25
  22. data/lib/tty/table/operation/alignment.rb +10 -8
  23. data/lib/tty/table/operation/escape.rb +2 -3
  24. data/lib/tty/table/operation/filter.rb +1 -1
  25. data/lib/tty/table/operation/padding.rb +4 -12
  26. data/lib/tty/table/operation/truncation.rb +4 -4
  27. data/lib/tty/table/operation/wrapped.rb +4 -4
  28. data/lib/tty/table/operations.rb +4 -15
  29. data/lib/tty/table/options.rb +2 -4
  30. data/lib/tty/table/orientation.rb +5 -5
  31. data/lib/tty/table/orientation/horizontal.rb +1 -1
  32. data/lib/tty/table/orientation/vertical.rb +1 -1
  33. data/lib/tty/table/renderer.rb +40 -35
  34. data/lib/tty/table/renderer/ascii.rb +4 -4
  35. data/lib/tty/table/renderer/basic.rb +85 -88
  36. data/lib/tty/table/renderer/unicode.rb +3 -3
  37. data/lib/tty/table/row.rb +10 -8
  38. data/lib/tty/table/transformation.rb +2 -2
  39. data/lib/tty/table/validatable.rb +25 -7
  40. data/lib/tty/table/version.rb +3 -3
  41. metadata +33 -283
  42. data/.gitignore +0 -14
  43. data/.rspec +0 -3
  44. data/.travis.yml +0 -24
  45. data/CODE_OF_CONDUCT.md +0 -49
  46. data/Gemfile +0 -18
  47. data/Rakefile +0 -8
  48. data/benchmarks/speed.rb +0 -41
  49. data/spec/spec_helper.rb +0 -50
  50. data/spec/unit/access_spec.rb +0 -86
  51. data/spec/unit/add_row_spec.rb +0 -28
  52. data/spec/unit/alignment_set/each_spec.rb +0 -17
  53. data/spec/unit/alignment_set/new_spec.rb +0 -27
  54. data/spec/unit/alignment_set/to_ary_spec.rb +0 -14
  55. data/spec/unit/alignment_spec.rb +0 -71
  56. data/spec/unit/border/ascii/rendering_spec.rb +0 -90
  57. data/spec/unit/border/new_spec.rb +0 -27
  58. data/spec/unit/border/null/rendering_spec.rb +0 -130
  59. data/spec/unit/border/options/from_spec.rb +0 -38
  60. data/spec/unit/border/options/new_spec.rb +0 -14
  61. data/spec/unit/border/unicode/rendering_spec.rb +0 -63
  62. data/spec/unit/border_options/new_spec.rb +0 -20
  63. data/spec/unit/border_options/update_spec.rb +0 -18
  64. data/spec/unit/column_constraint/enforce_spec.rb +0 -70
  65. data/spec/unit/column_constraint/widths_spec.rb +0 -35
  66. data/spec/unit/column_set/extract_widths_spec.rb +0 -48
  67. data/spec/unit/column_set/total_width_spec.rb +0 -15
  68. data/spec/unit/column_set/widths_from_spec.rb +0 -51
  69. data/spec/unit/data_spec.rb +0 -12
  70. data/spec/unit/each_spec.rb +0 -26
  71. data/spec/unit/each_with_index_spec.rb +0 -51
  72. data/spec/unit/empty_spec.rb +0 -23
  73. data/spec/unit/eql_spec.rb +0 -34
  74. data/spec/unit/field/equality_spec.rb +0 -51
  75. data/spec/unit/field/length_spec.rb +0 -35
  76. data/spec/unit/field/lines_spec.rb +0 -21
  77. data/spec/unit/field/new_spec.rb +0 -29
  78. data/spec/unit/field/width_spec.rb +0 -23
  79. data/spec/unit/filter_spec.rb +0 -22
  80. data/spec/unit/header/call_spec.rb +0 -30
  81. data/spec/unit/header/color_spec.rb +0 -19
  82. data/spec/unit/header/equality_spec.rb +0 -51
  83. data/spec/unit/header/height_spec.rb +0 -27
  84. data/spec/unit/header/new_spec.rb +0 -16
  85. data/spec/unit/header/set_spec.rb +0 -20
  86. data/spec/unit/header/to_ary_spec.rb +0 -14
  87. data/spec/unit/header_spec.rb +0 -13
  88. data/spec/unit/indentation/indent_spec.rb +0 -21
  89. data/spec/unit/new_spec.rb +0 -73
  90. data/spec/unit/operation/alignment/call_spec.rb +0 -39
  91. data/spec/unit/operation/escape/call_spec.rb +0 -15
  92. data/spec/unit/operation/filter/call_spec.rb +0 -16
  93. data/spec/unit/operation/truncation/call_spec.rb +0 -30
  94. data/spec/unit/operation/wrapped/call_spec.rb +0 -40
  95. data/spec/unit/operations/new_spec.rb +0 -30
  96. data/spec/unit/options/access_spec.rb +0 -14
  97. data/spec/unit/options_spec.rb +0 -25
  98. data/spec/unit/orientation_spec.rb +0 -145
  99. data/spec/unit/padding_spec.rb +0 -117
  100. data/spec/unit/properties_spec.rb +0 -25
  101. data/spec/unit/render_repeat_spec.rb +0 -42
  102. data/spec/unit/render_spec.rb +0 -63
  103. data/spec/unit/render_with_spec.rb +0 -106
  104. data/spec/unit/renderer/ascii/coloring_spec.rb +0 -70
  105. data/spec/unit/renderer/ascii/indentation_spec.rb +0 -41
  106. data/spec/unit/renderer/ascii/multiline_spec.rb +0 -101
  107. data/spec/unit/renderer/ascii/padding_spec.rb +0 -88
  108. data/spec/unit/renderer/ascii/render_spec.rb +0 -68
  109. data/spec/unit/renderer/ascii/resizing_spec.rb +0 -114
  110. data/spec/unit/renderer/ascii/separator_spec.rb +0 -28
  111. data/spec/unit/renderer/basic/alignment_spec.rb +0 -88
  112. data/spec/unit/renderer/basic/coloring_spec.rb +0 -61
  113. data/spec/unit/renderer/basic/extract_column_widths_spec.rb +0 -28
  114. data/spec/unit/renderer/basic/filter_spec.rb +0 -53
  115. data/spec/unit/renderer/basic/indentation_spec.rb +0 -48
  116. data/spec/unit/renderer/basic/multiline_spec.rb +0 -74
  117. data/spec/unit/renderer/basic/new_spec.rb +0 -26
  118. data/spec/unit/renderer/basic/options_spec.rb +0 -52
  119. data/spec/unit/renderer/basic/padding_spec.rb +0 -76
  120. data/spec/unit/renderer/basic/render_spec.rb +0 -57
  121. data/spec/unit/renderer/basic/resizing_spec.rb +0 -96
  122. data/spec/unit/renderer/basic/separator_spec.rb +0 -43
  123. data/spec/unit/renderer/basic/truncation_spec.rb +0 -35
  124. data/spec/unit/renderer/basic/wrapping_spec.rb +0 -40
  125. data/spec/unit/renderer/border_spec.rb +0 -104
  126. data/spec/unit/renderer/render_spec.rb +0 -36
  127. data/spec/unit/renderer/select_spec.rb +0 -22
  128. data/spec/unit/renderer/unicode/coloring_spec.rb +0 -70
  129. data/spec/unit/renderer/unicode/indentation_spec.rb +0 -41
  130. data/spec/unit/renderer/unicode/padding_spec.rb +0 -61
  131. data/spec/unit/renderer/unicode/render_spec.rb +0 -68
  132. data/spec/unit/renderer/unicode/separator_spec.rb +0 -26
  133. data/spec/unit/renderer_spec.rb +0 -19
  134. data/spec/unit/rotate_spec.rb +0 -86
  135. data/spec/unit/row/access_spec.rb +0 -25
  136. data/spec/unit/row/call_spec.rb +0 -45
  137. data/spec/unit/row/data_spec.rb +0 -26
  138. data/spec/unit/row/each_spec.rb +0 -31
  139. data/spec/unit/row/equality_spec.rb +0 -73
  140. data/spec/unit/row/height_spec.rb +0 -27
  141. data/spec/unit/row/new_spec.rb +0 -41
  142. data/spec/unit/row/to_ary_spec.rb +0 -14
  143. data/spec/unit/to_s_spec.rb +0 -56
  144. data/spec/unit/transformation/extract_tuples_spec.rb +0 -35
  145. data/spec/unit/utf_spec.rb +0 -33
  146. data/spec/unit/validatable/validate_options_spec.rb +0 -33
  147. data/spec/unit/validatable_spec.rb +0 -32
  148. data/tasks/console.rake +0 -10
  149. data/tasks/coverage.rake +0 -11
  150. data/tasks/spec.rake +0 -29
  151. data/tty-table.gemspec +0 -30
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --require spec_helper
3
- --warnings
@@ -1,24 +0,0 @@
1
- ---
2
- language: ruby
3
- sudo: false
4
- cache: bundler
5
- bundler_args: --without yard benchmarks
6
- script: "bundle exec rake ci"
7
- rvm:
8
- - 2.0.0
9
- - 2.1.10
10
- - 2.2.6
11
- - 2.3.3
12
- - 2.4.0
13
- - ruby-head
14
- - jruby-9.1.1.0
15
- - jruby-head
16
- matrix:
17
- allow_failures:
18
- - rvm: ruby-head
19
- - rvm: jruby-head
20
- fast_finish: true
21
- branches:
22
- only: master
23
- notifications:
24
- email: false
@@ -1,49 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, and in the interest of
4
- fostering an open and welcoming community, we pledge to respect all people who
5
- contribute through reporting issues, posting feature requests, updating
6
- documentation, submitting pull requests or patches, and other activities.
7
-
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, ethnicity, age, religion, or nationality.
12
-
13
- Examples of unacceptable behavior by participants include:
14
-
15
- * The use of sexualized language or imagery
16
- * Personal attacks
17
- * Trolling or insulting/derogatory comments
18
- * Public or private harassment
19
- * Publishing other's private information, such as physical or electronic
20
- addresses, without explicit permission
21
- * Other unethical or unprofessional conduct
22
-
23
- Project maintainers have the right and responsibility to remove, edit, or
24
- reject comments, commits, code, wiki edits, issues, and other contributions
25
- that are not aligned to this Code of Conduct, or to ban temporarily or
26
- permanently any contributor for other behaviors that they deem inappropriate,
27
- threatening, offensive, or harmful.
28
-
29
- By adopting this Code of Conduct, project maintainers commit themselves to
30
- fairly and consistently applying these principles to every aspect of managing
31
- this project. Project maintainers who do not follow or enforce the Code of
32
- Conduct may be permanently removed from the project team.
33
-
34
- This code of conduct applies both within project spaces and in public spaces
35
- when an individual is representing the project or its community.
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at [email]. All
39
- complaints will be reviewed and investigated and will result in a response that
40
- is deemed necessary and appropriate to the circumstances. Maintainers are
41
- obligated to maintain confidentiality with regard to the reporter of an
42
- incident.
43
-
44
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
- version 1.3.0, available at
46
- [http://contributor-covenant.org/version/1/3/0/][version]
47
-
48
- [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile DELETED
@@ -1,18 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- group :tools do
6
- gem 'rspec', '~> 3.5.0'
7
- gem 'yard', '~> 0.8.7'
8
- end
9
-
10
- group :metrics do
11
- gem 'coveralls', '~> 0.8.2'
12
- gem 'simplecov', '~> 0.10.0'
13
- gem 'yardstick', '~> 0.9.9'
14
- end
15
-
16
- group :benchmarks do
17
- gem 'benchmark_suite', '~> 1.0.0'
18
- end
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # coding: utf-8
2
-
3
- require "bundler/gem_tasks"
4
-
5
- FileList['tasks/**/*.rake'].each(&method(:import))
6
-
7
- desc 'Run all specs'
8
- task ci: %w[ spec ]
@@ -1,41 +0,0 @@
1
- # coding: utf-8
2
-
3
- # Benchmark speed of table operations
4
-
5
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
6
-
7
- require 'tty-table'
8
- require 'benchmark'
9
- require 'benchmark/ips'
10
-
11
- header = [:name, :color]
12
- rows = (1..100).map { |n| ["row#{n}", "red"] }
13
- table = TTY::Table.new(header, rows)
14
-
15
- Benchmark.ips do |r|
16
- r.report("Ruby #to_s") do
17
- rows.to_s
18
- end
19
-
20
- r.report("TTY #render") do
21
- table.render
22
- end
23
-
24
- r.report("TTY #render ASCII") do
25
- table.render(:ascii)
26
- end
27
-
28
- r.report("TTY #render Unicode") do
29
- table.render(:unicode)
30
- end
31
-
32
- r.report("TTY #render Color") do
33
- table.render(:ascii, border: {style: :red})
34
- end
35
- end
36
-
37
- # Ruby #to_s 2588.6 (±12.2%) i/s - 12948 in 5.084883s
38
- # TTY #render 20.8 (±9.6%) i/s - 104 in 5.030159s
39
- # TTY #render ASCII 18.1 (±16.5%) i/s - 89 in 5.041230s
40
- # TTY #render Unicode 18.0 (±16.7%) i/s - 88 in 5.029868s
41
- # TTY #render Color 11.7 (±17.1%) i/s - 58 in 5.071654s
@@ -1,50 +0,0 @@
1
- # coding: utf-8
2
-
3
- if RUBY_VERSION > '1.9' and (ENV['COVERAGE'] || ENV['TRAVIS'])
4
- require 'simplecov'
5
- require 'coveralls'
6
-
7
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
8
- SimpleCov::Formatter::HTMLFormatter,
9
- Coveralls::SimpleCov::Formatter
10
- ]
11
-
12
- SimpleCov.start do
13
- command_name 'spec'
14
- add_filter 'spec'
15
- end
16
- end
17
-
18
- require 'tty-table'
19
-
20
- RSpec.configure do |config|
21
- config.expect_with :rspec do |expectations|
22
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
23
- end
24
-
25
- config.mock_with :rspec do |mocks|
26
- mocks.verify_partial_doubles = true
27
- end
28
-
29
- # Limits the available syntax to the non-monkey patched syntax that is recommended.
30
- config.disable_monkey_patching!
31
-
32
- # This setting enables warnings. It's recommended, but in some cases may
33
- # be too noisy due to issues in dependencies.
34
- config.warnings = true
35
-
36
- if config.files_to_run.one?
37
- config.default_formatter = 'doc'
38
- end
39
-
40
- config.profile_examples = 2
41
-
42
- config.order = :random
43
-
44
- Kernel.srand config.seed
45
- end
46
-
47
- def unindent(string)
48
- prefix = string.scan(/^[ \t]+(?=\S)/).min
49
- string.gsub(/^#{prefix}/, '').chomp
50
- end
@@ -1,86 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::Table, 'access' do
6
- let(:header) { [:head1, :head2] }
7
- let(:rows) { [['a1', 'a2'], ['b1', 'b2']] }
8
-
9
- subject(:table) { TTY::Table.new rows: rows, header: header }
10
-
11
- it { is_expected.to respond_to(:element) }
12
-
13
- it { is_expected.to respond_to(:component) }
14
-
15
- it { is_expected.to respond_to(:at) }
16
-
17
- context 'when array like access' do
18
- it { expect(table[0,0]).to eq('a1') }
19
-
20
- it { expect(table[0]).to eq(['a1','a2']) }
21
-
22
- it { expect(table[5]).to eq(nil) }
23
-
24
- it { expect(table[-1]).to eq(['b1','b2']) }
25
-
26
- it { expect(table[5,5]).to eq(nil) }
27
-
28
- it 'raises error for negative indices' do
29
- expect { table[-5,-5] }.to raise_error(IndexError)
30
- end
31
- end
32
-
33
- context '#row' do
34
- it 'returns nil for wrong index' do
35
- expect(table.row(11)).to be_nil
36
- end
37
-
38
- it 'gets row at index' do
39
- expect(table.row(1)).to eq(rows[1])
40
- end
41
-
42
- it 'yields self for wrong index' do
43
- block = lambda { |el| [] << el }
44
- expect(table.row(11, &block)).to eq(table)
45
- end
46
-
47
- it 'yields row at index' do
48
- yields = []
49
- expect {
50
- table.row(1).each { |el| yields << el }
51
- }.to change { yields }.from( [] ).to( rows[1] )
52
- end
53
- end
54
-
55
- context '#column' do
56
- it "gets based on header name" do
57
- expect(table.column(:head1)).to eq(['a1', 'b1'])
58
- end
59
-
60
- it "yields based on header name" do
61
- yielded = []
62
- table.column(:head1) { |el| yielded << el }
63
- expect(yielded).to eql(['a1', 'b1'])
64
- end
65
-
66
- it 'returns nil for wrong index' do
67
- expect(table.column(11)).to be_nil
68
- end
69
-
70
- it 'gets column at index' do
71
- expect(table.column(0)).to eq(['a1', 'b1'])
72
- end
73
-
74
- it 'yields self for wrong index' do
75
- block = lambda { |el| [] << el }
76
- expect(table.column(11, &block)).to eq(table)
77
- end
78
-
79
- it 'yields column at index' do
80
- yields = []
81
- expect {
82
- table.column(1).each { |el| yields << el }
83
- }.to change { yields }.from( [] ).to( ['a2', 'b2'])
84
- end
85
- end
86
- end
@@ -1,28 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::Table, '#<<' do
6
- let(:rows) { ['a', 'b', 'c'] }
7
- let(:object) { described_class }
8
-
9
- subject(:table) { object[rows] }
10
-
11
- context 'with primitive values' do
12
- let(:row) { [1, 2, 3] }
13
-
14
- it 'extracts values correctly' do
15
- table << row
16
- expect(table.to_a.last).to eql(row)
17
- end
18
- end
19
-
20
- context 'with complex values' do
21
- let(:row) { [1, { value: 2 }, 3] }
22
-
23
- it 'extracts values correctly' do
24
- table << row
25
- expect(table.to_a.last).to eql([1,2,3])
26
- end
27
- end
28
- end
@@ -1,17 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::Table::AlignmentSet, '#each' do
6
- let(:alignments) { [:left, :center, :right] }
7
- let(:yields) { [] }
8
- let(:object) { described_class.new alignments }
9
-
10
- subject { object.each { |alignment| yields << alignment } }
11
-
12
- it 'yields each alignment' do
13
- expect { subject }.to change { yields.dup }.
14
- from([]).
15
- to(alignments)
16
- end
17
- end
@@ -1,27 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::Table::AlignmentSet, '#new' do
6
- let(:object) { described_class }
7
-
8
- subject(:alignment_set) { object.new(argument) }
9
-
10
- context 'with no argument' do
11
- let(:argument) { [] }
12
-
13
- it { is_expected.to be_kind_of(Enumerable) }
14
-
15
- it { is_expected.to be_instance_of(object) }
16
-
17
- it { expect(alignment_set.to_a).to eq([]) }
18
- end
19
-
20
- context 'with argument' do
21
- let(:argument) { [:center, :left] }
22
-
23
- it { is_expected.to be_instance_of(object) }
24
-
25
- it { expect(alignment_set.to_a).to eq(argument) }
26
- end
27
- end
@@ -1,14 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::Table::AlignmentSet, '#to_ary' do
6
- let(:argument) { [:center, :left] }
7
- let(:object) { described_class.new argument }
8
-
9
- subject { object.to_ary }
10
-
11
- it { is_expected.to be_instance_of(Array) }
12
-
13
- it { is_expected.to eq(argument) }
14
- end
@@ -1,71 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::Table, 'alignment' do
6
- it "aligns table columns when rendering" do
7
- table = TTY::Table.new ['header1', 'header2'], [['a1','a2'],['b1','b2']]
8
- expect(table.render(alignments: [:right, :center])).to eql([
9
- "header1 header2",
10
- " a1 a2 ",
11
- " b1 b2 "
12
- ].join("\n"))
13
- end
14
-
15
- it "uses default alignment when too few alignments provided" do
16
- table = TTY::Table.new ['header1', 'header2'], [['a1','a2'],['b1','b2']]
17
- expect(table.render(alignments: [:right])).to eql([
18
- "header1 header2",
19
- " a1 a2 ",
20
- " b1 b2 "
21
- ].join("\n"))
22
- end
23
-
24
- it "aligns table columns without header when rendering" do
25
- table = TTY::Table.new [['aaaaa1','a2'],['b1','bbbbb2']]
26
- expect(table.render(alignments: [:right, :center])).to eql([
27
- "aaaaa1 a2 ",
28
- " b1 bbbbb2"
29
- ].join("\n"))
30
- end
31
-
32
- it "aligns individual fields when rendering" do
33
- table = TTY::Table.new header: ['header1', 'header2']
34
- table << ['a1', {value: 'a2', alignment: :center}]
35
- table << [{value: 'b1', alignment: :right}, 'b2']
36
- expect(table.render).to eql([
37
- "header1 header2",
38
- "a1 a2 ",
39
- " b1 b2 "
40
- ].join("\n"))
41
- end
42
-
43
- it "prioritizes individual field options over table rendering options" do
44
- table = TTY::Table.new header: ['header1', 'header2']
45
- table << [{value: 'a1', alignment: :center},'a2']
46
- table << ['b1','b2']
47
- expect(table.render(alignments: [:right, :center])).to eql([
48
- "header1 header2",
49
- " a1 a2 ",
50
- " b1 b2 "
51
- ].join("\n"))
52
- end
53
-
54
- it "allows to align all columns at once" do
55
- table = TTY::Table.new ['header1', 'header2'], [['a1','a2'],['b1','b2']]
56
- expect(table.render(alignment: [:center])).to eql([
57
- "header1 header2",
58
- " a1 a2 ",
59
- " b1 b2 "
60
- ].join("\n"))
61
- end
62
-
63
- xit "aligns specific column" do
64
- table = TTY::Table.new ['header1', 'header2'], [['a1','a2'],['b1','b2']]
65
- expect(table.render(column_alignment: [1, :center])).to eql([
66
- "header1 header2",
67
- "a1 a2 ",
68
- "b1 b2 "
69
- ].join("\n"))
70
- end
71
- end