X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FProducer%2FTT%2FBase.pm;h=75338209ca044b2172028712fcc4fed5eaecd9df;hb=11ad2df91bcc0674faa8fb5b6bab52c9e4a73762;hp=0cebbc38145de0a249883165170e8d81fcf4e33c;hpb=7f3fc88362184316ad9d7ae5bcefa17e034aa4af;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Producer/TT/Base.pm b/lib/SQL/Translator/Producer/TT/Base.pm index 0cebbc3..7533820 100644 --- a/lib/SQL/Translator/Producer/TT/Base.pm +++ b/lib/SQL/Translator/Producer/TT/Base.pm @@ -1,9 +1,7 @@ package SQL::Translator::Producer::TT::Base; # ------------------------------------------------------------------- -# $Id: Base.pm,v 1.2 2004-05-13 22:52:00 grommit Exp $ -# ------------------------------------------------------------------- -# Copyright (C) 2002-4 SQLFairy Authors +# Copyright (C) 2002-2009 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 @@ -20,49 +18,23 @@ package SQL::Translator::Producer::TT::Base; # 02111-1307 USA # ------------------------------------------------------------------- -=pod +=pod =head1 NAME -SQL::Translator::Producer::TT::Base - TT based Producer base class. - -=head1 SYNOPSIS - - package SQL::Translator::Producer::Foo; - use base qw/SQL::Translator::Producer::TT::Base/; - - # Convert produce call into an object of our new class - sub produce { return __PACKAGE__->new( translator => shift )->run; }; - - # Return file name or template source - sub tt_schema { local $/ = undef; return \; } - - # Extra vars to add to the template - sub tt_vars { ( foo => "bar" ); } - -=head1 DESCRIPTION - -A base class producer designed to be sub-classed to create new TT base -producers cheaply by simply giving the template to use and sprinkling in some -extra template variables. - -See the synopsis above for an example of creating a simple producer using -a single template stored in the producers DATA section. - -WARNING: This is currently WORK IN PROGRESS and so subject to change, -but it does work ;-) +SQL::Translator::Producer::TT::Base - TT (Template Toolkit) based Producer base +class. =cut -# ------------------------------------------------------------------- - use strict; use vars qw[ $VERSION @EXPORT_OK ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/; +$VERSION = '1.59'; use Template; use Data::Dumper; +use IO::Handle; use Exporter; use base qw(Exporter); @EXPORT_OK = qw(produce); @@ -140,47 +112,222 @@ sub run { return $out; } -# Should returns a template file name to use, or a scalar ref of tt source, or -# an io handle. See L