termichunk 0.0.2 → 0.0.3
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/lib/termichunk/report.rb +3 -3
- data/lib/termichunk/version.rb +1 -1
- data/spec/report_spec.rb +33 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04a462cfdc6e469fd7b95ea3f5930f1a29eaf479
|
4
|
+
data.tar.gz: b49068d921d284e333d05a67c74dda9d16e52363
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36803d0cce0029741c99e917d1799aec0b351db929933b3e1ab5b8fcd0e1bfa5fd5048319c5733cfcc5ab050d1a67e7d2707f0923aefbcab3cf6e9c4bb25d231
|
7
|
+
data.tar.gz: ec822cd86b4d82bd184a158effa2130202ae863f458506cc1a663e2961095daf18df4640693687dac0c298af9a60eed097c7731166f637fca9a705d4b502ad16
|
data/lib/termichunk/report.rb
CHANGED
@@ -35,13 +35,13 @@ module TermiChunk
|
|
35
35
|
# @return [String]
|
36
36
|
def to_s
|
37
37
|
y = padding.times.map { Y }
|
38
|
-
[titlebar(TL), *y, body, *y, titlebar(BL)].compact.join("\n")
|
38
|
+
[titlebar(TL), *y, body, *(y if body), titlebar(BL)].compact.join("\n")
|
39
39
|
end
|
40
40
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def body
|
44
|
-
rows.map { |l| "#{Y} #{' ' * padding}#{l.chomp}" }.join("\n")
|
44
|
+
rows.map { |l| "#{Y} #{' ' * padding}#{l.chomp}" }.join("\n") unless rows.length.zero?
|
45
45
|
end
|
46
46
|
|
47
47
|
def titlebar(corner)
|
@@ -51,7 +51,7 @@ module TermiChunk
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def width
|
54
|
-
[rows.map(&:length).max + 2, title.length + 6].max
|
54
|
+
[(rows.map(&:length).max || 0) + 2, title.length + 6].max
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
data/lib/termichunk/version.rb
CHANGED
data/spec/report_spec.rb
CHANGED
@@ -40,6 +40,13 @@ module TermiChunk
|
|
40
40
|
EOF
|
41
41
|
end
|
42
42
|
|
43
|
+
it 'can make an empty report' do
|
44
|
+
expect(result).to eq <<~EOF
|
45
|
+
┌─[ Some Report ]──
|
46
|
+
└─[ Some Report ]──
|
47
|
+
EOF
|
48
|
+
end
|
49
|
+
|
43
50
|
context 'padding' do
|
44
51
|
let(:contents) { "Line 1 has some stuff in it\nLine 2 has less" }
|
45
52
|
let(:subject) { described_class.new(title: 'Some Report', padding: padding) { |r| r << contents } }
|
@@ -81,6 +88,18 @@ module TermiChunk
|
|
81
88
|
└─[ Some Report ]───────────────────
|
82
89
|
EOF
|
83
90
|
end
|
91
|
+
|
92
|
+
context 'empty' do
|
93
|
+
let(:subject) { described_class.new(title: 'Some Report', padding: padding) }
|
94
|
+
|
95
|
+
it 'can make an empty report' do
|
96
|
+
expect(result).to eq <<~EOF
|
97
|
+
┌─[ Some Report ]────
|
98
|
+
│
|
99
|
+
└─[ Some Report ]────
|
100
|
+
EOF
|
101
|
+
end
|
102
|
+
end
|
84
103
|
end
|
85
104
|
|
86
105
|
context '3' do
|
@@ -100,6 +119,20 @@ module TermiChunk
|
|
100
119
|
└─[ Some Report ]─────────────────────
|
101
120
|
EOF
|
102
121
|
end
|
122
|
+
|
123
|
+
context 'empty' do
|
124
|
+
let(:subject) { described_class.new(title: 'Some Report', padding: padding) }
|
125
|
+
|
126
|
+
it 'can make an empty report' do
|
127
|
+
expect(result).to eq <<~EOF
|
128
|
+
┌─[ Some Report ]────────
|
129
|
+
│
|
130
|
+
│
|
131
|
+
│
|
132
|
+
└─[ Some Report ]────────
|
133
|
+
EOF
|
134
|
+
end
|
135
|
+
end
|
103
136
|
end
|
104
137
|
end
|
105
138
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: termichunk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin McDonald
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|