[Jifty-commit] r7178 - in Jifty-DBI/trunk: lib/Jifty/DBI

Jifty commits jifty-commit at lists.jifty.org
Thu Jun 4 18:04:15 EDT 2009


Author: sartak
Date: Thu Jun  4 18:04:14 2009
New Revision: 7178

Modified:
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm
   Jifty-DBI/trunk/t/utils.pl   (contents, props changed)

Log:
Move supported_drivers and available_drivers into methods on the Handle class

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm	Thu Jun  4 18:04:14 2009
@@ -1319,6 +1319,39 @@
     return $self->simple_query("ALTER TABLE $args{'table'} RENAME TO $args{'to'}");
 }
 
+=head2 supported_drivers
+
+Returns a list of the drivers L<Jifty::DBI> supports.
+
+=cut
+
+sub supported_drivers {
+    return qw(
+        SQLite
+        Informix
+        mysql
+        mysqlPP
+        ODBC
+        Oracle
+        Pg
+        Sybase
+    );
+}
+
+=head2 available_drivers
+
+Returns a list of the available drivers based on the presence of C<DBD::*>
+modules.
+
+=cut
+
+sub available_drivers {
+    my $self = shift;
+
+    local $@;
+    return grep { eval "require DBD::" . $_ } $self->supported_drivers;
+}
+
 =head2 DESTROY
 
 When we get rid of the L<Jifty::DBI::Handle>, we need to disconnect

Modified: Jifty-DBI/trunk/t/utils.pl
==============================================================================
--- Jifty-DBI/trunk/t/utils.pl	(original)
+++ Jifty-DBI/trunk/t/utils.pl	Thu Jun  4 18:04:14 2009
@@ -2,6 +2,7 @@
 
 use strict;
 use File::Temp ();
+use Jifty::DBI::Handle;
 
 =head1 VARIABLES
 
@@ -11,19 +12,7 @@
 
 =cut
 
-our @supported_drivers = qw(
-        SQLite
-        Informix
-        mysql
-        mysqlPP
-        ODBC
-        Oracle
-        Pg
-        Sybase
-);
-
-
-
+our @supported_drivers = Jifty::DBI::Handle->supported_drivers;
 
 =head2 @available_drivers
 
@@ -32,7 +21,7 @@
 
 =cut
 
-our @available_drivers = grep { eval "require DBD::". $_ } @supported_drivers;
+our @available_drivers = Jifty::DBI::Handle->available_drivers;
 
 =head1 FUNCTIONS
 


More information about the Jifty-commit mailing list