release 0.11019
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator.pm
index 53867ea..13a0551 100644 (file)
@@ -3,9 +3,7 @@ package SQL::Translator;
 use Moo;
 our ( $DEFAULT_SUB, $DEBUG, $ERROR );
 
-require 5.005;
-
-our $VERSION  = '0.11013';
+our $VERSION  = '0.11019';
 $DEBUG    = 0 unless defined $DEBUG;
 $ERROR    = "";
 
@@ -16,9 +14,10 @@ use File::Find;
 use File::Spec::Functions qw(catfile);
 use File::Basename qw(dirname);
 use IO::Dir;
+use Sub::Quote qw(quote_sub);
 use SQL::Translator::Producer;
 use SQL::Translator::Schema;
-use SQL::Translator::Utils qw(throw ex2err);
+use SQL::Translator::Utils qw(throw ex2err carp_ro);
 
 $DEFAULT_SUB = sub { $_[0]->schema } unless defined $DEFAULT_SUB;
 
@@ -90,16 +89,16 @@ sub BUILD {
 
 has $_ => (
     is => 'rw',
-    default => sub { 0 },
-    coerce => sub { $_[0] ? 1 : 0 },
+    default => quote_sub(q{ 0 }),
+    coerce => quote_sub(q{ $_[0] ? 1 : 0 }),
 ) foreach qw(add_drop_table no_comments show_warnings trace validate);
 
 # quote_identifiers is on by default, use a 0-but-true as indicator
 # so we can allow individual producers to change the default
 has quote_identifiers => (
     is => 'rw',
-    default => sub { '0E0' },
-    coerce => sub { $_[0] || 0 },
+    default => quote_sub(q{ '0E0' }),
+    coerce => quote_sub(q{ $_[0] || 0 }),
 );
 
 sub quote_table_names {
@@ -137,7 +136,9 @@ around producer => sub {
 
 has producer_type => ( is => 'rwp', init_arg => undef );
 
-has producer_args => ( is => 'rw', default => sub { +{} } );
+around producer_type => carp_ro('producer_type');
+
+has producer_args => ( is => 'rw', default => quote_sub(q{ +{} }) );
 
 around producer_args => sub {
     my $orig = shift;
@@ -158,7 +159,9 @@ around parser => sub {
 
 has parser_type => ( is => 'rwp', init_arg => undef );
 
-has parser_args => ( is => 'rw', default => sub { +{} } );
+around parser_type => carp_ro('parser_type');
+
+has parser_args => ( is => 'rw', default => quote_sub(q{ +{} }) );
 
 around parser_args => sub {
     my $orig = shift;
@@ -167,7 +170,7 @@ around parser_args => sub {
 
 has filters => (
     is => 'rw',
-    default => sub { [] },
+    default => quote_sub(q{ [] }),
     coerce => sub {
         my @filters;
         # Set. Convert args to list of [\&code,@args]
@@ -198,12 +201,14 @@ around filters => sub {
 has filename => (
     is => 'rw',
     isa => sub {
-        my $filename = shift;
-        if (-d $filename) {
-            throw("Cannot use directory '$filename' as input source");
-        } elsif (not -f _ && -r _) {
-            throw("Cannot use '$filename' as input source: ".
-                  "file does not exist or is not readable.");
+        foreach my $filename (ref($_[0]) eq 'ARRAY' ? @{$_[0]} : $_[0]) {
+            if (-d $filename) {
+                throw("Cannot use directory '$filename' as input source");
+            }
+            elsif (not -f _ && -r _) {
+                throw("Cannot use '$filename' as input source: ".
+                      "file does not exist or is not readable.");
+            }
         }
     },
 );
@@ -273,6 +278,8 @@ has schema => (
     predicate => '_has_schema',
 );
 
+around schema => carp_ro('schema');
+
 around reset => sub {
     my $orig = shift;
     my $self = shift;
@@ -952,7 +959,7 @@ analogously to C<producer_type> and C<producer_args>
 
 =head2 filters
 
-Set or retreive the filters to run over the schema during the
+Set or retrieve the filters to run over the schema during the
 translation, before the producer creates its output. Filters are sub
 routines called, in order, with the schema object to filter as the 1st
 arg and a hash of options (passed as a list) for the rest of the args.
@@ -1112,19 +1119,12 @@ added to the project and what you'd like to contribute.
 
 =head1 COPYRIGHT
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; version 2.
+Copyright 2012 the SQL::Translator authors, as listed in L</AUTHORS>.
 
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
+=head1 LICENSE
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-USA
+This library is free software and may be distributed under the same terms as
+Perl 5 itself.
 
 =head1 BUGS