r26013 - in /branches/upstream/libtext-simpletable-perl: ./ current/ current/lib/ current/lib/Text/ current/t/

eloy at users.alioth.debian.org eloy at users.alioth.debian.org
Tue Oct 14 13:47:50 UTC 2008


Author: eloy
Date: Tue Oct 14 13:47:43 2008
New Revision: 26013

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=26013
Log:
[svn-inject] Installing original source of libtext-simpletable-perl

Added:
    branches/upstream/libtext-simpletable-perl/
    branches/upstream/libtext-simpletable-perl/current/
    branches/upstream/libtext-simpletable-perl/current/Changes
    branches/upstream/libtext-simpletable-perl/current/MANIFEST
    branches/upstream/libtext-simpletable-perl/current/META.yml
    branches/upstream/libtext-simpletable-perl/current/Makefile.PL
    branches/upstream/libtext-simpletable-perl/current/README
    branches/upstream/libtext-simpletable-perl/current/lib/
    branches/upstream/libtext-simpletable-perl/current/lib/Text/
    branches/upstream/libtext-simpletable-perl/current/lib/Text/SimpleTable.pm
    branches/upstream/libtext-simpletable-perl/current/t/
    branches/upstream/libtext-simpletable-perl/current/t/01use.t
    branches/upstream/libtext-simpletable-perl/current/t/02pod.t
    branches/upstream/libtext-simpletable-perl/current/t/03podcoverage.t
    branches/upstream/libtext-simpletable-perl/current/t/04tables.t

Added: branches/upstream/libtext-simpletable-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-simpletable-perl/current/Changes?rev=26013&op=file
==============================================================================
--- branches/upstream/libtext-simpletable-perl/current/Changes (added)
+++ branches/upstream/libtext-simpletable-perl/current/Changes Tue Oct 14 13:47:43 2008
@@ -1,0 +1,17 @@
+Tis file documents the revision history for Perl extension Text::SimpleTable.
+
+0.05  2008-08-28 00:00:00
+        - Adden new contact information
+        - No more os x garbage files (hopefully)
+
+0.04  2008-08-28 00:00:00
+        - Removed Build.PL
+
+0.03  2006-01-17 22:00:00
+        - Fixed bug where text items of '0' were not displayed
+
+0.02  2005-11-07 00:00:00
+        - Added support for newlines
+
+0.01  2005-10-24 00:00:00
+        - first release

Added: branches/upstream/libtext-simpletable-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-simpletable-perl/current/MANIFEST?rev=26013&op=file
==============================================================================
--- branches/upstream/libtext-simpletable-perl/current/MANIFEST (added)
+++ branches/upstream/libtext-simpletable-perl/current/MANIFEST Tue Oct 14 13:47:43 2008
@@ -1,0 +1,10 @@
+Changes
+lib/Text/SimpleTable.pm
+Makefile.PL
+MANIFEST			This list of files
+META.yml
+README
+t/01use.t
+t/02pod.t
+t/03podcoverage.t
+t/04tables.t

Added: branches/upstream/libtext-simpletable-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-simpletable-perl/current/META.yml?rev=26013&op=file
==============================================================================
--- branches/upstream/libtext-simpletable-perl/current/META.yml (added)
+++ branches/upstream/libtext-simpletable-perl/current/META.yml Tue Oct 14 13:47:43 2008
@@ -1,0 +1,12 @@
+--- #YAML:1.0
+name:                Text-SimpleTable
+version:             0.05
+abstract:            ~
+license:             ~
+author:              ~
+generated_by:        ExtUtils::MakeMaker version 6.42
+distribution_type:   module
+requires:     
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
+    version: 1.3

