blib/lib/Dist/Zilla/App/Command/add.pm

filter: Statementstmt 97.3% 37 / 38 Branchbran 50.0% 2 / 4 Conditioncond 37.5% 6 / 16 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 88.8% 8 / 9 Podpod 100% 5 / 5 totaltotal 74.3% 58 / 78 CC 12 SCAR 18.4
CC
12
Cov
78%
execute
11.3
validate_args
4.2
abstract
2.0
CRAP 6.3
« blib/lib/Dist/Zilla/Dist/Minter.pm ↑ Summary blib/lib/Dist/Zilla/App/Command/authordeps.pm »
1 package Dist::Zilla::App::Command::add 6.040;
2 # ABSTRACT: add a module to a dist
3  
4 4 ▶use Dist::Zilla::Pragmas;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Dist::Zilla::App -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Dist::Zilla::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 #pod =head1 SYNOPSIS
12 #pod
13 #pod Adds a new module to a Dist::Zilla-based distribution
14 #pod
15 #pod $ dzil add Some::New::Module
16 #pod
17 #pod There are two arguments, C<-p> and C<-P>. C<-P> specify the minting profile
18 #pod provider and C<-p> - the profile name. These work just like C<dzil new>.
19 #pod
20 #pod =cut
21  
22 0 ▶sub abstract { 'add modules to an existing dist' }
Subroutine abstract: not called CC=1 SCAR=6.9
Pod documented
23  
24 1 ▶sub usage_desc { '%c %o <ModuleName>' }
Subroutine usage_desc: called CC=1 SCAR=0.0
Pod documented
25  
26 1 ▶sub opt_spec {
Subroutine opt_spec: called CC=1 SCAR=0.0
Pod documented
27 1 [ 'profile|p=s', 'name of the profile to use' ],
28  
29 [ 'provider|P=s', 'name of the profile provider to use' ],
30  
31 # [ 'module|m=s@', 'module(s) to create; may be given many times' ],
32 }
33  
34 1 ▶sub validate_args {
Subroutine validate_args: called CC=4 SCAR=14.3
Pod documented
35 1 my ($self, $opt, $args) = @_;
36  
37 1 require MooseX::Types::Perl;
38  
39 1 ▶ $self->usage_error('dzil add takes one or more arguments') if @$args < 1;
Branch: 1 branch
BranchTrueFalseTotal
if @$args < 1 0 1 1
40  
41 1 for my $name ( @$args ) {
42 1 ▶ $self->usage_error("$name is not a valid module name")
Branch: 1 branch
BranchTrueFalseTotal
unless MooseX::Types::Perl::is_ModuleName($name) 0 1 1
43 unless MooseX::Types::Perl::is_ModuleName($name);
44 }
45 }
46  
47 1 ▶sub execute {
Subroutine execute: called CC=9 SCAR=24.2
Pod documented
48 1 my ($self, $opt, $arg) = @_;
49  
50 1 my $zilla = $self->zilla;
51 1 my $dist = $zilla->name;
52  
53 1 require File::pushd;
54  
55 1 my $mint_stash = $zilla->stash_named('%Mint');
56  
57 1 ▶ my $provider = $opt->provider
Condition37%3/8
($opt->provider // $mint_stash && $mint_stash->provider) // "Default"
l!l
01
$opt->provider // $mint_stash && $mint_stash->provider
l!l&&r!l&&!r
001
$mint_stash and $mint_stash->provider
!ll&&!rl&&r
100
MC/DC0%0/3
($opt->provider // $mint_stash && $mint_stash->provider) // "Default"
$opt->provider $mint_stash $mint_stash->provider
Truth table25%1/4
A // B and C
A= $opt->providerB= $mint_stashC= $mint_stash->provider
ABCresult
1XX1
0111
00X0
0100
58 // ($mint_stash && $mint_stash->provider)
59 // 'Default';
60  
61 1 ▶ my $profile = $opt->profile
Condition37%3/8
($opt->profile // $mint_stash && $mint_stash->profile) // "default"
l!l
01
$opt->profile // $mint_stash && $mint_stash->profile
l!l&&r!l&&!r
001
$mint_stash and $mint_stash->profile
!ll&&!rl&&r
100
MC/DC0%0/3
($opt->profile // $mint_stash && $mint_stash->profile) // "default"
$opt->profile $mint_stash $mint_stash->profile
Truth table25%1/4
A // B and C
A= $opt->profileB= $mint_stashC= $mint_stash->profile
ABCresult
1XX1
0111
00X0
0100
62 // ($mint_stash && $mint_stash->profile)
63 // 'default';
64  
65 1 require Dist::Zilla::Dist::Minter;
66 1 my $minter = Dist::Zilla::Dist::Minter->_new_from_profile(
67 [ $provider, $profile ],
68 {
69 chrome => $self->app->chrome,
70 name => $dist,
71 _global_stashes => $self->app->_build_global_stashes,
72 },
73 );
74  
75 1 my $root = path($zilla->root)->absolute;
76 1 my $wd = File::pushd::pushd($minter->root);
77  
78 1 my $factory = $minter->plugin_named(':DefaultModuleMaker');
79  
80 1 for my $name ( @$arg ) {
81 1 $factory->make_module({ name => $name });
82 }
83  
84 1 for my $file ( @{ $factory->zilla->files} ) {
85 1 $zilla->_write_out_file($file, $root);
86 }
87 }
88  
89 4 1;
90  
91 __END__
« blib/lib/Dist/Zilla/Dist/Minter.pm ↑ Summary blib/lib/Dist/Zilla/App/Command/authordeps.pm »