Commit | Line | Data |
f6595170 |
1 | package 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 |
25 | SQL::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 | |
37 | Slurps in a Schema from a Storable file on disk. You can then turn |
38 | the data into a database tables or graphs. |
39 | |
40 | =cut |
41 | |
42 | use strict; |
43 | use 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 | |
47 | use Storable; |
48 | use Exporter; |
49 | use SQL::Translator::Utils qw(debug normalize_name); |
50 | |
51 | use base qw(Exporter); |
52 | |
53 | @EXPORT_OK = qw(parse); |
54 | |
55 | sub 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 | |
69 | 1; |
70 | |
df32118c |
71 | # ------------------------------------------------------------------- |
72 | |
f6595170 |
73 | =pod |
74 | |
75 | =head1 SEE ALSO |
76 | |
b57555af |
77 | SQL::Translator. |
f6595170 |
78 | |
b57555af |
79 | =head1 AUTHOR |
f6595170 |
80 | |
df32118c |
81 | Paul Harrington E<lt>harringp@deshaw.comE<gt>. |
f6595170 |
82 | |
83 | =cut |