Added: branches/upstream/libtext-simpletable-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-simpletable-perl/current/Makefile.PL?rev=26013&op=file
==============================================================================
--- branches/upstream/libtext-simpletable-perl/current/Makefile.PL (added)
+++ branches/upstream/libtext-simpletable-perl/current/Makefile.PL Tue Oct 14 13:47:43 2008
@@ -1,0 +1,11 @@
+use strict;
+use warnings;
+
+use ExtUtils::MakeMaker;
+
+# Son, when you participate in sporting events,
+# it's not whether you win or lose, it's how drunk you get.
+WriteMakefile(
+   NAME          => 'Text::SimpleTable',
+   VERSION_FROM  => 'lib/Text/SimpleTable.pm',
+);

Added: branches/upstream/libtext-simpletable-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-simpletable-perl/current/README?rev=26013&op=file
==============================================================================
--- branches/upstream/libtext-simpletable-perl/current/README (added)
+++ branches/upstream/libtext-simpletable-perl/current/README Tue Oct 14 13:47:43 2008
@@ -1,0 +1,49 @@
+NAME
+    Text::SimpleTable - Simple Eyecandy ASCII Tables
+
+SYNOPSIS
+        use Text::SimpleTable;
+
+        my $t1 = Text::SimpleTable->new( 5, 10 );
+        $t1->row( 'foobarbaz', 'yadayadayada' );
+        print $t1->draw;
+
+        .-------+------------.
+        | foob- | yadayaday- |
+        | arbaz | ada        |
+        '-------+------------'
+
+
+        my $t2 = Text::SimpleTable->new( [ 5, 'Foo' ], [ 10, 'Bar' ] );
+        $t2->row( 'foobarbaz', 'yadayadayada' );
+        $t2->row( 'barbarbarbarbar', 'yada' );
+        print $t2->draw;
+
+        .-------+------------.
+        | Foo   | Bar        |
+        +-------+------------+
+        | foob- | yadayaday- |
+        | arbaz | ada        |
+        | barb- | yada       |
+        | arba- |            |
+        | rbar- |            |
+        | bar   |            |
+        '-------+------------'
+
+DESCRIPTION
+    Simple eyecandy ASCII tables, as seen in Catalyst.
+
+METHODS
+    $table->row( @texts )
+    $table->draw
+
+SEE ALSO
+    Catalyst
+
+AUTHOR
+    Sebastian Riedel, "sri at oook.de"
+
+COPYRIGHT
+    This program is free software, you can redistribute it and/or modify it
+    under the same terms as Perl itself.
+

