From: Rob Kinyon Date: Thu, 24 Feb 2005 16:44:49 +0000 (+0000) Subject: Finished changes for v0.21 - including documentation fixes and a new renderer X-Git-Tag: v0.21~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c11fa570a52d9613e40c4c80e22302c2a5caca70;p=p5sagit%2FExcel-Template.git Finished changes for v0.21 - including documentation fixes and a new renderer --- diff --git a/Changes b/Changes index a685b08..ffb96e3 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,7 @@ Revision history for Perl distribution Excel::Template - Added RENDERER option to new() - Deprecated BIG_FILE - Added pod.t and pod_coverage.t + - Tests now run under 5.005_02 without warnings 0.20 Wed Jan 26 12:00:00 2005 - Removed PM_FILTER by adding an optional USE_UNICODE runtime parameter. diff --git a/lib/Excel/Template.pm b/lib/Excel/Template.pm index 1dbfb9a..2c130fc 100644 --- a/lib/Excel/Template.pm +++ b/lib/Excel/Template.pm @@ -442,9 +442,9 @@ applications. =head1 CONTRIBUTORS -There is a mailing list at http://groups.google.com/group/ExcelTemplate +There is a mailing list at http://groups.google.com/group/ExcelTemplate or exceltemplate@googlegroups.com -Robert Graff - +=head2 Robert Graff =over 4 @@ -454,6 +454,46 @@ Robert Graff - =back +=head1 TEST COVERAGE + +I used Devel::Cover to test the coverage of my tests. Every release, I intend to improve these numbers. + +Excel::Template is also part of the CPAN Kwalitee initiative, being one of the top 100 non-core modules downloaded from CPAN. If you wish to help out, please feel free to contribute tests, patches, and/or suggestions. + +---------------------------- ------ ------ ------ ------ ------ ------ ------ +File stmt branch cond sub pod time total +---------------------------- ------ ------ ------ ------ ------ ------ ------ +blib/lib/Excel/Template.pm 90.0 57.1 50.0 90.5 100.0 26.0 80.8 +...ib/Excel/Template/Base.pm 83.3 50.0 66.7 75.0 88.9 8.8 80.0 +...cel/Template/Container.pm 46.3 20.0 33.3 58.3 85.7 4.6 47.7 +...emplate/Container/Bold.pm 100.0 n/a n/a 100.0 0.0 0.6 95.0 +.../Container/Conditional.pm 58.5 52.3 66.7 75.0 66.7 0.7 58.4 +...plate/Container/Format.pm 100.0 n/a n/a 100.0 0.0 0.8 96.6 +...plate/Container/Hidden.pm 100.0 n/a n/a 100.0 0.0 0.2 95.0 +...plate/Container/Italic.pm 100.0 n/a n/a 100.0 0.0 0.2 95.0 +...plate/Container/Locked.pm 100.0 n/a n/a 100.0 0.0 0.1 95.0 +...emplate/Container/Loop.pm 55.6 40.0 50.0 77.8 75.0 0.5 56.6 +...late/Container/Outline.pm 71.4 n/a n/a 80.0 0.0 0.0 70.0 +...Template/Container/Row.pm 100.0 75.0 n/a 100.0 50.0 0.3 93.8 +...mplate/Container/Scope.pm 100.0 n/a n/a 100.0 n/a 0.1 100.0 +...plate/Container/Shadow.pm 100.0 n/a n/a 100.0 0.0 0.1 95.0 +...te/Container/Strikeout.pm 100.0 n/a n/a 100.0 0.0 0.1 95.0 +...ate/Container/Workbook.pm 100.0 n/a n/a 100.0 n/a 1.1 100.0 +...te/Container/Worksheet.pm 94.1 50.0 n/a 100.0 0.0 0.9 88.0 +...Excel/Template/Context.pm 83.1 53.4 54.2 95.0 92.9 19.2 75.2 +...Excel/Template/Element.pm 100.0 n/a n/a 100.0 n/a 0.5 100.0 +...mplate/Element/Backref.pm 100.0 50.0 33.3 100.0 0.0 0.1 87.1 +.../Template/Element/Cell.pm 95.8 65.0 80.0 100.0 66.7 3.6 86.9 +...mplate/Element/Formula.pm 100.0 n/a n/a 100.0 0.0 0.3 94.1 +...Template/Element/Range.pm 100.0 66.7 n/a 100.0 66.7 0.2 93.3 +...l/Template/Element/Var.pm 100.0 n/a n/a 100.0 0.0 0.2 94.1 +...Excel/Template/Factory.pm 57.1 34.6 n/a 88.9 100.0 15.4 55.2 +.../Excel/Template/Format.pm 98.3 81.2 33.3 100.0 100.0 9.9 93.2 +...xcel/Template/Iterator.pm 85.2 70.6 70.6 84.6 87.5 2.0 80.4 +...el/Template/TextObject.pm 92.9 62.5 33.3 100.0 50.0 3.6 83.0 +Total 83.0 55.6 57.0 91.1 98.7 100.0 78.6 +---------------------------- ------ ------ ------ ------ ------ ------ ------ + =head1 COPYRIGHT This program is free software; you can redistribute diff --git a/lib/Excel/Template/Base.pm b/lib/Excel/Template/Base.pm index 082c2f0..9b93fb9 100644 --- a/lib/Excel/Template/Base.pm +++ b/lib/Excel/Template/Base.pm @@ -11,7 +11,7 @@ sub new { my $class = shift; - push @_, %{shift @_} while UNIVERSAL::isa($_[0], 'HASH'); + push @_, %{shift @_} while defined $_[0] && UNIVERSAL::isa($_[0], 'HASH'); (@_ % 2) and die "$class->new() called with odd number of option parameters\n"; @@ -112,7 +112,17 @@ None =head1 METHODS -None +=head2 calculate + +This is a wrapper around Excel::Template::Context->get() + +=head2 isa + +This is a wrapper around Excel::Template::Factory->isa() + +=head2 is_embedded + +This is a wrapper around Excel::Template::Factory->is_embedded() =head1 AUTHOR diff --git a/lib/Excel/Template/Container.pm b/lib/Excel/Template/Container.pm index 51ed783..df966d9 100644 --- a/lib/Excel/Template/Container.pm +++ b/lib/Excel/Template/Container.pm @@ -17,7 +17,9 @@ sub new my $class = shift; my $self = $class->SUPER::new(@_); - $self->{ELEMENTS} = [] unless UNIVERSAL::isa($self->{ELEMENTS}, 'ARRAY'); + $self->{ELEMENTS} = [] + unless exists $self->{ELEMENTS} && + UNIVERSAL::isa($self->{ELEMENTS}, 'ARRAY'); return $self; } diff --git a/lib/Excel/Template/Context.pm b/lib/Excel/Template/Context.pm index c8fe40a..d7218af 100644 --- a/lib/Excel/Template/Context.pm +++ b/lib/Excel/Template/Context.pm @@ -29,8 +29,11 @@ sub new $self->{ACTIVE_FORMAT} = Excel::Template::Format->blank_format($self); $self->{WORKSHEET_NAMES} = undef; - UNIVERSAL::isa($self->{$_}, 'ARRAY') || ($self->{$_} = []) - for qw( STACK PARAM_MAP NAME_MAP ); + for (qw( STACK PARAM_MAP NAME_MAP )) + { + next if defined $self->{$_} && UNIVERSAL::isa($self->{$_}, 'ARRAY'); + $self->{$_} = []; + } $self->{$_} = 0 for keys %isAbsolute; @@ -289,19 +292,55 @@ Excel::Template::Context =head1 PURPOSE +This is a helper node that provides the global context for the nodes do their processing within. It provides attribute scoping, parameter resolution, and other very nice things. + +Documentation is provided for if you wish to subclass another node. + =head1 NODE NAME +None + =head1 INHERITANCE +None + =head1 ATTRIBUTES +None + =head1 CHILDREN +None + =head1 AFFECTS +Everything + =head1 DEPENDENCIES -=head1 USAGE +None + +=head1 METHODS + +=head2 active_format + +=head2 active_worksheet + +=head2 add_reference + +=head2 get + +=head2 get_all_references + +=head2 get_last_reference + +=head2 named_param + +=head2 new_worksheet + +=head2 param + +=head2 use_unicode =head1 AUTHOR diff --git a/lib/Excel/Template/TextObject.pm b/lib/Excel/Template/TextObject.pm index 6c7a99e..607eaff 100755 --- a/lib/Excel/Template/TextObject.pm +++ b/lib/Excel/Template/TextObject.pm @@ -19,7 +19,9 @@ sub new my $class = shift; my $self = $class->SUPER::new(@_); - $self->{STACK} = [] unless UNIVERSAL::isa($self->{STACK}, 'ARRAY'); + $self->{STACK} = [] + unless defined $self->{STACK} && + UNIVERSAL::isa($self->{STACK}, 'ARRAY'); return $self; } diff --git a/t/002_workbook.t b/t/002_workbook.t index 32ad96a..75dec5e 100644 --- a/t/002_workbook.t +++ b/t/002_workbook.t @@ -4,7 +4,7 @@ use Test::More tests => 4; use lib 't'; use mock; -mock->reset; +mock::reset; my $CLASS = 'Excel::Template'; use_ok( $CLASS ); @@ -16,7 +16,7 @@ isa_ok( $object, $CLASS ); ok( $object->write_file( 'filename' ), 'Something returned' ); -my @calls = mock->get_calls; +my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::add_format( '' ) diff --git a/t/003_worksheet.t b/t/003_worksheet.t index 8428ee4..c9af1ce 100644 --- a/t/003_worksheet.t +++ b/t/003_worksheet.t @@ -4,7 +4,7 @@ use Test::More tests => 4; use lib 't'; use mock; -mock->reset; +mock::reset; my $CLASS = 'Excel::Template'; use_ok( $CLASS ); @@ -16,7 +16,7 @@ isa_ok( $object, $CLASS ); ok( $object->write_file( 'filename' ), 'Something returned' ); -my @calls = mock->get_calls; +my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::add_format( '' ) diff --git a/t/004_cell.t b/t/004_cell.t index ac696bd..2543ec5 100644 --- a/t/004_cell.t +++ b/t/004_cell.t @@ -4,7 +4,7 @@ use Test::More tests => 4; use lib 't'; use mock; -mock->reset; +mock::reset; my $CLASS = 'Excel::Template'; use_ok( $CLASS ); @@ -16,7 +16,7 @@ isa_ok( $object, $CLASS ); ok( $object->write_file( 'filename' ), 'Something returned' ); -my @calls = mock->get_calls; +my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::add_format( '' ) diff --git a/t/005_formats.t b/t/005_formats.t index 8d7b9e0..ae18d89 100644 --- a/t/005_formats.t +++ b/t/005_formats.t @@ -4,7 +4,7 @@ use Test::More tests => 4; use lib 't'; use mock; -mock->reset; +mock::reset; my $CLASS = 'Excel::Template'; use_ok( $CLASS ); @@ -16,7 +16,7 @@ isa_ok( $object, $CLASS ); ok( $object->write_file( 'filename' ), 'Something returned' ); -my @calls = mock->get_calls; +my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::add_format( '' ) diff --git a/t/006_variables.t b/t/006_variables.t index f3a498c..e08a690 100644 --- a/t/006_variables.t +++ b/t/006_variables.t @@ -4,7 +4,7 @@ use Test::More tests => 5; use lib 't'; use mock; -mock->reset; +mock::reset; my $CLASS = 'Excel::Template'; use_ok( $CLASS ); @@ -24,7 +24,7 @@ ok( ok( $object->write_file( 'filename' ), 'Something returned' ); -my @calls = mock->get_calls; +my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::add_format( '' ) diff --git a/t/007_cell_formats.t b/t/007_cell_formats.t index 7ea983b..078b3a0 100644 --- a/t/007_cell_formats.t +++ b/t/007_cell_formats.t @@ -4,7 +4,7 @@ use Test::More tests => 4; use lib 't'; use mock; -mock->reset; +mock::reset; my $CLASS = 'Excel::Template'; use_ok( $CLASS ); @@ -16,7 +16,7 @@ isa_ok( $object, $CLASS ); ok( $object->write_file( 'filename' ), 'Something returned' ); -my @calls = mock->get_calls; +my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::add_format( '' ) diff --git a/t/008_formula.t b/t/008_formula.t index 6ff878f..a85b030 100644 --- a/t/008_formula.t +++ b/t/008_formula.t @@ -4,7 +4,7 @@ use Test::More tests => 4; use lib 't'; use mock; -mock->reset; +mock::reset; my $CLASS = 'Excel::Template'; use_ok( $CLASS ); @@ -16,7 +16,7 @@ isa_ok( $object, $CLASS ); ok( $object->write_file( 'filename' ), 'Something returned' ); -my @calls = mock->get_calls; +my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::add_format( '' ) diff --git a/t/009_loop.t b/t/009_loop.t index 5e9384f..5052961 100644 --- a/t/009_loop.t +++ b/t/009_loop.t @@ -5,7 +5,7 @@ use Test::More tests => 5; use lib 't'; use mock; -mock->reset; +mock::reset; my $CLASS = 'Excel::Template'; use_ok( $CLASS ); @@ -39,7 +39,7 @@ ok( ok( $object->write_file( 'filename' ), 'Something returned' ); -my @calls = mock->get_calls; +my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::add_format( '' ) diff --git a/t/010_scope.t b/t/010_scope.t index 99cd23a..0e528fa 100644 --- a/t/010_scope.t +++ b/t/010_scope.t @@ -4,7 +4,7 @@ use Test::More tests => 4; use lib 't'; use mock; -mock->reset; +mock::reset; my $CLASS = 'Excel::Template'; use_ok( $CLASS ); @@ -16,7 +16,7 @@ isa_ok( $object, $CLASS ); ok( $object->write_file( 'filename' ), 'Something returned' ); -my @calls = mock->get_calls; +my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::add_format( '' ) diff --git a/t/011_conditional.t b/t/011_conditional.t index d4ca064..19b3d0c 100644 --- a/t/011_conditional.t +++ b/t/011_conditional.t @@ -4,7 +4,7 @@ use Test::More tests => 5; use lib 't'; use mock; -mock->reset; +mock::reset; my $CLASS = 'Excel::Template'; use_ok( $CLASS ); @@ -28,7 +28,7 @@ ok( ok( $object->write_file( 'filename' ), 'Something returned' ); -my @calls = mock->get_calls; +my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::add_format( '' ) diff --git a/t/012_backref.t b/t/012_backref.t index 831b344..ffd18b1 100644 --- a/t/012_backref.t +++ b/t/012_backref.t @@ -4,7 +4,7 @@ use Test::More tests => 4; use lib 't'; use mock; -mock->reset; +mock::reset; my $CLASS = 'Excel::Template'; use_ok( $CLASS ); @@ -16,7 +16,7 @@ isa_ok( $object, $CLASS ); ok( $object->write_file( 'filename' ), 'Something returned' ); -my @calls = mock->get_calls; +my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::add_format( '' ) diff --git a/t/013_range.t b/t/013_range.t index 38fd676..3873149 100644 --- a/t/013_range.t +++ b/t/013_range.t @@ -4,7 +4,7 @@ use Test::More tests => 4; use lib 't'; use mock; -mock->reset; +mock::reset; my $CLASS = 'Excel::Template'; use_ok( $CLASS ); @@ -16,7 +16,7 @@ isa_ok( $object, $CLASS ); ok( $object->write_file( 'filename' ), 'Something returned' ); -my @calls = mock->get_calls; +my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::add_format( '' ) diff --git a/t/014_heightwidth.t b/t/014_heightwidth.t index 502a2c2..413dea2 100644 --- a/t/014_heightwidth.t +++ b/t/014_heightwidth.t @@ -4,7 +4,7 @@ use Test::More tests => 4; use lib 't'; use mock; -mock->reset; +mock::reset; my $CLASS = 'Excel::Template'; use_ok( $CLASS ); @@ -16,7 +16,7 @@ isa_ok( $object, $CLASS ); ok( $object->write_file( 'filename' ), 'Something returned' ); -my @calls = mock->get_calls; +my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::add_format( '' ) diff --git a/t/015_cell_type.t b/t/015_cell_type.t index 1355d89..2c48544 100644 --- a/t/015_cell_type.t +++ b/t/015_cell_type.t @@ -4,7 +4,7 @@ use Test::More tests => 4; use lib 't'; use mock; -mock->reset; +mock::reset; my $CLASS = 'Excel::Template'; use_ok( $CLASS ); @@ -16,7 +16,7 @@ isa_ok( $object, $CLASS ); ok( $object->write_file( 'filename' ), 'Something returned' ); -my @calls = mock->get_calls; +my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::add_format( '' ) diff --git a/t/016_renderers.t b/t/016_renderers.t index 2213d1f..bfca8c8 100644 --- a/t/016_renderers.t +++ b/t/016_renderers.t @@ -9,7 +9,7 @@ my $CLASS = 'Excel::Template'; use_ok( $CLASS ); { - mock->reset; + mock::reset; my $object = $CLASS->new( renderer => 'big', filename => 't/016.xml', @@ -18,7 +18,7 @@ use_ok( $CLASS ); ok( $object->write_file( 'filename' ), 'Something returned' ); - my @calls = mock->get_calls; + my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::Big::new( 'filename' ) Spreadsheet::WriteExcel::Big::add_format( '' ) @@ -27,7 +27,7 @@ __END_EXPECTED__ } { - mock->reset; + mock::reset; my $object = $CLASS->new( renderer => Excel::Template->RENDER_XML, filename => 't/016.xml', @@ -36,7 +36,7 @@ __END_EXPECTED__ ok( $object->write_file( 'filename' ), 'Something returned' ); - my @calls = mock->get_calls; + my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcelXML::new( 'filename' ) Spreadsheet::WriteExcelXML::close( '' ) @@ -44,7 +44,7 @@ __END_EXPECTED__ } { - mock->reset; + mock::reset; my $object = $CLASS->new( renderer => Excel::Template->RENDER_NML, filename => 't/016.xml', @@ -53,7 +53,7 @@ __END_EXPECTED__ ok( $object->write_file( 'filename' ), 'Something returned' ); - my @calls = mock->get_calls; + my @calls = mock::get_calls; is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); Spreadsheet::WriteExcel::new( 'filename' ) Spreadsheet::WriteExcel::close( '' )