r24120 - in /branches/upstream/libdata-report-perl/current: ./ lib/Data/ lib/Data/Report/Plugin/ t/
angelabad-guest at users.alioth.debian.org
angelabad-guest at users.alioth.debian.org
Mon Aug 11 12:26:02 UTC 2008
Author: angelabad-guest
Date: Mon Aug 11 12:25:59 2008
New Revision: 24120
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=24120
Log:
[svn-upgrade] Integrating new upstream version, libdata-report-perl (0.09)
Added:
branches/upstream/libdata-report-perl/current/.includepath
branches/upstream/libdata-report-perl/current/.project
branches/upstream/libdata-report-perl/current/Makefile.PL
branches/upstream/libdata-report-perl/current/t/01text07.t
branches/upstream/libdata-report-perl/current/t/03csv05.t
branches/upstream/libdata-report-perl/current/t/03csv06.t
branches/upstream/libdata-report-perl/current/t/09poc06.t
Modified:
branches/upstream/libdata-report-perl/current/Build.PL
branches/upstream/libdata-report-perl/current/Changes
branches/upstream/libdata-report-perl/current/MANIFEST
branches/upstream/libdata-report-perl/current/META.yml
branches/upstream/libdata-report-perl/current/lib/Data/Report.pm
branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Csv.pm
branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Html.pm
branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Text.pm
branches/upstream/libdata-report-perl/current/t/00basic.t
branches/upstream/libdata-report-perl/current/t/03csv03.t
branches/upstream/libdata-report-perl/current/t/03csv04.t
Added: branches/upstream/libdata-report-perl/current/.includepath
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/.includepath?rev=24120&op=file
==============================================================================
--- branches/upstream/libdata-report-perl/current/.includepath (added)
+++ branches/upstream/libdata-report-perl/current/.includepath Mon Aug 11 12:25:59 2008
@@ -1,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<includepath>
+ <includepathentry path="${resource_loc:/Data::Report/lib}" />
+</includepath>
+
Added: branches/upstream/libdata-report-perl/current/.project
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/.project?rev=24120&op=file
==============================================================================
--- branches/upstream/libdata-report-perl/current/.project (added)
+++ branches/upstream/libdata-report-perl/current/.project Mon Aug 11 12:25:59 2008
@@ -1,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Data::Report</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.epic.perleditor.perlbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.epic.perleditor.perlnature</nature>
+ </natures>
+</projectDescription>
Modified: branches/upstream/libdata-report-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/Build.PL?rev=24120&op=diff
==============================================================================
--- branches/upstream/libdata-report-perl/current/Build.PL (original)
+++ branches/upstream/libdata-report-perl/current/Build.PL Mon Aug 11 12:25:59 2008
@@ -1,4 +1,4 @@
-# $Id: Build.PL,v 1.3 2006/05/22 13:31:44 jv Exp $
+# $Id: Build.PL,v 1.4 2008/08/07 14:50:31 jv Exp $
use strict;
use Module::Build 0.28;
@@ -16,6 +16,7 @@
build_requires => {
'Test::More' => 0,
+ 'Text::CSV' => 1.00,
},
# auto_features => {
@@ -34,6 +35,7 @@
meta_add => {
no_index => { package => [ qw(DB) ] },
},
+ create_makefile_pl => 'traditional',
);
$builder->create_build_script;
Modified: branches/upstream/libdata-report-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/Changes?rev=24120&op=diff
==============================================================================
--- branches/upstream/libdata-report-perl/current/Changes (original)
+++ branches/upstream/libdata-report-perl/current/Changes Mon Aug 11 12:25:59 2008
@@ -1,10 +1,23 @@
Revision history for Data-Report
-0.07 2008-08-03
+0.09 2008-08-06
+
+ Add column property 'ignore'. Does what the name implies.
+ This change was suggested by Mário Silva.
+
+ Upgrade requirements for Text::CSV to 1.00.
+
+0.08 2008-08-06 14:27
+
+ Allow handling of Latin texts with CSV plugin and Text::CSV_XS.
+ This change was suggested by Mário Silva.
+
+0.07 2008-08-03 16:26
Add 'raw_html' style mod for HTML plugin. When a cell has this
property, the data will be placed in the cell unmodified. This
makes it possible to place pre-prepared HTML code in the cell.
+ This change was suggested by Cristina Nunes.
0.05 2006-06-08 15:46
Modified: branches/upstream/libdata-report-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/MANIFEST?rev=24120&op=diff
==============================================================================
--- branches/upstream/libdata-report-perl/current/MANIFEST (original)
+++ branches/upstream/libdata-report-perl/current/MANIFEST Mon Aug 11 12:25:59 2008
@@ -1,3 +1,5 @@
+.includepath
+.project
Build.PL
Changes
lib/Data/Report.pm
@@ -15,14 +17,19 @@
t/01text04.t
t/01text05.t
t/01text06.t
+t/01text07.t
t/02html01.t
t/02html02.t
t/03csv01.t
t/03csv02.t
t/03csv03.t
t/03csv04.t
+t/03csv05.t
+t/03csv06.t
t/09poc01.t
t/09poc02.t
t/09poc03.t
t/09poc04.t
t/09poc05.t
+t/09poc06.t
+Makefile.PL
Modified: branches/upstream/libdata-report-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/META.yml?rev=24120&op=diff
==============================================================================
--- branches/upstream/libdata-report-perl/current/META.yml (original)
+++ branches/upstream/libdata-report-perl/current/META.yml Mon Aug 11 12:25:59 2008
@@ -1,6 +1,6 @@
---
name: Data-Report
-version: 0.07
+version: 0.09
author:
- 'Johan Vromans <jvromans at squirrel.nl>'
abstract: Framework for flexible reporting
@@ -9,12 +9,13 @@
license: http://dev.perl.org/licenses/
build_requires:
Test::More: 0
+ Text::CSV: 1
recommends:
HTML::Entities: 0
provides:
Data::Report:
file: lib/Data/Report.pm
- version: 0.07
+ version: 0.09
Data::Report::Base:
file: lib/Data/Report/Base.pm
Data::Report::Plugin::Csv:
Added: branches/upstream/libdata-report-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/Makefile.PL?rev=24120&op=file
==============================================================================
--- branches/upstream/libdata-report-perl/current/Makefile.PL (added)
+++ branches/upstream/libdata-report-perl/current/Makefile.PL Mon Aug 11 12:25:59 2008
@@ -1,0 +1,15 @@
+# Note: this file was auto-generated by Module::Build::Compat version 0.03
+use ExtUtils::MakeMaker;
+WriteMakefile
+(
+ 'PL_FILES' => {},
+ 'INSTALLDIRS' => 'site',
+ 'NAME' => 'Data::Report',
+ 'EXE_FILES' => [],
+ 'VERSION_FROM' => 'lib/Data/Report.pm',
+ 'PREREQ_PM' => {
+ 'Test::More' => 0,
+ 'Text::CSV' => '1'
+ }
+ )
+;
Modified: branches/upstream/libdata-report-perl/current/lib/Data/Report.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/lib/Data/Report.pm?rev=24120&op=diff
==============================================================================
--- branches/upstream/libdata-report-perl/current/lib/Data/Report.pm (original)
+++ branches/upstream/libdata-report-perl/current/lib/Data/Report.pm Mon Aug 11 12:25:59 2008
@@ -1,10 +1,10 @@
# Data::Reporter.pm -- Framework for flexible reporting
-# RCS Info : $Id: Report.pm,v 1.13 2008/08/03 14:24:15 jv Exp $
+# RCS Info : $Id: Report.pm,v 1.15 2008/08/07 20:05:00 jv Exp $
# Author : Johan Vromans
# Created On : Wed Dec 28 13:18:40 2005
# Last Modified By: Johan Vromans
-# Last Modified On: Sun Aug 3 16:23:30 2008
-# Update Count : 256
+# Last Modified On: Thu Aug 7 22:02:59 2008
+# Update Count : 260
# Status : Unknown, Use with caution!
package Data::Report;
@@ -13,13 +13,9 @@
Data::Report - Framework for flexible reporting
-=head1 VERSION
-
-0.07
-
=cut
-$VERSION = 0.07;
+$VERSION = 0.09;
=head1 SYNOPSIS
@@ -409,6 +405,12 @@
(Html) Do not escape special HTML characters, allowing pre-prepared
HTML code to be placed in the output. Use with care.
+
+=item C<ignore>
+
+(All) Ignore this column. Note that to prevent surprising results, the
+column must be ignored in all applicable styles, including the special
+style C<"head"> that controls the heading.
=back
Modified: branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Csv.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Csv.pm?rev=24120&op=diff
==============================================================================
--- branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Csv.pm (original)
+++ branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Csv.pm Mon Aug 11 12:25:59 2008
@@ -1,10 +1,10 @@
# Data::Report::Plugin::Csv.pm -- CSV plugin for Data::Report
-# RCS Info : $Id: Csv.pm,v 1.5 2006/06/06 20:33:41 jv Exp $
+# RCS Info : $Id: Csv.pm,v 1.8 2008/08/07 20:05:00 jv Exp $
# Author : Johan Vromans
# Created On : Thu Jan 5 18:47:37 2006
# Last Modified By: Johan Vromans
-# Last Modified On: Mon May 22 17:51:41 2006
-# Update Count : 99
+# Last Modified On: Thu Aug 7 19:57:28 2008
+# Update Count : 118
# Status : Unknown, Use with caution!
package Data::Report::Plugin::Csv;
@@ -52,7 +52,12 @@
$line = $self->_csv
( map {
$data->{$_->{name}} || ""
- } @{$self->_get_fields}
+ }
+ grep {
+ my $t = $self->_getstyle($style, $_->{name});
+ ! $t->{ignore};
+ }
+ @{$self->_get_fields}
);
$self->_print($line, "\n");
}
@@ -66,7 +71,17 @@
my ($self) = @_;
my $sep = $self->get_separator;
- $self->_print($self->_csv(map { $_->{title} } @{$self->_get_fields}), "\n");
+
+ $self->_print($self->_csv
+ (map {
+ $_->{title}
+ }
+ grep {
+ my $t = $self->_getstyle("head", $_->{name});
+ ! $t->{ignore};
+ }
+ @{$self->_get_fields}),
+ "\n");
}
################ Internal (used if no alternatives) ################
@@ -89,9 +104,11 @@
if ( $class && $class->isa("Text::CSV_XS") ) {
# Use always_quote to be compatible with Text::CSV.
+ # Use binary to deal with non-ASCII text.
$csv_implementation = Text::CSV_XS->new
({ sep_char => $self->get_separator,
always_quote => 1,
+ binary => 1,
});
# Assign the method.
@@ -100,10 +117,18 @@
$csv_implementation->combine(@_);
$csv_implementation->string;
};
+ warn("# CSV plugin uses Text::CSV_XS $Text::CSV_XS::VERSION\n")
+ if $ENV{AUTOMATED_TESTING};
}
elsif ( $class && $class->isa("Text::CSV") ) {
- $csv_implementation = Text::CSV->new;
+ # With modern Text::CSV, it will use Text::CSV_XS if possible.
+ # So this gotta be Text::CSV_PP...
+
+ $csv_implementation = Text::CSV->new
+ ({ always_quote => 1,
+ binary => 1,
+ });
# Assign the method.
*_csv = sub {
@@ -111,11 +136,15 @@
$csv_implementation->combine(@_);
$csv_implementation->string;
};
+ warn("# CSV plugin uses Text::CSV $Text::CSV::VERSION, PP version $Text::CSV_PP::VERSION\n")
+ if $ENV{AUTOMATED_TESTING};
}
else {
# Use our internal method.
*_csv = \&_csv_internal;
$csv_implementation = "Data::Report::Plugin::Csv::_csv_internal";
+ warn("# CSV plugin uses built-in CSV packer\n")
+ if $ENV{AUTOMATED_TESTING};
}
return $csv_implementation;
Modified: branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Html.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Html.pm?rev=24120&op=diff
==============================================================================
--- branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Html.pm (original)
+++ branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Html.pm Mon Aug 11 12:25:59 2008
@@ -1,10 +1,10 @@
# Data::Report::Plugin::Html.pm -- HTML plugin for Data::Report
-# RCS Info : $Id: Html.pm,v 1.6 2008/08/03 14:09:49 jv Exp $
+# RCS Info : $Id: Html.pm,v 1.7 2008/08/07 20:05:00 jv Exp $
# Author : Johan Vromans
# Created On : Thu Dec 29 15:46:47 2005
# Last Modified By: Johan Vromans
-# Last Modified On: Sun Aug 3 16:00:53 2008
-# Update Count : 77
+# Last Modified On: Thu Aug 7 17:13:11 2008
+# Update Count : 80
# Status : Unknown, Use with caution!
package Data::Report::Plugin::Html;
@@ -61,7 +61,8 @@
my $value = defined($data->{$fname}) ? $data->{$fname} : "";
# Examine style mods.
- my $t = $self->_getstyle("*", $fname);
+ my $t = $self->_getstyle($style, $fname);
+ next if $t->{ignore};
$self->_print("<td ", _align($col->{align}),
"class=\"c_$fname\">",
@@ -86,6 +87,11 @@
$self->_print("<tr class=\"head\">\n");
foreach ( @{$self->_get_fields} ) {
+
+ # Examine style mods.
+ my $t = $self->_getstyle("head", $_->{name});
+ next if $t->{ignore};
+
$self->_print("<th ", _align($_->{align}),
"class=\"h_", $_->{name}, "\">",
$self->_html($_->{title}), "</th>\n");
Modified: branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Text.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Text.pm?rev=24120&op=diff
==============================================================================
--- branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Text.pm (original)
+++ branches/upstream/libdata-report-perl/current/lib/Data/Report/Plugin/Text.pm Mon Aug 11 12:25:59 2008
@@ -1,10 +1,10 @@
# Data::Report::Plugin::Text.pm -- Text plugin for Data::Report
-# RCS Info : $Id: Text.pm,v 1.8 2006/05/23 09:35:39 jv Exp $
+# RCS Info : $Id: Text.pm,v 1.9 2008/08/07 20:05:00 jv Exp $
# Author : Johan Vromans
# Created On : Wed Dec 28 13:21:11 2005
# Last Modified By: Johan Vromans
-# Last Modified On: Tue May 23 11:23:52 2006
-# Update Count : 141
+# Last Modified On: Thu Aug 7 21:49:33 2008
+# Update Count : 147
# Status : Unknown, Use with caution!
package Data::Report::Plugin::Text;
@@ -58,6 +58,9 @@
foreach my $col ( @{$self->_get_fields} ) {
my $fname = $col->{name};
+ my $t = $style ? $self->_getstyle($style, $fname) : {};
+ next if $t->{ignore};
+
push(@values, defined($data->{$fname}) ? $data->{$fname} : "");
push(@widths, $col->{width});
if ($col->{truncate} ) {
@@ -68,30 +71,28 @@
my $indent = 0;
my $wrapindent = 0;
my $excess = 0;
- if ( $style ) {
- if ( my $t = $self->_getstyle($style, $fname) ) {
- $indent = $t->{indent} || 0;
- $wrapindent = defined($t->{wrap_indent}) ? $t->{wrap_indent} : $indent;
- croak("Row $style, column $fname, ".
- "illegal value for indent property: $indent")
- if $indent < 0 || $indent >= $self->_get_fdata->{$fname}->{width};
- croak("Row $style, column $fname, ".
- "illegal value for wrap_indent property: $wrapindent")
- if $wrapindent < 0 || $wrapindent >= $self->_get_fdata->{$fname}->{width};
- if ( $t->{line_before} ) {
- $linebefore->{$fname} =
- ($t->{line_before} eq "1" ? "-" : $t->{line_before}) x $col->{width};
- }
- if ( $t->{line_after} ) {
- $lineafter->{$fname} =
- ($t->{line_after} eq "1" ? "-" : $t->{line_after}) x $col->{width};
- }
- if ( $t->{excess} ) {
- $widths[-1] += 2;
- }
- if ( $t->{truncate} || $col->{truncate} ) {
- $values[-1] = substr($values[-1], 0, $widths[-1] - $indent);
- }
+ if ( $t ) {
+ $indent = $t->{indent} || 0;
+ $wrapindent = defined($t->{wrap_indent}) ? $t->{wrap_indent} : $indent;
+ croak("Row $style, column $fname, ".
+ "illegal value for indent property: $indent")
+ if $indent < 0 || $indent >= $self->_get_fdata->{$fname}->{width};
+ croak("Row $style, column $fname, ".
+ "illegal value for wrap_indent property: $wrapindent")
+ if $wrapindent < 0 || $wrapindent >= $self->_get_fdata->{$fname}->{width};
+ if ( $t->{line_before} ) {
+ $linebefore->{$fname} =
+ ($t->{line_before} eq "1" ? "-" : $t->{line_before}) x $col->{width};
+ }
+ if ( $t->{line_after} ) {
+ $lineafter->{$fname} =
+ ($t->{line_after} eq "1" ? "-" : $t->{line_after}) x $col->{width};
+ }
+ if ( $t->{excess} ) {
+ $widths[-1] += 2;
+ }
+ if ( $t->{truncate} || $col->{truncate} ) {
+ $values[-1] = substr($values[-1], 0, $widths[-1] - $indent);
}
}
push(@indents, [$indent, $wrapindent]);
@@ -175,7 +176,12 @@
# Print column names.
my $t = sprintf($self->{format},
- map { $_->{title} } @{$self->_get_fields});
+ map { $_->{title} }
+ grep {
+ my $t = $self->_getstyle("head", $_->{name});
+ ! $t->{ignore};
+ }
+ @{$self->_get_fields});
# Add separator line.
$t .= "-" x ($self->{width});
@@ -212,6 +218,9 @@
my $format = ""; # new format
foreach my $a ( @{$self->_get_fields} ) {
+
+ my $t = $self->_getstyle("head", $a->{name});
+ next if $t->{ignore};
# Never mind the trailing blanks -- we'll trim anyway.
$width += $a->{width} + 2;
Modified: branches/upstream/libdata-report-perl/current/t/00basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/t/00basic.t?rev=24120&op=diff
==============================================================================
--- branches/upstream/libdata-report-perl/current/t/00basic.t (original)
+++ branches/upstream/libdata-report-perl/current/t/00basic.t Mon Aug 11 12:25:59 2008
@@ -2,12 +2,10 @@
use strict;
use warnings;
-use Test::More qw(no_plan);
+use Test::More tests => 5;
BEGIN { use_ok('Data::Report'); }
BEGIN { use_ok('Data::Report::Base'); }
BEGIN { use_ok('Data::Report::Plugin::Text'); }
BEGIN { use_ok('Data::Report::Plugin::Html'); }
BEGIN { use_ok('Data::Report::Plugin::Csv' ); }
-
-diag("CSV uses ", Data::Report::Plugin::Csv->new->_select_csv_method, "\n");
Added: branches/upstream/libdata-report-perl/current/t/01text07.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/t/01text07.t?rev=24120&op=file
==============================================================================
--- branches/upstream/libdata-report-perl/current/t/01text07.t (added)
+++ branches/upstream/libdata-report-perl/current/t/01text07.t Mon Aug 11 12:25:59 2008
@@ -1,0 +1,63 @@
+#! perl
+
+use strict;
+use warnings;
+use Test::More qw(no_plan);
+
+use Data::Report;
+
+my $rep = Data::Report::->create(type => "text", stylist => \&my_stylist);
+
+$rep->set_layout
+ ([ { name => "one", title => "One", width => 10, },
+ { name => "two", title => "Two", width => 11, },
+ { name => "thr", title => "Three", width => 12, },
+ { name => "fou", title => "Four", width => 13, },
+ { name => "fiv", title => "Five", width => 14, },
+ ]);
+
+my $ref; { undef $/; $ref = <DATA>; }
+$ref =~ s/[\r\n]/\n/g;
+my $out = "";
+
+my $dd = "The quick brown fox jumps over the lazy dog.";
+$dd = "$dd $dd $dd";
+
+$rep->set_output(\$out);
+$rep->start;
+$rep->add({ one => $dd, two => $dd, thr => $dd, fou => $dd, fiv => $dd });
+$rep->finish;
+
+is($out, $ref);
+
+sub my_stylist {
+ my ($rep, $row, $col) = @_;
+
+ return unless defined $col;
+
+ return { ignore => 1, indent => 2 } if $col eq "two";
+ return { indent => 1, wrap_indent => 0 } if $col eq "thr";
+ return { wrap_indent => 2 } if $col eq "fou";
+ return { indent => 1, wrap_indent => 2 } if $col eq "fiv";
+
+ return;
+}
+
+__DATA__
+One Three Four Five
+-------------------------------------------------------
+The quick The quick The quick The quick
+brown fox brown fox brown fox brown fox
+jumps over jumps over jumps over jumps over
+the lazy the lazy the lazy the lazy
+dog. The dog. The dog. The dog. The
+quick quick brown quick brown quick brown
+brown fox fox jumps fox jumps fox jumps
+jumps over over the over the over the
+the lazy lazy dog. lazy dog. lazy dog.
+dog. The The quick The quick The quick
+quick brown fox brown fox brown fox
+brown fox jumps over jumps over jumps over
+jumps over the lazy the lazy the lazy
+the lazy dog. dog. dog.
+dog.
Modified: branches/upstream/libdata-report-perl/current/t/03csv03.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/t/03csv03.t?rev=24120&op=diff
==============================================================================
--- branches/upstream/libdata-report-perl/current/t/03csv03.t (original)
+++ branches/upstream/libdata-report-perl/current/t/03csv03.t Mon Aug 11 12:25:59 2008
@@ -18,7 +18,7 @@
my $out = "";
$rep->set_stylist(sub {
my ($self, $row, $col) = @_;
- return { ignore => 1 } if $row eq "total" && !$col;
+ return { ignore => 1 } if $row && $row eq "total" && !$col;
return;
});
$rep->set_output(\$out);
Modified: branches/upstream/libdata-report-perl/current/t/03csv04.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/t/03csv04.t?rev=24120&op=diff
==============================================================================
--- branches/upstream/libdata-report-perl/current/t/03csv04.t (original)
+++ branches/upstream/libdata-report-perl/current/t/03csv04.t Mon Aug 11 12:25:59 2008
@@ -18,7 +18,7 @@
my $out = "";
$rep->set_stylist(sub {
my ($self, $row, $col) = @_;
- return { ignore => 1 } if $row eq "total" && !$col;
+ return { ignore => 1 } if $row && $row eq "total" && !$col;
return;
});
$rep->set_output(\$out);
Added: branches/upstream/libdata-report-perl/current/t/03csv05.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/t/03csv05.t?rev=24120&op=file
==============================================================================
--- branches/upstream/libdata-report-perl/current/t/03csv05.t (added)
+++ branches/upstream/libdata-report-perl/current/t/03csv05.t Mon Aug 11 12:25:59 2008
@@ -1,0 +1,44 @@
+#! perl
+
+use strict;
+use warnings;
+use Test::More;
+
+plan(tests => 1);
+
+use Data::Report;
+
+my $rep = Data::Report::->create
+ (type => "csv",
+ layout => [ { name => "acct", title => "Acct", width => 6 },
+ { name => "desc", title => "Report", width => 40, align => "|" },
+ { name => "deb", title => "Debet", width => 10, align => "<" },
+ { name => "crd", title => "Credit", width => 10, align => ">" },
+ ],
+ );
+
+my $out = "";
+$rep->set_stylist(sub {
+ my ($self, $row, $col) = @_;
+ return { ignore => 1 } if $row && $row eq "total" && !$col;
+ return;
+});
+$rep->set_output(\$out);
+$rep->start;
+$rep->add({ acct => 1234, desc => "two", deb => "thrëe", crd => "four" });
+$rep->add({ acct => 1235, desc => "two", deb => "thrée", crd => "four" });
+$rep->add({ acct => 1236, desc => "two", deb => "thrÿe", crd => "four" });
+$rep->add({ desc => "total", deb => "three", crd => "four", _style => "total" });
+$rep->finish;
+$rep->close;
+
+my $ref; { undef $/; $ref = <DATA> }
+$ref =~ s/[\r\n]/\n/g;
+$out =~ s/[\r\n]/\n/g;
+is($out, $ref);
+
+__DATA__
+"Acct","Report","Debet","Credit"
+"1234","two","thrëe","four"
+"1235","two","thrée","four"
+"1236","two","thrÿe","four"
Added: branches/upstream/libdata-report-perl/current/t/03csv06.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/t/03csv06.t?rev=24120&op=file
==============================================================================
--- branches/upstream/libdata-report-perl/current/t/03csv06.t (added)
+++ branches/upstream/libdata-report-perl/current/t/03csv06.t Mon Aug 11 12:25:59 2008
@@ -1,0 +1,44 @@
+#! perl
+
+use strict;
+use warnings;
+use Test::More qw(no_plan);
+
+use Data::Report;
+
+my $rep = Data::Report::->create
+ (type => "csv",
+ layout => [ { name => "acct", title => "Acct", width => 6 },
+ { name => "desc", title => "Report", width => 40, align => "|" },
+ { name => "deb", title => "Debet", width => 10, align => "<" },
+ { name => "crd", title => "Credit", width => 10, align => ">" },
+ ],
+ );
+
+my $out = "";
+$rep->set_stylist(sub {
+ my ($self, $row, $col) = @_;
+ return { ignore => 1 } if $row && $row eq "total" && !$col;
+ return { ignore => 1 } if $col eq "deb";
+ return;
+});
+$rep->set_output(\$out);
+$rep->set_separator(":") if $rep->get_type eq "csv";
+$rep->start;
+$rep->add({ acct => 1234, desc => "two", deb => "three", crd => "four" });
+$rep->add({ acct => 1235, desc => "two", deb => "three", crd => "four" });
+$rep->add({ acct => 1236, desc => "two", deb => "three", crd => "four" });
+$rep->add({ desc => "total", deb => "three", crd => "four", _style => "total" });
+$rep->finish;
+$rep->close;
+
+my $ref; { undef $/; $ref = <DATA> }
+$ref =~ s/[\r\n]/\n/g;
+$out =~ s/[\r\n]/\n/g;
+is($out, $ref);
+
+__DATA__
+"Acct":"Report":"Credit"
+"1234":"two":"four"
+"1235":"two":"four"
+"1236":"two":"four"
Added: branches/upstream/libdata-report-perl/current/t/09poc06.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-report-perl/current/t/09poc06.t?rev=24120&op=file
==============================================================================
--- branches/upstream/libdata-report-perl/current/t/09poc06.t (added)
+++ branches/upstream/libdata-report-perl/current/t/09poc06.t Mon Aug 11 12:25:59 2008
@@ -1,0 +1,104 @@
+#! perl
+
+use strict;
+use warnings;
+use Test::More tests => 2;
+
+package POC::Report;
+
+use base qw(Data::Report);
+
+package POC::Report::Html;
+
+use base qw(Data::Report::Plugin::Html);
+
+sub _std_stylist {
+ my ($rep, $row, $col) = @_;
+
+ return unless $col;
+
+ return { raw_html => 1 }
+ if $col eq "address";
+ return { ignore => 1 }
+ if $col =~ /^city|zip$/;
+
+ return;
+}
+
+sub add {
+ my ($self, $data) = @_;
+
+ $data->{address}
+ = join('<br/>', map { $self->_html($_) } @$data{qw(address city zip)});
+
+ $self->SUPER::add($data);
+}
+
+package main;
+
+my $rep = POC::Report::->create(type => "html");
+isa_ok($rep, 'POC::Report::Html');
+
+$rep->set_layout(
+ [
+ { name => "id", title => "ID", width => 4 },
+ { name => "name", title => "Name", width => 20 },
+ { name => "address", title => "Address", width => 40 },
+ { name => "city", title => "City", width => 20 },
+ { name => "zip", title => "Zip", width => 10 },
+ ]
+);
+
+my $out = "";
+$rep->set_output(\$out);
+$rep->start();
+
+$rep->add(
+ {
+ id => 1,
+ name => "Rijksmuseum",
+ address => "Museumplein",
+ city => "Amsterdam",
+ zip => "1000 AA",
+ _style => "normal"
+ }
+);
+
+$rep->add(
+ {
+ id => 2,
+ name => "Kabouterland",
+ address => "Zuid&einde",
+ city => "Exloo",
+ zip => "7889 AA",
+ _style => "normal"
+ }
+);
+
+
+$rep->finish;
+$rep->close;
+
+my $ref; { undef $/; $ref = <DATA>; }
+$ref =~ s/[\r\n]/\n/g;
+
+is($out, $ref, "contents");
+
+__DATA__
+<table class="main">
+<tr class="head">
+<th align="left" class="h_id">ID</th>
+<th align="left" class="h_name">Name</th>
+<th align="left" class="h_address">Address</th>
+</tr>
+<tr class="r_normal">
+<td align="left" class="c_id">1</td>
+<td align="left" class="c_name">Rijksmuseum</td>
+<td align="left" class="c_address">Museumplein<br/>Amsterdam<br/>1000 AA</td>
+</tr>
+<tr class="r_normal">
+<td align="left" class="c_id">2</td>
+<td align="left" class="c_name">Kabouterland</td>
+<td align="left" class="c_address">Zuid&einde<br/>Exloo<br/>7889 AA</td>
+</tr>
+</table>
More information about the Pkg-perl-cvs-commits
mailing list