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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47c94a272fd0424effa802c0c4fae6e86c21d0ee
4
- data.tar.gz: 4c6dbcd6deb94d9cce9def3308d250150be3ad92
3
+ metadata.gz: 04a462cfdc6e469fd7b95ea3f5930f1a29eaf479
4
+ data.tar.gz: b49068d921d284e333d05a67c74dda9d16e52363
5
5
  SHA512:
6
- metadata.gz: 13a3f1aa0487eb528d026d0a15ea24c01c28a35c182a5184703b88205a45395a8044d3603d23de6bba5ae07d6974972d1b04cb713f2b3c153bec79957151b6ba
7
- data.tar.gz: c438a0ec2be02cc3d2f395edd37d16c2b13c3aa461eb9d84c779896fa61cb19e3b3da4a65e838c883f5ed3fa83c80175301c06ac1ff5e9f602d985e606c4fd02
6
+ metadata.gz: 36803d0cce0029741c99e917d1799aec0b351db929933b3e1ab5b8fcd0e1bfa5fd5048319c5733cfcc5ab050d1a67e7d2707f0923aefbcab3cf6e9c4bb25d231
7
+ data.tar.gz: ec822cd86b4d82bd184a158effa2130202ae863f458506cc1a663e2961095daf18df4640693687dac0c298af9a60eed097c7731166f637fca9a705d4b502ad16
@@ -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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module TermiChunk
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
@@ -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.2
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-15 00:00:00.000000000 Z
11
+ date: 2020-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler