term_utils 0.3.0 → 0.3.1

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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -1
  3. data/Rakefile +22 -13
  4. data/doc/TermUtils/AP/Article.html +1 -1
  5. data/doc/TermUtils/AP/Element.html +1 -1
  6. data/doc/TermUtils/AP/Flag.html +1 -1
  7. data/doc/TermUtils/AP/Level.html +1 -1
  8. data/doc/TermUtils/AP/NoSuchValueError.html +1 -1
  9. data/doc/TermUtils/AP/Parameter.html +1 -1
  10. data/doc/TermUtils/AP/ParseError.html +1 -1
  11. data/doc/TermUtils/AP/Parser.html +1 -1
  12. data/doc/TermUtils/AP/Result.html +202 -67
  13. data/doc/TermUtils/AP/Syntax.html +1 -1
  14. data/doc/TermUtils/AP/SyntaxError.html +1 -1
  15. data/doc/TermUtils/AP.html +1 -1
  16. data/doc/TermUtils/FF/Config.html +1 -1
  17. data/doc/TermUtils/FF/Cursor/Context.html +1 -1
  18. data/doc/TermUtils/FF/Cursor.html +1 -1
  19. data/doc/TermUtils/FF/Query.html +1 -1
  20. data/doc/TermUtils/FF.html +1 -1
  21. data/doc/TermUtils/PropertyTreeNode.html +1 -1
  22. data/doc/TermUtils/Tab/Column.html +170 -199
  23. data/doc/TermUtils/Tab/Header.html +536 -0
  24. data/doc/TermUtils/Tab/Holder.html +570 -34
  25. data/doc/TermUtils/Tab/Printer.html +50 -50
  26. data/doc/TermUtils/Tab/Table.html +675 -119
  27. data/doc/TermUtils/Tab/TableError.html +217 -0
  28. data/doc/TermUtils/Tab.html +1016 -45
  29. data/doc/TermUtils.html +1 -1
  30. data/doc/_index.html +15 -1
  31. data/doc/class_list.html +1 -1
  32. data/doc/file.README.html +1 -1
  33. data/doc/index.html +1 -1
  34. data/doc/method_list.html +261 -69
  35. data/doc/top-level-namespace.html +1 -1
  36. data/lib/term_utils/ap/result.rb +23 -1
  37. data/lib/term_utils/tab.rb +255 -68
  38. data/term_utils.gemspec +2 -2
  39. metadata +4 -3
  40. data/doc/TermUtils/AP/ResultView.html +0 -597
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Sun Nov 10 18:36:19 2019 by
103
+ Generated on Sat Nov 16 17:06:14 2019 by
104
104
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
105
  0.9.20 (ruby-2.6.5).
106
106
  </div>
@@ -35,8 +35,30 @@ module TermUtils
35
35
  @value = TermUtils::PropertyTreeNode.new
36
36
  end
37
37
  end
38
+ # Collects IDs.
39
+ # @param id [Symbol, Array<Symbol>] ID path.
40
+ # @return [Array<Symbol>]
41
+ def collect(id, &block)
42
+ node = @value
43
+ if id
44
+ id = [id] if id.is_a? Symbol
45
+ node = @value.find_node(id)
46
+ end
47
+ res = []
48
+ return res unless node && node.child_nodes
49
+ if block
50
+ node.child_nodes.each do |n|
51
+ res << n.key if block.call(n.key)
52
+ end
53
+ else
54
+ node.child_nodes.each do |n|
55
+ res << n.key
56
+ end
57
+ end
58
+ res
59
+ end
38
60
  # Tests whether a given level/parameter/article is present in the result value.
39
- # @param id [Symbol, Array<Symbol>]
61
+ # @param id [Symbol, Array<Symbol>] ID path.
40
62
  # @return [Boolean]
41
63
  def present?(id)
42
64
  if id.is_a? Symbol
@@ -16,22 +16,142 @@
16
16
  module TermUtils
17
17
  # The tab module provides a way to print formatted tables.
