Add sqlite roundtrip test (probably need to do the same for the rest of the parser...
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Parser / Storable.pm
CommitLineData
f6595170 1package SQL::Translator::Parser::Storable;
2
df32118c 3# -------------------------------------------------------------------
821a0fde 4# $Id$
df32118c 5# -------------------------------------------------------------------
478f608d 6# Copyright (C) 2002-2009 SQLFairy Authors
df32118c 7#
8# This program is free software; you can redistribute it and/or
9# modify it under the terms of the GNU General Public License as
10# published by the Free Software Foundation; version 2.
11#
12# This program is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15# General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20# 02111-1307 USA
21# -------------------------------------------------------------------
f6595170 22
23=head1 NAME
24
df32118c 25SQL::Translator::Parser::Storable - parser for Schema objects serialized
26 with the Storable module
f6595170 27
28=head1 SYNOPSIS
29
30 use SQL::Translator;
f6595170 31
32 my $translator = SQL::Translator->new;
df32118c 33 $translator->parser('Storable');
f6595170 34
35=head1 DESCRIPTION
36
37Slurps in a Schema from a Storable file on disk. You can then turn
38the data into a database tables or graphs.
39
40=cut
41
42use strict;
478f608d 43use vars qw($DEBUG @EXPORT_OK);
f6595170 44$DEBUG = 0 unless defined $DEBUG;
f6595170 45
46use Storable;
47use Exporter;
48use SQL::Translator::Utils qw(debug normalize_name);
49
50use base qw(Exporter);
51
52@EXPORT_OK = qw(parse);
53
54sub parse {
55 my ($translator, $data) = @_;
56
ca0022de 57 if (defined($data)) {
58 $translator->{'schema'} = Storable::thaw($data);
59 return 1;
60 } elsif (defined($translator->filename)) {
61 $translator->{'schema'} = Storable::retrieve($translator->filename);
62 return 1;
63 }
f6595170 64
ca0022de 65 return 0;
f6595170 66}
67
681;
69
df32118c 70# -------------------------------------------------------------------
71
f6595170 72=pod
73
74=head1 SEE ALSO
75
b57555af 76SQL::Translator.
f6595170 77
b57555af 78=head1 AUTHOR
f6595170 79
df32118c 80Paul Harrington E<lt>harringp@deshaw.comE<gt>.
f6595170 81
82=cut