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