18
18
  module Tab
19
+ # Represents a table error.
20
+ class TableError < StandardError
21
+ def initialize(msg)
22
+ super
23
+ end
24
+ end
25
+ # Creates initial column properties.
26
+ # @return [Hash] `:offset`, `:column_separator_width`.
27
+ def self.init_table_props
28
+ {:offset => 0, :column_separator_width => 2}
29
+ end
30
+ # Creates initial column properties.
31
+ # @return [Hash] `:width`, `:align`, `:fixed`, `:ellipsis`, `:format`.
32
+ def self.init_column_props
33
+ {:width => 8, :align => :left, :fixed => false, :ellipsis => "?", :format => nil}
34
+ end
35
+ # Assigns table properties.
36
+ # @param target [Hash]
37
+ # @param source [Hash] `:offset`, `:column_separator_width`.
38
+ # @return [Hash]
39
+ def self.assign_table_props(target, source)
40
+ if (source.has_key? :offset) && (source[:offset].is_a? Integer) && (source[:offset] >= 0)
41
+ target[:offset] = source[:offset]
42
+ end
43
+ if (source.has_key? :column_separator_width) && (source[:column_separator_width].is_a? Integer) && (source[:column_separator_width] > 0)
44
+ target[:column_separator_width] = source[:column_separator_width]
45
+ end
46
+ target
47
+ end
48
+ # Assigns column properties.
49
+ # @param target [Hash]
50
+ # @param source [Hash] `:width`, `:align`, `:fixed`, `:ellipsis`, `:format`.
51
+ # @return [Hash]
52
+ def self.assign_column_props(target, source)
53
+ if (source.has_key? :width) && (source[:width].is_a? Integer) && (source[:width] > 0)
54
+ target[:width] = source[:width]
55
+ end
56
+ if (source.has_key? :align) && %i[left right].index(source[:align])
57
+ target[:align] = source[:align]
58
+ end
59
+ if (source.has_key? :fixed) && (!!source[:fixed] == source[:fixed])
60
+ target[:fixed] = source[:fixed]
61
+ end
62
+ if (source.has_key? :ellipsis) && (source[:ellipsis].is_a? String)
63
+ target[:ellipsis] = source[:ellipsis]
64
+ end
65
+ if (source.has_key? :format) && ((source[:ellipsis] == nil) || (source[:ellipsis].is_a? Proc) || (source[:ellipsis].is_a? String))
66
+ target[:format] = source[:format]
67
+ end
68
+ target
69
+ end
70
+ # Aligns and cuts a given string.
71
+ # @param src [String]
72
+ # @param align [Symbol] `:left`, `:right`.
73
+ # @param fixed [Boolean] Whether the column width is fixed.
74
+ # @param width [Integer] The column width.
75
+ # @param ellipsis [String] The ellipsis when not fixed.
76
+ # @return [String]
77
+ def self.align_cut(src, align, fixed, width, ellipsis)
78
+ res = src
79
+ if align == :left
80
+ # Align left
81
+ if fixed && (src.length > width)
82
+ if ellipsis.length >= width
83
+ res = ellipsis[0..(width - 1)]
84
+ else
85
+ res = "%s%s" % [src[0..(width - (ellipsis.length + 1))], ellipsis]
86
+ end
87
+ else
88
+ res = "%-*s" % [width, src]
89
+ end
90
+ elsif align == :right
91
+ # Align right
92
+ if fixed && (src.length > width)
93
+ if ellipsis.length >= width
94
+ res = ellipsis[0..(width - 1)]
95
+ else
96
+ res = "%s%s" % [ellipsis, src[(src.length - width + ellipsis.length)..(src.length - 1)]]
97
+ end
98
+ else
99
+ res = "%*s" % [width, src]
100
+ end
101
+ end
102
+ res
103
+ end
19
104
  # Represents a table.
20
105
  class Table
21
106
  # @return [Symbol]
22
107
  attr_accessor :id
