tty-table 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +13 -0
- data/README.md +67 -3
- data/Rakefile +2 -0
- data/lib/tty-table.rb +0 -3
- data/lib/tty/table.rb +35 -12
- data/lib/tty/table/alignment_set.rb +2 -2
- data/lib/tty/table/border.rb +6 -3
- data/lib/tty/table/border/ascii.rb +1 -1
- data/lib/tty/table/border/null.rb +3 -2
- data/lib/tty/table/border/row_line.rb +1 -1
- data/lib/tty/table/border/unicode.rb +1 -2
- data/lib/tty/table/border_dsl.rb +3 -3
- data/lib/tty/table/border_options.rb +21 -1
- data/lib/tty/table/column_constraint.rb +1 -1
- data/lib/tty/table/columns.rb +0 -1
- data/lib/tty/table/empty.rb +2 -0
- data/lib/tty/table/error.rb +1 -1
- data/lib/tty/table/field.rb +1 -1
- data/lib/tty/table/header.rb +1 -1
- data/lib/tty/table/indentation.rb +2 -3
- data/lib/tty/table/operation/alignment.rb +8 -6
- data/lib/tty/table/operation/escape.rb +1 -1
- data/lib/tty/table/operation/filter.rb +1 -1
- data/lib/tty/table/operation/padding.rb +1 -9
- data/lib/tty/table/operation/truncation.rb +1 -1
- data/lib/tty/table/operation/wrapped.rb +1 -1
- data/lib/tty/table/operations.rb +1 -1
- data/lib/tty/table/options.rb +1 -1
- data/lib/tty/table/orientation.rb +1 -1
- data/lib/tty/table/orientation/horizontal.rb +1 -1
- data/lib/tty/table/orientation/vertical.rb +1 -1
- data/lib/tty/table/renderer.rb +4 -4
- data/lib/tty/table/renderer/ascii.rb +1 -1
- data/lib/tty/table/renderer/basic.rb +19 -20
- data/lib/tty/table/renderer/unicode.rb +1 -1
- data/lib/tty/table/row.rb +2 -2
- data/lib/tty/table/transformation.rb +2 -2
- data/lib/tty/table/validatable.rb +1 -1
- data/lib/tty/table/version.rb +3 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/access_spec.rb +1 -3
- data/spec/unit/add_row_spec.rb +1 -3
- data/spec/unit/alignment_set/each_spec.rb +1 -3
- data/spec/unit/alignment_set/new_spec.rb +1 -3
- data/spec/unit/alignment_set/to_ary_spec.rb +1 -3
- data/spec/unit/alignment_spec.rb +1 -3
- data/spec/unit/border/ascii/rendering_spec.rb +1 -3
- data/spec/unit/border/new_spec.rb +1 -3
- data/spec/unit/border/null/rendering_spec.rb +1 -3
- data/spec/unit/border/options/from_spec.rb +1 -3
- data/spec/unit/border/options/new_spec.rb +1 -3
- data/spec/unit/border/unicode/rendering_spec.rb +1 -3
- data/spec/unit/border_options/new_spec.rb +1 -3
- data/spec/unit/border_options/update_spec.rb +1 -3
- data/spec/unit/column_constraint/enforce_spec.rb +1 -3
- data/spec/unit/column_constraint/widths_spec.rb +1 -3
- data/spec/unit/columns/extract_widths_spec.rb +1 -1
- data/spec/unit/columns/total_width_spec.rb +0 -1
- data/spec/unit/columns/widths_from_spec.rb +1 -1
- data/spec/unit/data_spec.rb +1 -3
- data/spec/unit/each_spec.rb +1 -3
- data/spec/unit/each_with_index_spec.rb +1 -3
- data/spec/unit/empty_spec.rb +1 -3
- data/spec/unit/eql_spec.rb +1 -3
- data/spec/unit/field/equality_spec.rb +1 -3
- data/spec/unit/field/length_spec.rb +1 -3
- data/spec/unit/field/lines_spec.rb +1 -3
- data/spec/unit/field/new_spec.rb +1 -3
- data/spec/unit/field/width_spec.rb +1 -3
- data/spec/unit/filter_spec.rb +1 -3
- data/spec/unit/header/call_spec.rb +1 -3
- data/spec/unit/header/color_spec.rb +1 -3
- data/spec/unit/header/equality_spec.rb +1 -3
- data/spec/unit/header/height_spec.rb +1 -3
- data/spec/unit/header/new_spec.rb +1 -4
- data/spec/unit/header/set_spec.rb +1 -3
- data/spec/unit/header/to_ary_spec.rb +1 -3
- data/spec/unit/header_spec.rb +1 -3
- data/spec/unit/indentation/indent_spec.rb +1 -3
- data/spec/unit/new_spec.rb +1 -3
- data/spec/unit/operation/alignment/call_spec.rb +1 -3
- data/spec/unit/operation/escape/call_spec.rb +1 -3
- data/spec/unit/operation/filter/call_spec.rb +1 -3
- data/spec/unit/operation/truncation/call_spec.rb +1 -3
- data/spec/unit/operation/wrapped/call_spec.rb +1 -3
- data/spec/unit/operations/new_spec.rb +1 -1
- data/spec/unit/options/access_spec.rb +1 -3
- data/spec/unit/options_spec.rb +1 -3
- data/spec/unit/orientation_spec.rb +1 -3
- data/spec/unit/padding_spec.rb +1 -3
- data/spec/unit/properties_spec.rb +1 -3
- data/spec/unit/render_repeat_spec.rb +1 -4
- data/spec/unit/render_spec.rb +1 -3
- data/spec/unit/render_with_spec.rb +1 -3
- data/spec/unit/renderer/ascii/coloring_spec.rb +16 -3
- data/spec/unit/renderer/ascii/indentation_spec.rb +1 -3
- data/spec/unit/renderer/ascii/multiline_spec.rb +1 -3
- data/spec/unit/renderer/ascii/padding_spec.rb +1 -3
- data/spec/unit/renderer/ascii/render_spec.rb +1 -3
- data/spec/unit/renderer/ascii/resizing_spec.rb +1 -3
- data/spec/unit/renderer/ascii/separator_spec.rb +14 -4
- data/spec/unit/renderer/basic/alignment_spec.rb +1 -3
- data/spec/unit/renderer/basic/coloring_spec.rb +1 -3
- data/spec/unit/renderer/basic/extract_column_widths_spec.rb +1 -3
- data/spec/unit/renderer/basic/filter_spec.rb +1 -3
- data/spec/unit/renderer/basic/indentation_spec.rb +1 -3
- data/spec/unit/renderer/basic/multiline_spec.rb +1 -3
- data/spec/unit/renderer/basic/new_spec.rb +1 -3
- data/spec/unit/renderer/basic/options_spec.rb +1 -3
- data/spec/unit/renderer/basic/padding_spec.rb +1 -3
- data/spec/unit/renderer/basic/render_spec.rb +1 -3
- data/spec/unit/renderer/basic/resizing_spec.rb +1 -3
- data/spec/unit/renderer/basic/separator_spec.rb +1 -3
- data/spec/unit/renderer/basic/single_row_separator_spec.rb +80 -0
- data/spec/unit/renderer/basic/truncation_spec.rb +1 -3
- data/spec/unit/renderer/basic/wrapping_spec.rb +1 -3
- data/spec/unit/renderer/border_spec.rb +1 -3
- data/spec/unit/renderer/render_spec.rb +1 -3
- data/spec/unit/renderer/select_spec.rb +1 -3
- data/spec/unit/renderer/unicode/coloring_spec.rb +1 -3
- data/spec/unit/renderer/unicode/indentation_spec.rb +1 -3
- data/spec/unit/renderer/unicode/padding_spec.rb +1 -3
- data/spec/unit/renderer/unicode/render_spec.rb +1 -3
- data/spec/unit/renderer/unicode/separator_spec.rb +13 -3
- data/spec/unit/renderer_spec.rb +1 -3
- data/spec/unit/rotate_spec.rb +1 -3
- data/spec/unit/row/access_spec.rb +1 -3
- data/spec/unit/row/call_spec.rb +1 -3
- data/spec/unit/row/data_spec.rb +1 -3
- data/spec/unit/row/each_spec.rb +1 -3
- data/spec/unit/row/equality_spec.rb +1 -3
- data/spec/unit/row/height_spec.rb +1 -3
- data/spec/unit/row/new_spec.rb +1 -3
- data/spec/unit/row/to_ary_spec.rb +1 -3
- data/spec/unit/to_s_spec.rb +1 -1
- data/spec/unit/transformation/extract_tuples_spec.rb +1 -3
- data/spec/unit/utf_spec.rb +1 -3
- data/spec/unit/validatable/validate_options_spec.rb +1 -3
- data/spec/unit/validatable_spec.rb +1 -3
- data/tasks/console.rake +1 -0
- data/tty-table.gemspec +19 -10
- metadata +21 -27
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.travis.yml +0 -26
- data/CODE_OF_CONDUCT.md +0 -49
- data/Gemfile +0 -17
- data/appveyor.yml +0 -21
- data/benchmarks/speed.rb +0 -39
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
module TTY
|
@@ -27,8 +26,8 @@ module TTY
|
|
27
26
|
#
|
28
27
|
# @api public
|
29
28
|
def insert_indentation(line, indentation)
|
30
|
-
line = line
|
31
|
-
|
29
|
+
line = Array(line)[0]
|
30
|
+
' ' * indentation + line.to_s if line
|
32
31
|
end
|
33
32
|
module_function :insert_indentation
|
34
33
|
end # Indentation
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'strings'
|
4
4
|
|
@@ -19,10 +19,14 @@ module TTY
|
|
19
19
|
|
20
20
|
# Evaluate alignment of the provided row
|
21
21
|
#
|
22
|
+
# @param [TTY::Table::Field] field
|
23
|
+
# the table field
|
24
|
+
#
|
22
25
|
# @param [Array] row
|
23
26
|
# the table row
|
24
|
-
#
|
25
|
-
#
|
27
|
+
#
|
28
|
+
# @param [Integer] col
|
29
|
+
# the table column index
|
26
30
|
#
|
27
31
|
# @return [TTY::Table::Field]
|
28
32
|
#
|
@@ -42,11 +46,9 @@ module TTY
|
|
42
46
|
# @param [TTY::Table::Field] field
|
43
47
|
# the table field
|
44
48
|
#
|
45
|
-
# @param [Integer]
|
49
|
+
# @param [Integer] col
|
46
50
|
# the table column index
|
47
51
|
#
|
48
|
-
# @param [Hash] options
|
49
|
-
#
|
50
52
|
# @return [TTY::Table::Field]
|
51
53
|
#
|
52
54
|
# @api private
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'strings'
|
4
4
|
|
@@ -13,8 +13,6 @@ module TTY
|
|
13
13
|
#
|
14
14
|
# @param [Strings::Padder] padding
|
15
15
|
#
|
16
|
-
# @param [Array[Integer]] widths
|
17
|
-
#
|
18
16
|
# @api public
|
19
17
|
def initialize(padding)
|
20
18
|
@padding = padding
|
@@ -25,12 +23,6 @@ module TTY
|
|
25
23
|
# @param [TTY::Table::Field] field
|
26
24
|
# the table field
|
27
25
|
#
|
28
|
-
# @param [Integer] row
|
29
|
-
# the field row index
|
30
|
-
#
|
31
|
-
# @param [Integer] col
|
32
|
-
# the field column index
|
33
|
-
#
|
34
26
|
# @return [TTY::Table::Field]
|
35
27
|
#
|
36
28
|
# @api public
|
data/lib/tty/table/operations.rb
CHANGED
data/lib/tty/table/options.rb
CHANGED
data/lib/tty/table/renderer.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'error'
|
4
4
|
require_relative 'renderer/basic'
|
@@ -21,11 +21,11 @@ module TTY
|
|
21
21
|
|
22
22
|
# Select renderer class based on string name.
|
23
23
|
#
|
24
|
-
# The possible values for
|
24
|
+
# The possible values for type are
|
25
25
|
# [:basic, :ascii, :unicode]
|
26
26
|
#
|
27
|
-
# @param [Symbol]
|
28
|
-
# the renderer used for displaying table
|
27
|
+
# @param [Symbol] type
|
28
|
+
# the renderer type used for displaying table
|
29
29
|
#
|
30
30
|
# @return [TTY::Table::Renderer]
|
31
31
|
#
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'tty-screen'
|
4
4
|
require 'strings'
|
@@ -151,6 +151,7 @@ module TTY
|
|
151
151
|
elsif !not_set
|
152
152
|
@border = TTY::Table::BorderOptions.from(options)
|
153
153
|
end
|
154
|
+
@border.separator ||= @table.separators unless @table.separators.empty?
|
154
155
|
@border
|
155
156
|
end
|
156
157
|
alias_method :border=, :border
|
@@ -251,7 +252,7 @@ module TTY
|
|
251
252
|
rows_with_border = render_rows(data_border)
|
252
253
|
bottom_line = data_border.bottom_line
|
253
254
|
|
254
|
-
Indentation.indent(bottom_line, @indent) if bottom_line
|
255
|
+
bottom_line = Indentation.indent(bottom_line, @indent) if bottom_line
|
255
256
|
|
256
257
|
[header, rows_with_border, bottom_line].compact
|
257
258
|
end
|
@@ -261,7 +262,7 @@ module TTY
|
|
261
262
|
# @param [TTY::Table::Row, TTY::Table::Header] row
|
262
263
|
# the first row in the table
|
263
264
|
#
|
264
|
-
# @param [TTY::Table::Border]
|
265
|
+
# @param [TTY::Table::Border] data_border
|
265
266
|
# the border for this table
|
266
267
|
#
|
267
268
|
# @return [String]
|
@@ -269,17 +270,15 @@ module TTY
|
|
269
270
|
# @api private
|
270
271
|
def render_header(row, data_border)
|
271
272
|
top_line = data_border.top_line
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
top_line
|
277
|
-
end
|
273
|
+
return top_line unless row.is_a?(TTY::Table::Header)
|
274
|
+
separator = data_border.separator if !border.separator || border.separator?(0)
|
275
|
+
header = [top_line, data_border.row_line(row), separator]
|
276
|
+
Indentation.indent(header.compact, @indent)
|
278
277
|
end
|
279
278
|
|
280
279
|
# Format the rows
|
281
280
|
#
|
282
|
-
# @param [TTY::Table::Border]
|
281
|
+
# @param [TTY::Table::Border] data_border
|
283
282
|
# the border for this table
|
284
283
|
#
|
285
284
|
# @return [Arrays[String]]
|
@@ -288,8 +287,9 @@ module TTY
|
|
288
287
|
def render_rows(data_border)
|
289
288
|
rows = table.rows
|
290
289
|
size = rows.size
|
290
|
+
offset = table.first.is_a?(TTY::Table::Header) ? 1 : 0
|
291
291
|
rows.each_with_index.map do |row, index|
|
292
|
-
render_row(row, data_border, size != (index
|
292
|
+
render_row(row, index+offset, data_border, size != (index + 1))
|
293
293
|
end
|
294
294
|
end
|
295
295
|
|
@@ -298,21 +298,20 @@ module TTY
|
|
298
298
|
# @param [Array] row
|
299
299
|
# a row to decorate
|
300
300
|
#
|
301
|
-
# @param [TTY::Table::Border]
|
301
|
+
# @param [TTY::Table::Border] data_border
|
302
302
|
# the border for this table
|
303
303
|
#
|
304
|
-
# @param [Boolean]
|
304
|
+
# @param [Boolean] is_not_last_row
|
305
305
|
#
|
306
306
|
# @api private
|
307
|
-
def render_row(row, data_border,
|
307
|
+
def render_row(row, index, data_border, is_not_last_row)
|
308
308
|
separator = data_border.separator
|
309
309
|
row_line = data_border.row_line(row)
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
end
|
310
|
+
line = if border.separator?(index) && is_not_last_row
|
311
|
+
[row_line, separator]
|
312
|
+
else
|
313
|
+
row_line
|
314
|
+
end
|
316
315
|
Indentation.indent(line, @indent)
|
317
316
|
end
|
318
317
|
end # Basic
|
data/lib/tty/table/row.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'forwardable'
|
4
4
|
|
@@ -101,7 +101,7 @@ module TTY
|
|
101
101
|
# Lookup a value in the row given an attribute allowing for Array or
|
102
102
|
# Hash like indexing
|
103
103
|
#
|
104
|
-
# @
|
104
|
+
# @example
|
105
105
|
# row[1]
|
106
106
|
# row[:id]
|
107
107
|
# row.call(:id)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module TTY
|
4
4
|
class Table
|
@@ -26,7 +26,7 @@ module TTY
|
|
26
26
|
|
27
27
|
# Group hash keys into header and values into rows
|
28
28
|
#
|
29
|
-
# @
|
29
|
+
# @param [Hash] value
|
30
30
|
#
|
31
31
|
# @api public
|
32
32
|
def self.group_header_and_rows(value)
|
data/lib/tty/table/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/unit/access_spec.rb
CHANGED
data/spec/unit/add_row_spec.rb
CHANGED
data/spec/unit/alignment_spec.rb
CHANGED