[Midnightbsd-cvs] mports: lib/Mport: Make the db connection in Mport::Index overrideable.

ctriv at midnightbsd.org ctriv at midnightbsd.org
Fri Oct 19 00:36:00 EDT 2007


Log Message:
-----------
Make the db connection in Mport::Index overrideable.  Magus::Index will use
this.

Modified Files:
--------------
    mports/Tools/lib/Mport:
        Index.pm (r1.2 -> r1.3)

Added Files:
-----------
    mports/Tools/lib/Magus:
        Index.pm (r1.1)

-------------- next part --------------
--- /dev/null
+++ Tools/lib/Magus/Index.pm
@@ -0,0 +1,21 @@
+package Magus::Index;
+#
+# $MidnightBSD: mports/Tools/lib/Magus/Index.pm,v 1.1 2007/10/19 04:35:58 ctriv Exp $
+#
+use strict;
+use warnings;
+
+use base 'Mport::Index'
+  
+  
+sub connect_db {
+  my ($class) = @_;
+  
+  # Connect to mysql here.
+}  
+  
+
+   
+1;
+__END__
+ 
\ No newline at end of file
Index: Index.pm
===================================================================
RCS file: /home/cvs/mports/Tools/lib/Mport/Index.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -LTools/lib/Mport/Index.pm -LTools/lib/Mport/Index.pm -u -r1.2 -r1.3
--- Tools/lib/Mport/Index.pm
+++ Tools/lib/Mport/Index.pm
@@ -16,7 +16,7 @@
 sub build {
   my ($class) = @_;
   
-  my $dbh = create_db();
+  my $dbh = $class->create_db();
   
   my $categories_inserted;
   
@@ -78,9 +78,18 @@
 }
       
 
+sub connect_db {
+  my ($class) = @_;
+
+  return DBI->connect("dbi:SQLite:dbname=$INDEX", "", "", { RaiseError => 1, PrintError => 0 });
+}
+  
+
 sub create_db {
+  my ($class) = @_;
   unlink($INDEX);
-  my $dbh = DBI->connect("dbi:SQLite:dbname=$INDEX", "", "", { RaiseError => 1, PrintError => 0 });
+
+  my $dbh = $class->connect_db();
   $dbh->do(<<END_O_SQL);
 CREATE TABLE ports (
   name text primary key,


More information about the Midnightbsd-cvs mailing list