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

filter: Statementstmt 26.9% 7 / 26 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 19 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 28.5% 2 / 7 Podpod 100% 5 / 5 totaltotal 19.7% 14 / 71 CC 11 SCAR 34.8
CC
11
Cov
14%
execute
56.0
validate_args
30.0
abstract
2.0
CRAP 32.4
« blib/lib/Dist/Zilla/Chrome/Term.pm ↑ Summary blib/lib/Dist/Zilla/App/Command/listdeps.pm »
1 package Dist::Zilla::App::Command::new 6.040;
2 # ABSTRACT: mint a new 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  
8 #pod =head1 SYNOPSIS
9 #pod
10 #pod Creates a new Dist-Zilla based distribution under the current directory.
11 #pod
12 #pod $ dzil new Main::Module::Name
13 #pod
14 #pod There are two arguments, C<-p> and C<-P>. C<-P> specify the minting profile
15 #pod provider and C<-p> - the profile name.
16 #pod
17 #pod The default profile provider first looks in the
18 #pod F<~/.dzil/profiles/$profile_name> and then among standard profiles, shipped
19 #pod with Dist::Zilla. For example:
20 #pod
21 #pod $ dzil new -p work Corporate::Library
22 #pod
23 #pod This command would instruct C<dzil> to look in F<~/.dzil/profiles/work> for a
24 #pod F<profile.ini> (or other "profile" config file). If no profile name is given,
25 #pod C<dzil> will look for the C<default> profile. If no F<default> directory
26 #pod exists, it will use a very simple configuration shipped with Dist::Zilla.
27 #pod
28 #pod $ dzil new -P Foo Corporate::Library
29 #pod
30 #pod This command would instruct C<dzil> to consult the Foo provider about the
31 #pod directory of 'default' profile.
32 #pod
33 #pod Furthermore, it is possible to specify the default minting provider and profile
34 #pod in the F<~/.dzil/config.ini> file, for example:
35 #pod
36 #pod [%Mint]
37 #pod provider = FooCorp
38 #pod profile = work
39 #pod
40 #pod =cut
41  
42 0 ▶sub abstract { 'mint a new dist' }
Subroutine abstract: not called CC=1 SCAR=6.9
Pod documented
43  
44 0 ▶sub usage_desc { '%c new %o <ModuleName>' }
Subroutine usage_desc: not called CC=1 SCAR=6.9
Pod documented
45  
46 0 ▶sub opt_spec {
Subroutine opt_spec: not called CC=1 SCAR=6.9
Pod documented
47 0 [ 'profile|p=s', 'name of the profile to use' ],
48  
49 [ 'provider|P=s', 'name of the profile provider to use' ],
50  
51 # [ 'module|m=s@', 'module(s) to create; may be given many times' ],
52 }
53  
54 0 ▶sub validate_args {
Subroutine validate_args: not called CC=5 SCAR=34.0
Pod documented
55 0 my ($self, $opt, $args) = @_;
56  
57 0 require MooseX::Types::Perl;
58  
59 0 ▶ $self->usage_error('dzil new takes exactly one argument') if @$args != 1;
Branch: 1 branch
BranchTrueFalseTotal
if @$args != 1 0 0 0
60  
61 0 my $name = $args->[0];
62  
63 0 ▶ $name =~ s/::/-/g if MooseX::Types::Perl::is_ModuleName($name)
Branch: 1 branch
BranchTrueFalseTotal
if MooseX::Types::Perl::is_ModuleName($name) and not MooseX::Types::Perl::is_DistName($name) 0 0 0
Condition0%0/3
MooseX::Types::Perl::is_ModuleName($name) and not MooseX::Types::Perl::is_DistName($name)
!ll&&!rl&&r
000
MC/DC0%0/2
MooseX::Types::Perl::is_ModuleName($name) and not MooseX::Types::Perl::is_DistName($name)
MooseX::Types::Perl::is_ModuleName($name) not MooseX::Types::Perl::is_DistName($name)
Truth table0%0/3
A and not(B)
A= MooseX::Types::Perl::is_ModuleName($name)B= not MooseX::Types::Perl::is_DistName($name)
ABresult
0X0
100
111
64 and not MooseX::Types::Perl::is_DistName($name);
65  
66 0 ▶ $self->usage_error("$name is not a valid distribution name")
Branch: 1 branch
BranchTrueFalseTotal
unless MooseX::Types::Perl::is_DistName($name) 0 0 0
67 unless MooseX::Types::Perl::is_DistName($name);
68  
69 0 $args->[0] = $name;
70 }
71  
72 0 ▶sub execute {
Subroutine execute: not called CC=7 SCAR=40.3
Pod documented
73 0 my ($self, $opt, $arg) = @_;
74  
75 0 my $dist = $arg->[0];
76  
77 0 my $stash = $self->app->_build_global_stashes;
78 0 my $mint_stash = $stash->{'%Mint'};
79  
80 0 ▶ my $provider = $opt->provider // ($mint_stash && $mint_stash->provider) // 'Default';
Condition0%0/8
($opt->provider // $mint_stash && $mint_stash->provider) // "Default"
l!l
00
$opt->provider // $mint_stash && $mint_stash->provider
l!l&&r!l&&!r
000
$mint_stash and $mint_stash->provider
!ll&&!rl&&r
000
MC/DC0%0/3
($opt->provider // $mint_stash && $mint_stash->provider) // "Default"
$opt->provider $mint_stash $mint_stash->provider
Truth table0%0/4
A // B and C
A= $opt->providerB= $mint_stashC= $mint_stash->provider
ABCresult
1XX1
0111
00X0
0100
81 0 ▶ my $profile = $opt->profile // ($mint_stash && $mint_stash->profile) // 'default';
Condition0%0/8
($opt->profile // $mint_stash && $mint_stash->profile) // "default"
l!l
00
$opt->profile // $mint_stash && $mint_stash->profile
l!l&&r!l&&!r
000
$mint_stash and $mint_stash->profile
!ll&&!rl&&r
000
MC/DC0%0/3
($opt->profile // $mint_stash && $mint_stash->profile) // "default"
$opt->profile $mint_stash $mint_stash->profile
Truth table0%0/4
A // B and C
A= $opt->profileB= $mint_stashC= $mint_stash->profile
ABCresult
1XX1
0111
00X0
0100
82  
83 0 require Dist::Zilla::Dist::Minter;
84 0 my $minter = Dist::Zilla::Dist::Minter->_new_from_profile(
85 [ $provider, $profile ],
86 {
87 chrome => $self->app->chrome,
88 name => $dist,
89 _global_stashes => $stash,
90 },
91 );
92  
93 0 $minter->mint_dist({
94 # modules => $opt->module,
95 });
96 }
97  
98 4 1;
99  
100 __END__
« blib/lib/Dist/Zilla/Chrome/Term.pm ↑ Summary blib/lib/Dist/Zilla/App/Command/listdeps.pm »