Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Commit 854410c

Browse files
committed
bugfix ConsoleOutput
1 parent c96818c commit 854410c

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
All Notable changes to `Period Visualizer` will be documented in this file
44

5+
## 0.2.2 - 2018-12-20
6+
7+
- Bug Fix `ConsoleOutput::render` method. No newline character must be added at the end of the line.
8+
59
## 0.2.1 - 2018-12-20
610

7-
- Bug Fix `ConsoleOutput::render` method.
11+
- Bug Fix `ConsoleOutput::render` method. Once the matrix is created we just use it and we non longer rely on
12+
the submitted data.
813

914
## 0.2.0 - 2018-12-20
1015

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,14 @@ $config = (new ConsoleConfig())
362362
;
363363

364364
$output = new ConsoleOutput($config);
365-
echo $output->display([
365+
$content = $output->render([
366366
['first', new Period('2018-01-01 08:00:00', '2018-01-01 12:00:00')],
367367
['last', new Period('2018-01-01 10:00:00', '2018-01-01 14:00:00')],
368368
]);
369+
370+
foreach ($content as $line) {
371+
echo $line, PHP_EOL;
372+
}
369373
~~~
370374

371375
results:

src/ConsoleOutput.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function display(array $blocks): string
9999
{
100100
ob_start();
101101
foreach ($this->render($blocks) as $row) {
102-
echo $row;
102+
echo $row.$this->newline;
103103
}
104104

105105
return (string) ob_get_clean();
@@ -122,7 +122,7 @@ public function render(array $blocks): iterable
122122
$line = str_pad($name, $nameLength, ' ').' '.$this->toLine($row);
123123
$color = $colorOffsets[++$key % count($colorOffsets)];
124124

125-
yield $this->writeln("<<$color>>$line<<reset>>");
125+
yield $this->write("<<$color>>$line<<reset>>");
126126
}
127127
}
128128

@@ -173,9 +173,9 @@ private function toLine(array $row): string
173173
*
174174
* Inspired by Aura\Cli\Stdio\Formatter (https://github.com/auraphp/Aura.Cli).
175175
*/
176-
private function writeln(string $str): string
176+
private function write(string $str): string
177177
{
178-
return $this->{$this->method}($str).$this->newline;
178+
return $this->{$this->method}($str);
179179
}
180180

181181
/**

0 commit comments

Comments
 (0)