[Bast-commits] r3145 - in trunk/Template-Provider-DBIC: . examples lib/Template/Provider t

davecardwell at dev.catalyst.perl.org davecardwell at dev.catalyst.perl.org
Wed Mar 28 23:51:05 GMT 2007


Author: davecardwell
Date: 2007-03-28 23:51:04 +0100 (Wed, 28 Mar 2007)
New Revision: 3145

Added:
   trunk/Template-Provider-DBIC/INSTALL
   trunk/Template-Provider-DBIC/examples/
   trunk/Template-Provider-DBIC/examples/example.pl
Removed:
   trunk/Template-Provider-DBIC/Makefile.PL
Modified:
   trunk/Template-Provider-DBIC/Build.PL
   trunk/Template-Provider-DBIC/Changes
   trunk/Template-Provider-DBIC/MANIFEST
   trunk/Template-Provider-DBIC/lib/Template/Provider/DBIC.pm
   trunk/Template-Provider-DBIC/t/00.load.t
   trunk/Template-Provider-DBIC/t/01.functionality.t
   trunk/Template-Provider-DBIC/t/02.perlcritic.t
   trunk/Template-Provider-DBIC/t/03.pod.t
   trunk/Template-Provider-DBIC/t/04.pod-coverage.t
Log:
0.02	2007-03-28:
Tidied up distribution:
	* Improved documentation and moved it inline
	* Tidied up testing
	* Fixed problems with build system


Modified: trunk/Template-Provider-DBIC/Build.PL
===================================================================
--- trunk/Template-Provider-DBIC/Build.PL	2007-03-27 18:16:13 UTC (rev 3144)
+++ trunk/Template-Provider-DBIC/Build.PL	2007-03-28 22:51:04 UTC (rev 3145)
@@ -1,24 +1,26 @@
 use strict;
 use warnings;
