Added Globals filter.
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Parser / Storable.pm
CommitLineData
f6595170 1package SQL::Translator::Parser::Storable;
2
df32118c 3# -------------------------------------------------------------------
90075866 4# $Id: Storable.pm,v 1.5 2004-02-09 22:23:40 kycl4rk Exp $
df32118c 5# -------------------------------------------------------------------
90075866 6# Copyright (C) 2002-4 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;
43use vars qw($DEBUG $VERSION @EXPORT_OK);
44$DEBUG = 0 unless defined $DEBUG;
90075866 45$VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/;
f6595170 46
47use Storable;
48use Exporter;
49use SQL::Translator::Utils qw(debug normalize_name);
50
51use base qw(Exporter);
52
53@EXPORT_OK = qw(parse);
54
55sub parse {
56 my ($translator, $data) = @_;
57
ca0022de 58 if (defined($data)) {
59 $translator->{'schema'} = Storable::thaw($data);
60 return 1;
61 } elsif (defined($translator->filename)) {
62 $translator->{'schema'} = Storable::retrieve($translator->filename);
63 return 1;
64 }
f6595170 65
ca0022de 66 return 0;
f6595170 67}
68
691;
70
df32118c 71# -------------------------------------------------------------------
72
f6595170 73=pod
74
75=head1 SEE ALSO
76
b57555af 77SQL::Translator.
f6595170 78
b57555af 79=head1 AUTHOR
f6595170 80
df32118c 81Paul Harrington E<lt>harringp@deshaw.comE<gt>.
f6595170 82
83=cut