108
+ # @return [Integer]
109
+ attr_accessor :offset
110
+ # @return [Integer]
111
+ attr_accessor :column_separator_width
112
+ # @return [Hash] `:width`, `:align`, `:fixed`, `:ellipsis`, `:format`.
113
+ attr_accessor :column_defaults
23
114
  # @return [Array<Tab::Column>]
24
115
  attr_accessor :columns
25
116
  # @param opts [Hash]
26
117
  # @option opts [Symbol] :id
118
+ # @option opts [Integer] :offset
119
+ # @option opts [Hash] :column_defaults
27
120
  def initialize(opts = {})
121
+ opts = TermUtils::Tab.init_table_props.merge(opts)
28
122
  @id = opts.fetch(:id, nil)
123
+ @offset = opts.fetch(:offset)
124
+ @column_separator_width = opts.fetch(:column_separator_width)
125
+ if opts.has_key? :column_defaults
126
+ @column_defaults = opts[:column_defaults].dup
127
+ else
128
+ @column_defaults = TermUtils::Tab.default_column_props
129
+ end
29
130
  @columns = []
30
131
  end
132
+ # Returns the properties of this one.
133
+ # @return [Hash]
134
+ def props
135
+ {:offset => @offset, :column_separator_width => @column_separator_width}
136
+ end
137
+ # Sets column default properties.
138
+ # @param opts [Hash]
139
+ # @option opts [Integer] :width
140
+ # @option opts [Symbol] :align
141
+ # @option opts [Boolean] :fixed
142
+ # @option opts [String] :ellipsis
143
+ # @option opts [Proc, String, nil] :format
144
+ def set_column_defaults(opts = {})
145
+ TermUtils::Tab.assign_column_props(@column_defaults, opts)
146
+ end
31
147
  # Defines a column.
32
148
  # @param id [Symbol]
33
149
  # @param opts [Hash]
34
150
  # @option opts [Integer] :width
151
+ # @option opts [Symbol] :align
152
+ # @option opts [Boolean] :fixed
153
+ # @option opts [String] :ellipsis
154
+ # @option opts [Proc, String, nil] :format
35
155
  # @return [Tab::Column]
36
156
  def define_column(id, opts = {}, &block)
37
157
  col = @columns.find { |c| c.id == id }
@@ -41,7 +161,7 @@ module TermUtils
41
161
  else
42
162
  opts[:id] = id
43
163
  opts[:index] = @columns.length
44
- col = Column.new(opts)
164
+ col = Column.new(@column_defaults.merge(opts))
45
165
  block.call(col) if block
46
166
  col.validate
47
167
  @columns << col
@@ -55,36 +175,37 @@ module TermUtils
55
175
  @columns.find { |c| c.id == id }
56
176
  end
57
177
  # Creates a new table printer.
58
- # @param io [IO]
178
+ # @param io [#puts]
59
179
  # @param opts [Hash]
60
180
  # @option opts [Integer] :offset
61
181
  # @option opts [Integer] :column_separator_width
62
182
  # @return [Tab::Printer]
63
183
  def printer(io, opts = {}, &block)
64
- ptr = Printer.new(self, io, opts)
184
+ ptr = Printer.new(self, io, props.merge(opts))
65
185
  block.call(ptr) if block
66
186
  ptr
67
187
  end
68
188
  # Prints a header row.
69
- # @param io [IO]
189
+ # @param io [#puts]
70
190
  # @param values [Array<Object>, Hash<Symbol, Object>]
71
191
  # @param opts [Hash]
72
192
  # @option opts [Integer] :offset
73
193
  # @option opts [Integer] :column_separator_width
74
194
  # @return [nil]
195
+ # @raise [TermUtils::Tab::TableError]
75
196
  def print_header(io, values = nil, opts = {})
76
197
  vals = values
77
198
  if values.nil?
78
- vals = @columns.map { |col| col.id.to_s }
199
+ vals = @columns.map { |col| col.header.title }
79
200
  elsif values.is_a? Hash
