Multigit/Future.pm

filter: Statementstmt 57.8% 11 / 19 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 100% 1 / 1 totaltotal 55.5% 15 / 27 CC 2 SCAR 10.4
CC
2
Cov
52%
__ANON__
6.0
finally
2.0
BEGIN
1.0
CRAP 2.8
« Multigit/Repo.pm ↑ Summary Multigit/Script.pm »
1 package App::Multigit::Future;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use base qw( IO::Async::Future );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $VERSION = '0.18';
9  
10 =head1 NAME
11  
12 App::Multigit::Future - Futures for App::Multigit
13  
14 =head1 DESCRIPTION
15  
16 Extensio of IO::Async::Future with a few extra methods.
17  
18 =head1 METHODS
19  
20 =head2 finally
21  
22 Like C<followed_by>, but unpacks the Future and calls C<done> on the result.
23  
24 As documented in L<run|App::Multigit::Repo/"run($command, [%data])">, all
25 operations complete with the same data structure. This is also true when a
26 command fails to run.
27  
28 This is therefore a convenience method that runs the subref with the C<%data>
29 structure, irrespective of whether the preceding steps caused a failure or not.
30  
31 my $final_f = mg_each(sub {
32 my $repo = shift;
33 $repo->run([qw/ git command that might fail /])
34 ->finally($repo->curry::report);
35 });
36  
37 =cut
38  
39 0 ▶sub finally {
Subroutine finally: not called CC=1 SCAR=6.9
Pod documented
40 0 my ($self, $code) = @_;
41  
42 0 ▶ $self->followed_by( sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
43 0 my $f = shift;
44 0 my @result;
45  
46  
47 0 ▶ if (@result = $f->failure) {
Branch: 1 branch
BranchTrueFalseTotal
if (@result = $f->failure) { } 0 0 0
48 0 @result = @result[2 .. $#result];
49 }
50 else {
51 0 @result = $f->get;
52 }
53  
54 0 (ref $f)->done(@result);
55 })
56 0 ->then($code);
57 }
58  
59 2 1;
« Multigit/Repo.pm ↑ Summary Multigit/Script.pm »