producer to using evil hack of templates in INC.
-# $Id: Build.PL,v 1.10 2006-01-31 03:28:07 kycl4rk Exp $
+# $Id: Build.PL,v 1.11 2006-03-06 13:08:42 grommit Exp $
use strict;
use lib './lib';
-use SQL::Translator::Module::Build;
+use Module::Build;
-my $builder = SQL::Translator::Module::Build->new(
+my $builder = Module::Build->new(
create_readme => 0,
dist_abstract => 'SQL DDL transformations and more',
dist_author => 'Ken Y. Clark <kclark@cpan.org>',
},
);
-my $install_dir = $builder->args('install_dir');
-print "SqlFairy needs to install some additional files such as templates.\n";
-$install_dir = $builder->prompt( "Where should they go?", $install_dir );
-print "\n";
-
-# Add the install (and template) dir to the config data. They will then be
-# available via the (Module::Build) generated SQL::Translator::ConfigData.
-# During build time they are availiable from $builder->config_data( NAME )
-my $template_dir = "$install_dir/template";
-$builder->config_data( install_dir => $install_dir );
-$builder->config_data( template_dir => $template_dir );
-
-# Add build element for templates, these are processed by
-# SQL::Translator::Module::Build::process_template_files
-$builder->add_build_element('template');
-$builder->install_path->{template} = $template_dir;
-
+# Copy .tt2 files in lib into blib/lib
+$builder->add_build_element('tt2');
$builder->create_build_script;
print "Now run './Build', './Build test', and './Build install'\n";
* Added mysql_character_set for 4.1+ -mda
-* Two experimental filters. -mda
-* Added build support for installing templates. -mda
+* Two experimental filters (DefaultExtra, Names). -mda
* Added the initial work on a template based Dia UML producer. -mda
# -----------------------------------------------------------
+++ /dev/null
-package SQL::Translator::Module::Build;
-
-use strict;
-use warnings;
-use File::Find;
-
-use base qw/Module::Build/;
-
-# Copies contents of ./templates into blib/templates. These are then installed
-# based on the install_paths setting given to the constructor.
-# Called by Module::Build due to add_build_element call in Build.PL
-sub process_template_files {
- my $build = shift;
- find({
- no_chdir => 1,
- wanted => sub {
- return unless -f $_;
- $build->copy_if_modified( from => $_, to_dir => "blib", verbose => 1);
- },
- },'templates');
-}
-
-# Install the templates copied into blib above. Uses
-sub ACTION_install {
- my $build = shift;
- $build->SUPER::ACTION_install(@_);
- require ExtUtils::Install;
- my $install_to = $build->config_data( 'template_dir' );
- ExtUtils::Install::install(
- { 'templates' => $install_to }, 1, 0, $build->{args}{uninst} || 0 );
-}
-
-1;
package SQL::Translator::Producer::DiaUml;
# -------------------------------------------------------------------
-# $Id: DiaUml.pm,v 1.1 2006-01-20 16:17:21 grommit Exp $
+# $Id: DiaUml.pm,v 1.2 2006-03-06 13:08:43 grommit Exp $
# -------------------------------------------------------------------
# Copyright (C) 2002-4 SQLFairy Authors
#
use strict;
use vars qw[ $DEBUG $VERSION @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/;
$DEBUG = 0 unless defined $DEBUG;
use SQL::Translator::Utils 'debug';
-use SQL::Translator::ConfigData;
use base qw/SQL::Translator::Producer::TT::Base/;
# Convert produce call into a method call on our class
sub produce { return __PACKAGE__->new( translator => shift )->run; };
-# Add the installed templates to the inc path.
+# Uses dir in lib with this mods name as the template dir
+my $_TEMPLATE_DIR = __FILE__;
+$_TEMPLATE_DIR =~ s/\.pm$//;
+
sub tt_config {
- ( INCLUDE_PATH => SQL::Translator::ConfigData->config('template_dir')."/dia_uml" );
+ ( INCLUDE_PATH => $_TEMPLATE_DIR );
}
sub tt_schema { 'schema.tt2' }
[%# vim:ft=tt2 -%]
-[% WRAPPER diagram %]
- [% WRAPPER layer name="Background" %]
+[% WRAPPER diagram.tt2 %]
+ [% WRAPPER layer.tt2 name="Background" %]
[% FOREACH table IN schema.get_tables %]
- [% INCLUDE 'uml-class-start'
+ [% INCLUDE 'uml-class-start.tt2'
name = table.name
stereotype = 'Table'
visible_operations = 'false'
[% FOREACH field IN table.get_fields;
SET type = field.data_type;
SET type = "$type($field.size)" IF field.size;
- INCLUDE "uml-attribute"
+ INCLUDE "uml-attribute.tt2"
name = field.name
stereotype = 'Field'
type = type
<dia:boolean val="false"/>
</dia:attribute>
<dia:attribute name="templates"/>
- [% INCLUDE 'uml-class-end' %]
+ [% INCLUDE 'uml-class-end.tt2' %]
[% END %]
[% END %]
[% END %]
</dia:attribute>
<dia:attribute name="attributes">
[% FOREACH attributes %]
- [% INCLUDE "uml-attribute" %]
+ [% INCLUDE "uml-attribute.tt2" %]
[% END %]
</dia:attribute>
<dia:attribute name="operations"/>
[%# vim:ft=tt2
-%]
- [% INCLUDE 'uml-class-start' %]
+ [% INCLUDE 'uml-class-start.tt2' %]
<dia:attribute name="attributes">
[%- FOREACH attributes;
- INCLUDE "uml-attribute";
+ INCLUDE "uml-attribute.tt2";
END %]
</dia:attribute>
<dia:attribute name="operations"/>
<dia:boolean val="false"/>
</dia:attribute>
<dia:attribute name="templates"/>
- [% INCLUDE 'uml-class-end' %]
+ [% INCLUDE 'uml-class-end.tt2' %]