| 1 | 4 | ▶ | use 5.008; # utf8 | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | package Git::Wrapper::Plus::Util; | ||||||||||
| 7 | 4 | $Git::Wrapper::Plus::Util::VERSION = '0.004010'; | |||||||||
| 8 | # ABSTRACT: Misc plumbing tools for Git::Wrapper::Plus | ||||||||||
| 9 | |||||||||||
| 10 | 4 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||
| 11 | |||||||||||
| 12 | 4 | use Sub::Exporter::Progressive -setup => { | |||||||||
| 13 | exports => [qw( exit_status_handler )], | ||||||||||
| 14 | groups => { | ||||||||||
| 15 | default => [qw( exit_status_handler )], | ||||||||||
| 16 | }, | ||||||||||
| 17 | 4 | ▶ | }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | 4 | ▶ | use Try::Tiny qw( try catch ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 4 | ▶ | use Scalar::Util qw(blessed); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 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 | sub exit_status_handler { | ||||||||||
| 55 | 2 | ▶ | my ( $callback, $status_map ) = @_; | ||||||||
|
Subroutine
exit_status_handler: called CC=2 SCAR=7.3
Pod
documented
| |||||||||||
| 56 | 2 | my $return = 1; | |||||||||
| 57 | try { | ||||||||||
| 58 | 2 | ▶ | $callback->(); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 59 | } | ||||||||||
| 60 | catch { | ||||||||||
| 61 | ## no critic (ErrorHandling::RequireUseOfExceptions) | ||||||||||
| 62 | 1 | ▶ | undef $return; | ||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=20.8
| |||||||||||
| 63 | 1 | ▶ | if ( not ref $_ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 0 | die $_; | |||||||||
| 65 | } | ||||||||||
| 66 | 1 | ▶ | if ( not blessed $_ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 0 | die $_; | |||||||||
| 68 | } | ||||||||||
| 69 | 1 | ▶ | if ( not $_->isa('Git::Wrapper::Exception') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | 0 | die $_; | |||||||||
| 71 | } | ||||||||||
| 72 | 1 | for my $status ( sort keys %{$status_map} ) { | |||||||||
| 73 | 1 | ▶ | if ( $status == $_->status ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | 1 | $return = $status_map->{$status}->($_); | |||||||||
| 75 | 1 | return; | |||||||||
| 76 | } | ||||||||||
| 77 | } | ||||||||||
| 78 | 0 | die $_; | |||||||||
| 79 | 2 | }; | |||||||||
| 80 | 2 | ▶ | return 1 if $return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | 1 | return; | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | 4 | 1; | |||||||||
| 85 | |||||||||||
| 86 | __END__ | ||||||||||