2009/4/20 Matt S Trout <[email protected]>:
> On Mon, Apr 20, 2009 at 05:16:55AM +0300, Oleg Kostyuk wrote:
>> PS: probably, it's needed to check all other places, that use
>> Text::SimpleTable
>
> That'd be well worth doing. Please send us a patch if you find any more when
> you check them :)
Sure, why not :)
New patch attached. We need one more dependency to get this working,
Text::SimpleTable::AutoWidth.
Feel free to patch my patch :) by changing fixed_width to max_width
and vice versa, if you think that that will looks better. Tables that
created with "max_width" will be not wider than needed, and tables
that created with "fixed_width" will be always all terminal wide.
Any feedback welcome.
--
Sincerely yours,
Oleg Kostyuk (CUB-UANIC)
diff -ru cat.orig/Catalyst/Dispatcher.pm cat.new/Catalyst/Dispatcher.pm
--- cat.orig/Catalyst/Dispatcher.pm 2009-04-20 06:42:26.000000000 +0300
+++ cat.new/Catalyst/Dispatcher.pm 2009-04-20 21:52:01.000000000 +0300
@@ -11,7 +11,7 @@
use Catalyst::DispatchType::Default;
use Catalyst::DispatchType::Index;
use Catalyst::Utils;
-use Text::SimpleTable;
+use Text::SimpleTable::AutoWidth;
use Tree::Simple;
use Tree::Simple::Visitor::FindByPath;
@@ -605,9 +605,9 @@
sub _display_action_tables {
my ($self, $c) = @_;
- my $column_width = Catalyst::Utils::term_width() - 36 - 36 - 12;
- my $privates = Text::SimpleTable->new(
- [ 36, 'Private' ], [ 36, 'Class' ], [ $column_width, 'Method' ]
+ my $privates = Text::SimpleTable::AutoWidth->new(
+ max_width => Catalyst::Utils::term_width(),
+ captions => ['Private', 'Class', 'Method'],
);
my $has_private = 0;
diff -ru cat.orig/Catalyst/DispatchType/Chained.pm cat.new/Catalyst/DispatchType/Chained.pm
--- cat.orig/Catalyst/DispatchType/Chained.pm 2009-04-20 06:31:47.000000000 +0300
+++ cat.new/Catalyst/DispatchType/Chained.pm 2009-04-20 21:50:05.000000000 +0300
@@ -3,7 +3,7 @@
use Moose;
extends 'Catalyst::DispatchType';
-use Text::SimpleTable;
+use Text::SimpleTable::AutoWidth;
use Catalyst::ActionChain;
use Catalyst::Utils;
use URI;
@@ -79,14 +79,15 @@
return unless $self->_endpoints;
- my $column_width = Catalyst::Utils::term_width() - 35 - 9;
- my $paths = Text::SimpleTable->new(
- [ 35, 'Path Spec' ], [ $column_width, 'Private' ],
+ my $paths = Text::SimpleTable::AutoWidth->new(
+ max_width => Catalyst::Utils::term_width(),
+ captions => ['Path Spec', 'Private'],
);
my $has_unattached_actions;
- my $unattached_actions = Text::SimpleTable->new(
- [ 35, 'Private' ], [ $column_width, 'Missing parent' ],
+ my $unattached_actions = Text::SimpleTable::AutoWidth->new(
+ max_width => Catalyst::Utils::term_width(),
+ captions => ['Private', 'Missing parent'],
);
ENDPOINT: foreach my $endpoint (
diff -ru cat.orig/Catalyst/DispatchType/Path.pm cat.new/Catalyst/DispatchType/Path.pm
--- cat.orig/Catalyst/DispatchType/Path.pm 2009-04-18 12:09:56.000000000 +0300
+++ cat.new/Catalyst/DispatchType/Path.pm 2009-04-20 21:51:41.000000000 +0300
@@ -3,7 +3,7 @@
use Moose;
extends 'Catalyst::DispatchType';
-use Text::SimpleTable;
+use Text::SimpleTable::AutoWidth;
use Catalyst::Utils;
use URI;
@@ -47,9 +47,9 @@
sub list {
my ( $self, $c ) = @_;
- my $column_width = Catalyst::Utils::term_width() - 35 - 9;
- my $paths = Text::SimpleTable->new(
- [ 35, 'Path' ], [ $column_width, 'Private' ]
+ my $paths = Text::SimpleTable::AutoWidth->new(
+ max_width => Catalyst::Utils::term_width(),
+ captions => ['Path', 'Private'],
);
foreach my $path ( sort keys %{ $self->_paths } ) {
my $display_path = $path eq '/' ? $path : "/$path";
diff -ru cat.orig/Catalyst/DispatchType/Regex.pm cat.new/Catalyst/DispatchType/Regex.pm
--- cat.orig/Catalyst/DispatchType/Regex.pm 2009-04-18 12:09:56.000000000 +0300
+++ cat.new/Catalyst/DispatchType/Regex.pm 2009-04-20 21:51:32.000000000 +0300
@@ -3,7 +3,7 @@
use Moose;
extends 'Catalyst::DispatchType::Path';
-use Text::SimpleTable;
+use Text::SimpleTable::AutoWidth;
use Catalyst::Utils;
use Text::Balanced ();
@@ -47,8 +47,10 @@
sub list {
my ( $self, $c ) = @_;
- my $column_width = Catalyst::Utils::term_width() - 35 - 9;
- my $re = Text::SimpleTable->new( [ 35, 'Regex' ], [ $column_width, 'Private' ] );
+ my $re = Text::SimpleTable::AutoWidth->new(
+ max_width => Catalyst::Utils::term_width(),
+ captions => ['Regex', 'Private'],
+ );
for my $regex ( @{ $self->_compiled } ) {
my $action = $regex->{action};
$re->row( $regex->{path}, "/$action" );
diff -ru cat.orig/Catalyst/Stats.pm cat.new/Catalyst/Stats.pm
--- cat.orig/Catalyst/Stats.pm 2009-02-08 21:17:34.000000000 +0200
+++ cat.new/Catalyst/Stats.pm 2009-04-20 21:50:43.000000000 +0300
@@ -2,7 +2,7 @@
use Moose;
use Time::HiRes qw/gettimeofday tv_interval/;
-use Text::SimpleTable ();
+use Text::SimpleTable::AutoWidth;
use Catalyst::Utils;
use Tree::Simple qw/use_weak_refs/;
use Tree::Simple::Visitor::FindByUID;
@@ -91,8 +91,10 @@
sub report {
my $self = shift;
- my $column_width = Catalyst::Utils::term_width() - 9 - 13;
- my $t = Text::SimpleTable->new( [ $column_width, 'Action' ], [ 9, 'Time' ] );
+ my $t = Text::SimpleTable::AutoWidth->new(
+ max_width => Catalyst::Utils::term_width(),
+ captions => [ 'Action', 'Time'],
+ );
my @results;
$self->traverse(
sub {
diff -ru cat.orig/Catalyst.pm cat.new/Catalyst.pm
--- cat.orig/Catalyst.pm 2009-04-18 22:44:08.000000000 +0300
+++ cat.new/Catalyst.pm 2009-04-20 21:54:18.000000000 +0300
@@ -14,7 +14,7 @@
use Devel::InnerPackage ();
use File::stat;
use Module::Pluggable::Object ();
-use Text::SimpleTable ();
+use Text::SimpleTable::AutoWidth;
use Path::Class::Dir ();
use Path::Class::File ();
use URI ();
@@ -1030,12 +1030,14 @@
}
if ( $class->debug ) {
- my @plugins = map { "$_ " . ( $_->VERSION || '' ) } $class->registered_plugins;
+ my @plugins = map { [$_, $_->VERSION || ''] } $class->registered_plugins;
if (@plugins) {
- my $column_width = Catalyst::Utils::term_width() - 6;
- my $t = Text::SimpleTable->new($column_width);
- $t->row($_) for @plugins;
+ my $t = Text::SimpleTable::AutoWidth->new(
+ max_width => Catalyst::Utils::term_width(),
+ captions => ['Plugin', 'Version'],
+ );
+ $t->rows(\...@plugins);
$class->log->debug( "Loaded plugins:\n" . $t->draw . "\n" );
}
@@ -1066,8 +1068,10 @@
$class->setup_components;
if ( $class->debug ) {
- my $column_width = Catalyst::Utils::term_width() - 8 - 9;
- my $t = Text::SimpleTable->new( [ $column_width, 'Class' ], [ 8, 'Type' ] );
+ my $t = Text::SimpleTable::AutoWidth->new(
+ max_width => Catalyst::Utils::term_width(),
+ captions => ['Class', 'Type'],
+ );
for my $comp ( sort keys %{ $class->components } ) {
my $type = ref $class->components->{$comp} ? 'instance' : 'class';
$t->row( $comp, $type );
@@ -1889,7 +1893,10 @@
$c->prepare_uploads;
if ( $c->debug && keys %{ $c->req->body_parameters } ) {
- my $t = Text::SimpleTable->new( [ 35, 'Parameter' ], [ 36, 'Value' ] );
+ my $t = Text::SimpleTable::AutoWidth->new(
+ fixed_width => Catalyst::Utils::term_width(),
+ captions => ['Parameter', 'Value'],
+ );
for my $key ( sort keys %{ $c->req->body_parameters } ) {
my $param = $c->req->body_parameters->{$key};
my $value = defined($param) ? $param : '';
@@ -1983,7 +1990,10 @@
$c->engine->prepare_query_parameters( $c, @_ );
if ( $c->debug && keys %{ $c->request->query_parameters } ) {
- my $t = Text::SimpleTable->new( [ 35, 'Parameter' ], [ 36, 'Value' ] );
+ my $t = Text::SimpleTable::AutoWidth->new(
+ fixed_width => Catalyst::Utils::term_width(),
+ captions => ['Parameter', 'Value'],
+ );
for my $key ( sort keys %{ $c->req->query_parameters } ) {
my $param = $c->req->query_parameters->{$key};
my $value = defined($param) ? $param : '';
@@ -2022,11 +2032,9 @@
$c->engine->prepare_uploads( $c, @_ );
if ( $c->debug && keys %{ $c->request->uploads } ) {
- my $t = Text::SimpleTable->new(
- [ 12, 'Parameter' ],
- [ 26, 'Filename' ],
- [ 18, 'Type' ],
- [ 9, 'Size' ]
+ my $t = Text::SimpleTable::AutoWidth->new(
+ fixed_width => Catalyst::Utils::term_width(),
+ captions => ['Parameter', 'Filename', 'Type', 'Size'],
);
for my $key ( sort keys %{ $c->request->uploads } ) {
my $upload = $c->request->uploads->{$key};
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/