| 1 | package Backup::EZ::Dir; | ||||||||||||||
| 2 | 11 | $Backup::EZ::Dir::VERSION = '0.46'; | |||||||||||||
| 3 | =head1 NAME | ||||||||||||||
| 4 | |||||||||||||||
| 5 | Backup::EZ::Dir | ||||||||||||||
| 6 | |||||||||||||||
| 7 | =head1 VERSION | ||||||||||||||
| 8 | |||||||||||||||
| 9 | version 0.46 | ||||||||||||||
| 10 | |||||||||||||||
| 11 | =cut | ||||||||||||||
| 12 | |||||||||||||||
| 13 | 11 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | 11 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 15 | 11 | ▶ | use warnings FATAL => 'all'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 16 | 11 | ▶ | use Carp; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 17 | 11 | ▶ | use Devel::Confess 'color'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 18 | 11 | ▶ | use File::Spec; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 19 | 11 | ▶ | use Data::Printer alias => 'pdump'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 20 | |||||||||||||||
| 21 | 20 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.8
Pod
undocumented
| |||||||||||||||
| 22 | 20 | my $class = shift; | |||||||||||||
| 23 | 20 | my @args = @_; | |||||||||||||
| 24 | |||||||||||||||
| 25 | 20 | my $self = { | |||||||||||||
| 26 | dirname => undef, # scalar | ||||||||||||||
| 27 | chunked => 0, # bool | ||||||||||||||
| 28 | excludes_aref => undef, # arrayref | ||||||||||||||
| 29 | }; | ||||||||||||||
| 30 | |||||||||||||||
| 31 | 20 | my @excludes; | |||||||||||||
| 32 | |||||||||||||||
| 33 | 20 | my ( $dirname, @opts ) = split( /,/, $args[0] ); | |||||||||||||
| 34 | 20 | $self->{dirname} = _trim($dirname); | |||||||||||||
| 35 | |||||||||||||||
| 36 | 20 | foreach my $i (@opts) { | |||||||||||||
| 37 | 6 | my $opt = _trim($i); | |||||||||||||
| 38 | 6 | ▶ | if ($opt) { # ignore whitespace opts | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 39 | |||||||||||||||
| 40 | 6 | ▶ | if ( $opt =~ /^chunked$/i ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 41 | 2 | $self->{chunked} = 1; | |||||||||||||
| 42 | } | ||||||||||||||
| 43 | elsif ( $opt =~ /exclude\s*=\s*(.+)$/ ) { | ||||||||||||||
| 44 | 4 | push(@excludes, sprintf('--%s', $opt)); | |||||||||||||
| 45 | } | ||||||||||||||
| 46 | else { | ||||||||||||||
| 47 | 0 | confess "unknown dir option: $opt"; | |||||||||||||
| 48 | } | ||||||||||||||
| 49 | } | ||||||||||||||
| 50 | } | ||||||||||||||
| 51 | |||||||||||||||
| 52 | 20 | ▶ | if ( !$self->{dirname} ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 53 | 0 | confess "unable to determine dir in stanza: @_"; | |||||||||||||
| 54 | } | ||||||||||||||
| 55 | |||||||||||||||
| 56 | 20 | ▶ | if ( !File::Spec->file_name_is_absolute( $self->{dirname} ) ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 57 | 1 | confess "relative dirs are not supported"; | |||||||||||||
| 58 | } | ||||||||||||||
| 59 | |||||||||||||||
| 60 | 19 | $self->{excludes_aref} = \@excludes; | |||||||||||||
| 61 | |||||||||||||||
| 62 | 19 | bless $self, $class; | |||||||||||||
| 63 | 19 | return $self; | |||||||||||||
| 64 | } | ||||||||||||||
| 65 | |||||||||||||||
| 66 | # returns scalar | ||||||||||||||
| 67 | 16 | ▶ | sub dirname { | ||||||||||||
|
Subroutine
dirname: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 68 | 16 | my $self = shift; | |||||||||||||
| 69 | 16 | return $self->{dirname}; | |||||||||||||
| 70 | } | ||||||||||||||
| 71 | |||||||||||||||
| 72 | # returns bool | ||||||||||||||
| 73 | 8 | ▶ | sub chunked { | ||||||||||||
|
Subroutine
chunked: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 74 | 8 | my $self = shift; | |||||||||||||
| 75 | 8 | return $self->{chunked}; | |||||||||||||
| 76 | } | ||||||||||||||
| 77 | |||||||||||||||
| 78 | # returns arrayref | ||||||||||||||
| 79 | 8 | ▶ | sub excludes { | ||||||||||||
|
Subroutine
excludes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 80 | 8 | my $self = shift; | |||||||||||||
| 81 | 8 | return [ @{ $self->{excludes_aref} } ]; | |||||||||||||
| 82 | } | ||||||||||||||
| 83 | |||||||||||||||
| 84 | 26 | ▶ | sub _trim { | ||||||||||||
|
Subroutine
_trim: called CC=2 SCAR=7.0
| |||||||||||||||
| 85 | 26 | my $str = shift; | |||||||||||||
| 86 | |||||||||||||||
| 87 | 26 | ▶ | if ($str) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 88 | 26 | $str =~ s/^\s+//; | |||||||||||||
| 89 | 26 | $str =~ s/\s+$//; | |||||||||||||
| 90 | } | ||||||||||||||
| 91 | |||||||||||||||
| 92 | 26 | return $str; | |||||||||||||
| 93 | } | ||||||||||||||
| 94 | |||||||||||||||
| 95 | =head1 AUTHOR | ||||||||||||||
| 96 | |||||||||||||||
| 97 | John Gravatt, C<< <john at gravatt.org> >> | ||||||||||||||
| 98 | |||||||||||||||
| 99 | =head1 BUGS | ||||||||||||||
| 100 | |||||||||||||||
| 101 | Please report any bugs or feature requests to C<bug-backup-ez at rt.cpan.org>, or through | ||||||||||||||
| 102 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Backup-EZ>. I will be notified, and then you'll | ||||||||||||||
| 103 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||
| 104 | |||||||||||||||
| 105 | |||||||||||||||
| 106 | |||||||||||||||
| 107 | |||||||||||||||
| 108 | =head1 SUPPORT | ||||||||||||||
| 109 | |||||||||||||||
| 110 | You can find documentation for this module with the perldoc command. | ||||||||||||||
| 111 | |||||||||||||||
| 112 | perldoc Backup::EZ | ||||||||||||||
| 113 | |||||||||||||||
| 114 | |||||||||||||||
| 115 | You can also look for information at: | ||||||||||||||
| 116 | |||||||||||||||
| 117 | =over 4 | ||||||||||||||
| 118 | |||||||||||||||
| 119 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||
| 120 | |||||||||||||||
| 121 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Backup-EZ> | ||||||||||||||
| 122 | |||||||||||||||
| 123 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||
| 124 | |||||||||||||||
| 125 | L<http://annocpan.org/dist/Backup-EZ> | ||||||||||||||
| 126 | |||||||||||||||
| 127 | =item * CPAN Ratings | ||||||||||||||
| 128 | |||||||||||||||
| 129 | L<http://cpanratings.perl.org/d/Backup-EZ> | ||||||||||||||
| 130 | |||||||||||||||
| 131 | =item * Search CPAN | ||||||||||||||
| 132 | |||||||||||||||
| 133 | L<http://search.cpan.org/dist/Backup-EZ/> | ||||||||||||||
| 134 | |||||||||||||||
| 135 | =back | ||||||||||||||
| 136 | |||||||||||||||
| 137 | |||||||||||||||
| 138 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||
| 139 | |||||||||||||||
| 140 | |||||||||||||||
| 141 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||
| 142 | |||||||||||||||
| 143 | Copyright 2014 John Gravatt. | ||||||||||||||
| 144 | |||||||||||||||
| 145 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||
| 146 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||||||
| 147 | copy of the full license at: | ||||||||||||||
| 148 | |||||||||||||||
| 149 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||||
| 150 | |||||||||||||||
| 151 | Any use, modification, and distribution of the Standard or Modified | ||||||||||||||
| 152 | Versions is governed by this Artistic License. By using, modifying or | ||||||||||||||
| 153 | distributing the Package, you accept this license. Do not use, modify, | ||||||||||||||
| 154 | or distribute the Package, if you do not accept this license. | ||||||||||||||
| 155 | |||||||||||||||
| 156 | If your Modified Version has been derived from a Modified Version made | ||||||||||||||
| 157 | by someone other than you, you are nevertheless required to ensure that | ||||||||||||||
| 158 | your Modified Version complies with the requirements of this license. | ||||||||||||||
| 159 | |||||||||||||||
| 160 | This license does not grant you the right to use any trademark, service | ||||||||||||||
| 161 | mark, tradename, or logo of the Copyright Holder. | ||||||||||||||
| 162 | |||||||||||||||
| 163 | This license includes the non-exclusive, worldwide, free-of-charge | ||||||||||||||
| 164 | patent license to make, have made, use, offer to sell, sell, import and | ||||||||||||||
| 165 | otherwise transfer the Package with respect to any patent claims | ||||||||||||||
| 166 | licensable by the Copyright Holder that are necessarily infringed by the | ||||||||||||||
| 167 | Package. If you institute patent litigation (including a cross-claim or | ||||||||||||||
| 168 | counterclaim) against any party alleging that the Package constitutes | ||||||||||||||
| 169 | direct or contributory patent infringement, then this Artistic License | ||||||||||||||
| 170 | to you shall terminate on the date that such litigation is filed. | ||||||||||||||
| 171 | |||||||||||||||
| 172 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||||||||||||||
| 173 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||||||||||||||
| 174 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||||||||||||
| 175 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||||||||||||||
| 176 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||||||||||||||
| 177 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||||||||||||||
| 178 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||||||||||||||
| 179 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||
| 180 | |||||||||||||||
| 181 | |||||||||||||||
| 182 | =cut | ||||||||||||||
| 183 | |||||||||||||||
| 184 | 11 | 1; | |||||||||||||