« blib/lib/Git/PurePerl/Walker/OnCommit/List.pm
↑ Summary
blib/lib/Git/PurePerl/Walker/Method/FirstParent.pm »
| 1 | 2 | ▶ | use 5.008; # utf8 | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | package Git::PurePerl::Walker::OnCommit::List; | ||||||||||
| 7 | |||||||||||
| 8 | 2 | our $VERSION = '0.004000'; | |||||||||
| 9 | |||||||||||
| 10 | # ABSTRACT: Execute an ordered list of OnCommit events. | ||||||||||
| 11 | |||||||||||
| 12 | 2 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||
| 13 | |||||||||||
| 14 | 2 | ▶ | use Moose qw( with has around ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 2 | ▶ | use MooseX::Types::Moose qw( ArrayRef ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 2 | ▶ | use Git::PurePerl::Walker::Types qw( GPPW_OnCommit ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 2 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | 2 | with qw( Git::PurePerl::Walker::Role::OnCommit ); | |||||||||
| 26 | |||||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | |||||||||||
| 31 | |||||||||||
| 32 | |||||||||||
| 33 | |||||||||||
| 34 | |||||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | |||||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | |||||||||||
| 42 | |||||||||||
| 43 | |||||||||||
| 44 | |||||||||||
| 45 | |||||||||||
| 46 | |||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | |||||||||||
| 50 | |||||||||||
| 51 | |||||||||||
| 52 | |||||||||||
| 53 | |||||||||||
| 54 | |||||||||||
| 55 | has 'events' => ( | ||||||||||
| 56 | isa => ArrayRef [GPPW_OnCommit], | ||||||||||
| 57 | is => 'rw', | ||||||||||
| 58 | handles => { | ||||||||||
| 59 | all_events => 'elements', | ||||||||||
| 60 | add_event => 'push', | ||||||||||
| 61 | }, | ||||||||||
| 62 | traits => [qw( Array )], | ||||||||||
| 63 | 1 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 64 | 2 | ); | |||||||||
| 65 | |||||||||||
| 66 | |||||||||||
| 67 | |||||||||||
| 68 | |||||||||||
| 69 | |||||||||||
| 70 | |||||||||||
| 71 | |||||||||||
| 72 | sub handle { | ||||||||||
| 73 | 1 | ▶ | my ( $self, $commit ) = @_; | ||||||||
|
Subroutine
handle: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 74 | 1 | for my $child ( $self->all_events ) { | |||||||||
| 75 | 2 | $child->handle($commit); | |||||||||
| 76 | } | ||||||||||
| 77 | 1 | return $self; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | |||||||||||
| 83 | |||||||||||
| 84 | |||||||||||
| 85 | |||||||||||
| 86 | ## no critic ( Subroutines::ProhibitBuiltinHomonyms ) | ||||||||||
| 87 | sub reset { | ||||||||||
| 88 | 0 | ▶ | my ( $self, ) = @_; | ||||||||
|
Subroutine
reset: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 89 | 0 | for my $child ( $self->events ) { | |||||||||
| 90 | 0 | $child->reset(); | |||||||||
| 91 | } | ||||||||||
| 92 | 0 | return $self; | |||||||||
| 93 | } | ||||||||||
| 94 | ## use critic | ||||||||||
| 95 | |||||||||||
| 96 | around add_event => sub { | ||||||||||
| 97 | 3 | ▶ | my ( $orig, $self, @args ) = @_; | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 98 | 3 | ▶ | if ( not $self->_repo ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 99 | 2 | return $orig->( $self, @args ); | |||||||||
| 100 | } | ||||||||||
| 101 | 1 | my (@new) = map { $_->for_repository( $self->_repo ) } @args; | |||||||||
| 102 | 1 | return $orig->( $self, @new ); | |||||||||
| 103 | |||||||||||
| 104 | 2 | }; | |||||||||
| 105 | around for_repository => sub { | ||||||||||
| 106 | 1 | ▶ | my ( $orig, $self, @args ) = @_; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 107 | 1 | my $new = $self->$orig(@args); | |||||||||
| 108 | 1 | $new->events( [ map { $_->for_repository( $args[0] ) } $self->all_events ] ); | |||||||||
| 109 | 1 | return $new; | |||||||||
| 110 | 2 | }; | |||||||||
| 111 | |||||||||||
| 112 | 2 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 113 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||
| 114 | 2 | 1; | |||||||||
| 115 | |||||||||||
| 116 | __END__ | ||||||||||
| 117 | |||||||||||
| 118 | =pod | ||||||||||
| 119 | |||||||||||
| 120 | =encoding UTF-8 | ||||||||||
| 121 | |||||||||||
| 122 | =head1 NAME | ||||||||||
| 123 | |||||||||||
| 124 | Git::PurePerl::Walker::OnCommit::List - Execute an ordered list of OnCommit events. | ||||||||||
| 125 | |||||||||||
| 126 | =head1 VERSION | ||||||||||
| 127 | |||||||||||
| 128 | version 0.004000 | ||||||||||
| 129 | |||||||||||
| 130 | =head1 CONSTRUCTOR ARGUMENTS | ||||||||||
| 131 | |||||||||||
| 132 | =head2 events | ||||||||||
| 133 | |||||||||||
| 134 | =head1 ATTRIBUTES | ||||||||||
| 135 | |||||||||||
| 136 | =head2 events | ||||||||||
| 137 | |||||||||||
| 138 | =head1 ATTRIBUTE GENERATED METHODS | ||||||||||
| 139 | |||||||||||
| 140 | =head2 all_events | ||||||||||
| 141 | |||||||||||
| 142 | =head2 add_event | ||||||||||
| 143 | |||||||||||
| 144 | =head1 INHERITED METHODS | ||||||||||
| 145 | |||||||||||
| 146 | =head2 for_repository | ||||||||||
| 147 | |||||||||||
| 148 | L<< C<Git::PurePerl::B<Walker::Role::HasRepo>-E<gt>I<for_repository( $repo )>>|Git::PurePerl::Walker::Role::HasRepo/for_repository >> | ||||||||||
| 149 | |||||||||||
| 150 | =head2 clone | ||||||||||
| 151 | |||||||||||
| 152 | L<< C<MooseX::B<Clone>-E<gt>I<clone( %params )>>|MooseX::Clone/clone-params >> | ||||||||||
| 153 | |||||||||||
| 154 | =head2 _repo | ||||||||||
| 155 | |||||||||||
| 156 | L<< C<Git::PurePerl::B<Walker::Role::HasRepo>-E<gt>I<_repo( $repo )>>|Git::PurePerl::Walker::Role::HasRepo/_repo >> | ||||||||||
| 157 | |||||||||||
| 158 | =head1 CONSUMED ROLES | ||||||||||
| 159 | |||||||||||
| 160 | =head2 Git::PurePerl::Walker::Role::OnCommit | ||||||||||
| 161 | |||||||||||
| 162 | L<< C<Git::PurePerl::B<Walker::Role::OnCommit>>|Git::PurePerl::Walker::Role::OnCommit >> | ||||||||||
| 163 | |||||||||||
| 164 | =head1 ROLE SATISFYING METHODS | ||||||||||
| 165 | |||||||||||
| 166 | =head2 handle | ||||||||||
| 167 | |||||||||||
| 168 | L<< C<Git::PurePerl::B<Walker::Role::OnCommit>-E<gt>I<handle( $commit )>>|Git::PurePerl::Walker::Role::OnCommit/handle >> | ||||||||||
| 169 | |||||||||||
| 170 | =head2 reset | ||||||||||
| 171 | |||||||||||
| 172 | L<< C<Git::PurePerl::B<Walker::Role::OnCommit>-E<gt>I<reset()>>|Git::PurePerl::Walker::Role::OnCommit/reset >> | ||||||||||
| 173 | |||||||||||
| 174 | =head1 AUTHOR | ||||||||||
| 175 | |||||||||||
| 176 | Kent Fredric <kentnl@cpan.org> | ||||||||||
| 177 | |||||||||||
| 178 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 179 | |||||||||||
| 180 | This software is copyright (c) 2014 by Kent Fredric <kentnl@cpan.org>. | ||||||||||
| 181 | |||||||||||
| 182 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 183 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 184 | |||||||||||
| 185 | =cut | ||||||||||