fat_table 0.5.4 → 0.5.5
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 +4 -4
- data/README.org +33 -10
- data/TODO.org +28 -1
- data/lib/fat_table/column.rb +76 -37
- data/lib/fat_table/convert.rb +4 -8
- data/lib/fat_table/footer.rb +1 -1
- data/lib/fat_table/formatters/formatter.rb +9 -4
- data/lib/fat_table/formatters/org_formatter.rb +3 -3
- data/lib/fat_table/formatters/term_formatter.rb +3 -3
- data/lib/fat_table/formatters/text_formatter.rb +3 -3
- data/lib/fat_table/table.rb +2 -2
- data/lib/fat_table/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f391d5e4ad9d7a4dcb303098b90f6fb42379d9df382192c4bacaf169523dab1
|
4
|
+
data.tar.gz: ea75f906fcd164752a3ca2220324ad10d8438562bb31c4846bc6575723e834fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2914c40a497cf24bcdba8868c4a4607ea1bdb0a94fba8caa3d6e31407ff6832621df2a0b4a8a2bb98c3b40080fed6d752f8e936f66a96270fe675e93d5a852d6
|
7
|
+
data.tar.gz: dbc43f4d2bac4a2a19bc7cc90d1fbfbf739a12f0f280a543670af588cfcf2bb0df74d50cfb7ded76b851f5470fd30d4f971659cead5131f9ea15e24b492e5823
|
data/README.org
CHANGED
@@ -32,7 +32,7 @@ The following is for org.
|
|
32
32
|
#+end_src
|
33
33
|
|
34
34
|
#+begin_EXAMPLE
|
35
|
-
Current version is: 0.5.
|
35
|
+
Current version is: 0.5.4
|
36
36
|
#+end_EXAMPLE
|
37
37
|
|
38
38
|
* Introduction
|
@@ -442,11 +442,26 @@ or nil. There are only five permissible types for a ~Column~:
|
|
442
442
|
5. *NilClass* (for the undetermined column type).
|
443
443
|
|
444
444
|
When a ~Table~ is constructed from an external source, all ~Columns~ start out
|
445
|
-
having a type of ~NilClass~, that is, their type is as yet undetermined. When
|
446
|
-
string or object of one of the four determined types is added to a ~Column
|
447
|
-
|
448
|
-
|
449
|
-
|
445
|
+
having a type of ~NilClass~, that is, their type is as yet undetermined. When
|
446
|
+
a string or object of one of the four determined types is added to a ~Column~
|
447
|
+
and it can be converted into one of the permissible types, it fixes the type
|
448
|
+
of the column, and all further items added to the ~Column~ must either be
|
449
|
+
~nil~ (indicating no value) or be capable of being coerced to the column's
|
450
|
+
type. Otherwise, ~FatTable~ raises an exception.
|
451
|
+
|
452
|
+
The strictness of requiring all items to be of the same type can be relaxed by
|
453
|
+
declaring a column to be "tolerant." You can do so when you create the table
|
454
|
+
by adding a tolerant_columns keyword parameter. If a Column is tolerant,
|
455
|
+
~FatTable~ tries to convert new items into a type other than a ~String~ and,
|
456
|
+
if it can do so, sets /that/ as the Column's type. Any later items that
|
457
|
+
cannot be converted into the Column's type are converted to strings. These
|
458
|
+
interloper strings are treated like nils for purposes of sorting and
|
459
|
+
evaluation, but are displayed according to any string formatting on output.
|
460
|
+
See [[*Designating "Tolerant" Columns][Designating "Tolerant" Columns]] below.
|
461
|
+
|
462
|
+
It is also possible to force ~FatTable~ to treat a column as a String type,
|
463
|
+
even its items look like one of the other types. See [[*Forcing String Type][Forcing String Type]]
|
464
|
+
below.
|
450
465
|
|
451
466
|
Items of input must be either one of the permissible ruby objects or strings. If
|
452
467
|
they are strings, ~FatTable~ attempts to parse them as one of the permissible
|
@@ -603,10 +618,18 @@ columns to be created:
|
|
603
618
|
**** Forcing String Type
|
604
619
|
Occasionally, ~FatTable~'s automatic type detection can get in the way and you
|
605
620
|
just want it to treat one or more columns as Strings regardless of their
|
606
|
-
appearance. Think, for example, of zip codes.
|
607
|
-
table, you can
|
608
|
-
|
609
|
-
|
621
|
+
appearance. Think, for example, of zip codes. If headers are given when a
|
622
|
+
table is contructed, you can designate a forced-string column by appending a
|
623
|
+
~!~ to the end of the header. It will not become part of the header, it will
|
624
|
+
just mark it as a forced-string Column.
|
625
|
+
|
626
|
+
#+begin_SRC emacs-lisp :wrap EXAMPLE
|
627
|
+
tab = FatTable.new(:a, 'b', 'C!', :d, :zip!)
|
628
|
+
#+end_SRC
|
629
|
+
|
630
|
+
In addition, at any time after creating a table, you can force the String type
|
631
|
+
on any number of columns with the ~force_string!~ method. When you do so, all
|
632
|
+
exisiting items in the column are converted to strings with the #to_s method.
|
610
633
|
|
611
634
|
#+begin_src ruby :wrap EXAMPLE
|
612
635
|
tab = FatTable.new(:a, 'b', 'C', :d, :zip)
|
data/TODO.org
CHANGED
@@ -1,10 +1,37 @@
|
|
1
|
+
|
2
|
+
* TODO Specify Column Widths
|
3
|
+
Allow a formatter to specify column widths. This could be a number of
|
4
|
+
characters, which would be interpreted as a number of "ems" for LaTeX.
|
5
|
+
Cell content larger than the width would be truncated. Any column without a
|
6
|
+
width specified would be set at the width of the longest value in that cell,
|
7
|
+
after initial formatting.
|
8
|
+
|
9
|
+
#+begin_SRC ruby
|
10
|
+
tab.to_text do |f|
|
11
|
+
f.widths(a: 13, b: 30)
|
12
|
+
end
|
13
|
+
#+end_SRC
|
14
|
+
|
15
|
+
Possible enhancements:
|
16
|
+
- specify an overall width and column widths as decimal or fractions, so that
|
17
|
+
a column's width would be that fraction of the overall width.
|
18
|
+
- specify a Range for a width, so that the column would at least min and at
|
19
|
+
most max, otherwise the width of its largest cell.
|
20
|
+
|
1
21
|
* TODO Conversion to Spreadsheets
|
2
22
|
- State "TODO" from [2017-04-21 Fri 10:36]
|
3
23
|
This is a [[https://github.com/westonganger/spreadsheet_architect][gem]] that I can include into the Table model to convert a table into
|
4
24
|
a spread-sheet, or even a sheet in a multi-sheet spreadsheet file.
|
5
25
|
|
6
|
-
* TODO Add
|
26
|
+
* TODO Add Quandl or EODDATA Queries
|
27
|
+
Possible replacements for YQL.
|
28
|
+
|
29
|
+
* CNCL Add from_yql for fetching from Yahoo
|
30
|
+
CLOSED: [2022-01-30 Sun 06:03]
|
7
31
|
- State "TODO" from [2017-04-21 Fri 10:35]
|
32
|
+
|
33
|
+
Cancelled because Yahoo shut down the YQL api service.
|
34
|
+
|
8
35
|
Add a constructor to allow fetching stock data from yql. Perhaps grab all
|
9
36
|
available fields, then allow a select of those of interest.
|
10
37
|
|
data/lib/fat_table/column.rb
CHANGED
@@ -191,8 +191,11 @@ module FatTable
|
|
191
191
|
|
192
192
|
# :category: Aggregates
|
193
193
|
|
194
|
-
# Return the first non-nil item in the Column
|
194
|
+
# Return the first non-nil item in the Column, or nil if all items are
|
195
|
+
# nil. Works with any Column type.
|
195
196
|
def first
|
197
|
+
return nil if items.all?(&:nil?)
|
198
|
+
|
196
199
|
if type == 'String'
|
197
200
|
items.reject(&:blank?).first
|
198
201
|
else
|
@@ -204,6 +207,8 @@ module FatTable
|
|
204
207
|
|
205
208
|
# Return the last non-nil item in the Column. Works with any Column type.
|
206
209
|
def last
|
210
|
+
return nil if items.all?(&:nil?)
|
211
|
+
|
207
212
|
if type == 'String'
|
208
213
|
items.reject(&:blank?).last
|
209
214
|
else
|
@@ -213,9 +218,11 @@ module FatTable
|
|
213
218
|
|
214
219
|
# :category: Aggregates
|
215
220
|
|
216
|
-
# Return a count of the non-nil items in the Column
|
217
|
-
# type.
|
221
|
+
# Return a count of the non-nil items in the Column, or the size of the
|
222
|
+
# column if all items are nil. Works with any Column type.
|
218
223
|
def count
|
224
|
+
return items.size if items.all?(&:nil?)
|
225
|
+
|
219
226
|
if type == 'String'
|
220
227
|
items.reject(&:blank?).count.to_d
|
221
228
|
else
|
@@ -225,8 +232,8 @@ module FatTable
|
|
225
232
|
|
226
233
|
# :category: Aggregates
|
227
234
|
|
228
|
-
# Return the smallest non-nil, non-blank item in the Column
|
229
|
-
# numeric, string, and datetime Columns.
|
235
|
+
# Return the smallest non-nil, non-blank item in the Column, or nil if all
|
236
|
+
# items are nil. Works with numeric, string, and datetime Columns.
|
230
237
|
def min
|
231
238
|
only_with('min', 'NilClass', 'Numeric', 'String', 'DateTime')
|
232
239
|
if type == 'String'
|
@@ -238,8 +245,8 @@ module FatTable
|
|
238
245
|
|
239
246
|
# :category: Aggregates
|
240
247
|
|
241
|
-
# Return the largest non-nil, non-blank item in the Column
|
242
|
-
# numeric, string, and datetime Columns.
|
248
|
+
# Return the largest non-nil, non-blank item in the Column, or nil if all
|
249
|
+
# items are nil. Works with numeric, string, and datetime Columns.
|
243
250
|
def max
|
244
251
|
only_with('max', 'NilClass', 'Numeric', 'String', 'DateTime')
|
245
252
|
if type == 'String'
|
@@ -251,19 +258,24 @@ module FatTable
|
|
251
258
|
|
252
259
|
# :category: Aggregates
|
253
260
|
|
254
|
-
# Return a Range object for the smallest to largest value in the column
|
255
|
-
# Works with numeric, string, and datetime
|
261
|
+
# Return a Range object for the smallest to largest value in the column,
|
262
|
+
# or nil if all items are nil. Works with numeric, string, and datetime
|
263
|
+
# Columns.
|
256
264
|
def range
|
257
265
|
only_with('range', 'NilClass', 'Numeric', 'String', 'DateTime')
|
266
|
+
return nil if items.all?(&:nil?)
|
267
|
+
|
258
268
|
Range.new(min, max)
|
259
269
|
end
|
260
270
|
|
261
271
|
# :category: Aggregates
|
262
272
|
|
263
|
-
# Return the sum of the non-nil items in the Column
|
264
|
-
# string Columns. For a string Column, it
|
265
|
-
# the non-nil items.
|
273
|
+
# Return the sum of the non-nil items in the Column, or 0 if all items are
|
274
|
+
# nil. Works with numeric and string Columns. For a string Column, it
|
275
|
+
# will return the concatenation of the non-nil items.
|
266
276
|
def sum
|
277
|
+
return 0 if type == 'NilClass' || items.all?(&:nil?)
|
278
|
+
|
267
279
|
only_with('sum', 'Numeric', 'String')
|
268
280
|
if type == 'String'
|
269
281
|
items.reject(&:blank?).join(' ')
|
@@ -274,11 +286,13 @@ module FatTable
|
|
274
286
|
|
275
287
|
# :category: Aggregates
|
276
288
|
|
277
|
-
# Return the average value of the non-nil items in the Column
|
278
|
-
# numeric and datetime Columns. For datetime
|
279
|
-
# to its Julian day number, computes the
|
280
|
-
# average back to a DateTime.
|
289
|
+
# Return the average value of the non-nil items in the Column, or 0 if all
|
290
|
+
# items are nil. Works with numeric and datetime Columns. For datetime
|
291
|
+
# Columns, it converts each date to its Julian day number, computes the
|
292
|
+
# average, and then converts the average back to a DateTime.
|
281
293
|
def avg
|
294
|
+
return 0 if type == 'NilClass' || items.all?(&:nil?)
|
295
|
+
|
282
296
|
only_with('avg', 'DateTime', 'Numeric')
|
283
297
|
itms = items.filter_to_type(type)
|
284
298
|
size = itms.size.to_d
|
@@ -293,11 +307,14 @@ module FatTable
|
|
293
307
|
# :category: Aggregates
|
294
308
|
|
295
309
|
# Return the sample variance (the unbiased estimator of the population
|
296
|
-
# variance using a divisor of N-1) as the average squared deviation from
|
297
|
-
# mean, of the non-nil items in the Column
|
298
|
-
# Columns. For datetime Columns, it
|
299
|
-
# number and computes the variance of
|
310
|
+
# variance using a divisor of N-1) as the average squared deviation from
|
311
|
+
# the mean, of the non-nil items in the Column, or 0 if all items are
|
312
|
+
# nil. Works with numeric and datetime Columns. For datetime Columns, it
|
313
|
+
# converts each date to its Julian day number and computes the variance of
|
314
|
+
# those numbers.
|
300
315
|
def var
|
316
|
+
return 0 if type == 'NilClass' || items.all?(&:nil?)
|
317
|
+
|
301
318
|
only_with('var', 'DateTime', 'Numeric')
|
302
319
|
all_items =
|
303
320
|
if type == 'DateTime'
|
@@ -319,10 +336,13 @@ module FatTable
|
|
319
336
|
|
320
337
|
# Return the population variance (the biased estimator of the population
|
321
338
|
# variance using a divisor of N) as the average squared deviation from the
|
322
|
-
# mean, of the non-nil items in the Column
|
323
|
-
# Columns. For datetime Columns, it
|
324
|
-
# number and computes the variance of
|
339
|
+
# mean, of the non-nil items in the Column, or 0 if all items are
|
340
|
+
# nil. Works with numeric and datetime Columns. For datetime Columns, it
|
341
|
+
# converts each date to its Julian day number and computes the variance of
|
342
|
+
# those numbers.
|
325
343
|
def pvar
|
344
|
+
return 0 if type == 'NilClass' || items.all?(&:nil?)
|
345
|
+
|
326
346
|
only_with('var', 'DateTime', 'Numeric')
|
327
347
|
n = items.filter_to_type(type).size.to_d
|
328
348
|
return BigDecimal('0.0') if n <= 1
|
@@ -333,11 +353,13 @@ module FatTable
|
|
333
353
|
|
334
354
|
# Return the sample standard deviation (the unbiased estimator of the
|
335
355
|
# population standard deviation using a divisor of N-1) as the square root
|
336
|
-
# of the sample variance, of the non-nil items in the Column
|
337
|
-
# numeric and datetime Columns. For datetime
|
338
|
-
# to its Julian day number and computes the
|
339
|
-
# numbers.
|
356
|
+
# of the sample variance, of the non-nil items in the Column, or 0 if all
|
357
|
+
# items are nil. Works with numeric and datetime Columns. For datetime
|
358
|
+
# Columns, it converts each date to its Julian day number and computes the
|
359
|
+
# standard deviation of those numbers.
|
340
360
|
def dev
|
361
|
+
return 0 if type == 'NilClass' || items.all?(&:nil?)
|
362
|
+
|
341
363
|
only_with('dev', 'DateTime', 'Numeric')
|
342
364
|
var.sqrt(20)
|
343
365
|
end
|
@@ -345,12 +367,14 @@ module FatTable
|
|
345
367
|
# :category: Aggregates
|
346
368
|
|
347
369
|
# Return the population standard deviation (the biased estimator of the
|
348
|
-
# population standard deviation using a divisor of N) as the square root
|
349
|
-
# the population variance, of the non-nil items in the Column
|
350
|
-
# numeric and datetime Columns. For datetime
|
351
|
-
# to its Julian day number and computes the
|
352
|
-
# numbers.
|
370
|
+
# population standard deviation using a divisor of N) as the square root
|
371
|
+
# of the population variance, of the non-nil items in the Column, or 0 if
|
372
|
+
# all items are nil. Works with numeric and datetime Columns. For datetime
|
373
|
+
# Columns, it converts each date to its Julian day number and computes the
|
374
|
+
# standard deviation of those numbers.
|
353
375
|
def pdev
|
376
|
+
return 0 if type == 'NilClass' || items.all?(&:nil?)
|
377
|
+
|
354
378
|
only_with('dev', 'DateTime', 'Numeric')
|
355
379
|
Math.sqrt(pvar)
|
356
380
|
end
|
@@ -358,8 +382,10 @@ module FatTable
|
|
358
382
|
# :category: Aggregates
|
359
383
|
|
360
384
|
# Return true if any of the items in the Column are true; otherwise return
|
361
|
-
# false. Works only with boolean Columns.
|
385
|
+
# false, or false if all items are nil. Works only with boolean Columns.
|
362
386
|
def any?
|
387
|
+
return false if type == 'NilClass' || items.all?(&:nil?)
|
388
|
+
|
363
389
|
only_with('any?', 'Boolean')
|
364
390
|
items.filter_to_type(type).any?
|
365
391
|
end
|
@@ -367,17 +393,22 @@ module FatTable
|
|
367
393
|
# :category: Aggregates
|
368
394
|
|
369
395
|
# Return true if all of the items in the Column are true; otherwise return
|
370
|
-
# false. Works only with boolean Columns.
|
396
|
+
# false, or false if all items are nil. Works only with boolean Columns.
|
371
397
|
def all?
|
398
|
+
return false if type == 'NilClass' || items.all?(&:nil?)
|
399
|
+
|
372
400
|
only_with('all?', 'Boolean')
|
373
401
|
items.filter_to_type(type).all?
|
374
402
|
end
|
375
403
|
|
376
404
|
# :category: Aggregates
|
377
405
|
|
378
|
-
# Return true if none of the items in the Column are true; otherwise
|
379
|
-
# false. Works only with boolean
|
406
|
+
# Return true if none of the items in the Column are true; otherwise
|
407
|
+
# return false, or true if all items are nil. Works only with boolean
|
408
|
+
# Columns.
|
380
409
|
def none?
|
410
|
+
return true if type == 'NilClass' || items.all?(&:nil?)
|
411
|
+
|
381
412
|
only_with('none?', 'Boolean')
|
382
413
|
items.filter_to_type(type).none?
|
383
414
|
end
|
@@ -387,6 +418,8 @@ module FatTable
|
|
387
418
|
# Return true if precisely one of the items in the Column is true;
|
388
419
|
# otherwise return false. Works only with boolean Columns.
|
389
420
|
def one?
|
421
|
+
return false if type == 'NilClass' || items.all?(&:nil?)
|
422
|
+
|
390
423
|
only_with('one?', 'Boolean')
|
391
424
|
items.filter_to_type(type).one?
|
392
425
|
end
|
@@ -395,6 +428,7 @@ module FatTable
|
|
395
428
|
|
396
429
|
def only_with(agg, *valid_types)
|
397
430
|
return self if valid_types.include?(type)
|
431
|
+
|
398
432
|
msg = "aggregate '#{agg}' cannot be applied to a #{type} column"
|
399
433
|
raise UserError, msg
|
400
434
|
end
|
@@ -436,7 +470,12 @@ module FatTable
|
|
436
470
|
private
|
437
471
|
|
438
472
|
def convert_and_set_type(val)
|
439
|
-
|
473
|
+
begin
|
474
|
+
new_val = Convert.convert_to_type(val, type, tolerant: tolerant?)
|
475
|
+
rescue IncompatibleTypeError
|
476
|
+
err_msg = "attempt to add '#{val}' to column '#{header}' already typed as #{type}"
|
477
|
+
raise IncompatibleTypeError, err_msg
|
478
|
+
end
|
440
479
|
if new_val && (type == 'NilClass' || type == 'String')
|
441
480
|
@type =
|
442
481
|
if [true, false].include?(new_val)
|
data/lib/fat_table/convert.rb
CHANGED
@@ -36,8 +36,7 @@ module FatTable
|
|
36
36
|
else
|
37
37
|
new_val = convert_to_boolean(val)
|
38
38
|
if new_val.nil?
|
39
|
-
|
40
|
-
raise IncompatibleTypeError, msg
|
39
|
+
raise IncompatibleTypeError
|
41
40
|
end
|
42
41
|
new_val
|
43
42
|
end
|
@@ -47,8 +46,7 @@ module FatTable
|
|
47
46
|
else
|
48
47
|
new_val = convert_to_date_time(val)
|
49
48
|
if new_val.nil?
|
50
|
-
|
51
|
-
raise IncompatibleTypeError, msg
|
49
|
+
raise IncompatibleTypeError
|
52
50
|
end
|
53
51
|
new_val
|
54
52
|
end
|
@@ -58,8 +56,7 @@ module FatTable
|
|
58
56
|
else
|
59
57
|
new_val = convert_to_numeric(val)
|
60
58
|
if new_val.nil?
|
61
|
-
|
62
|
-
raise IncompatibleTypeError, msg
|
59
|
+
raise IncompatibleTypeError
|
63
60
|
end
|
64
61
|
new_val
|
65
62
|
end
|
@@ -82,8 +79,7 @@ module FatTable
|
|
82
79
|
else
|
83
80
|
new_val = convert_to_string(val)
|
84
81
|
if new_val.nil?
|
85
|
-
|
86
|
-
raise IncompatibleTypeError, msg
|
82
|
+
raise IncompatibleTypeError
|
87
83
|
end
|
88
84
|
new_val
|
89
85
|
end
|
data/lib/fat_table/footer.rb
CHANGED
@@ -532,7 +532,7 @@ module FatTable
|
|
532
532
|
valid_keys = table.headers + %i[string numeric datetime boolean nil]
|
533
533
|
invalid_keys = (fmts.keys - valid_keys).uniq
|
534
534
|
unless invalid_keys.empty?
|
535
|
-
msg = "invalid #{location} column or type: #{invalid_keys.join(',')}"
|
535
|
+
msg = "invalid #{location} column or type: #{invalid_keys.join(', ')}"
|
536
536
|
raise UserError, msg
|
537
537
|
end
|
538
538
|
|
@@ -1004,9 +1004,14 @@ module FatTable
|
|
1004
1004
|
# converted to strings formatted according to the Formatter's formatting
|
1005
1005
|
# directives given in Formatter.format_for or Formatter.format.
|
1006
1006
|
def output
|
1007
|
-
#
|
1008
|
-
#
|
1009
|
-
|
1007
|
+
# If there are neither headers nor any rows in the table, return an
|
1008
|
+
# empty string.
|
1009
|
+
return '' if table.empty? && table.headers.empty?
|
1010
|
+
|
1011
|
+
# This results in a hash of two-element arrays. The key
|
1012
|
+
# is the header and the value is an array of the header and formatted
|
1013
|
+
# header. We do the latter so the structure parallels the structure for
|
1014
|
+
# rows explained next.
|
1010
1015
|
formatted_headers = build_formatted_headers
|
1011
1016
|
|
1012
1017
|
# These produce an array with each element representing a row of the
|
@@ -20,7 +20,7 @@ module FatTable
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def pre_header(widths)
|
23
|
-
result = '|'
|
23
|
+
result = +'|'
|
24
24
|
widths.each_value do |w|
|
25
25
|
result += '-' * (w + 2) + '+'
|
26
26
|
end
|
@@ -53,7 +53,7 @@ module FatTable
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def hline(widths)
|
56
|
-
result = '|'
|
56
|
+
result = +'|'
|
57
57
|
widths.each_value do |w|
|
58
58
|
result += '-' * (w + 2) + '+'
|
59
59
|
end
|
@@ -62,7 +62,7 @@ module FatTable
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def post_footers(widths)
|
65
|
-
result = '|'
|
65
|
+
result = +'|'
|
66
66
|
widths.each_value do |w|
|
67
67
|
result += '-' * (w + 2) + '+'
|
68
68
|
end
|
@@ -221,7 +221,7 @@ module FatTable
|
|
221
221
|
end
|
222
222
|
|
223
223
|
def pre_header(widths)
|
224
|
-
result = upper_left
|
224
|
+
result = +upper_left
|
225
225
|
widths.each_value do |w|
|
226
226
|
result += double_rule * (w + 2) + upper_tee
|
227
227
|
end
|
@@ -255,7 +255,7 @@ module FatTable
|
|
255
255
|
end
|
256
256
|
|
257
257
|
def hline(widths)
|
258
|
-
result = left_tee
|
258
|
+
result = +left_tee
|
259
259
|
widths.each_value do |w|
|
260
260
|
result += horizontal_rule * (w + 2) + single_cross
|
261
261
|
end
|
@@ -289,7 +289,7 @@ module FatTable
|
|
289
289
|
end
|
290
290
|
|
291
291
|
def post_footers(widths)
|
292
|
-
result = lower_left
|
292
|
+
result = +lower_left
|
293
293
|
widths.each_value do |w|
|
294
294
|
result += double_rule * (w + 2) + lower_tee
|
295
295
|
end
|
@@ -16,7 +16,7 @@ module FatTable
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def pre_header(widths)
|
19
|
-
result = '+'
|
19
|
+
result = +'+'
|
20
20
|
widths.each_value do |w|
|
21
21
|
result += '=' * (w + 2) + '+'
|
22
22
|
end
|
@@ -49,7 +49,7 @@ module FatTable
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def hline(widths)
|
52
|
-
result = '+'
|
52
|
+
result = +'+'
|
53
53
|
widths.each_value do |w|
|
54
54
|
result += '-' * (w + 2) + '+'
|
55
55
|
end
|
@@ -82,7 +82,7 @@ module FatTable
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def post_footers(widths)
|
85
|
-
result = '+'
|
85
|
+
result = +'+'
|
86
86
|
widths.each_value do |w|
|
87
87
|
result += '=' * (w + 2) + '+'
|
88
88
|
end
|
data/lib/fat_table/table.rb
CHANGED
@@ -105,7 +105,7 @@ module FatTable
|
|
105
105
|
unless heads.empty?
|
106
106
|
heads.each do |h|
|
107
107
|
if h.to_s.end_with?('!') || @tolerant_columns.include?(h)
|
108
|
-
@columns << Column.new(header: h.to_s.sub(/!\s*\z/, ''),
|
108
|
+
@columns << Column.new(header: h.to_s.sub(/!\s*\z/, ''), type: 'String')
|
109
109
|
else
|
110
110
|
@columns << Column.new(header: h)
|
111
111
|
end
|
@@ -120,7 +120,7 @@ module FatTable
|
|
120
120
|
# though FatTable::Table objects have no instance variables, a class that
|
121
121
|
# inherits from it might.
|
122
122
|
def empty_dup
|
123
|
-
|
123
|
+
dup.__empty!
|
124
124
|
end
|
125
125
|
|
126
126
|
def __empty!
|
data/lib/fat_table/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fat_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel E. Doherty
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -332,7 +332,7 @@ licenses: []
|
|
332
332
|
metadata:
|
333
333
|
allowed_push_host: https://rubygems.org
|
334
334
|
yard.run: yri
|
335
|
-
post_install_message:
|
335
|
+
post_install_message:
|
336
336
|
rdoc_options: []
|
337
337
|
require_paths:
|
338
338
|
- lib
|
@@ -348,7 +348,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
348
348
|
version: '0'
|
349
349
|
requirements: []
|
350
350
|
rubygems_version: 3.3.3
|
351
|
-
signing_key:
|
351
|
+
signing_key:
|
352
352
|
specification_version: 4
|
353
353
|
summary: Provides tools for working with tables as a data type.
|
354
354
|
test_files: []
|