| 1 | 3 | ▶ | use 5.006; # our | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | package Dist::Zilla::Plugin::if::ENV; | ||||||||||
| 6 | |||||||||||
| 7 | 3 | our $VERSION = '0.001001'; | |||||||||
| 8 | |||||||||||
| 9 | # ABSTRACT: Load a plugin when an ENV key is true. | ||||||||||
| 10 | |||||||||||
| 11 | 3 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||
| 12 | |||||||||||
| 13 | 3 | ▶ | use Moose qw( has around with ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 3 | ▶ | use Dist::Zilla::Util qw(); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 3 | with 'Dist::Zilla::Role::PluginLoader::Configurable'; | |||||||||
| 16 | |||||||||||
| 17 | 3 | has key => ( is => ro =>, required => 1 ); | |||||||||
| 18 | |||||||||||
| 19 | 2 | ▶ | around dump_config => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||
| 20 | 2 | my ( $orig, $self, @args ) = @_; | |||||||||
| 21 | 2 | my $config = $self->$orig(@args); | |||||||||
| 22 | 2 | my $localconf = $config->{ +__PACKAGE__ } = {}; | |||||||||
| 23 | |||||||||||
| 24 | 2 | $localconf->{key} = $self->key; | |||||||||
| 25 | |||||||||||
| 26 | 2 | ▶ | $localconf->{ q[$] . __PACKAGE__ . '::VERSION' } = $VERSION | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | unless __PACKAGE__ eq ref $self; | ||||||||||
| 28 | |||||||||||
| 29 | 2 | return $config; | |||||||||
| 30 | 3 | }; | |||||||||
| 31 | |||||||||||
| 32 | 2 | ▶ | around load_plugins => sub { | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||
| 33 | 2 | my ( $orig, $self, $loader ) = @_; | |||||||||
| 34 | 2 | my $key = $self->key; | |||||||||
| 35 | 2 | ▶ | return unless exists $ENV{$key}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 2 | ▶ | return unless $ENV{$key}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 1 | return $self->$orig($loader); | |||||||||
| 38 | 3 | }; | |||||||||
| 39 | |||||||||||
| 40 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||
| 41 | 3 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 42 | |||||||||||
| 43 | 3 | 1; | |||||||||
| 44 | |||||||||||
| 45 | __END__ | ||||||||||