80
201
  vals = []
81
202
  @columns.each do |col|
82
203
  vals << values[col.id]
83
204
  end
84
205
  end
85
- raise "wrong values (not array)" unless vals.is_a? Array
86
- offset = opts.fetch(:offset, 0)
87
- column_separator_width = opts.fetch(:column_separator_width, 2)
206
+ raise TermUtils::Tab::TableError, "wrong values (not array)" unless vals.is_a? Array
207
+ offset = opts.fetch(:offset)
208
+ column_separator_width = opts.fetch(:column_separator_width)
88
209
  sb = StringIO.new
89
210
  sb << " " * offset if offset > 0
90
211
  @columns.each do |col|
@@ -94,12 +215,13 @@ module TermUtils
94
215
  io.puts sb.string
95
216
  end
96
217
  # Prints a data row.
97
- # @param io [IO]
218
+ # @param io [#puts]
98
219
  # @param values [Array<Object>, Hash<Symbol, Object>]
99
220
  # @param opts [Hash]
100
221
  # @option opts [Integer] :offset
101
222
  # @option opts [Integer] :column_separator_width
102
223
  # @return [nil]
224
+ # @raise [TermUtils::Tab::TableError]
103
225
  def print_data(io, values, opts = {})
104
226
  vals = values
105
227
  if values.is_a? Hash
@@ -108,9 +230,9 @@ module TermUtils
108
230
  vals << values[col.id]
109
231
  end
110
232
  end
111
- raise "wrong values (not array)" unless vals.is_a? Array
112
- offset = opts.fetch(:offset, 0)
113
- column_separator_width = opts.fetch(:column_separator_width, 2)
233
+ raise TermUtils::Tab::TableError, "wrong values (not array)" unless vals.is_a? Array
234
+ offset = opts.fetch(:offset)
235
+ column_separator_width = opts.fetch(:column_separator_width)
114
236
  sb = StringIO.new
115
237
  sb << " " * offset if offset > 0
116
238
  @columns.each do |col|
@@ -120,14 +242,14 @@ module TermUtils
120
242
  io.puts sb.string
121
243
  end
122
244
  # Prints a separator row.
123
- # @param io [IO]
245
+ # @param io [#puts]
124
246
  # @param opts [Hash]
125
247
  # @option opts [Integer] :offset
126
248
  # @option opts [Integer] :column_separator_width
127
249
  # @return [nil]
128
250
  def print_separator(io, opts = {})
129
- offset = opts.fetch(:offset, 0)
130
- column_separator_width = opts.fetch(:column_separator_width, 2)
251
+ offset = opts.fetch(:offset)
252
+ column_separator_width = opts.fetch(:column_separator_width)
131
253
  sb = StringIO.new
132
254
  sb << " " * offset if offset > 0
133
255
  @columns.each do |col|
@@ -162,6 +284,8 @@ module TermUtils
162
284
  attr_accessor :ellipsis
163
285
  # @return [Proc, String, nil]
164
286
  attr_accessor :format
287
+ # @return [TermUtils::Tab::Header]
288
+ attr_accessor :header
165
289
  # @param opts [Hash]
166
290
  # @option opts [Symbol] :id
167
291
  # @option opts [Integer] :index
@@ -178,62 +302,65 @@ module TermUtils
178
302
  @fixed = opts.fetch(:fixed, false)
179
303
  @ellipsis = opts.fetch(:ellipsis, "?")
180
304
  @format = opts.fetch(:format, nil)
305
+ @header = TermUtils::Tab::Header.new(:title => @id.to_s, :align => @align)
181
306
  end
182
307
  # Validates the column represented by this one.
183
308
  # @return [nil]
309
+ # @raise [TermUtils::Tab::TableError]
184
310
  def validate
