|
Revision 364, 1.7 kB
(checked in by miya, 2 years ago)
|
Archer::Plugin::Rsync: fix pod.
|
| Line | |
|---|
| 1 |
package Archer::Plugin::Rsync; |
|---|
| 2 |
use strict; |
|---|
| 3 |
use warnings; |
|---|
| 4 |
use base qw( Archer::Plugin ); |
|---|
| 5 |
use File::Spec; |
|---|
| 6 |
use File::Rsync; |
|---|
| 7 |
|
|---|
| 8 |
sub run { |
|---|
| 9 |
my ($self, $context, $args) = @_; |
|---|
| 10 |
|
|---|
| 11 |
my $global = $context->{config}->{global}; |
|---|
| 12 |
my $source = $self->{config}->{source} |
|---|
| 13 |
|| File::Spec->catfile($global->{work_dir}, $context->{project}); |
|---|
| 14 |
my $dest = $self->{config}->{dest} || "$args->{server}:$global->{dest_dir}"; |
|---|
| 15 |
my $user = $self->{config}->{user}; |
|---|
| 16 |
if ( $user ) { |
|---|
| 17 |
$dest = join '@', $user, $dest; |
|---|
| 18 |
delete $self->{config}->{user}; |
|---|
| 19 |
} |
|---|
| 20 |
|
|---|
| 21 |
$source = $self->templatize($source); |
|---|
| 22 |
$dest = $self->templatize($dest); |
|---|
| 23 |
|
|---|
| 24 |
delete $self->{config}->{source}; |
|---|
| 25 |
delete $self->{config}->{dest}; |
|---|
| 26 |
|
|---|
| 27 |
my %defaults = ( |
|---|
| 28 |
archive => 1, |
|---|
| 29 |
update => 1, |
|---|
| 30 |
compress => 1, |
|---|
| 31 |
delete => 1, |
|---|
| 32 |
exclude => [ '.svn/' ], |
|---|
| 33 |
rsh => 'ssh', |
|---|
| 34 |
source => $source, |
|---|
| 35 |
dest => $dest, |
|---|
| 36 |
); |
|---|
| 37 |
|
|---|
| 38 |
my $option = $self->{config} || {}; |
|---|
| 39 |
my $rsync = File::Rsync->new({ |
|---|
| 40 |
%defaults, |
|---|
| 41 |
%$option, |
|---|
| 42 |
}); |
|---|
| 43 |
|
|---|
| 44 |
$rsync->exec; |
|---|
| 45 |
|
|---|
| 46 |
$self->log( debug => $rsync->out ) if $rsync->out; |
|---|
| 47 |
$self->log( debug => $rsync->err ) if $rsync->err; |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
1; |
|---|
| 51 |
__END__ |
|---|
| 52 |
|
|---|
| 53 |
=head1 NAME |
|---|
| 54 |
|
|---|
| 55 |
Archer::Plugin::Rsync - execute rsync. |
|---|
| 56 |
|
|---|
| 57 |
=head1 SYNOPSIS |
|---|
| 58 |
|
|---|
| 59 |
- module: Rsync |
|---|
| 60 |
config: |
|---|
| 61 |
user: mizzy |
|---|
| 62 |
source: "[% work_dir %]/[% project %]" |
|---|
| 63 |
dest: "[% server %]:[% dest_dir %]" |
|---|
| 64 |
archive: 1 |
|---|
| 65 |
compress: 1 |
|---|
| 66 |
rsh: ssh |
|---|
| 67 |
update: 1 |
|---|
| 68 |
delete: 1 |
|---|
| 69 |
exclude: |
|---|
| 70 |
- .svn/ |
|---|
| 71 |
|
|---|
| 72 |
=head1 DESCRIPTION |
|---|
| 73 |
|
|---|
| 74 |
Execute rsync. |
|---|
| 75 |
|
|---|
| 76 |
=head1 CONFIG |
|---|
| 77 |
|
|---|
| 78 |
See L<File::Rsync>. |
|---|
| 79 |
|
|---|
| 80 |
=head1 AUTHORS |
|---|
| 81 |
|
|---|
| 82 |
Gosuke Miyashita |
|---|
| 83 |
|
|---|
| 84 |
=head1 SEE ALSO |
|---|
| 85 |
|
|---|
| 86 |
L<File::Rsync> |
|---|
| 87 |
|
|---|
| 88 |
=cut |
|---|
| 89 |
|
|---|