package SQL::Translator;
# ----------------------------------------------------------------------
-# $Id: Translator.pm,v 1.46 2003-10-03 20:17:48 dlc Exp $
+# $Id: Translator.pm,v 1.54 2004-03-09 19:15:31 kycl4rk Exp $
# ----------------------------------------------------------------------
-# Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>,
-# darren chamberlain <darren@cpan.org>,
-# Chris Mungall <cjm@fruitfly.org>
+# Copyright (C) 2002-4 The 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
require 5.004;
-$VERSION = '0.03';
-$REVISION = sprintf "%d.%02d", q$Revision: 1.46 $ =~ /(\d+)\.(\d+)/;
+$VERSION = '0.05';
+$REVISION = sprintf "%d.%02d", q$Revision: 1.54 $ =~ /(\d+)\.(\d+)/;
$DEBUG = 0 unless defined $DEBUG;
$ERROR = "";
my @files = ref($filename) eq 'ARRAY' ? @$filename : ($filename);
foreach my $file (@files) {
- unless (open FH, $file) {
- return $self->error("Can't read file '$file': $!");
- }
+ unless (open FH, $file) {
+ return $self->error("Can't read file '$file': $!");
+ }
- $data .= <FH>;
+ $data .= <FH>;
- unless (close FH) {
- return $self->error("Can't close file '$file': $!");
- }
+ unless (close FH) {
+ return $self->error("Can't close file '$file': $!");
+ }
}
$self->{'data'} = \$data;
eval { $producer_output = $producer->($self) };
if ($@ || ! $producer_output) {
- my $msg = sprintf "translate: Error with producer '%s': %s",
- $producer_type, ($@) ? $@ : " no results";
+ my $err = $@ || $self->error || "no results";
+ my $msg = "translate: Error with producer '$producer_type': $err";
return $self->error($msg);
}
my $mod = $_;
$mod =~ s/\.pm$//;
my $cur_dir = $File::Find::dir;
- my $base_dir = catfile 'SQL', 'Translator', $uctype;
+ my $base_dir = quotemeta catfile 'SQL', 'Translator', $uctype;
#
# See if the current directory is below the base directory.
}
# ----------------------------------------------------------------------
+# version
+#
+# Returns the $VERSION of the main SQL::Translator package.
+# ----------------------------------------------------------------------
+sub version {
+ my $self = shift;
+ return $VERSION;
+}
+
+# ----------------------------------------------------------------------
sub validate {
my ( $self, $arg ) = @_;
if ( defined $arg ) {
SQL are handled (CREATE, ALTER), not the manipulation of data (INSERT,
UPDATE, DELETE).
+This documentation covers the API for SQL::Translator. For a more general
+discussion of how to use the modules and scripts, please see
+L<SQL::Translator::Manual>.
+
=head1 CONSTRUCTOR
The constructor is called C<new>, and accepts a optional hash of options.
Whether or not to validate the schema object after parsing and before
producing.
+=head2 version
+
+Returns the version of the SQL::Translator release.
+
=head1 AUTHORS
The following people have contributed to the SQLFairy project:
=item * Sam Angiuoli <angiuoli@users.sourceforge.net>
+=item * Dave Cash <dave@gnofn.org>
+
=item * Darren Chamberlain <dlc@users.sourceforge.net>
=item * Ken Y. Clark <kclark@cpan.org>