table_pal 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/plain_text_coloured.rb +44 -1
- data/lib/row.rb +3 -2
- data/lib/validate.rb +2 -1
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f81c508e3e0a0d2044c6cb2742b8f512128427b044c19b8dcf418ff90b0ed92c
|
4
|
+
data.tar.gz: 0abc768ae7bc5ab6a7947f3d825eea34292c2ab6fbd3997b4b469e8d2006412e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ca3403f46af6166dc8a2d91fb41e78b7b551fceaddd5299b51560bd861803ab96f26256339449fa027c6a20b62658e3f260766b6b19a329c32803f5c3d514db
|
7
|
+
data.tar.gz: '09fc643fa26f0175eb752b80cb687ddfd60f2c71d99c221163134c9388da40a31e7fad8758b76562edcf4331de41139895fd8c748e4c09e294c100bee5a24eac'
|
data/Gemfile.lock
CHANGED
data/lib/plain_text_coloured.rb
CHANGED
@@ -14,9 +14,39 @@ module TablePal
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def print_row(row)
|
17
|
+
if row.heading
|
18
|
+
print_heading_row(row)
|
19
|
+
elsif row.subheading
|
20
|
+
print_subheading_row(row)
|
21
|
+
elsif row.section_end
|
22
|
+
print_section_end_row(row)
|
23
|
+
else
|
24
|
+
print_regular_row(row)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def print_heading_row(row)
|
29
|
+
print_cells(row)
|
30
|
+
puts
|
31
|
+
underline
|
32
|
+
empty
|
33
|
+
end
|
34
|
+
|
35
|
+
def print_subheading_row(row)
|
36
|
+
print_cells(row)
|
37
|
+
puts
|
38
|
+
empty
|
39
|
+
end
|
40
|
+
|
41
|
+
def print_section_end_row(row)
|
42
|
+
print_cells(row)
|
43
|
+
puts
|
44
|
+
empty
|
45
|
+
end
|
46
|
+
|
47
|
+
def print_regular_row(row)
|
17
48
|
print_cells(row)
|
18
49
|
puts
|
19
|
-
underline if row.heading
|
20
50
|
end
|
21
51
|
|
22
52
|
def print_cells(row)
|
@@ -46,5 +76,18 @@ module TablePal
|
|
46
76
|
puts
|
47
77
|
end
|
48
78
|
|
79
|
+
def empty
|
80
|
+
table.columns.map do |column|
|
81
|
+
char = ' '
|
82
|
+
print column.left_border
|
83
|
+
print column.left_padding_char(char)
|
84
|
+
print char * column.width
|
85
|
+
print column.right_padding_char(char)
|
86
|
+
print column.right_border
|
87
|
+
end
|
88
|
+
|
89
|
+
puts
|
90
|
+
end
|
91
|
+
|
49
92
|
end
|
50
93
|
end
|
data/lib/row.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
module TablePal
|
2
2
|
class Row
|
3
3
|
|
4
|
-
attr_reader :table, :formatter, :heading, :subheading, :justification, :colour
|
4
|
+
attr_reader :table, :formatter, :heading, :subheading, :section_end, :justification, :colour
|
5
5
|
|
6
|
-
def initialize(table:, formatter: nil, heading: false, subheading: false, justification: nil, colour: nil)
|
6
|
+
def initialize(table:, formatter: nil, heading: false, subheading: false, section_end: false, justification: nil, colour: nil)
|
7
7
|
@table = table
|
8
8
|
@formatter = formatter
|
9
9
|
@heading = heading
|
10
10
|
@subheading = subheading
|
11
|
+
@section_end = section_end
|
11
12
|
@justification = justification
|
12
13
|
@colour = colour
|
13
14
|
end
|
data/lib/validate.rb
CHANGED
@@ -24,7 +24,8 @@ module TablePal
|
|
24
24
|
when :right_border then validate(key: key, value: value, classes: [String, NilClass])
|
25
25
|
when :right_padding then validate(key: key, value: value, classes: String)
|
26
26
|
when :row then validate(key: key, value: value, classes: Row)
|
27
|
-
when :subheading then validate(key: key, value: value, classes: [TrueClass])
|
27
|
+
when :subheading then validate(key: key, value: value, classes: [TrueClass, FalseClass])
|
28
|
+
when :section_end then validate(key: key, value: value, classes: [TrueClass, FalseClass])
|
28
29
|
else raise TablePalError, "#{class_method} received Unexpected option: `#{key}`"
|
29
30
|
end
|
30
31
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_pal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Lerner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: interesting_methods
|