| 1 | package Dist::Zilla::Role::PluginBundle::Airplane; | ||||||||||||||||||||||||
| 2 | 2 | our $VERSION = '0.002'; | |||||||||||||||||||||||
| 3 | 2 | ▶ | use Moose::Role; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||
| 5 | # ABSTRACT: A role for building packages with Dist::Zilla in an airplane | ||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||
| 7 | 2 | ▶ | use Dist::Zilla::Util; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||
| 9 | 2 | requires 'build_network_plugins'; | |||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||
| 11 | 2 | has airplane => ( | |||||||||||||||||||||||
| 12 | is => 'ro', | ||||||||||||||||||||||||
| 13 | isa => 'Bool', | ||||||||||||||||||||||||
| 14 | init_arg => undef, | ||||||||||||||||||||||||
| 15 | lazy => 1, | ||||||||||||||||||||||||
| 16 | builder => '_build_airplane_mode', | ||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||
| 19 | 2 | has network_plugins => ( | |||||||||||||||||||||||
| 20 | is => 'ro', | ||||||||||||||||||||||||
| 21 | isa => 'ArrayRef', | ||||||||||||||||||||||||
| 22 | init_arg => undef, | ||||||||||||||||||||||||
| 23 | lazy => 1, | ||||||||||||||||||||||||
| 24 | builder => 'build_network_plugins', | ||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||
| 27 | 5 | ▶ | sub _build_airplane_mode { | ||||||||||||||||||||||
|
Subroutine
_build_airplane_mode: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||
| 28 | 5 | ▶ | return $ENV{DZIL_AIRPLANE} // $_[0]->payload->{airplane} // 0; | ||||||||||||||||||||||
|
Condition80%4/5
($ENV{"DZIL_AIRPLANE"} // $_[0]->payload->{"airplane"}) // 0
$ENV{"DZIL_AIRPLANE"} // $_[0]->payload->{"airplane"}
MC/DC50%1/2
($ENV{"DZIL_AIRPLANE"} // $_[0]->payload->{"airplane"}) // 0
$ENV{"DZIL_AIRPLANE"}
$_[0]->payload->{"airplane"}
Truth table66%2/3
A // B
A= $ENV{"DZIL_AIRPLANE"}B= $_[0]->payload->{"airplane"}
| |||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||
| 31 | 3 | ▶ | sub _get_network_plugins { | ||||||||||||||||||||||
|
Subroutine
_get_network_plugins: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||
| 32 | 3 | my ($self) = @_; | |||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||
| 34 | 3 | my %network_plugins; | |||||||||||||||||||||||
| 35 | 3 | for (@{$self->network_plugins}) { | |||||||||||||||||||||||
| 36 | 3 | $network_plugins{$self->_plugin_to_name($_)} = 1; | |||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||
| 38 | 3 | return \%network_plugins; | |||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||
| 41 | 5 | ▶ | sub _plugin_to_name { | ||||||||||||||||||||||
|
Subroutine
_plugin_to_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 42 | 5 | my ($self, $plugin) = @_; | |||||||||||||||||||||||
| 43 | 5 | return Dist::Zilla::Util->expand_config_package_name($plugin); | |||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||
| 46 | 5 | ▶ | around add_plugins => sub { | ||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||
| 47 | 5 | my $orig = shift; | |||||||||||||||||||||||
| 48 | 5 | my $self = shift; | |||||||||||||||||||||||
| 49 | 5 | my @plugins = @_; | |||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||
| 52 | 5 | ▶ | if ($self->airplane) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 53 | 3 | my $plugins = $self->_get_network_plugins(); | |||||||||||||||||||||||
| 54 | @plugins = grep { | ||||||||||||||||||||||||
| 55 | 3 | not exists $plugins->{ | |||||||||||||||||||||||
| 56 | 3 | ▶ | $self->_plugin_to_name( | ||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||
| 57 | !ref $_ ? $_ : ref eq 'ARRAY' ? $_->[0] : die "unable") | ||||||||||||||||||||||||
| 58 | }; | ||||||||||||||||||||||||
| 59 | } @plugins; | ||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||
| 62 | # halt release after pre-release checks, but before ConfirmRelease | ||||||||||||||||||||||||
| 63 | 2 | push @plugins, 'BlockRelease'; | |||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||
| 66 | 4 | $orig->($self, @plugins); | |||||||||||||||||||||||
| 67 | 2 | }; | |||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||
| 69 | 2 | 1; | |||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||
| 71 | __END__ | ||||||||||||||||||||||||