tty-table 0.10.0 → 0.11.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 +13 -0
- data/README.md +67 -3
- data/Rakefile +2 -0
- data/lib/tty-table.rb +0 -3
- data/lib/tty/table.rb +35 -12
- data/lib/tty/table/alignment_set.rb +2 -2
- data/lib/tty/table/border.rb +6 -3
- data/lib/tty/table/border/ascii.rb +1 -1
- data/lib/tty/table/border/null.rb +3 -2
- data/lib/tty/table/border/row_line.rb +1 -1
- data/lib/tty/table/border/unicode.rb +1 -2
- data/lib/tty/table/border_dsl.rb +3 -3
- data/lib/tty/table/border_options.rb +21 -1
- data/lib/tty/table/column_constraint.rb +1 -1
- data/lib/tty/table/columns.rb +0 -1
- data/lib/tty/table/empty.rb +2 -0
- data/lib/tty/table/error.rb +1 -1
- data/lib/tty/table/field.rb +1 -1
- data/lib/tty/table/header.rb +1 -1
- data/lib/tty/table/indentation.rb +2 -3
- data/lib/tty/table/operation/alignment.rb +8 -6
- data/lib/tty/table/operation/escape.rb +1 -1
- data/lib/tty/table/operation/filter.rb +1 -1
- data/lib/tty/table/operation/padding.rb +1 -9
- data/lib/tty/table/operation/truncation.rb +1 -1
- data/lib/tty/table/operation/wrapped.rb +1 -1
- data/lib/tty/table/operations.rb +1 -1
- data/lib/tty/table/options.rb +1 -1
- data/lib/tty/table/orientation.rb +1 -1
- data/lib/tty/table/orientation/horizontal.rb +1 -1
- data/lib/tty/table/orientation/vertical.rb +1 -1
- data/lib/tty/table/renderer.rb +4 -4
- data/lib/tty/table/renderer/ascii.rb +1 -1
- data/lib/tty/table/renderer/basic.rb +19 -20
- data/lib/tty/table/renderer/unicode.rb +1 -1
- data/lib/tty/table/row.rb +2 -2
- data/lib/tty/table/transformation.rb +2 -2
- data/lib/tty/table/validatable.rb +1 -1
- data/lib/tty/table/version.rb +3 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/access_spec.rb +1 -3
- data/spec/unit/add_row_spec.rb +1 -3
- data/spec/unit/alignment_set/each_spec.rb +1 -3
- data/spec/unit/alignment_set/new_spec.rb +1 -3
- data/spec/unit/alignment_set/to_ary_spec.rb +1 -3
- data/spec/unit/alignment_spec.rb +1 -3
- data/spec/unit/border/ascii/rendering_spec.rb +1 -3
- data/spec/unit/border/new_spec.rb +1 -3
- data/spec/unit/border/null/rendering_spec.rb +1 -3
- data/spec/unit/border/options/from_spec.rb +1 -3
- data/spec/unit/border/options/new_spec.rb +1 -3
- data/spec/unit/border/unicode/rendering_spec.rb +1 -3
- data/spec/unit/border_options/new_spec.rb +1 -3
- data/spec/unit/border_options/update_spec.rb +1 -3
- data/spec/unit/column_constraint/enforce_spec.rb +1 -3
- data/spec/unit/column_constraint/widths_spec.rb +1 -3
- data/spec/unit/columns/extract_widths_spec.rb +1 -1
- data/spec/unit/columns/total_width_spec.rb +0 -1
- data/spec/unit/columns/widths_from_spec.rb +1 -1
- data/spec/unit/data_spec.rb +1 -3
- data/spec/unit/each_spec.rb +1 -3
- data/spec/unit/each_with_index_spec.rb +1 -3
- data/spec/unit/empty_spec.rb +1 -3
- data/spec/unit/eql_spec.rb +1 -3
- data/spec/unit/field/equality_spec.rb +1 -3
- data/spec/unit/field/length_spec.rb +1 -3
- data/spec/unit/field/lines_spec.rb +1 -3
- data/spec/unit/field/new_spec.rb +1 -3
- data/spec/unit/field/width_spec.rb +1 -3
- data/spec/unit/filter_spec.rb +1 -3
- data/spec/unit/header/call_spec.rb +1 -3
- data/spec/unit/header/color_spec.rb +1 -3
- data/spec/unit/header/equality_spec.rb +1 -3
- data/spec/unit/header/height_spec.rb +1 -3
- data/spec/unit/header/new_spec.rb +1 -4
- data/spec/unit/header/set_spec.rb +1 -3
- data/spec/unit/header/to_ary_spec.rb +1 -3
- data/spec/unit/header_spec.rb +1 -3
- data/spec/unit/indentation/indent_spec.rb +1 -3
- data/spec/unit/new_spec.rb +1 -3
- data/spec/unit/operation/alignment/call_spec.rb +1 -3
- data/spec/unit/operation/escape/call_spec.rb +1 -3
- data/spec/unit/operation/filter/call_spec.rb +1 -3
- data/spec/unit/operation/truncation/call_spec.rb +1 -3
- data/spec/unit/operation/wrapped/call_spec.rb +1 -3
- data/spec/unit/operations/new_spec.rb +1 -1
- data/spec/unit/options/access_spec.rb +1 -3
- data/spec/unit/options_spec.rb +1 -3
- data/spec/unit/orientation_spec.rb +1 -3
- data/spec/unit/padding_spec.rb +1 -3
- data/spec/unit/properties_spec.rb +1 -3
- data/spec/unit/render_repeat_spec.rb +1 -4
- data/spec/unit/render_spec.rb +1 -3
- data/spec/unit/render_with_spec.rb +1 -3
- data/spec/unit/renderer/ascii/coloring_spec.rb +16 -3
- data/spec/unit/renderer/ascii/indentation_spec.rb +1 -3
- data/spec/unit/renderer/ascii/multiline_spec.rb +1 -3
- data/spec/unit/renderer/ascii/padding_spec.rb +1 -3
- data/spec/unit/renderer/ascii/render_spec.rb +1 -3
- data/spec/unit/renderer/ascii/resizing_spec.rb +1 -3
- data/spec/unit/renderer/ascii/separator_spec.rb +14 -4
- data/spec/unit/renderer/basic/alignment_spec.rb +1 -3
- data/spec/unit/renderer/basic/coloring_spec.rb +1 -3
- data/spec/unit/renderer/basic/extract_column_widths_spec.rb +1 -3
- data/spec/unit/renderer/basic/filter_spec.rb +1 -3
- data/spec/unit/renderer/basic/indentation_spec.rb +1 -3
- data/spec/unit/renderer/basic/multiline_spec.rb +1 -3
- data/spec/unit/renderer/basic/new_spec.rb +1 -3
- data/spec/unit/renderer/basic/options_spec.rb +1 -3
- data/spec/unit/renderer/basic/padding_spec.rb +1 -3
- data/spec/unit/renderer/basic/render_spec.rb +1 -3
- data/spec/unit/renderer/basic/resizing_spec.rb +1 -3
- data/spec/unit/renderer/basic/separator_spec.rb +1 -3
- data/spec/unit/renderer/basic/single_row_separator_spec.rb +80 -0
- data/spec/unit/renderer/basic/truncation_spec.rb +1 -3
- data/spec/unit/renderer/basic/wrapping_spec.rb +1 -3
- data/spec/unit/renderer/border_spec.rb +1 -3
- data/spec/unit/renderer/render_spec.rb +1 -3
- data/spec/unit/renderer/select_spec.rb +1 -3
- data/spec/unit/renderer/unicode/coloring_spec.rb +1 -3
- data/spec/unit/renderer/unicode/indentation_spec.rb +1 -3
- data/spec/unit/renderer/unicode/padding_spec.rb +1 -3
- data/spec/unit/renderer/unicode/render_spec.rb +1 -3
- data/spec/unit/renderer/unicode/separator_spec.rb +13 -3
- data/spec/unit/renderer_spec.rb +1 -3
- data/spec/unit/rotate_spec.rb +1 -3
- data/spec/unit/row/access_spec.rb +1 -3
- data/spec/unit/row/call_spec.rb +1 -3
- data/spec/unit/row/data_spec.rb +1 -3
- data/spec/unit/row/each_spec.rb +1 -3
- data/spec/unit/row/equality_spec.rb +1 -3
- data/spec/unit/row/height_spec.rb +1 -3
- data/spec/unit/row/new_spec.rb +1 -3
- data/spec/unit/row/to_ary_spec.rb +1 -3
- data/spec/unit/to_s_spec.rb +1 -1
- data/spec/unit/transformation/extract_tuples_spec.rb +1 -3
- data/spec/unit/utf_spec.rb +1 -3
- data/spec/unit/validatable/validate_options_spec.rb +1 -3
- data/spec/unit/validatable_spec.rb +1 -3
- data/tasks/console.rake +1 -0
- data/tty-table.gemspec +19 -10
- metadata +21 -27
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.travis.yml +0 -26
- data/CODE_OF_CONDUCT.md +0 -49
- data/Gemfile +0 -17
- data/appveyor.yml +0 -21
- data/benchmarks/speed.rb +0 -39
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe TTY::Table::Renderer::Basic, 'individual row separators' do
|
4
|
+
context 'using the separator option' do
|
5
|
+
let(:header) { ['h1', 'h2', 'h3'] }
|
6
|
+
let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3']] }
|
7
|
+
let(:table) { TTY::Table.new(header, rows) }
|
8
|
+
|
9
|
+
let(:object) { described_class.new table }
|
10
|
+
|
11
|
+
subject(:renderer) { object }
|
12
|
+
|
13
|
+
it "can use an array to specify the rows to separate" do
|
14
|
+
renderer.border.separator = [2]
|
15
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
16
|
+
h1 h2 h3
|
17
|
+
a1 a2 a3
|
18
|
+
b1 b2 b3
|
19
|
+
|
20
|
+
c1 c2 c3
|
21
|
+
EOS
|
22
|
+
end
|
23
|
+
|
24
|
+
it "can use a proc to specify the rows to separate" do
|
25
|
+
renderer.border.separator = ->(line) { line == 2 }
|
26
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
27
|
+
h1 h2 h3
|
28
|
+
a1 a2 a3
|
29
|
+
b1 b2 b3
|
30
|
+
|
31
|
+
c1 c2 c3
|
32
|
+
EOS
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it "works without a header row" do
|
37
|
+
table = TTY::Table.new([['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3']])
|
38
|
+
renderer = described_class.new(table)
|
39
|
+
renderer.border.separator = [1]
|
40
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
41
|
+
a1 a2 a3
|
42
|
+
b1 b2 b3
|
43
|
+
|
44
|
+
c1 c2 c3
|
45
|
+
EOS
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'using the :separator keyword as a row' do
|
49
|
+
it "the :separator keyword can be used in the row definition" do
|
50
|
+
table = TTY::Table.new([['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], :separator, ['c1', 'c2', 'c3']])
|
51
|
+
expect(described_class.new(table).render).to eq unindent(<<-EOS)
|
52
|
+
a1 a2 a3
|
53
|
+
b1 b2 b3
|
54
|
+
|
55
|
+
c1 c2 c3
|
56
|
+
EOS
|
57
|
+
end
|
58
|
+
|
59
|
+
it "the :separator keyword can be pushed into a run" do
|
60
|
+
table = TTY::Table.new([['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']])
|
61
|
+
table << :separator << ['c1', 'c2', 'c3']
|
62
|
+
expect(described_class.new(table).render).to eq unindent(<<-EOS)
|
63
|
+
a1 a2 a3
|
64
|
+
b1 b2 b3
|
65
|
+
|
66
|
+
c1 c2 c3
|
67
|
+
EOS
|
68
|
+
end
|
69
|
+
|
70
|
+
it "the :separator keyword be used between the header and the body" do
|
71
|
+
table = TTY::Table.new(['h1', 'h2', 'h3'], [:separator, ['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']])
|
72
|
+
expect(described_class.new(table).render).to eq unindent(<<-EOS)
|
73
|
+
h1 h2 h3
|
74
|
+
|
75
|
+
a1 a2 a3
|
76
|
+
b1 b2 b3
|
77
|
+
EOS
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
require 'spec_helper'
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
3
|
RSpec.describe TTY::Table::Renderer::Unicode, 'with separator' do
|
6
4
|
let(:header) { ['h1', 'h2', 'h3'] }
|
@@ -23,4 +21,16 @@ RSpec.describe TTY::Table::Renderer::Unicode, 'with separator' do
|
|
23
21
|
└──┴──┴──┘
|
24
22
|
EOS
|
25
23
|
end
|
24
|
+
|
25
|
+
it "will not the default separator if individual separators are specified" do
|
26
|
+
renderer.border.separator = [1]
|
27
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
28
|
+
┌──┬──┬──┐
|
29
|
+
│h1│h2│h3│
|
30
|
+
│a1│a2│a3│
|
31
|
+
├──┼──┼──┤
|
32
|
+
│b1│b2│b3│
|
33
|
+
└──┴──┴──┘
|
34
|
+
EOS
|
35
|
+
end
|
26
36
|
end
|
data/spec/unit/renderer_spec.rb
CHANGED
data/spec/unit/rotate_spec.rb
CHANGED
data/spec/unit/row/call_spec.rb
CHANGED
data/spec/unit/row/data_spec.rb
CHANGED
data/spec/unit/row/each_spec.rb
CHANGED
data/spec/unit/row/new_spec.rb
CHANGED
data/spec/unit/to_s_spec.rb
CHANGED
data/spec/unit/utf_spec.rb
CHANGED
data/tasks/console.rake
CHANGED
data/tty-table.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'tty/table/version'
|
@@ -7,26 +6,36 @@ Gem::Specification.new do |spec|
|
|
7
6
|
spec.name = 'tty-table'
|
8
7
|
spec.version = TTY::Table::VERSION
|
9
8
|
spec.authors = ["Piotr Murach"]
|
10
|
-
spec.email = [""]
|
9
|
+
spec.email = ["me@piotrmurach.com"]
|
11
10
|
spec.summary = %q{A flexible and intuitive table generator}
|
12
11
|
spec.description = %q{A flexible and intuitive table generator}
|
13
12
|
spec.homepage = "https://piotrmurach.github.io/tty/"
|
14
13
|
spec.license = "MIT"
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
if spec.respond_to?(:metadata=)
|
15
|
+
spec.metadata = {
|
16
|
+
"allowed_push_host" => "https://rubygems.org",
|
17
|
+
"bug_tracker_uri" => "https://github.com/piotrmurach/tty-table/issues",
|
18
|
+
"changelog_uri" => "https://github.com/piotrmurach/tty-table/blob/master/CHANGELOG.md",
|
19
|
+
"documentation_uri" => "https://www.rubydoc.info/gems/tty-table",
|
20
|
+
"homepage_uri" => spec.homepage,
|
21
|
+
"source_code_uri" => "https://github.com/piotrmurach/tty-table"
|
22
|
+
}
|
23
|
+
end
|
24
|
+
spec.files = Dir['{lib,spec,examples}/**/*.rb']
|
25
|
+
spec.files += Dir['{bin,tasks}/*', 'tty-table.gemspec']
|
26
|
+
spec.files += Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt', 'Rakefile']
|
18
27
|
spec.test_files = spec.files.grep(%r{^(spec|features)/})
|
19
28
|
spec.require_paths = ["lib"]
|
20
29
|
|
21
30
|
spec.required_ruby_version = '>= 2.0.0'
|
22
31
|
|
23
|
-
spec.add_dependency 'equatable', '~> 0.
|
24
|
-
spec.add_dependency 'necromancer', '~> 0.
|
32
|
+
spec.add_dependency 'equatable', '~> 0.6'
|
33
|
+
spec.add_dependency 'necromancer', '~> 0.5'
|
25
34
|
spec.add_dependency 'pastel', '~> 0.7.2'
|
26
|
-
spec.add_dependency 'tty-screen', '~> 0.
|
27
|
-
spec.add_dependency 'strings', '~> 0.1.
|
35
|
+
spec.add_dependency 'tty-screen', '~> 0.7'
|
36
|
+
spec.add_dependency 'strings', '~> 0.1.5'
|
28
37
|
|
29
|
-
spec.add_development_dependency 'bundler', '>= 1.5.0'
|
38
|
+
spec.add_development_dependency 'bundler', '>= 1.5.0'
|
30
39
|
spec.add_development_dependency 'rake'
|
31
40
|
spec.add_development_dependency 'rspec', '~> 3.1'
|
32
41
|
end
|