Also rename some App::Rgit::Policy features and expand POD.
} elsif ($opts{K}) {
$policy = 'Keep';
}
-$policy = eval { App::Rgit::Policy->new(name => $policy) };
+$policy = eval { App::Rgit::Policy->new(policy => $policy) };
if (not defined $policy) {
print STDERR $@ if $@;
- $policy = App::Rgit::Policy->new(name => 'Default');
+ $policy = App::Rgit::Policy->new(policy => 'Default');
}
setpgrp 0, 0 if $Config{d_setpgrp};
sub report {
my ($self) = @_;
- my $code = $self->policy->report(@_);
+ my $code = $self->policy->handle(@_);
return defined $code ? $code : NEXT;
}
L<rgit>.
+L<App::Rgit::Command>.
+
=head1 AUTHOR
Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
L<rgit>.
+L<App::Rgit::Command>.
+
=head1 AUTHOR
Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
L<rgit>.
+L<App::Rgit::Config>.
+
=head1 AUTHOR
Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
our $VERSION = '0.06';
+=head1 DESCRIPTION
+
+Base class for L<App::Rgit> policies.
+
+This is an internal class to L<rgit>.
+
+=head1 METHODS
+
+=head2 C<< new policy => $policy >>
+
+Creates a new policy object of type C<$policy> by requiring and redispatching the method call to the module named C<$policy> if it contains C<'::'> or to C<App::Rgit::Policy::$policy> otherwise.
+The class represented by C<$policy> must inherit this class.
+
+=cut
+
sub new {
my $class = shift;
$class = ref $class || $class;
my %args = @_;
if ($class eq __PACKAGE__) {
- my $policy = delete $args{name};
+ my $policy = delete $args{policy};
$policy = 'Default' unless defined $policy;
$policy = __PACKAGE__ . "::$policy" unless $policy =~ /::/;
eval "require $policy" or die $@;
bless { }, $class;
}
+=head2 C<handle $cmd, $config, $repo, $status, $signal>
+
+Make the policy handle the end of execution of the L<App::Rgit::Command> object C<$cmd> with L<App::Rgit::Config> configuration C<$config> in the L<App::Rgit::Repository> repository C<$repo> that exited with status C<$status> and maybe received signal C<$sigal>.
+
+This method must be implemented when subclassing.
+
+=cut
+
+sub handle;
+
=head1 SEE ALSO
L<rgit>.
our $VERSION = '0.06';
-sub report {
+=head1 DESCRIPTION
+
+This is the default policy.
+It stops as soon as a run returned a non-zero status, but continues if it was signalled.
+
+=head1 METHODS
+
+This class inherits from L<App::Rgit::Policy>.
+
+It implements :
+
+=head2 C<handle>
+
+=cut
+
+sub handle {
my ($policy, $cmd, $conf, $repo, $status, $signal) = @_;
$status ? LAST : NEXT;
L<rgit>.
+L<App::Rgit::Policy>.
+
=head1 AUTHOR
Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
our $VERSION = '0.06';
+=head1 DESCRIPTION
+
+When a run exited with non-zero status, this policy asks the user whether he wants to ignore and continue with the next repository, ignore all future possible errors, retry this run or open a shell in the current repository.
+In this last case, the user will be asked again what to do when he will close the shell.
+
+=head1 METHODS
+
+This class inherits from L<App::Rgit::Policy>.
+
+It implements :
+
+=head2 C<new>
+
+The constructor will die if L<Term::ReadKey> can't be loaded.
+
+=cut
+
my ($int_code, $shell);
sub new {
$class->SUPER::new(@_);
}
+=head2 C<handle>
+
+=cut
+
my %codes = (
'a' => [ LAST, 'aborting' ],
'i' => [ NEXT, 'ignoring' ],
'r' => [ REDO, 'retrying' ],
);
-sub report {
+sub handle {
my ($policy, $cmd, $conf, $repo, $status, $signal) = @_;
return NEXT unless $status;
L<rgit>.
+L<App::Rgit::Policy>.
+
+L<Term::ReadKey>.
+
=head1 AUTHOR
Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
our $VERSION = '0.06';
-sub report { NEXT }
+=head1 DESCRIPTION
+
+This policy always proceed to the next repository even when an error occurs.
+
+=head1 METHODS
+
+This class inherits from L<App::Rgit::Policy>.
+
+It implements :
+
+=head2 C<handle>
+
+=cut
+
+sub handle { NEXT }
=head1 SEE ALSO
L<rgit>.
+L<App::Rgit::Policy>.
+
=head1 AUTHOR
Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
my ($fh, $filename) = tempfile(UNLINK => 1);
my $policy = App::Rgit::Policy->new(
- @_ > 2 ? (name => 'Callback', callback => $_[2])
- : (name => 'Default')
+ @_ > 2 ? (policy => 'Callback', callback => $_[2])
+ : (policy => 'Default')
);
my $ar = App::Rgit->new(
eval "use Pod::Coverage $min_pc";
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@;
-all_pod_coverage_ok();
+my $trustparents = { coverage_class => 'Pod::Coverage::CountParents' };
+
+plan tests => 12;
+
+pod_coverage_ok('App::Rgit');
+
+pod_coverage_ok('App::Rgit::Command');
+pod_coverage_ok('App::Rgit::Command::Each', $trustparents);
+pod_coverage_ok('App::Rgit::Command::Once', $trustparents);
+
+pod_coverage_ok('App::Rgit::Config');
+pod_coverage_ok('App::Rgit::Config::Default', $trustparents);
+
+pod_coverage_ok('App::Rgit::Policy');
+pod_coverage_ok('App::Rgit::Policy::Default', $trustparents);
+pod_coverage_ok('App::Rgit::Policy::Interactive', $trustparents);
+pod_coverage_ok('App::Rgit::Policy::Keep', $trustparents);
+
+pod_coverage_ok('App::Rgit::Repository');
+
+pod_coverage_ok('App::Rgit::Utils');
eval "sub $_ { \$_[0]->{$_} }" for qw/callback/;
}
-sub report {
+sub handle {
my $policy = shift;
$policy->callback->(@_);