X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FProducer%2FTT%2FBase.pm;h=3a6105cc5d6f7e0b68ea126c3b813683df464b46;hb=c0ec0e22d3f0e3852c00daac5ef5763010b410c3;hp=90446aa242a7b49b0840e472b9574a487e7e6d12;hpb=f33f9d7029b19438c17ac3edf9f2d9c9ecbc3522;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Producer/TT/Base.pm b/lib/SQL/Translator/Producer/TT/Base.pm index 90446aa..3a6105c 100644 --- a/lib/SQL/Translator/Producer/TT/Base.pm +++ b/lib/SQL/Translator/Producer/TT/Base.pm @@ -1,25 +1,5 @@ package SQL::Translator::Producer::TT::Base; -# ------------------------------------------------------------------- -# $Id: Base.pm,v 1.5 2004-08-19 19:55:36 grommit Exp $ -# ------------------------------------------------------------------- -# Copyright (C) 2002-4 SQLFairy Authors -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; version 2. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -# 02111-1307 USA -# ------------------------------------------------------------------- - =pod =head1 NAME @@ -30,9 +10,10 @@ class. =cut use strict; +use warnings; -use vars qw[ $VERSION @EXPORT_OK ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/; +our @EXPORT_OK; +our $VERSION = '1.59'; use Template; use Data::Dumper; @@ -151,13 +132,11 @@ sub tt_vars { () }; 1; -# ------------------------------------------------------------------- - =pod =head1 SYNOPSIS -# Create a producer using a template in the __DATA__ section. + # Create a producer using a template in the __DATA__ section. package SQL::Translator::Producer::Foo; use base qw/SQL::Translator::Producer::TT::Base/; @@ -181,13 +160,12 @@ sub tt_vars { () }; =head1 DESCRIPTION -WARNING: This is currently WORK IN PROGRESS and so subject to change, -but it does work ;-) - A base class producer designed to be sub-classed to create new TT based producers cheaply - by simply giving the template to use and sprinkling in some extra template variables and config. +You can find an introduction to this module in L. + The 1st thing the module does is convert the produce sub routine call we get from SQL::Translator into a method call on an object, which we can then sub-class. This is done with the following code which needs to appear in B @@ -196,14 +174,14 @@ sub classes. # Convert produce call into an object method call sub produce { return __PACKAGE__->new( translator => shift )->run; }; -See L below for details. +See L below for details. The upshot of this is we can make new template producers by sub classing this base class, adding the above snippet and a template. The module also provides a number of hooks into the templating process, -see L for details. +see L for details. -See the L above for an example of creating a simple producer using +See the L above for an example of creating a simple producer using a single template stored in the producers DATA section. =head1 SUB CLASS HOOKS @@ -227,7 +205,7 @@ The template to use, return a file name or a scalar ref of TT source, or an L. See L