Added: branches/upstream/libtext-simpletable-perl/current/lib/Text/SimpleTable.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-simpletable-perl/current/lib/Text/SimpleTable.pm?rev=26013&op=file
==============================================================================
--- branches/upstream/libtext-simpletable-perl/current/lib/Text/SimpleTable.pm (added)
+++ branches/upstream/libtext-simpletable-perl/current/lib/Text/SimpleTable.pm Tue Oct 14 13:47:43 2008
@@ -1,0 +1,268 @@
+package Text::SimpleTable;
+
+use strict;
+
+our $VERSION = '0.05';
+
+our $TOP_LEFT      = '.-';
+our $TOP_BORDER    = '-';
+our $TOP_SEPARATOR = '-+-';
+our $TOP_RIGHT     = '-.';
+
+our $MIDDLE_LEFT      = '+-';
+our $MIDDLE_BORDER    = '-';
+our $MIDDLE_SEPARATOR = '-+-';
+our $MIDDLE_RIGHT     = '-+';
+
+our $LEFT_BORDER  = '| ';
+our $SEPARATOR    = ' | ';
+our $RIGHT_BORDER = ' |';
+
+our $BOTTOM_LEFT      = "'-";
+our $BOTTOM_SEPARATOR = "-+-";
+our $BOTTOM_BORDER    = '-';
+our $BOTTOM_RIGHT     = "-'";
+
+our $WRAP = '-';
+
+=head1 NAME
+
+Text::SimpleTable - Simple Eyecandy ASCII Tables
+
+=head1 SYNOPSIS
+
+    use Text::SimpleTable;
+
+    my $t1 = Text::SimpleTable->new( 5, 10 );
+    $t1->row( 'foobarbaz', 'yadayadayada' );
+    print $t1->draw;
+
+    .-------+------------.
+    | foob- | yadayaday- |
+    | arbaz | ada        |
+    '-------+------------'
+
+
+    my $t2 = Text::SimpleTable->new( [ 5, 'Foo' ], [ 10, 'Bar' ] );
+    $t2->row( 'foobarbaz', 'yadayadayada' );
+    $t2->row( 'barbarbarbarbar', 'yada' );
+    print $t2->draw;
+
+    .-------+------------.
+    | Foo   | Bar        |
+    +-------+------------+
+    | foob- | yadayaday- |
+    | arbaz | ada        |
+    | barb- | yada       |
+    | arba- |            |
+    | rbar- |            |
+    | bar   |            |
+    '-------+------------'
+
+
+=head1 DESCRIPTION
+
+Simple eyecandy ASCII tables, as seen in L<Catalyst>.
+
+=head1 METHODS
+
+=over 4
+
+=cut
+
+sub new {
+    my ( $class, @args ) = @_;
+    $class = ref $class || $class;
+    my $self  = bless {}, $class;
+    my $cache = [];
+    my $max   = 0;
+    for my $arg (@args) {
+        my $width;
+        my $name;
+        if ( ref $arg ) {
+            $width = $arg->[0];
+            $name  = $arg->[1];
+        }
+        else { $width = $arg }
+        my $title = $name ? $self->_wrap( $name, $width ) : [];
+        my $col = [ $width, [], $title ];
+        $max = @{ $col->[2] } if $max < @{ $col->[2] };
+        push @$cache, $col;
+    }
+    for my $col (@$cache) {
+        push @{ $col->[2] }, '' while @{ $col->[2] } < $max;
+    }
+    $self->{columns} = $cache;
+    return $self;
+}
+
+=item $table->row( @texts )
+
+=cut
+
+sub row {
+    my ( $self, @texts ) = @_;
+    my $size = @{ $self->{columns} } - 1;
+    return $self if $size < 0;
+    for ( 1 .. $size ) {
+        last if $size <= @texts;
+        push @texts, '';
+    }
+    my $cache = [];
+    my $max   = 0;
+    for my $i ( 0 .. $size ) {
+        my $text   = shift @texts;
+        my $column = $self->{columns}->[$i];
+        my $width  = $column->[0];
+        my $pieces = $self->_wrap( $text, $width );
+        push @{ $cache->[$i] }, @$pieces;
+        $max = @$pieces if @$pieces > $max;
+    }
+    for my $col ( @{$cache} ) { push @{$col}, '' while @{$col} < $max }
+    for my $i ( 0 .. $size ) {
+        my $column = $self->{columns}->[$i];
+        my $store  = $column->[1];
+        push @{$store}, @{ $cache->[$i] };
+    }
+    return $self;
+}
+
+=item $table->draw
+
+=cut
+
+sub draw {
+    my $self = shift;
+    return unless $self->{columns};
+    my $rows    = @{ $self->{columns}->[0]->[1] } - 1;
+    my $columns = @{ $self->{columns} } - 1;
+    my $output  = '';
+
+    # Top border
+    for my $j ( 0 .. $columns ) {
+        my $column = $self->{columns}->[$j];
+        my $width  = $column->[0];
+        my $text   = $TOP_BORDER x $width;
+        if ( ( $j == 0 ) && ( $columns == 0 ) ) {
+            $text = "$TOP_LEFT$text$TOP_RIGHT";
+        }
+        elsif ( $j == 0 )        { $text = "$TOP_LEFT$text$TOP_SEPARATOR" }
+        elsif ( $j == $columns ) { $text = "$text$TOP_RIGHT" }
+        else { $text = "$text$TOP_SEPARATOR" }
+        $output .= $text;
+    }
+    $output .= "\n";
+
+    my $title = 0;
+    for my $column ( @{ $self->{columns} } ) {
+        $title = @{ $column->[2] } if $title < @{ $column->[2] };
+    }
+    if ($title) {
+
+        # Titles
+        for my $i ( 0 .. $title - 1 ) {
+
+            for my $j ( 0 .. $columns ) {
+                my $column = $self->{columns}->[$j];
+                my $width  = $column->[0];
+                my $text   = $column->[2]->[$i] || '';
+                $text = sprintf "%-${width}s", $text;
+                if ( ( $j == 0 ) && ( $columns == 0 ) ) {
+                    $text = "$LEFT_BORDER$text$RIGHT_BORDER";
+                }
+                elsif ( $j == 0 ) { $text = "$LEFT_BORDER$text$SEPARATOR" }
+                elsif ( $j == $columns ) { $text = "$text$RIGHT_BORDER" }
+                else { $text = "$text$SEPARATOR" }
+                $output .= $text;
+            }
+            $output .= "\n";
+        }
+
+        # Title separator
+        for my $j ( 0 .. $columns ) {
+            my $column = $self->{columns}->[$j];
+            my $width  = $column->[0];
+            my $text   = $MIDDLE_BORDER x $width;
+            if ( ( $j == 0 ) && ( $columns == 0 ) ) {
+                $text = "$MIDDLE_LEFT$text$MIDDLE_RIGHT";
+            }
+            elsif ( $j == 0 ) { $text = "$MIDDLE_LEFT$text$MIDDLE_SEPARATOR" }
+            elsif ( $j == $columns ) { $text = "$text$MIDDLE_RIGHT" }
+            else { $text = "$text$MIDDLE_SEPARATOR" }
+            $output .= $text;
+        }
+        $output .= "\n";
+
+    }
+
+    # Rows
+    for my $i ( 0 .. $rows ) {
+
+        for my $j ( 0 .. $columns ) {
+            my $column = $self->{columns}->[$j];
+            my $width  = $column->[0];
+            my $text
+                = ( defined $column->[1]->[$i] ) ? $column->[1]->[$i] : '';
+            $text = sprintf "%-${width}s", $text;
+            if ( ( $j == 0 ) && ( $columns == 0 ) ) {
+                $text = "$LEFT_BORDER$text$RIGHT_BORDER";
+            }
+            elsif ( $j == 0 )        { $text = "$LEFT_BORDER$text$SEPARATOR" }
+            elsif ( $j == $columns ) { $text = "$text$RIGHT_BORDER" }
+            else { $text = "$text$SEPARATOR" }
+            $output .= $text;
+        }
+        $output .= "\n";
+    }
+
+    # Bottom border
+    for my $j ( 0 .. $columns ) {
+        my $column = $self->{columns}->[$j];
+        my $width  = $column->[0];
+        my $text   = $BOTTOM_BORDER x $width;
+        if ( ( $j == 0 ) && ( $columns == 0 ) ) {
+            $text = "$BOTTOM_LEFT$text$BOTTOM_RIGHT";
+        }
+        elsif ( $j == 0 ) { $text = "$BOTTOM_LEFT$text$BOTTOM_SEPARATOR" }
+        elsif ( $j == $columns ) { $text = "$text$BOTTOM_RIGHT" }
+        else { $text = "$text$BOTTOM_SEPARATOR" }
+        $output .= $text;
+    }
+    $output .= "\n";
+
+    return $output;
+}
+
+sub _wrap {
+    my ( $self, $text, $width ) = @_;
+    my @cache;
+    my @parts = split "\n", $text;
+    for my $part (@parts) {
+        while ( length $part > $width ) {
+            my $subtext;
+            $subtext = substr $part, 0, $width - length($WRAP), '';
+            push @cache, "$subtext$WRAP";
+        }
+        push @cache, $part if defined $part;
+    }
+    return \@cache;
+}
+
+=back
+
+=head1 SEE ALSO
+
+L<Catalyst>
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at cpan.org>
+
+=head1 COPYRIGHT
+
+This program is free software, you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=cut
+
+1;

