From: Darren Chamberlain Date: Thu, 31 Jul 2003 20:49:42 +0000 (+0000) Subject: .cvsignore X-Git-Tag: v0.04~367 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4b6a634117887e197c80a3acfb53c03307d37cb2;p=dbsrgits%2FSQL-Translator.git .cvsignore --- diff --git a/MANIFEST b/MANIFEST index 50b32db..a29f640 100644 --- a/MANIFEST +++ b/MANIFEST @@ -10,6 +10,7 @@ bin/sqlt-diagram.pl bin/sqlt-graph.pl bin/sql_translator.pl bin/sql_translator.cgi +bin/sqltsh lib/SQL/Translator/Parser.pm lib/SQL/Translator/Parser/Excel.pm lib/SQL/Translator/Parser/MySQL.pm @@ -35,6 +36,7 @@ lib/SQL/Translator/Schema/Field.pm lib/SQL/Translator/Schema/Index.pm lib/SQL/Translator/Schema/Table.pm lib/SQL/Translator/Schema/View.pm +lib/SQL/Translator/Shell.pm lib/SQL/Translator/Utils.pm lib/SQL/Translator.pm t/01load.t diff --git a/Makefile.PL b/Makefile.PL index ad64d8b..f74169e 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -2,33 +2,122 @@ package SQL::Translator; use strict; use ExtUtils::MakeMaker; +$|++; + +my %PREREQ_PM; +my %missing = ( + optional => [ ], + required => [ ], +); + +print "Checking for required and recommended modules.\n"; +# Module Name Version Optional? +check_version('Class::Base' => 0 => 0); +check_version('File::Basename' => 0 => 0); +check_version('File::Spec' => 0 => 0); +check_version('GD' => 0 => 1); +check_version('GraphViz' => 0 => 1); +check_version('IO::Dir' => 0 => 0); +check_version('IO::File' => 0 => 0); +check_version('IO::Scalar' => 0 => 0); +check_version('Parse::RecDescent' => 1.94 => 0); +check_version('Pod::Usage' => 0 => 0); +check_version('Spreadsheet::ParseExcel' => 0 => 1); +check_version('Test::More' => 0 => 0); +check_version('Text::ParseWords' => 0 => 0); +check_version('Text::RecordParser' => 0.02 => 0); +check_version('XML::Writer' => 0 => 1); + +print "\n"; + +if (@{$missing{'optional'}} + @{$missing{'required'}}) { + print "Some components might not work correctly:\n"; + my $count; + if ($missing{'required'}) { + $count = scalar(@{$missing{'required'}}); + printf " You are missing %d required module%s: %s\n", + $count, + $count == 1 ? '' : 's', + join ', ', @{$missing{'required'}}; + } + if ($missing{'optional'}) { + $count = scalar(@{$missing{'optional'}}); + printf " You are missing %d optional module%s: %s\n", + $count, + $count == 1 ? '' : 's', + join ', ', @{$missing{'optional'}}; + } + + print "\n"; +} WriteMakefile( 'NAME' => __PACKAGE__, 'VERSION_FROM' => 'lib/SQL/Translator.pm', 'EXE_FILES' => [ 'bin/sqlt-diagram.pl', + 'bin/sqlt-dumper.pl', 'bin/sqlt-graph.pl', 'bin/sql_translator.pl', ], - 'PREREQ_PM' => { - 'Class::Base' => 0, - 'File::Basename' => 0, - 'File::Spec' => 0, - 'GD' => 0, - 'GraphViz' => 0, - 'IO::Dir' => 0, - 'IO::File' => 0, - 'IO::Scalar' => 0, - 'Parse::RecDescent' => 1.94, - 'Pod::Usage' => 0, - 'Spreadsheet::ParseExcel' => 0, - 'Test::More' => 0, - 'Text::ParseWords' => 0, - 'Text::RecordParser' => 0.02, - 'XML::Writer' => 0, - }, - clean => { - FILES => '$(DISTNAME)-$(VERSION).tar.gz', + 'PREREQ_PM' => \%PREREQ_PM, + 'clean' => { + FILES => '$(DISTVNAME).tar$(SUFFIX)', }, ); + +# ---------------------------------------------------------------------- +# check_version($module, $version, $optional) +# +# Takes a module name, optional version number, and a flag indicating +# whether the module is optional (default is no). +# ---------------------------------------------------------------------- +sub check_version { + my ($module, $version, $optional) = @_; + my ($dots, $load); + + if ($version) { + $load = "$module $version"; + } + else { + $load = $module; + } + + $dots = '.' x (36 - length($load)); + + eval "use $load;"; + if ($@) { + if ($optional) { + push @{$missing{'optional'}}, $module; + } + else { + push @{$missing{'required'}}, $module; + } + print "$load $dots not found!"; + if ($optional) { + print optional('not found!'), "\n"; + return; + } + print required('not found!'); + print "\n"; + } + else { + no strict qw(refs); + my $version = ${"$module\::VERSION"}; + print "$load $dots $version"; + print $optional ? optional($version) : required($version); + print "\n"; + } + + $PREREQ_PM{$module} = $version; +} + +sub optional { return _message("[optional]", @_) } +sub required { return _message("", @_) } + +sub _message { + my ($message, $version) = @_; + my $size = 24 - (length "$version"); + my $fmt = '%' . $size . 's'; + sprintf $fmt => $message; +} diff --git a/lib/SQL/Translator.pm b/lib/SQL/Translator.pm index 681dc28..08a1295 100644 --- a/lib/SQL/Translator.pm +++ b/lib/SQL/Translator.pm @@ -1,7 +1,7 @@ package SQL::Translator; # ---------------------------------------------------------------------- -# $Id: Translator.pm,v 1.36 2003-07-09 05:59:24 allenday Exp $ +# $Id: Translator.pm,v 1.37 2003-07-31 20:49:42 dlc Exp $ # ---------------------------------------------------------------------- # Copyright (C) 2003 Ken Y. Clark , # darren chamberlain , @@ -26,8 +26,10 @@ use strict; use vars qw( $VERSION $REVISION $DEFAULT_SUB $DEBUG $ERROR ); use base 'Class::Base'; +require 5.004; + $VERSION = '0.02'; -$REVISION = sprintf "%d.%02d", q$Revision: 1.36 $ =~ /(\d+)\.(\d+)/; +$REVISION = sprintf "%d.%02d", q$Revision: 1.37 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; $ERROR = ""; @@ -547,7 +549,7 @@ sub translate { return $self->error($msg); } - if ( $self->validate ) { + if ($self->validate) { my $schema = $self->schema; return $self->error('Invalid schema') unless $schema->is_valid; } @@ -644,7 +646,7 @@ sub _list { my $path = catfile "SQL", "Translator", $uctype; for (@INC) { my $dir = catfile $_, $path; - $self->debug("_list_${type}s searching $dir"); + $self->debug("_list_${type}s searching $dir\n"); next unless -d $dir; my $dh = IO::Dir->new($dir);