Storable! 0.24! DBIx_DBSchema_0_24
authorivan <ivan>
Fri, 11 Mar 2005 10:21:26 +0000 (10:21 +0000)
committerivan <ivan>
Fri, 11 Mar 2005 10:21:26 +0000 (10:21 +0000)
Changes
DBSchema.pm
Makefile.PL
README

diff --git a/Changes b/Changes
index f3e0d5b..e4ecd42 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,6 @@
 Revision history for Perl extension DBIx::DBSchema.
 
-0.24 unreleased
+0.24 Fri Mar 11 02:20:55 PST 2005
        - Oracle driver from Daniel Hanks <hanksdc@about-inc.com> and Peter
           Bowen <pbowen@aboutws.com>.
         - Switch from FreezeThaw to Storable, keep ability to read old files
index fc4916d..96aa843 100644 (file)
@@ -5,7 +5,7 @@ use vars qw(@ISA $VERSION);
 #use Exporter;
 use Carp qw(confess);
 use DBI;
-use FreezeThaw qw(freeze thaw cmpStr);
+use Storable;
 use DBIx::DBSchema::Table;
 use DBIx::DBSchema::Column;
 use DBIx::DBSchema::ColGroup::Unique;
@@ -14,7 +14,7 @@ use DBIx::DBSchema::ColGroup::Index;
 #@ISA = qw(Exporter);
 @ISA = ();
 
-$VERSION = "0.23";
+$VERSION = "0.24";
 
 =head1 NAME
 
@@ -136,12 +136,23 @@ Loads a DBIx::DBSchema object from a file.
 
 sub load {
   my($proto,$file)=@_; #use $proto ?
-  open(FILE,"<$file") or die "Can't open $file: $!";
-  my($string)=join('',<FILE>); #can $string have newlines?  pry not?
-  close FILE or die "Can't close $file: $!";
-  my($self)=thaw $string;
-  #no bless needed?
+
+  my $self;
+
+  #first try Storable
+  eval { $self = Storable::retrieve($file); };
+
+  if ( $@ && $@ =~ /not.*storable/i ) { #then try FreezeThaw
+    eval "use FreezeThaw;";
+    die $@ if $@;
+    open(FILE,"<$file") or die "Can't open $file: $!";
+    my $string = join('',<FILE>);
+    close FILE or die "Can't close $file: $!";
+    ($self) = FreezeThaw::thaw($string);
+  }
+
   $self;
+
 }
 
 =item save FILENAME
@@ -151,14 +162,8 @@ Saves a DBIx::DBSchema object to a file.
 =cut
 
 sub save {
-  my($self,$file)=@_;
-  my($string)=freeze $self;
-  open(FILE,">$file") or die "Can't open $file: $!";
-  print FILE $string;
-  close FILE or die "Can't close file: $!";
-  my($check_self)=thaw $string;
-  die "Verify error: Can't freeze and thaw dbdef $self"
-    if (cmpStr($self,$check_self));
+  #my($self, $file) = @_;
+  Storable::nstore(@_);
 }
 
 =item addtable TABLE_OBJECT
@@ -268,7 +273,7 @@ sub pretty_print {
           ). " ],\n"
         #"  'index' => [ ".    " ],\n"
     } $self->tables
-  ), "}\n";
+  ). "}\n";
 }
 
 =cut
@@ -337,7 +342,7 @@ Charles Shapiro <charles.shapiro@numethods.com> and Mitchell Friedman
 
 =head1 COPYRIGHT
 
-Copyright (c) 2000 Ivan Kohler
+Copyright (c) 2000-2005 Ivan Kohler
 Copyright (c) 2000 Mail Abuse Prevention System LLC
 All rights reserved.
 This program is free software; you can redistribute it and/or modify it under
index a10e4da..14c04d4 100644 (file)
@@ -7,5 +7,6 @@ WriteMakefile(
     'PREREQ_PM'    => {
                         'DBI' => 0,
                         'FreezeThaw' => 0,
+                        'Storable' => 0,
                       },
 );
diff --git a/README b/README
index 4e41f8b..6d3b137 100644 (file)
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
 DBIx::DBSchema
 
-Copyright (c) 2000-2004 Ivan Kohler
+Copyright (c) 2000-2005 Ivan Kohler
 Copyright (c) 2000 Mail Abuse Prevention System LLC
 All rights reserved.
 This program is free software; you can redistribute it and/or modify it under
@@ -12,7 +12,7 @@ schema from an existing database.  You can save the schema to disk and restore
 it from different process.  Most importantly, DBIx::DBSchema can write SQL
 CREATE statements for different databases from a single source.
 
-Currently supported databases are MySQL, PostgreSQL, Sybase and Oracle.
+Currently supported databases are MySQL, PostgreSQL, Oracle and Sybase.
 DBIx::DBSchema will attempt to use generic SQL syntax for other databases.
 Assistance adding support for other databases is welcomed.  See the
 DBIx::DBSchema::DBD manpage, "Driver Writer's Guide and Base Class".
@@ -39,4 +39,4 @@ A mailing list is available.  Send a blank message to
 
 Homepage: <http://www.420.am/dbix-dbschema>
 
-$Id: README,v 1.10 2004-02-26 01:34:24 ivan Exp $
+$Id: README,v 1.11 2005-03-11 10:17:53 ivan Exp $