tty-table 0.7.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +57 -0
- data/LICENSE.txt +1 -1
- data/README.md +165 -94
- data/lib/tty-table.rb +1 -5
- data/lib/tty/table.rb +102 -42
- data/lib/tty/table/alignment_set.rb +3 -6
- data/lib/tty/table/border.rb +57 -68
- data/lib/tty/table/border/ascii.rb +17 -17
- data/lib/tty/table/border/null.rb +20 -22
- data/lib/tty/table/border/row_line.rb +4 -3
- data/lib/tty/table/border/unicode.rb +17 -17
- data/lib/tty/table/border_dsl.rb +28 -25
- data/lib/tty/table/border_options.rb +50 -25
- data/lib/tty/table/column_constraint.rb +29 -17
- data/lib/tty/table/{column_set.rb → columns.rb} +44 -69
- data/lib/tty/table/empty.rb +2 -0
- data/lib/tty/table/error.rb +1 -1
- data/lib/tty/table/field.rb +43 -35
- data/lib/tty/table/header.rb +7 -5
- data/lib/tty/table/indentation.rb +16 -25
- data/lib/tty/table/operation/alignment.rb +10 -8
- data/lib/tty/table/operation/escape.rb +2 -3
- data/lib/tty/table/operation/filter.rb +1 -1
- data/lib/tty/table/operation/padding.rb +4 -12
- data/lib/tty/table/operation/truncation.rb +4 -4
- data/lib/tty/table/operation/wrapped.rb +4 -4
- data/lib/tty/table/operations.rb +4 -15
- data/lib/tty/table/options.rb +2 -4
- data/lib/tty/table/orientation.rb +5 -5
- data/lib/tty/table/orientation/horizontal.rb +1 -1
- data/lib/tty/table/orientation/vertical.rb +1 -1
- data/lib/tty/table/renderer.rb +40 -35
- data/lib/tty/table/renderer/ascii.rb +4 -4
- data/lib/tty/table/renderer/basic.rb +85 -88
- data/lib/tty/table/renderer/unicode.rb +3 -3
- data/lib/tty/table/row.rb +10 -8
- data/lib/tty/table/transformation.rb +2 -2
- data/lib/tty/table/validatable.rb +25 -7
- data/lib/tty/table/version.rb +3 -3
- metadata +33 -283
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.travis.yml +0 -24
- data/CODE_OF_CONDUCT.md +0 -49
- data/Gemfile +0 -18
- data/Rakefile +0 -8
- data/benchmarks/speed.rb +0 -41
- data/spec/spec_helper.rb +0 -50
- data/spec/unit/access_spec.rb +0 -86
- data/spec/unit/add_row_spec.rb +0 -28
- data/spec/unit/alignment_set/each_spec.rb +0 -17
- data/spec/unit/alignment_set/new_spec.rb +0 -27
- data/spec/unit/alignment_set/to_ary_spec.rb +0 -14
- data/spec/unit/alignment_spec.rb +0 -71
- data/spec/unit/border/ascii/rendering_spec.rb +0 -90
- data/spec/unit/border/new_spec.rb +0 -27
- data/spec/unit/border/null/rendering_spec.rb +0 -130
- data/spec/unit/border/options/from_spec.rb +0 -38
- data/spec/unit/border/options/new_spec.rb +0 -14
- data/spec/unit/border/unicode/rendering_spec.rb +0 -63
- data/spec/unit/border_options/new_spec.rb +0 -20
- data/spec/unit/border_options/update_spec.rb +0 -18
- data/spec/unit/column_constraint/enforce_spec.rb +0 -70
- data/spec/unit/column_constraint/widths_spec.rb +0 -35
- data/spec/unit/column_set/extract_widths_spec.rb +0 -48
- data/spec/unit/column_set/total_width_spec.rb +0 -15
- data/spec/unit/column_set/widths_from_spec.rb +0 -51
- data/spec/unit/data_spec.rb +0 -12
- data/spec/unit/each_spec.rb +0 -26
- data/spec/unit/each_with_index_spec.rb +0 -51
- data/spec/unit/empty_spec.rb +0 -23
- data/spec/unit/eql_spec.rb +0 -34
- data/spec/unit/field/equality_spec.rb +0 -51
- data/spec/unit/field/length_spec.rb +0 -35
- data/spec/unit/field/lines_spec.rb +0 -21
- data/spec/unit/field/new_spec.rb +0 -29
- data/spec/unit/field/width_spec.rb +0 -23
- data/spec/unit/filter_spec.rb +0 -22
- data/spec/unit/header/call_spec.rb +0 -30
- data/spec/unit/header/color_spec.rb +0 -19
- data/spec/unit/header/equality_spec.rb +0 -51
- data/spec/unit/header/height_spec.rb +0 -27
- data/spec/unit/header/new_spec.rb +0 -16
- data/spec/unit/header/set_spec.rb +0 -20
- data/spec/unit/header/to_ary_spec.rb +0 -14
- data/spec/unit/header_spec.rb +0 -13
- data/spec/unit/indentation/indent_spec.rb +0 -21
- data/spec/unit/new_spec.rb +0 -73
- data/spec/unit/operation/alignment/call_spec.rb +0 -39
- data/spec/unit/operation/escape/call_spec.rb +0 -15
- data/spec/unit/operation/filter/call_spec.rb +0 -16
- data/spec/unit/operation/truncation/call_spec.rb +0 -30
- data/spec/unit/operation/wrapped/call_spec.rb +0 -40
- data/spec/unit/operations/new_spec.rb +0 -30
- data/spec/unit/options/access_spec.rb +0 -14
- data/spec/unit/options_spec.rb +0 -25
- data/spec/unit/orientation_spec.rb +0 -145
- data/spec/unit/padding_spec.rb +0 -117
- data/spec/unit/properties_spec.rb +0 -25
- data/spec/unit/render_repeat_spec.rb +0 -42
- data/spec/unit/render_spec.rb +0 -63
- data/spec/unit/render_with_spec.rb +0 -106
- data/spec/unit/renderer/ascii/coloring_spec.rb +0 -70
- data/spec/unit/renderer/ascii/indentation_spec.rb +0 -41
- data/spec/unit/renderer/ascii/multiline_spec.rb +0 -101
- data/spec/unit/renderer/ascii/padding_spec.rb +0 -88
- data/spec/unit/renderer/ascii/render_spec.rb +0 -68
- data/spec/unit/renderer/ascii/resizing_spec.rb +0 -114
- data/spec/unit/renderer/ascii/separator_spec.rb +0 -28
- data/spec/unit/renderer/basic/alignment_spec.rb +0 -88
- data/spec/unit/renderer/basic/coloring_spec.rb +0 -61
- data/spec/unit/renderer/basic/extract_column_widths_spec.rb +0 -28
- data/spec/unit/renderer/basic/filter_spec.rb +0 -53
- data/spec/unit/renderer/basic/indentation_spec.rb +0 -48
- data/spec/unit/renderer/basic/multiline_spec.rb +0 -74
- data/spec/unit/renderer/basic/new_spec.rb +0 -26
- data/spec/unit/renderer/basic/options_spec.rb +0 -52
- data/spec/unit/renderer/basic/padding_spec.rb +0 -76
- data/spec/unit/renderer/basic/render_spec.rb +0 -57
- data/spec/unit/renderer/basic/resizing_spec.rb +0 -96
- data/spec/unit/renderer/basic/separator_spec.rb +0 -43
- data/spec/unit/renderer/basic/truncation_spec.rb +0 -35
- data/spec/unit/renderer/basic/wrapping_spec.rb +0 -40
- data/spec/unit/renderer/border_spec.rb +0 -104
- data/spec/unit/renderer/render_spec.rb +0 -36
- data/spec/unit/renderer/select_spec.rb +0 -22
- data/spec/unit/renderer/unicode/coloring_spec.rb +0 -70
- data/spec/unit/renderer/unicode/indentation_spec.rb +0 -41
- data/spec/unit/renderer/unicode/padding_spec.rb +0 -61
- data/spec/unit/renderer/unicode/render_spec.rb +0 -68
- data/spec/unit/renderer/unicode/separator_spec.rb +0 -26
- data/spec/unit/renderer_spec.rb +0 -19
- data/spec/unit/rotate_spec.rb +0 -86
- data/spec/unit/row/access_spec.rb +0 -25
- data/spec/unit/row/call_spec.rb +0 -45
- data/spec/unit/row/data_spec.rb +0 -26
- data/spec/unit/row/each_spec.rb +0 -31
- data/spec/unit/row/equality_spec.rb +0 -73
- data/spec/unit/row/height_spec.rb +0 -27
- data/spec/unit/row/new_spec.rb +0 -41
- data/spec/unit/row/to_ary_spec.rb +0 -14
- data/spec/unit/to_s_spec.rb +0 -56
- data/spec/unit/transformation/extract_tuples_spec.rb +0 -35
- data/spec/unit/utf_spec.rb +0 -33
- data/spec/unit/validatable/validate_options_spec.rb +0 -33
- data/spec/unit/validatable_spec.rb +0 -32
- data/tasks/console.rake +0 -10
- data/tasks/coverage.rake +0 -11
- data/tasks/spec.rake +0 -29
- data/tty-table.gemspec +0 -30
@@ -1,35 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe TTY::Table::Transformation, '#extract_tuples' do
|
6
|
-
let(:object) { described_class }
|
7
|
-
let(:header) { ['Header1', 'Header2'] }
|
8
|
-
let(:rows) { [['a1', 'a2'], ['b1', 'b2']] }
|
9
|
-
|
10
|
-
subject { object.extract_tuples(value) }
|
11
|
-
|
12
|
-
context 'when rows' do
|
13
|
-
let(:value) { [rows] }
|
14
|
-
|
15
|
-
it { expect(subject[:header]).to be_nil }
|
16
|
-
|
17
|
-
it { expect(subject[:rows]).to eql(rows) }
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'when header and rows' do
|
21
|
-
let(:value) { [header, rows] }
|
22
|
-
|
23
|
-
it { expect(subject[:header]).to eql(header) }
|
24
|
-
|
25
|
-
it { expect(subject[:rows]).to eql(rows) }
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'when hash' do
|
29
|
-
let(:value) { [[{'Header1' => ['a1', 'a2'], 'Header2' => ['b1', 'b2'] }]] }
|
30
|
-
|
31
|
-
it { expect(subject[:header]).to eql(header) }
|
32
|
-
|
33
|
-
it { expect(subject[:rows]).to eql(rows) }
|
34
|
-
end
|
35
|
-
end
|
data/spec/unit/utf_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
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
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe TTY::Table::Validatable, '#validate_options!' do
|
6
|
-
let(:described_class) { Class.new { include TTY::Table::Validatable } }
|
7
|
-
|
8
|
-
subject { described_class.new.validate_options! options }
|
9
|
-
|
10
|
-
context 'with empty rows' do
|
11
|
-
let(:options) { {rows: []} }
|
12
|
-
|
13
|
-
it { expect { subject }.not_to raise_error() }
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'with invalid rows type' do
|
17
|
-
let(:options) { {rows: 1 } }
|
18
|
-
|
19
|
-
it { expect { subject }.to raise_error(TTY::Table::InvalidArgument) }
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'with empty header' do
|
23
|
-
let(:options) { {header: []} }
|
24
|
-
|
25
|
-
it { expect { subject }.to raise_error(TTY::Table::InvalidArgument) }
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'with invalid header type' do
|
29
|
-
let(:options) { {header: 1} }
|
30
|
-
|
31
|
-
it { expect { subject }.to raise_error(TTY::Table::InvalidArgument) }
|
32
|
-
end
|
33
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe TTY::Table::Validatable do
|
6
|
-
let(:described_class) { Class.new { include TTY::Table::Validatable } }
|
7
|
-
let(:rows) { [['a1', 'a2'], ['b1']] }
|
8
|
-
|
9
|
-
subject { described_class.new }
|
10
|
-
|
11
|
-
it 'raises no exception' do
|
12
|
-
rows[1] << ['b2']
|
13
|
-
expect { subject.assert_row_sizes(rows) }.not_to raise_error
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'raises exception for mismatched rows' do
|
17
|
-
expect { subject.assert_row_sizes(rows) }.
|
18
|
-
to raise_error(TTY::Table::DimensionMismatchError)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "raises exception when :header key has wrong data type" do
|
22
|
-
options = {header: 'h1'}
|
23
|
-
expect { subject.validate_options!(options) }.
|
24
|
-
to raise_error(TTY::Table::InvalidArgument)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "raises exception when :rows key has wrong data type" do
|
28
|
-
options = {rows: 'a1'}
|
29
|
-
expect { subject.validate_options!(options) }.
|
30
|
-
to raise_error(TTY::Table::InvalidArgument)
|
31
|
-
end
|
32
|
-
end
|
data/tasks/console.rake
DELETED
data/tasks/coverage.rake
DELETED
data/tasks/spec.rake
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
|
6
|
-
desc 'Run all specs'
|
7
|
-
RSpec::Core::RakeTask.new(:spec) do |task|
|
8
|
-
task.pattern = 'spec/{unit,integration}{,/*/**}/*_spec.rb'
|
9
|
-
end
|
10
|
-
|
11
|
-
namespace :spec do
|
12
|
-
desc 'Run unit specs'
|
13
|
-
RSpec::Core::RakeTask.new(:unit) do |task|
|
14
|
-
task.pattern = 'spec/unit{,/*/**}/*_spec.rb'
|
15
|
-
end
|
16
|
-
|
17
|
-
desc 'Run integration specs'
|
18
|
-
RSpec::Core::RakeTask.new(:integration) do |task|
|
19
|
-
task.pattern = 'spec/integration{,/*/**}/*_spec.rb'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
rescue LoadError
|
24
|
-
%w[spec spec:unit spec:integration].each do |name|
|
25
|
-
task name do
|
26
|
-
$stderr.puts "In order to run #{name}, do `gem install rspec`"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/tty-table.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'tty/table/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'tty-table'
|
8
|
-
spec.version = TTY::Table::VERSION
|
9
|
-
spec.authors = ["Piotr Murach"]
|
10
|
-
spec.email = [""]
|
11
|
-
spec.summary = %q{A flexible and intuitive table generator}
|
12
|
-
spec.description = %q{A flexible and intuitive table generator}
|
13
|
-
spec.homepage = "http://piotrmurach.github.io/tty/"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_dependency 'equatable', '~> 0.5.0'
|
22
|
-
spec.add_dependency 'necromancer', '~> 0.3.0'
|
23
|
-
spec.add_dependency 'pastel', '~> 0.7.0'
|
24
|
-
spec.add_dependency 'tty-screen', '~> 0.5.0'
|
25
|
-
spec.add_dependency 'verse', '~> 0.5.0'
|
26
|
-
spec.add_dependency 'unicode-display_width','~> 1.1.0'
|
27
|
-
|
28
|
-
spec.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0'
|
29
|
-
spec.add_development_dependency 'rake'
|
30
|
-
end
|