185
- raise "missing column id (nil)" if @id.nil?
186
- raise "missing column index (nil)" if @index.nil?
187
- raise "wrong column index (not integer)" unless @index.is_a? Integer
188
- raise "wrong column index (not >= 0)" if @index < 0
189
- raise "missing column width (nil)" if @width.nil?
190
- raise "wrong column width (not integer)" unless @width.is_a? Integer
191
- raise "wrong column width (not > 0)" if @width <= 0
192
- raise "wrong column align (not :left or :right)" unless %i{left right}.index @align
193
- end
194
- # Aligns and cuts a given string.
195
- # @param str [String]
196
- # @return [String]
197
- def align_cut(str)
198
- if @align == :left
199
- # Align left
200
- if @fixed and (str.length > @width)
201
- str = "#{str[0..(@width - (@ellipsis.length + 1))]}#{@ellipsis}"
202
- else
203
- str = "%-*s" % [@width, str]
204
- end
205
- else
206
- # Align right
207
- if @fixed and (str.length > @width)
208
- str = "#{@ellipsis}#{str[(str.length - @width + @ellipsis.length)..(str.length - 1)]}"
209
- else
210
- str = "%*s" % [@width, str]
211
- end
212
- end
213
- str
311
+ raise TermUtils::Tab::TableError, "missing column id (nil)" if @id.nil?
312
+ raise TermUtils::Tab::TableError, "missing column index (nil)" if @index.nil?
313
+ raise TermUtils::Tab::TableError, "wrong column index (not integer)" unless @index.is_a? Integer
314
+ raise TermUtils::Tab::TableError, "wrong column index (not >= 0)" if @index < 0
315
+ raise TermUtils::Tab::TableError, "missing column width (nil)" if @width.nil?
316
+ raise TermUtils::Tab::TableError, "wrong column width (not integer)" unless @width.is_a? Integer
317
+ raise TermUtils::Tab::TableError, "wrong column width (not > 0)" if @width <= 0
318
+ raise TermUtils::Tab::TableError, "wrong column align (not :left or :right)" unless %i[left right].index(@align)
319
+ @header.validate
214
320
  end
215
321
  # Renders a given header.
216
- # @param v [Object]
322
+ # @param val [Object]
217
323
  # return [String]
218
- def render_header(v)
219
- str = v
220
- str = str.to_s unless str.is_a? String
221
- align_cut str
324
+ def render_header(val)
325
+ src = (val.is_a? String) ? val : val.to_s
326
+ TermUtils::Tab.align_cut(src, @header.align, @fixed, @width, @ellipsis)
222
327
  end
223
328
  # Renders a given value.
224
- # @param v [Object]
329
+ # @param val [Object]
225
330
  # return [String]
226
- def render_data(v)
227
- str = v
228
- if v
331
+ def render_data(val)
332
+ src = val
333
+ if val
229
334
  if @format.is_a? Proc
230
- str = @format.call(v)
335
+ src = @format.call(val)
231
336
  elsif @format.is_a? String
232
- str = @format % v
337
+ src = @format % val
233
338
  end
234
339
  end
235
- str = str.to_s unless str.is_a? String
236
- align_cut str
340
+ src = (src.is_a? String) ? src : src.to_s
341
+ TermUtils::Tab.align_cut(src, @align, @fixed, @width, @ellipsis)
342
+ end
343
+ end
344
+ # Represents a column header.
345
+ class Header
346
+ # @return [String]
347
+ attr_accessor :title
348
+ # @return [Symbol] `:left`, `:right`.
349
+ attr_accessor :align
350
+ # Constructs a new Header.
351
+ # @param opts [Hash]
352
+ # @option opts [String] :title
353
+ # @option opts [Symbol] :align
354
+ def initialize(opts = {})
355
+ @title = opts.fetch(:title)
356
+ @align = opts.fetch(:align, :left)
357
+ end
358
+ # Validates the column represented by this one.
359
+ # @return [nil]
360
+ # @raise [TermUtils::Tab::TableError]
361
+ def validate
362
+ raise TermUtils::Tab::TableError, "missing header title (nil)" if @title.nil?
363
+ raise TermUtils::Tab::TableError, "wrong header align (not :left or :right)" unless %i[left right].index(@align)
237
364
  end
