blib/lib/Git/PurePerl/Walker/OnCommit/List.pm untested

filter: Statementstmt 0.0% 0 / 59 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 74 CC 1 SCAR 6.9
CC
1
Cov
0%
handle
2.0
reset
2.0
BEGIN
2.0
CRAP 2.0
1 use 5.008; # utf8
2 use strict;
3 use warnings;
4 use utf8;
5  
6 package Git::PurePerl::Walker::OnCommit::List;
7  
8 our $VERSION = '0.004000';
9  
10 # ABSTRACT: Execute an ordered list of OnCommit events.
11  
12 our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13  
14 use Moose qw( with has around );
15 use MooseX::Types::Moose qw( ArrayRef );
16 use Git::PurePerl::Walker::Types qw( GPPW_OnCommit );
17 use namespace::autoclean;
18  
19  
20  
21  
22  
23  
24  
25 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 default => sub { [] },
64 );
65  
66  
67  
68  
69  
70  
71  
72 sub handle {
73 my ( $self, $commit ) = @_;
74 for my $child ( $self->all_events ) {
75 $child->handle($commit);
76 }
77 return $self;
78 }
79  
80  
81  
82  
83  
84  
85  
86 ## no critic ( Subroutines::ProhibitBuiltinHomonyms )
87 sub reset {
88 my ( $self, ) = @_;
89 for my $child ( $self->events ) {
90 $child->reset();
91 }
92 return $self;
93 }
94 ## use critic
95  
96 around add_event => sub {
97 my ( $orig, $self, @args ) = @_;
98 if ( not $self->_repo ) {
99 return $orig->( $self, @args );
100 }
101 my (@new) = map { $_->for_repository( $self->_repo ) } @args;
102 return $orig->( $self, @new );
103  
104 };
105 around for_repository => sub {
106 my ( $orig, $self, @args ) = @_;
107 my $new = $self->$orig(@args);
108 $new->events( [ map { $_->for_repository( $args[0] ) } $self->all_events ] );
109 return $new;
110 };
111  
112 no Moose;
113 __PACKAGE__->meta->make_immutable;
114 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