Added: branches/upstream/libtext-simpletable-perl/current/t/01use.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-simpletable-perl/current/t/01use.t?rev=26013&op=file
==============================================================================
--- branches/upstream/libtext-simpletable-perl/current/t/01use.t (added)
+++ branches/upstream/libtext-simpletable-perl/current/t/01use.t Tue Oct 14 13:47:43 2008
@@ -1,0 +1,3 @@
+use Test::More tests => 1;
+
+use_ok('Text::SimpleTable');

Added: branches/upstream/libtext-simpletable-perl/current/t/02pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-simpletable-perl/current/t/02pod.t?rev=26013&op=file
==============================================================================
--- branches/upstream/libtext-simpletable-perl/current/t/02pod.t (added)
+++ branches/upstream/libtext-simpletable-perl/current/t/02pod.t Tue Oct 14 13:47:43 2008
@@ -1,0 +1,7 @@
+use Test::More;
+
+eval "use Test::Pod 1.14";
+plan skip_all => 'Test::Pod 1.14 required' if $@;
+plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
+
+all_pod_files_ok();

Added: branches/upstream/libtext-simpletable-perl/current/t/03podcoverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-simpletable-perl/current/t/03podcoverage.t?rev=26013&op=file
==============================================================================
--- branches/upstream/libtext-simpletable-perl/current/t/03podcoverage.t (added)
+++ branches/upstream/libtext-simpletable-perl/current/t/03podcoverage.t Tue Oct 14 13:47:43 2008
@@ -1,0 +1,7 @@
+use Test::More;
+
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
+plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
+
+all_pod_coverage_ok();