238
365
  end
239
366
  # Represents a table printer.
@@ -262,8 +389,8 @@ module TermUtils
262
389
  # @option opts [Integer] :offset
263
390
  # @option opts [Integer] :column_separator_width
264
391
  # @return [nil]
265
- def header(values = nil, opts = {})
266
- @table.print_header(@io, values, @options.merge(opts))
392
+ def header(values = nil, opts = nil)
393
+ @table.print_header(@io, values, opts ? @options.merge(opts) : @options)
267
394
  end
268
395
  # Prints a data row.
269
396
  # @param values [Array<Object>, Hash<Symbol, Object>]
@@ -271,26 +398,60 @@ module TermUtils
271
398
  # @option opts [Integer] :offset
272
399
  # @option opts [Integer] :column_separator_width
273
400
  # @return [nil]
274
- def data(values, opts = {})
275
- @table.print_data(@io, values, @options.merge(opts))
401
+ def data(values, opts = nil)
402
+ @table.print_data(@io, values, opts ? @options.merge(opts) : @options)
276
403
  end
277
404
  # Prints a separator.
278
405
  # @param opts [Hash]
279
406
  # @option opts [Integer] :offset
280
407
  # @option opts [Integer] :column_separator_width
281
408
  # @return [nil]
282
- def separator(opts = {})
283
- @table.print_separator(@io, @options.merge(opts))
409
+ def separator(opts = nil)
410
+ @table.print_separator(@io, opts ? @options.merge(opts) : @options)
284
411
  end
285
412
  end
286
413
  # Represents a holder of tables.
287
414
  class Holder
415
+ # @return [Hash] `:offset`, `:column_separator_width`.
416
+ attr_accessor :table_defaults
417
+ # @return [Hash] `:width`, `:align`, `:fixed`, `:ellipsis`, `:format`.
418
+ attr_accessor :column_defaults
288
419
  # @return [Hash<Symbol, Tab::Table>]
289
420
  attr_accessor :tables
290
421
  def initialize(opts = {})
422
+ @table_defaults = TermUtils::Tab.init_table_props
423
+ @column_defaults = TermUtils::Tab.init_column_props
291
424
  @tables = {}
292
425
  end
293
- # Defines a table.
426
+ # Sets table default properties.
427
+ # @param opts [Hash]
428
+ # @option opts [Integer] :offset
429
+ # @option opts [Symbol] :column_separator_width
430
+ def set_table_defaults(opts = {})
431
+ TermUtils::Tab.assign_table_props(@table_defaults, opts)
432
+ end
433
+ # Sets column default properties.
434
+ # @param opts [Hash]
435
+ # @option opts [Integer] :width
436
+ # @option opts [Symbol] :align
437
+ # @option opts [Boolean] :fixed
438
+ # @option opts [String] :ellipsis
439
+ # @option opts [Proc, String, nil] :format
440
+ def set_column_defaults(opts = {})
441
+ TermUtils::Tab.assign_column_props(@column_defaults, opts)
442
+ end
443
+ # Creates a new table, using default properties, without registering it.
444
+ # @param opts [Hash]
445
+ # @return [Tab::Table]
446
+ def create_table(opts = {}, &block)
447
+ opts[:offset] = @table_defaults.fetch(:offset)
448
+ opts[:column_separator_width] = @table_defaults.fetch(:column_separator_width)
449
+ opts[:column_defaults] = @column_defaults.dup
450
+ new_tab = Table.new(opts)
451
+ block.call(new_tab) if block
452
+ new_tab
453
+ end
454
+ # Defines a table, using default properties.
294
455
  # @param id [Symbol]
295
456
  # @param opts [Hash]
296
457
  # @return [Tab::Table]
@@ -299,6 +460,9 @@ module TermUtils
299
460
  block.call(@tables[id]) if block
300
461
  else
301
462
  opts[:id] = id
