line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
4330154
|
use 5.006; # our |
|
3
|
|
|
|
|
9
|
|
2
|
3
|
|
|
3
|
|
10
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
72
|
|
3
|
3
|
|
|
3
|
|
19
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
262
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::if::ENV; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.001001'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Load a plugin when an ENV key is true. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
473
|
use Moose qw( has around with ); |
|
3
|
|
|
|
|
319736
|
|
|
3
|
|
|
|
|
32
|
|
14
|
3
|
|
|
3
|
|
13400
|
use Dist::Zilla::Util qw(); |
|
3
|
|
|
|
|
9876
|
|
|
3
|
|
|
|
|
576
|
|
15
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::PluginLoader::Configurable'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has key => ( is => ro =>, required => 1 ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
around dump_config => sub { |
20
|
|
|
|
|
|
|
my ( $orig, $self, @args ) = @_; |
21
|
|
|
|
|
|
|
my $config = $self->$orig(@args); |
22
|
|
|
|
|
|
|
my $localconf = $config->{ +__PACKAGE__ } = {}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$localconf->{key} = $self->key; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$localconf->{ q[$] . __PACKAGE__ . '::VERSION' } = $VERSION |
27
|
|
|
|
|
|
|
unless __PACKAGE__ eq ref $self; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
return $config; |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
around load_plugins => sub { |
33
|
|
|
|
|
|
|
my ( $orig, $self, $loader ) = @_; |
34
|
|
|
|
|
|
|
my $key = $self->key; |
35
|
|
|
|
|
|
|
return unless exists $ENV{$key}; |
36
|
|
|
|
|
|
|
return unless $ENV{$key}; |
37
|
|
|
|
|
|
|
return $self->$orig($loader); |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
41
|
3
|
|
|
3
|
|
16
|
no Moose; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
15
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=pod |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=encoding UTF-8 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Dist::Zilla::Plugin::if::ENV - Load a plugin when an ENV key is true. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 VERSION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
version 0.001001 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 SYNOPSIS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
[if::ENV] |
62
|
|
|
|
|
|
|
key = UBERTESTING |
63
|
|
|
|
|
|
|
dz_plugin = Some::Plugin |
64
|
|
|
|
|
|
|
dz_plugin_name = UBERTEST/Some::Plugin |
65
|
|
|
|
|
|
|
>= some_plugin_argument = itsvalue |
66
|
|
|
|
|
|
|
>= some_plugin_argument = itsvalue |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Then |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
dzil build # Some::Plugin not loaded, but declared as a develop dep anyway |
71
|
|
|
|
|
|
|
UBERTESTING=1 dzil build # Some::Plugin loaded! |
72
|
|
|
|
|
|
|
UBERTESTING=0 dzil build # Some::Plugin NOT loaded |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 SEE ALSO |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=over 4 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item * C<[if]> - L<< Dist::Zilla::Plugin::if|Dist::Zilla::Plugin::if >> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item * C<[if::not]> - L<< Dist::Zilla::Plugin::if::not|Dist::Zilla::Plugin::if::not >> |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * C<[if::not::ENV]> - L<< Dist::Zilla::Plugin::if::not::ENV|Dist::Zilla::Plugin::if::not::ENV >> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * C<PluginLoader::Configurable role> - L<< |
85
|
|
|
|
|
|
|
Dist::Zilla::Role::PluginLoader::Configurable|Dist::Zilla::Role::PluginLoader::Configurable |
86
|
|
|
|
|
|
|
>> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * C<PluginLoader role> - L<< Dist::Zilla::Role::PluginLoader|Dist::Zilla::Role::PluginLoader >> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * C<PluginLoader util> - L<< Dist::Zilla::Util::PluginLoader|Dist::Zilla::Util::PluginLoader >> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=back |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 AUTHOR |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
103
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |