| File: | blib/lib/App/Rgit/Policy.pm |
| Coverage: | 83.9% |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | package App::Rgit::Policy; | ||||||
| 2 | |||||||
| 3 | 3 3 3 | 19776 10 110 | use strict; | ||||
| 4 | 3 3 3 | 21 7 939 | use warnings; | ||||
| 5 | |||||||
| 6 - 14 | =head1 NAME App::Rgit::Policy - Base class for App::Rgit policies. =head1 VERSION Version 0.08 =cut | ||||||
| 15 | |||||||
| 16 | our $VERSION = '0.08'; | ||||||
| 17 | |||||||
| 18 - 31 | =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 | ||||||
| 32 | |||||||
| 33 | sub new { | ||||||
| 34 | 8 | 1 | 434568 | my $class = shift; | |||
| 35 | 8 | 87 | $class = ref $class || $class; | ||||
| 36 | |||||||
| 37 | 8 | 47 | my %args = @_; | ||||
| 38 | |||||||
| 39 | 8 | 42 | if ($class eq __PACKAGE__) { | ||||
| 40 | 4 | 26 | my $policy = delete $args{policy}; | ||||
| 41 | 4 | 17 | $policy = 'Default' unless defined $policy; | ||||
| 42 | 4 | 32 | $policy = __PACKAGE__ . "::$policy" unless $policy =~ /::/; | ||||
| 43 | 4 | 385 | eval "require $policy" or die $@; | ||||
| 44 | 4 | 90 | return $policy->new(%args); | ||||
| 45 | } | ||||||
| 46 | |||||||
| 47 | 4 | 100 | bless { }, $class; | ||||
| 48 | } | ||||||
| 49 | |||||||
| 50 - 56 | =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 | ||||||
| 57 | |||||||
| 58 | sub handle; | ||||||
| 59 | |||||||
| 60 - 87 | =head1 SEE ALSO
L<rgit>.
=head1 AUTHOR
Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
You can contact me by mail or on C<irc.perl.org> (vincent).
=head1 BUGS
Please report any bugs or feature requests to C<bug-rgit at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=rgit>.
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc App::Rgit::Policy
=head1 COPYRIGHT & LICENSE
Copyright 2008,2009,2010 Vincent Pit, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
=cut | ||||||
| 88 | |||||||
| 89 | 1; # End of App::Rgit::Policy | ||||||