463
+ opts[:offset] = @table_defaults.fetch(:offset)
464
+ opts[:column_separator_width] = @table_defaults.fetch(:column_separator_width)
465
+ opts[:column_defaults] = @column_defaults.dup
302
466
  new_tab = Table.new(opts)
303
467
  block.call(new_tab) if block
304
468
  @tables[id] = new_tab
@@ -323,20 +487,43 @@ module TermUtils
323
487
  end
324
488
  end
325
489
  @@default_holder = Holder.new
326
- # Defines a table.
490
+ # Sets table default properties.
491
+ # @param opts [Hash]
492
+ # @option opts [Integer] :offset
493
+ # @option opts [Symbol] :column_separator_width
494
+ def self.set_table_defaults(opts = {})
495
+ @@default_holder.set_table_defaults(opts)
496
+ end
497
+ # Sets column default properties.
498
+ # @param opts [Hash]
499
+ # @option opts [Integer] :width
500
+ # @option opts [Symbol] :align
501
+ # @option opts [Boolean] :fixed
502
+ # @option opts [String] :ellipsis
503
+ # @option opts [Proc, String, nil] :format
504
+ def self.set_column_defaults(opts = {})
505
+ @@default_holder.set_column_defaults(opts)
506
+ end
507
+ # Creates a new Table, using default properties, without registering it.
508
+ # @param opts [Hash]
509
+ # @return [Tab::Table]
510
+ def self.create_table(opts = {}, &block)
511
+ @@default_holder.create_table(opts, &block)
512
+ end
513
+ # Defines a new Table, using default properties, and registers it.
327
514
  # @param id [Symbol]
328
515
  # @param opts [Hash]
329
516
  # @return [Tab::Table]
330
517
  def self.define_table(id, opts = {}, &block)
331
- @@default_holder.define_table(id, opts = {}, &block)
518
+ @@default_holder.define_table(id, opts, &block)
332
519
  end
333
- # Finds a table.
520
+ # Finds a registered table.
334
521
  # @param id [Symbol]
335
522
  # @return [Tab::Table, nil]
336
523
  def self.find_table(id)
337
524
  @@default_holder.find_table(id)
338
525
  end
339
- # Creates a new table printer.
526
+ # Creates a new Printer for a registered Table.
340
527
  # @param id [Symbol]
341
528
  # @param io [IO]
342
529
  # @param opts [Hash]
data/term_utils.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "term_utils"
3
- s.version = "0.3.0"
4
- s.date = "2019-11-10"
3
+ s.version = "0.3.1"
4
+ s.date = "2019-11-16"
5
5
  s.summary = "Terminal utilities."
6
6
  s.description = <<-EOS
7
7
  Provides terminal utilities like table formatting.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: term_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Baron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-10 00:00:00.000000000 Z
11
+ date: 2019-11-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Provides terminal utilities like table formatting.
14
14
 
@@ -34,7 +34,6 @@ files:
34
34
  - doc/TermUtils/AP/ParseError.html
35
35
  - doc/TermUtils/AP/Parser.html
36
36
  - doc/TermUtils/AP/Result.html
37
- - doc/TermUtils/AP/ResultView.html
38
37
  - doc/TermUtils/AP/Syntax.html
39
38
  - doc/TermUtils/AP/SyntaxError.html
40
39
  - doc/TermUtils/FF.html
@@ -45,9 +44,11 @@ files:
45
44
  - doc/TermUtils/PropertyTreeNode.html
46
45
  - doc/TermUtils/Tab.html
47
46
  - doc/TermUtils/Tab/Column.html
47
+ - doc/TermUtils/Tab/Header.html
48
48
  - doc/TermUtils/Tab/Holder.html
49
49
  - doc/TermUtils/Tab/Printer.html
50
50
  - doc/TermUtils/Tab/Table.html
51
+ - doc/TermUtils/Tab/TableError.html
51
52
  - doc/_index.html
52
53
  - doc/class_list.html
53
54
  - doc/css/common.css