Backed out M::B ConfigData based installed templates and moved DiaUml
Mark Addison [Mon, 6 Mar 2006 13:08:43 +0000 (13:08 +0000)]
producer to using evil hack of templates in INC.

12 files changed:
Build.PL
Changes
lib/SQL/Translator/Module/Build.pm [deleted file]
lib/SQL/Translator/Producer/DiaUml.pm
lib/SQL/Translator/Producer/DiaUml/diagram.tt2 [moved from templates/dia_uml/diagram with 100% similarity]
lib/SQL/Translator/Producer/DiaUml/layer.tt2 [moved from templates/dia_uml/layer with 100% similarity]
lib/SQL/Translator/Producer/DiaUml/schema.tt2 [moved from templates/dia_uml/schema.tt2 with 81% similarity]
lib/SQL/Translator/Producer/DiaUml/uml-attribute.tt2 [moved from templates/dia_uml/uml-attribute with 100% similarity]
lib/SQL/Translator/Producer/DiaUml/uml-class-all.tt2 [moved from templates/dia_uml/uml-class-all with 98% similarity]
lib/SQL/Translator/Producer/DiaUml/uml-class-end.tt2 [moved from templates/dia_uml/uml-class-end with 100% similarity]
lib/SQL/Translator/Producer/DiaUml/uml-class-start.tt2 [moved from templates/dia_uml/uml-class-start with 100% similarity]
lib/SQL/Translator/Producer/DiaUml/uml-class.tt2 [moved from templates/dia_uml/uml-class with 72% similarity]

index 16b1b08..f35c6db 100644 (file)
--- a/Build.PL
+++ b/Build.PL
@@ -1,10 +1,10 @@
-# $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>',
@@ -55,23 +55,8 @@ my $builder = SQL::Translator::Module::Build->new(
     },
 );
 
-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";
diff --git a/Changes b/Changes
index b3e58e9..b58efd1 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,7 +1,6 @@
 
 * 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
 
 # -----------------------------------------------------------
diff --git a/lib/SQL/Translator/Module/Build.pm b/lib/SQL/Translator/Module/Build.pm
deleted file mode 100644 (file)
index 5d0a7de..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-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;
index 2cbf7a4..bb5b71d 100644 (file)
@@ -1,7 +1,7 @@
 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
 #
@@ -59,18 +59,20 @@ automatically arrange them horizontally or vertically.
 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' }
similarity index 81%
rename from templates/dia_uml/schema.tt2
rename to lib/SQL/Translator/Producer/DiaUml/schema.tt2
index d8488e3..81f0411 100644 (file)
@@ -1,8 +1,8 @@
 [%# 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'
@@ -11,7 +11,7 @@
               [% 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
@@ -24,7 +24,7 @@
                 <dia:boolean val="false"/>
               </dia:attribute>
               <dia:attribute name="templates"/>
-            [% INCLUDE 'uml-class-end' %]
+            [% INCLUDE 'uml-class-end.tt2' %]
         [% END %]
     [% END %]
 [% END %]
similarity index 98%
rename from templates/dia_uml/uml-class-all
rename to lib/SQL/Translator/Producer/DiaUml/uml-class-all.tt2
index dfe39cb..f5cf3c1 100644 (file)
@@ -96,7 +96,7 @@
       </dia:attribute>
       <dia:attribute name="attributes">
         [% FOREACH attributes %]
-            [% INCLUDE "uml-attribute" %]
+            [% INCLUDE "uml-attribute.tt2" %]
         [% END %]
       </dia:attribute>
       <dia:attribute name="operations"/>
similarity index 72%
rename from templates/dia_uml/uml-class
rename to lib/SQL/Translator/Producer/DiaUml/uml-class.tt2
index 64112c6..f3b17db 100644 (file)
@@ -1,9 +1,9 @@
 [%# 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"/>
@@ -11,4 +11,4 @@
         <dia:boolean val="false"/>
       </dia:attribute>
       <dia:attribute name="templates"/>
-    [% INCLUDE 'uml-class-end' %]
+    [% INCLUDE 'uml-class-end.tt2' %]