blib/lib/Dist/Zilla/App.pm

filter: Statementstmt 54.4% 43 / 79 Branchbran 37.5% 9 / 24 Conditioncond 22.2% 2 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 62.5% 10 / 16 Podpod 66.6% 2 / 3 totaltotal 48.1% 66 / 137 CC 18 SCAR 23.0
CC
18
Cov
48%
__ANON__
20.0
zilla
19.3
__ANON__
12.0
CRAP 9.9
« blib/lib/Dist/Zilla/App/Command/smoke.pm ↑ Summary blib/lib/Dist/Zilla/PluginBundle/Filter.pm »
1 package Dist::Zilla::App 6.040;
2 # ABSTRACT: Dist::Zilla's App::Cmd
3  
4 4 ▶use Dist::Zilla::Pragmas;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use App::Cmd::Setup 0.330 -app; # better compilation error detection
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 4 $Carp::Internal{'Module::Runtime'} = 1;
14  
15 20 ▶sub global_opt_spec {
Subroutine global_opt_spec: called CC=1 SCAR=1.2
Pod documented
16 20 my ($self) = @_;
17  
18 return (
19 [ "verbose|v", "log additional output" ],
20 [ "verbose-plugin|V=s@", "log additional output from some plugins only" ],
21 [ "lib-inc|I=s@", "additional \@INC dirs", {
22 0 ▶ callbacks => { 'always fine' => sub { unshift @INC, @{$_[0]}; } }
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 20 } ],
24 $self->SUPER::global_opt_spec,
25 );
26 }
27  
28 21 ▶sub _build_global_stashes {
Subroutine _build_global_stashes: called CC=3 SCAR=21.5
29 21 my ($self) = @_;
30  
31 21 ▶ return $self->{__global_stashes__} if $self->{__global_stashes__};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"__global_stashes__"} 0 21 21
32  
33 # tests shouldn't depend on the user's configuration
34 21 ▶ return {} if $ENV{DZIL_TESTING};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DZIL_TESTING"} 21 0 21
35  
36 0 my $stash_registry = $self->{__global_stashes__} = {};
37  
38 0 require Dist::Zilla::Util;
39 0 my $config_dir = Dist::Zilla::Util->_global_config_root;
40  
41 0 my $config_base = $config_dir->child('config');
42  
43 0 require Dist::Zilla::MVP::Reader::Finder;
44 0 require Dist::Zilla::MVP::Assembler::GlobalConfig;
45 0 require Dist::Zilla::MVP::Section;
46 0 my $assembler = Dist::Zilla::MVP::Assembler::GlobalConfig->new({
47 chrome => $self->chrome,
48 stash_registry => $stash_registry,
49 section_class => 'Dist::Zilla::MVP::Section', # make this DZMA default
50 });
51  
52 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 my $reader = Dist::Zilla::MVP::Reader::Finder->new({
54 0 ▶ if_none => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
55 # warn <<'END_WARN';
56 # WARNING: No global configuration file was found in ~/.dzil -- this limits the
57 # ability of Dist::Zilla to perform some tasks. You can run "dzil setup" to
58 # create a simple first-pass configuration file, or you can touch the file
59 # ~/.dzil/config.ini to suppress this message in the future.
60 # END_WARN
61 return $_[2]->{assembler}->sequence
62 0 },
63 0 });
64  
65 0 my $seq = $reader->read_config($config_base, { assembler => $assembler });
66 0 ▶ } catch {
Subroutine __ANON__: not called CC=4 SCAR=30.0
67 0 my $e = $_;
68 0 ▶ if (eval { $e->isa('Config::MVP::Error') and $e->ident eq 'package not installed' }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $e->isa('Config::MVP::Error') and $e->ident eq 'package not installed' } }) { } 0 0 0
Condition0%0/3
$e->isa('Config::MVP::Error') && $e->ident eq 'package not installed'
!ll&&!rl&&r
000
MC/DC0%0/2
$e->isa('Config::MVP::Error') && $e->ident eq 'package not installed'
$e->isa('Config::MVP::Error') $e->ident eq 'package not installed'
Truth table0%0/3
A && B
A= $e->isa('Config::MVP::Error')B= $e->ident eq 'package not installed'
ABresult
0X0
100
111
69 0 my $package = $e->package;
70  
71 0 ▶ my $bundle = $package =~ /^@/ ? ' bundle' : '';
Branch: 1 branch
BranchTrueFalseTotal
$package =~ /^@/u ? : 0 0 0
72 0 die <<"END_DIE";
73 Required plugin$bundle $package isn't installed. Remedy with:
74  
75 cpanm $package
76  
77 END_DIE
78 }
79 else {
80 0 die <<'END_DIE';
81  
82 Your global configuration file couldn't be loaded. It's a file matching
83 ~/.dzil/config.*
84  
85 You can try deleting the file or you might need to upgrade from pre-version 4
86 format. In most cases, this will just mean replacing [!release] with [%PAUSE]
87 and deleting any [!new] stanza. You can also delete the existing file and run
88 "dzil setup"
89 END_DIE
90 }
91 0 };
92  
93 0 return $stash_registry;
94 }
95  
96 #pod =method zilla
97 #pod
98 #pod This returns the Dist::Zilla object in use by the command. If none has yet
99 #pod been constructed, one will be by calling C<< Dist::Zilla->from_config >>.
100 #pod
101 #pod =cut
102  
103 59 ▶sub chrome {
Subroutine chrome: called CC=4 SCAR=14.5
Pod undocumented
104 59 my ($self) = @_;
105 59 require Dist::Zilla::Chrome::Term;
106  
107 59 ▶ return $self->{__chrome__} if $self->{__chrome__};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"__chrome__"} 39 20 59
108  
109 20 $self->{__chrome__} = Dist::Zilla::Chrome::Term->new;
110  
111 my @v_plugins = $self->global_options->verbose_plugin
112 0 ▶ ? grep { length } @{ $self->global_options->verbose_plugin }
Branch: 1 branch
BranchTrueFalseTotal
$self->global_options->verbose_plugin ? : 0 20 20
113 : ();
114  
115 20 my $verbose = $self->global_options->verbose;
116  
117 20 ▶ $self->{__chrome__}->logger->set_debug($verbose ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$verbose ? : 0 20 20
118  
119 20 return $self->{__chrome__};
120 }
121  
122 23 ▶sub zilla {
Subroutine zilla: called CC=8 SCAR=29.6
Pod documented
123 23 my ($self) = @_;
124  
125 23 require Dist::Zilla::Dist::Builder;
126  
127 23 ▶ return $self->{'' . __PACKAGE__}{zilla} ||= do {
Condition66%2/3
$self->{"Dist::Zilla::App"}{"zilla"} ||= do { my(@v_plugins) = $self->global_options->verbose_plugin ? grep({length $_;} @{$self->global_options->verbose_plugin;}) : (); my $verbose = $self->global_options->verbose; $self->chrome->logger->set_debug($verbose ? 1 : 0); my $core_debug = grep({/\A[-_]\z/u;} @v_plugins); my $zilla; &try(sub { $zilla = "Dist::Zilla::Dist::Builder"->from_config({"chrome", $self->chrome, "_global_stashes", $self->_build_global_stashes}); } , &catch(sub { die $_ unless &try(sub { $_->isa("Config::MVP::Error"); } ) and $_->ident =~ /no viable config/u; $self->chrome->logger->log_fatal("no configuration (e.g, dist.ini) found"); } )); $zilla->logger->set_debug($verbose ? 1 : 0); VERBOSE_PLUGIN: foreach my $plugin_name (grep {not /\A[-_]\z/u;} @v_plugins) { my(@plugins) = grep({$_->plugin_name =~ /\b\Q$plugin_name\E\b/u;} @{$zilla->plugins;}); $zilla->log_fatal("can't find plugins matching $plugin_name to set debug") unless @plugins; $_->logger->set_debug(1) foreach (@plugins); } ; $zilla }
l!l&&r!l&&!r
3200
MC/DC0%0/2
$self->{"Dist::Zilla::App"}{"zilla"} ||= do { my(@v_plugins) = $self->global_options->verbose_plugin ? grep({length $_;} @{$self->global_options->verbose_plugin;}) : (); my $verbose = $self->global_options->verbose; $self->chrome->logger->set_debug($verbose ? 1 : 0); my $core_debug = grep({/\A[-_]\z/u;} @v_plugins); my $zilla; &try(sub { $zilla = "Dist::Zilla::Dist::Builder"->from_config({"chrome", $self->chrome, "_global_stashes", $self->_build_global_stashes}); } , &catch(sub { die $_ unless &try(sub { $_->isa("Config::MVP::Error"); } ) and $_->ident =~ /no viable config/u; $self->chrome->logger->log_fatal("no configuration (e.g, dist.ini) found"); } )); $zilla->logger->set_debug($verbose ? 1 : 0); VERBOSE_PLUGIN: foreach my $plugin_name (grep {not /\A[-_]\z/u;} @v_plugins) { my(@plugins) = grep({$_->plugin_name =~ /\b\Q$plugin_name\E\b/u;} @{$zilla->plugins;}); $zilla->log_fatal("can't find plugins matching $plugin_name to set debug") unless @plugins; $_->logger->set_debug(1) foreach (@plugins); } ; $zilla }
$self->{"Dist::Zilla::App"}{"zilla"} do { my(@v_plugins) = $self->global_options->verbose_plugin ? grep({length $_;} @{$self->global_options->verbose_plugin;}) : (); my $verbose = $self->global_options->verbose; $self->chrome->logger->set_debug($verbose ? 1 : 0); my $core_debug = grep({/\A[-_]\z/u;} @v_plugins); my $zilla; &try(sub { $zilla = "Dist::Zilla::Dist::Builder"->from_config({"chrome", $self->chrome, "_global_stashes", $self->_build_global_stashes}); } , &catch(sub { die $_ unless &try(sub { $_->isa("Config::MVP::Error"); } ) and $_->ident =~ /no viable config/u; $self->chrome->logger->log_fatal("no configuration (e.g, dist.ini) found"); } )); $zilla->logger->set_debug($verbose ? 1 : 0); VERBOSE_PLUGIN: foreach my $plugin_name (grep {not /\A[-_]\z/u;} @v_plugins) { my(@plugins) = grep({$_->plugin_name =~ /\b\Q$plugin_name\E\b/u;} @{$zilla->plugins;}); $zilla->log_fatal("can't find plugins matching $plugin_name to set debug") unless @plugins; $_->logger->set_debug(1) foreach (@plugins); } ; $zilla }
Truth table66%2/3
A ||= B
A= $self->{"Dist::Zilla::App"}{"zilla"}B= do { my(@v_plugins) = $self->global_options->verbose_plugin ? grep({length $_;} @{$self->global_options->verbose_plugin;}) : (); my $verbose = $self->global_options->verbose; $self->chrome->logger->set_debug($verbose ? 1 : 0); my $core_debug = grep({/\A[-_]\z/u;} @v_plugins); my $zilla; &try(sub { $zilla = "Dist::Zilla::Dist::Builder"->from_config({"chrome", $self->chrome, "_global_stashes", $self->_build_global_stashes}); } , &catch(sub { die $_ unless &try(sub { $_->isa("Config::MVP::Error"); } ) and $_->ident =~ /no viable config/u; $self->chrome->logger->log_fatal("no configuration (e.g, dist.ini) found"); } )); $zilla->logger->set_debug($verbose ? 1 : 0); VERBOSE_PLUGIN: foreach my $plugin_name (grep {not /\A[-_]\z/u;} @v_plugins) { my(@plugins) = grep({$_->plugin_name =~ /\b\Q$plugin_name\E\b/u;} @{$zilla->plugins;}); $zilla->log_fatal("can't find plugins matching $plugin_name to set debug") unless @plugins; $_->logger->set_debug(1) foreach (@plugins); } ; $zilla }
ABresult
1X1
011
000
128 my @v_plugins = $self->global_options->verbose_plugin
129 0 ▶ ? grep { length } @{ $self->global_options->verbose_plugin }
Branch: 1 branch
BranchTrueFalseTotal
$self->global_options->verbose_plugin ? : 0 20 20
130 : ();
131  
132 20 my $verbose = $self->global_options->verbose;
133  
134 20 ▶ $self->chrome->logger->set_debug($verbose ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$verbose ? : 0 20 20
135  
136 0 my $core_debug = grep { m/\A[-_]\z/ } @v_plugins;
137  
138 20 my $zilla;
139 20 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
140 20 $zilla = Dist::Zilla::Dist::Builder->from_config({
141 chrome => $self->chrome,
142 _global_stashes => $self->_build_global_stashes,
143 });
144 0 ▶ } catch {
Subroutine __ANON__: not called CC=3 SCAR=24.8
145 0 ▶ die $_ unless try { $_->isa('Config::MVP::Error') }
Subroutine __ANON__: not called CC=1 SCAR=6.9
146 0 ▶ && $_->ident =~ /no viable config/;
Branch: 1 branch
BranchTrueFalseTotal
unless &try(sub { $_->isa("Config::MVP::Error"); } ) and $_->ident =~ /no viable config/u 0 0 0
Condition0%0/3
&try(sub { $_->isa("Config::MVP::Error"); } ) and $_->ident =~ /no viable config/u
!ll&&!rl&&r
000
MC/DC0%0/2
&try(sub { $_->isa("Config::MVP::Error"); } ) and $_->ident =~ /no viable config/u
&try(sub { $_->isa("Config::MVP::Error"); } ) $_->ident =~ /no viable config/u
Truth table0%0/3
A and B
A= &try(sub { $_->isa("Config::MVP::Error"); } )B= $_->ident =~ /no viable config/u
ABresult
0X0
100
111
147 0 $self->chrome->logger->log_fatal("no configuration (e.g, dist.ini) found");
148 20 };
149  
150 20 ▶ $zilla->logger->set_debug($verbose ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$verbose ? : 0 20 20
151  
152 0 VERBOSE_PLUGIN: for my $plugin_name (grep { ! m{\A[-_]\z} } @v_plugins) {
153 0 my @plugins = grep { $_->plugin_name =~ /\b\Q$plugin_name\E\b/ }
154 0 @{ $zilla->plugins };
155  
156 0 ▶ $zilla->log_fatal("can't find plugins matching $plugin_name to set debug")
Branch: 1 branch
BranchTrueFalseTotal
unless @plugins 0 0 0
157 unless @plugins;
158  
159 0 $_->logger->set_debug(1) for @plugins;
160 }
161  
162 20 $zilla;
163 }
164 }
165  
166 4 1;
167  
168 __END__
« blib/lib/Dist/Zilla/App/Command/smoke.pm ↑ Summary blib/lib/Dist/Zilla/PluginBundle/Filter.pm »