Added: branches/upstream/libtext-simpletable-perl/current/t/04tables.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-simpletable-perl/current/t/04tables.t?rev=26013&op=file
==============================================================================
--- branches/upstream/libtext-simpletable-perl/current/t/04tables.t (added)
+++ branches/upstream/libtext-simpletable-perl/current/t/04tables.t Tue Oct 14 13:47:43 2008
@@ -1,0 +1,46 @@
+use Test::More tests => 4;
+
+use_ok('Text::SimpleTable');
+
+my $t1 = Text::SimpleTable->new( 5, 10 );
+$t1->row( 'Catalyst',          'rockz!' );
+$t1->row( 'DBIx::Class',       'rockz!' );
+$t1->row( 'Template::Toolkit', 'rockz!' );
+is( $t1->draw, <<"EOF");
+.-------+------------.
+| Cata- | rockz!     |
+| lyst  |            |
+| DBIx- | rockz!     |
+| ::Cl- |            |
+| ass   |            |
+| Temp- | rockz!     |
+| late- |            |
+| ::To- |            |
+| olkit |            |
+'-------+------------'
+EOF
+
+my $t2 =
+  Text::SimpleTable->new( [ 5, 'ROCKZ!' ], [ 10, 'Rockz!' ], [ 7, 'rockz!' ] );
+$t2->row( 'Catalyst', 'DBIx::Class', 'Template::Toolkit', 'HTML::Mason' );
+is( $t2->draw, <<"EOF");
+.-------+------------+---------.
+| ROCK- | Rockz!     | rockz!  |
+| Z!    |            |         |
++-------+------------+---------+
+| Cata- | DBIx::Cla- | Templa- |
+| lyst  | ss         | te::To- |
+|       |            | olkit   |
+'-------+------------+---------'
+EOF
+
+my $t3 = Text::SimpleTable->new(5);
+$t3->row('Everything works!');
+is( $t3->draw, <<"EOF");
+.-------.
+| Ever- |
+| ythi- |
+| ng w- |
+| orks! |
+'-------'
+EOF




More information about the Pkg-perl-cvs-commits mailing list