From: Darren Chamberlain Date: Tue, 11 Jun 2002 12:09:13 +0000 (+0000) Subject: Fixed some typos, added some basic re-logicing (is that even a word?) X-Git-Tag: v0.01~49 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=38254289a9e626128e01ce962bec80f7fc2d998f;p=dbsrgits%2FSQL-Translator.git Fixed some typos, added some basic re-logicing (is that even a word?) --- diff --git a/lib/SQL/Translator.pm b/lib/SQL/Translator.pm index d50ffcf..b27cdf7 100644 --- a/lib/SQL/Translator.pm +++ b/lib/SQL/Translator.pm @@ -1,7 +1,7 @@ package SQL::Translator; # ---------------------------------------------------------------------- -# $Id: Translator.pm,v 1.6 2002-03-27 12:41:52 dlc Exp $ +# $Id: Translator.pm,v 1.7 2002-06-11 12:09:13 dlc Exp $ # ---------------------------------------------------------------------- # Copyright (C) 2002 Ken Y. Clark , # darren chamberlain @@ -57,7 +57,7 @@ contributing their parsers or producers back to the project. use strict; use vars qw($VERSION $DEFAULT_SUB $DEBUG); -$VERSION = sprintf "%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/; $DEBUG = 1 unless defined $DEBUG; # ---------------------------------------------------------------------- @@ -116,7 +116,7 @@ advantage is gained by passing options to the constructor. # ---------------------------------------------------------------------- sub new { my $class = shift; - my $args = isa($_[0], 'HASH') ? shift : { @_ }; + my $args = $_[0] && isa($_[0], 'HASH') ? shift : { @_ }; my $self = bless { } => $class; # ------------------------------------------------------------------ @@ -489,7 +489,7 @@ or: $tr->data(\$create_script); B takes a string, which is interpreted as a filename. -B takes a reference to a string, which is used as the data o be +B takes a reference to a string, which is used as the data to be parsed. If a filename is set, then that file is opened and read when the B method is called, as long as the data instance variable is not set. @@ -584,7 +584,13 @@ sub translate { # {{{ Passed something else entirely. else { # We're not impressed. Take your empty string and leave. - return ""; + # return ""; + + # Actually, if data, parser, and producer are set, then be can + # continue. Too bad, because I like my comment (above)... + return "" unless ($self->data && + $self->producer && + $self->parser); } # }}} } @@ -620,18 +626,16 @@ sub translate { # ---------------------------------------------------------------- if ($parser = ($args->{'parser'} || $args->{'from'})) { $self->parser($parser); - } else { - $parser = $self->parser; } + $parser = $self->parser; # ---------------------------------------------------------------- # Local reference to the producer subroutine # ---------------------------------------------------------------- if ($producer = ($args->{'producer'} || $args->{'to'})) { $self->producer($producer); - } else { - $producer = $self->producer; } + $producer = $self->producer; # ---------------------------------------------------------------- # Execute the parser, then execute the producer with that output diff --git a/lib/SQL/Translator/Validator.pm b/lib/SQL/Translator/Validator.pm index ea63a43..71450bb 100644 --- a/lib/SQL/Translator/Validator.pm +++ b/lib/SQL/Translator/Validator.pm @@ -1,7 +1,7 @@ package SQL::Translator::Validator; # ---------------------------------------------------------------------- -# $Id: Validator.pm,v 1.2 2002-03-27 12:41:53 dlc Exp $ +# $Id: Validator.pm,v 1.3 2002-06-11 12:09:13 dlc Exp $ # ---------------------------------------------------------------------- # Copyright (C) 2002 Ken Y. Clark , # darren chamberlain @@ -23,7 +23,7 @@ package SQL::Translator::Validator; use strict; use vars qw($VERSION @EXPORT); -$VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/; use Exporter; use base qw(Exporter); @@ -75,13 +75,13 @@ sub validate { "not defined"; } - # Indeces: array of hashes + # Indices: array of hashes unless (defined $table_data->{"indeces"} && UNIVERSAL::isa($table_data->{"indeces"}, "ARRAY")) { - return by_context $wa, 0, "Indeces is missing or is not an ARRAY"; + return by_context $wa, 0, "Indices is missing or is not an ARRAY"; } else { my @indeces = @{$table_data->{"indeces"}}; - $log .= "\n\tIndeces:"; + $log .= "\n\tIndices:"; if (@indeces) { for my $index (@indeces) { $log .= "\n\t\t" . ($index->{"name"} || "(unnamed)") @@ -147,7 +147,7 @@ SQL::Translator::Validate - Validate that a data structure is correct When writing a parser module for SQL::Translator, it is helpful to have a tool to automatically check the return of your module, to make sure that it is returning the Right Thing. While only a full Producer -and the associated database can determine if you are producing valud +and the associated database can determine if you are producing valid output, SQL::Translator::Validator can tell you if the basic format of the data structure is correct. While this will not catch many errors, it will catch the basic ones. @@ -185,7 +185,7 @@ Produces the following summary: Contains 2 tables. Table 1: random Type: not defined - Indeces: none defined + Indices: none defined Fields: id int (11) Default: 1 @@ -195,7 +195,7 @@ Produces the following summary: Null: no Table 2: session Type: HEAP - Indeces: + Indices: (unnamed) on id Fields: foo char (255)