[libcatmandu-perl] 03/46: use MultiMarkdown table format
Jonas Smedegaard
dr at jones.dk
Tue Oct 14 13:52:51 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.9205
in repository libcatmandu-perl.
commit 2b7933652924d62e7598c520621e106ef8f5c426
Author: Jakob Voss <voss at gbv.de>
Date: Mon Jun 23 14:13:48 2014 +0200
use MultiMarkdown table format
---
lib/Catmandu/Iterable.pm | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/Catmandu/Iterable.pm b/lib/Catmandu/Iterable.pm
index 8ca7ff2..e757223 100644
--- a/lib/Catmandu/Iterable.pm
+++ b/lib/Catmandu/Iterable.pm
@@ -4,7 +4,6 @@ use namespace::clean;
use Catmandu::Sane;
use Catmandu::Util qw(:is :check);
use Time::HiRes qw(gettimeofday tv_interval);
-use List::Util ();
require Catmandu::Iterator;
require Catmandu::ArrayIterator;
use Role::Tiny;
@@ -337,14 +336,14 @@ sub format {
$row;
})->to_array;
- my $longest_row = List::Util::sum(@col_lengths) + (length($opts{col_sep}) * (scalar(@cols) - 1));
my @indices = 0 .. @cols-1;
my $pattern = join($opts{col_sep}, map { "%-$col_lengths[$_]s" } @indices)."\n";
if ($opts{header}) {
printf $pattern, @cols;
- print '=' x $longest_row;
- print "\n";
+ my $sep = $opts{col_sep};
+ $sep =~ s/[^|]/-/g;
+ print join($sep, map { '-' x $col_lengths[$_] } @indices)."\n";
}
for my $row (@$rows) {
printf $pattern, @$row;
@@ -655,7 +654,9 @@ Prints the number of records processed per second to STDERR.
=head2 format(cols => ['key', ...], col_sep => ' | ', header => 1|0)
Print the iterator data formatted as a spreadsheet like table. Note that this
-method will load the whole dataset in memory to calculate column widths.
+method will load the whole dataset in memory to calculate column widths. See
+also L<Catmandu::Exporter::Table> for a more elaborated method of printing
+iterators in tabular form.
=head1 SEE ALSO
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-perl.git
More information about the Pkg-perl-cvs-commits
mailing list