+
 use Module::Build;
 
 my $builder = Module::Build->new(
-    module_name         => 'Template::Provider::DBIC',
-    license             => 'perl',
-    author              => 'Dave Cardwell <dcardwell at cpan.org>',
-    dist_version_from   => 'lib/Template/Provider/DBIC.pm',
-    dist_abstract       => 'Load templates using DBIx::Class.',
-    requires => {
-        'Test::More'  => 0,
-        'version'     => 0,
-        'Date::Parse' => 0,
-        'Template'    => 2.15,
+    add_to_cleanup     => [qw/ Template-Provider-DBIC-* /],
+    build_requires     => {
+        'DBD::SQLite' => '1.11',
+        'DBIx::Class' => '0',
+        'Test::More'  => '0',
     },
-    build_requires => {
-        'DBD::SQLite' => 1.11,
-        'DBIx::Class' => 0,
+    create_makefile_pl => 'passthrough',
+    create_readme      => 1,
+    dist_version_from  => 'lib/Template/Provider/DBIC.pm',
+    license            => 'perl',
+    module_name        => 'Template::Provider::DBIC',
+    requires           => {
+        'Date::Parse'        => '0',
+        'File::Path'         => '0',
+        'File::Spec'         => '0',
+        'Template::Provider' => '0',
     },
-    add_to_cleanup      => [ 'Template-Provider-DBIC-*' ],
 );
 
 $builder->create_build_script();

Modified: trunk/Template-Provider-DBIC/Changes
===================================================================
--- trunk/Template-Provider-DBIC/Changes	2007-03-27 18:16:13 UTC (rev 3144)
+++ trunk/Template-Provider-DBIC/Changes	2007-03-28 22:51:04 UTC (rev 3145)
@@ -1,4 +1,10 @@
 Revision history for Template-Provider-DBIC
 
-0.01  2007-03-02:
-      Initial release.
+0.02	2007-03-28:
+		Tidied up distribution:
+			* Improved documentation and moved it inline
+			* Tidied up testing
+			* Fixed problems with build system
+
+0.01	2007-03-02:
+		Initial release.

Added: trunk/Template-Provider-DBIC/INSTALL
===================================================================
--- trunk/Template-Provider-DBIC/INSTALL	                        (rev 0)
+++ trunk/Template-Provider-DBIC/INSTALL	2007-03-28 22:51:04 UTC (rev 3145)
@@ -0,0 +1,13 @@
+To install this module, run the following commands...
+
+	perl Makefile.PL
+	make
+	make test
+	make install
+
+Alternatively, to install with Module::Build...
+
+	perl Build.PL
+	./Build
+	./Build test
+	./Build install

Modified: trunk/Template-Provider-DBIC/MANIFEST
===================================================================
--- trunk/Template-Provider-DBIC/MANIFEST	2007-03-27 18:16:13 UTC (rev 3144)
+++ trunk/Template-Provider-DBIC/MANIFEST	2007-03-28 22:51:04 UTC (rev 3145)
@@ -1,13 +1,14 @@
 Build.PL
 Changes
-Makefile.PL
+examples/example.pl
+INSTALL
+lib/Template/Provider/DBIC.pm
 MANIFEST
-lib/Template/Provider/DBIC.pm
 t/00.load.t
 t/01.functionality.t
 t/02.perlcritic.t
 t/03.pod.t
 t/04.pod-coverage.t
 t/lib/TemplateProviderDBICTest.pm
+t/lib/TestSchema/Template.pm
 t/lib/TestSchema.pm
-t/lib/TestSchema/Template.pm

Deleted: trunk/Template-Provider-DBIC/Makefile.PL
===================================================================
--- trunk/Template-Provider-DBIC/Makefile.PL	2007-03-27 18:16:13 UTC (rev 3144)
+++ trunk/Template-Provider-DBIC/Makefile.PL	2007-03-28 22:51:04 UTC (rev 3145)
@@ -1,19 +0,0 @@
-use strict;
-use warnings;
-use ExtUtils::MakeMaker;
-
-WriteMakefile(
-    NAME                => 'Template::Provider::DBIC',
-    VERSION_FROM        => 'lib/Template/Provider/DBIC.pm',
-    ABSTRACT_FROM       => 'lib/Template/Provider/DBIC.pm',
-    AUTHOR              => 'Dave Cardwell <dcardwell at cpan.org>',
-    PL_FILES            => {},
-    PREREQ_PM => {
-        'Test::More'  => 0,
-        'version'     => 0,
-        'Date::Parse' => 0,
-        'Template'    => 2.15,
-    },
-    dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
-    clean               => { FILES => 'Template-Provider-DBIC-*' },
-);

Added: trunk/Template-Provider-DBIC/examples/example.pl
===================================================================
--- trunk/Template-Provider-DBIC/examples/example.pl	                        (rev 0)
+++ trunk/Template-Provider-DBIC/examples/example.pl	2007-03-28 22:51:04 UTC (rev 3145)
@@ -0,0 +1,27 @@
+#!/usr/bin/perl -wT
+
+use My::DBIC::Schema;
+use Template;
+use Template::Provider::DBIC;
+
+my $schema = My::DBIC::Schema->connect(
+    $dsn, $user, $password, \%options
+);
+my $resultset = $schema->resultset('Template');
+
+my $template = Template->new({
+    LOAD_TEMPLATES => [
+        Template::Provider::DBIC->new({
+            RESULTSET => $resultset,
+            # Other template options like COMPILE_EXT...
+        }),
+    ],
+});
+
+# Process the template 'my_template' from resultset 'Template'.
+$template->process('my_template');
+# Process the template 'other_template' from resultset 'Template'.
+$template->process('other_template');
+
+
+1;

Modified: trunk/Template-Provider-DBIC/lib/Template/Provider/DBIC.pm
===================================================================
--- trunk/Template-Provider-DBIC/lib/Template/Provider/DBIC.pm	2007-03-27 18:16:13 UTC (rev 3144)
+++ trunk/Template-Provider-DBIC/lib/Template/Provider/DBIC.pm	2007-03-28 22:51:04 UTC (rev 3145)
@@ -5,14 +5,138 @@
 
 use base qw/ Template::Provider /;
 
-use Date::Parse;
+use Carp qw( croak );
+use Date::Parse ();
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 
 
-# ->_init( \%options )
-# Check that valid Template::Provider::DBIC-specific arguments have been
-# supplied and store the appropriate values.
+=head1 NAME
+
+Template::Provider::DBIC - Load templates using DBIx::Class
+
+
+=head1 SYNOPSIS
+
+    use My::DBIC::Schema;
+    use Template;
+    use Template::Provider::DBIC;
+
+    my $schema = My::DBIC::Schema->connect(
+        $dsn, $user, $password, \%options
+    );
+    my $resultset = $schema->resultset('Template');
+
+If all of your templates are stored in a single table the most convenient
+method is to pass the provider a L<DBIx::Class::ResultSet>.
+
+    my $template = Template->new({
+        LOAD_TEMPLATES => [
+            Template::Provider::DBIC->new({
+                RESULTSET => $resultset,
+                # Other template options like COMPILE_EXT...
+            }),
+        ],
+    });
+
+    # Process the template 'my_template' from resultset 'Template'.
+    $template->process('my_template');
+    # Process the template 'other_template' from resultset 'Template'.
+    $template->process('other_template');
+
+Alternatively, where your templates are stored in several tables you can pass
+a L<DBIx::Class::Schema> and specify the result set and template name in the
+form C<ResultSet/template_name>.
+
+    my $template2 = Template->new({
+        LOAD_TEMPLATES => [
+            Template::Provider::DBIC->new({
+                SCHEMA => $schema,
+                # Other template options...
+            }),
+        ],
+    });
+
+    # Process the template 'my_template' from resultset 'Template'.
+    $template->process('Template/my_template');
+    # Process the template 'my_template' from resultset 'Other'.
+    $template->process('Other/my_template');
+
+In cases where both are supplied, the more specific RESULTSET will take
+precedence.
+
+
+=head1 DESCRIPTION
+
+Template::Provider::DBIC allows a L<Template> object to fetch its data using
+L<DBIx::Class> instead of, or in addition to, the default filesystem-based
+L<Template::Provider>.
+
+
+=head2 SCHEMA
+
+This provider requires a schema containing at least the following:
+
+=over
+
+=item
+
+A column containing the template name. When C<$template-E<gt>provider($name)>
+is called the provider will search this column for the corresponding C<$name>.
+For this reason the column must be a unique key, else an exception will be
+raised.
+
+=item
+
+A column containing the actual template content itself. This is what will be
+compiled and returned when the template is processed.
+
+=item
+
+A column containing the time the template was last modified. This must return
+ - or be inflated to - a date string recognisable by L<Date::Parse>.
+
+=back
+
+
+=head2 OPTIONS
+
+In addition to supplying a RESULTSET or SCHEMA and the standard
+L<Template::Provider> options, you may set the following preferences:
+
+=over 4
+
+=item COLUMN_NAME
+
+The table column that contains the template name. This will default to 'name'.
+
+=item COLUMN_CONTENT
+
+The table column that contains the template data itself. This will default to
+'content'.
+
+=item COLUMN_MODIFIED
+
+The table column that contains the date that the template was last modified.
+This will default to 'modified'.
+
+=back
+
+
+=head1 METHODS
+
+=begin comment
+
+->_init( \%options )
+
+Check that valid Template::Provider::DBIC-specific arguments have been
+supplied and store the appropriate values. See above for the available
+options.
+
+=end comment
+
+=cut
+
 sub _init {
     my ( $self, $options ) = @_;
     
@@ -61,10 +185,14 @@
 }
 
 
+=head2 ->fetch( $name )
 
-# ->fetch( $name )
-# Return a compiled template for the given name, using the cache where
-# possible.
+This method is called automatically during L<Template>'s C<-E<gt>process()>
+and returns a compiled template for the given C<$name>, using the cache where
+possible.
+
+=cut
+
 sub fetch {
     my ( $self, $name ) = @_;
     
@@ -159,10 +287,17 @@
 }
 
 
+=begin comment
 
-# ->_load( $name )
-# Load the template from the database and return a hash containing its name,
-# content, the time it was last modified, and the time it was loaded (now).
+->_load( $name )
+
+Load the template from the database and return a hash containing its name,
+content, the time it was last modified, and the time it was loaded (now).
+
+=end comment
+
+=cut
+
 sub _load {
     my ( $self, $name ) = @_;
     my ( $data, $error );
@@ -202,11 +337,18 @@
 }
 
 
+=begin comment
 
-# ->_modified( $name [, $time ] )
-# When called with a single argument, returns the modification time of the
-# given template. When called with a second argument it returns true if $name
-# has been modified since $time.
+->_modified( $name, $time )
+
+When called with a single argument, returns the modification time of the
+given template. When called with a second argument it returns true if $name
+has been modified since $time.
+
+=end comment
+
+=cut
+
 sub _modified {
     my ( $self, $name, $time ) = @_;
     
@@ -218,7 +360,7 @@
     my $resultset = $self->{ RESULTSET }
                  || $self->{ SCHEMA }->resultset($table);
                  
-    # Try to retrieve the template from the database.
+    # Try to retrieve the template from the database...
     my $template = $resultset->find(
         $name, { key => $self->{ COLUMN_NAME } }
     );
@@ -233,126 +375,9 @@
 }
 
 
-
-1;
+1; # End of the module code; everything from here is documentation...
 __END__
-=head1 NAME
 
-Template::Provider::DBIC - Load templates using DBIx::Class.
-
-
-=head1 VERSION
-
-This document describes Template::Provider::DBIC version 0.01
-
-
-=head1 SYNOPSIS
-
-    use My::DBIC::Schema;
-    use Template;
-    use Template::Provider::DBIC;
-
-    my $schema = My::DBIC::Schema->connect(
-        $dsn, $user, $password, \%options
-    );
-    my $resultset = $schema->resultset('Template');
-
-If all of your templates are stored in a single table the most convenient
-method is to pass the provider a L<DBIx::Class::ResultSet>.
-
-    my $template = Template->new({
-        LOAD_TEMPLATES => [
-            Template::Provider::DBIC->new({
-                RESULTSET => $resultset,
-                # Other template options like COMPILE_EXT...
-            }),
-        ],
-    });
-
-    # Process the template 'my_template' from resultset 'Template'.
-    $template->process('my_template');
-    # Process the template 'other_template' from resultset 'Template'.
-    $template->process('other_template');
-
-Alternatively, where your templates are stored in several tables you can pass
-a L<DBIx::Class::Schema> and specify the result set and template name in the
-form C<ResultSet/template_name>.
-
-    my $template2 = Template->new({
-        LOAD_TEMPLATES => [
-            Template::Provider::DBIC->new({
-                SCHEMA => $schema,
-                # Other template options...
-            }),
-        ],
-    });
-
-    # Process the template 'my_template' from resultset 'Template'.
-    $template->process('Template/my_template');
-    # Process the template 'my_template' from resultset 'Other'.
-    $template->process('Other/my_template');
-
-In cases where both are supplied, the more specific RESULTSET will take
-precedence.
-
-
-=head1 DESCRIPTION
-
-Template::Provider::DBIC allows a L<Template> object to fetch its data using
-L<DBIx::Class> instead of, or in addition to, the default filesystem-based
-L<Template::Provider>.
-
-
-=head2 SCHEMA
-
-This provider requires a schema containing at least the following:
-
-=over
-
-=item
-
-A column containing the template name. When C<$template-E<gt>provider($name)>
-is called the provider will search this column for the corresponding C<$name>.
-For this reason the column must be a unique key, else an exception will be
-raised.
-
-=item
-
-A column containing the actual template content itself. This is what will be
-compiled and returned when the template is processed.
-
-=item
-
-A column containing the time the template was last modified. This must return
- - or be inflated to - a date string recognisable by L<Date::Parse>.
-
-=back
-
-
-=head2 OPTIONS
-
-In addition to supplying a RESULTSET or SCHEMA and the standard
-L<Template::Provider> options, you may set the following preferences:
-
-=over 4
-
-=item COLUMN_NAME
-
-The table column that contains the template name. This will default to 'name'.
-
-=item COLUMN_CONTENT
-
-The table column that contains the template data itself. This will default to
-'content'.
-
-=item COLUMN_MODIFIED
-
-The table column that contains the date that the template was last modified.
-This will default to 'modified'.
-
-=back
-
-
 =head2 USE WITH OTHER PROVIDERS
 
 By default Template::Provider::DBIC will raise an exception when it cannot
@@ -380,15 +405,11 @@
 providers.
 
 
-=head1 PUBLIC METHODS
+=head1 SEE ALSO
 
-=head2 ->fetch( $name )
+L<Template>, L<Template::Provider>, L<DBIx::Class::Schema>
 
-This method is called automatically during L<Template>'s C<-E<gt>process()>
-and returns a compiled template for the given C<$name>, using the cache where
-possible.
 
-
 =head1 DIAGNOSTICS
 
 In addition to errors raised by L<Template::Provider> and L<DBIx::Class>,
@@ -420,18 +441,28 @@
 
 =head1 DEPENDENCIES
 
-Template::Provider::DBIC requires the following modules:
-
 =over
 
 =item
 
-L<Template::Provider>
+L<Carp>
 
 =item
 
 L<Date::Parse>
 
+=item
+
+L<File::Path>
+
+=item
+
+L<File::Spec>
+
+=item
+
+L<Template::Provider>
+
 =back
 
 Additionally, use of this module requires an object of the class
@@ -457,11 +488,11 @@
 
 =item * Template::Provider::DBIC
 
-L<http://perlprogrammer.co.uk/module/Template::Provider::DBIC/>
+L<http://perlprogrammer.co.uk/modules/Template::Provider::DBIC/>
 
 =item * AnnoCPAN: Annotated CPAN documentation
 
-L<http://annocpan.org/dist/Template-Provider-DBIC>
+L<http://annocpan.org/dist/Template-Provider-DBIC/>
 
 =item * RT: CPAN's request tracker
 
@@ -469,7 +500,7 @@
 
 =item * Search CPAN
 
-L<http://search.cpan.org/dist/Template-Provider-DBIC>
+L<http://search.cpan.org/dist/Template-Provider-DBIC/>
 
 =back
 
@@ -478,9 +509,13 @@
 
 Dave Cardwell <dcardwell at cpan.org>
 
+
 =head1 COPYRIGHT AND LICENSE
 
 Copyright (c) 2007 Dave Cardwell. All rights reserved.
 
 This module is free software; you can redistribute it and/or
 modify it under the same terms as Perl itself. See L<perlartistic>.
+
+
+=cut

Modified: trunk/Template-Provider-DBIC/t/00.load.t
===================================================================
--- trunk/Template-Provider-DBIC/t/00.load.t	2007-03-27 18:16:13 UTC (rev 3144)
+++ trunk/Template-Provider-DBIC/t/00.load.t	2007-03-28 22:51:04 UTC (rev 3145)
@@ -1,7 +1,11 @@
+#!perl -wT
+
+use strict;
+use warnings;
+
 use Test::More tests => 1;
 
-BEGIN {
-    use_ok( 'Template::Provider::DBIC' );
-}
+use_ok( 'Template::Provider::DBIC' );
 
-diag( "Testing Template::Provider::DBIC $Template::Provider::DBIC::VERSION" );
+diag( 'Testing Template::Provider::DBIC '
+            . $Template::Provider::DBIC::VERSION );

Modified: trunk/Template-Provider-DBIC/t/01.functionality.t
===================================================================
--- trunk/Template-Provider-DBIC/t/01.functionality.t	2007-03-27 18:16:13 UTC (rev 3144)
+++ trunk/Template-Provider-DBIC/t/01.functionality.t	2007-03-28 22:51:04 UTC (rev 3145)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More;
+use Test::More tests => 6;
 
 use lib qw( t/lib );
 use TemplateProviderDBICTest;
@@ -15,9 +15,7 @@
 my $schema    = TemplateProviderDBICTest->init_schema();
 my $resultset = $schema->resultset('Template');
 
-plan tests => 6;
 
-
 # Test Template::Provider::DBIC with a SCHEMA.
 my $schema_provider = Template::Provider::DBIC->new({
                           SCHEMA => $schema,
@@ -50,5 +48,4 @@
     'Parsed template by RESULTSET' );
 
 
-
 1;

Modified: trunk/Template-Provider-DBIC/t/02.perlcritic.t
===================================================================
--- trunk/Template-Provider-DBIC/t/02.perlcritic.t	2007-03-27 18:16:13 UTC (rev 3144)
+++ trunk/Template-Provider-DBIC/t/02.perlcritic.t	2007-03-28 22:51:04 UTC (rev 3145)
@@ -1,9 +1,15 @@
-#!perl
+#!perl -wT
 
-if (!require Test::Perl::Critic) {
-    Test::More::plan(
-        skip_all => "Test::Perl::Critic required for testing PBP compliance"
-    );
+use strict;
+use warnings;
+
+use Test::More;
+
+
+eval 'use Test::Perl::Critic';
+if ( $@ ) {
+    plan skip_all => 'Test::Perl::Critic required to test for best-practices';
 }
-
-Test::Perl::Critic::all_critic_ok();
+else {
+    Test::Perl::Critic::all_critic_ok();
+}

Modified: trunk/Template-Provider-DBIC/t/03.pod.t
===================================================================
--- trunk/Template-Provider-DBIC/t/03.pod.t	2007-03-27 18:16:13 UTC (rev 3144)
+++ trunk/Template-Provider-DBIC/t/03.pod.t	2007-03-28 22:51:04 UTC (rev 3145)
@@ -1,6 +1,15 @@
-#!perl -T
+#!perl -wT
 
+use strict;
+use warnings;
+
 use Test::More;
-eval "use Test::Pod 1.14";
-plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
-all_pod_files_ok();
+
+
+eval 'use Test::Pod 1.14';
+if ( $@ ) {
+    plan skip_all => 'Test::Pod 1.14 required for testing POD';
+}
+else {
+    Test::Pod::all_pod_files_ok();
+}

Modified: trunk/Template-Provider-DBIC/t/04.pod-coverage.t
===================================================================
--- trunk/Template-Provider-DBIC/t/04.pod-coverage.t	2007-03-27 18:16:13 UTC (rev 3144)
+++ trunk/Template-Provider-DBIC/t/04.pod-coverage.t	2007-03-28 22:51:04 UTC (rev 3145)
@@ -1,6 +1,15 @@
-#!perl -T
+#!perl -wT
 
+use strict;
+use warnings;
+
 use Test::More;
-eval "use Test::Pod::Coverage 1.04";
-plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
-all_pod_coverage_ok();
+
+
+eval 'use Test::Pod::Coverage 1.04';
+if ( $@ ) {
+    plan skip_all => 'Test::Pod::Coverage 1.04 required for testing POD coverage';
+}
+else {
+    Test::Pod::Coverage::all_pod_coverage_ok();
+}




More information about the Bast-commits mailing list