File Coverage

blib/lib/Pg/CLI/pg_dump.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Pg::CLI::pg_dump;
2             {
3             $Pg::CLI::pg_dump::VERSION = '0.11';
4             }
5              
6 1     1   1585 use Moose;
  1         293990  
  1         6  
7              
8 1     1   5168 use namespace::autoclean;
  1         5762  
  1         4  
9              
10 1     1   394 use MooseX::SemiAffordanceAccessor;
  1         8017  
  1         3  
11              
12             with qw( Pg::CLI::Role::Connects Pg::CLI::Role::Executable );
13              
14             __PACKAGE__->meta()->make_immutable();
15              
16             1;
17              
18             # ABSTRACT: Wrapper for the F<pg_dump> utility
19              
20             __END__
21              
22             =pod
23              
24             =head1 NAME
25              
26             Pg::CLI::pg_dump - Wrapper for the F<pg_dump> utility
27              
28             =head1 VERSION
29              
30             version 0.11
31              
32             =head1 SYNOPSIS
33              
34             my $pg_dump = Pg::CLI::pg_dump->new(
35             username => 'foo',
36             password => 'bar',
37             host => 'pg.example.com',
38             port => 5433,
39             );
40              
41             $pg_dump->run(
42             database => 'database',
43             options => [ '-C' ],
44             );
45              
46             my $sql;
47             $pg_dump->run(
48             database => 'database',
49             options => [ '-C' ],
50             stdout => \$sql,
51             );
52              
53             =head1 DESCRIPTION
54              
55             This class provides a wrapper for the F<pg_dump> utility.
56              
57             =head1 METHODS
58              
59             This class provides the following methods:
60              
61             =head2 Pg::CLI::pg_dump->new( ... )
62              
63             The constructor accepts a number of parameters:
64              
65             =over 4
66              
67             =item * executable
68              
69             The path to F<pg_dump>. By default, this will look for F<pg_dump> in your path
70             and throw an error if it cannot be found.
71              
72             =item * username
73              
74             The username to use when connecting to the database. Optional.
75              
76             =item * password
77              
78             The password to use when connecting to the database. Optional.
79              
80             =item * host
81              
82             The host to use when connecting to the database. Optional.
83              
84             =item * port
85              
86             The port to use when connecting to the database. Optional.
87              
88             =item * require_ssl
89              
90             If this is true, then the C<PGSSLMODE> environment variable will be set to
91             "require" when connecting to the database.
92              
93             =back
94              
95             =head2 $pg_dump->run( database => ..., options => [ ... ] )
96              
97             This method dumps the specified database. Any values passed in C<options> will
98             be passed on to pg_dump.
99              
100             This method also accepts optional C<stdin>, C<stdout>, and C<stderr>
101             parameters. These parameters can be any defined value that could be passed as
102             the relevant parameter to L<IPC::Run3>'s C<run3> subroutine.
103              
104             Notably, you can capture the dump output in a scalar reference for the
105             C<stdout> output.
106              
107             =head2 $pg_dump->version()
108              
109             Returns a the three part version as a string.
110              
111             =head2 $pg_dump->two_part_version()
112              
113             Returns the first two decimal numbers in the version.
114              
115             =head1 BUGS
116              
117             See L<Pg::CLI> for bug reporting details.
118              
119             =head1 AUTHOR
120              
121             Dave Rolsky <autarch@urth.org>
122              
123             =head1 COPYRIGHT AND LICENSE
124              
125             This software is Copyright (c) 2013 by Dave Rolsky.
126              
127             This is free software, licensed under:
128              
129             The Artistic License 2.0 (GPL Compatible)
130              
131             =cut