blib/lib/Dist/Zilla/Dist/Minter.pm

filter: Statementstmt 93.9% 77 / 82 Branchbran 37.5% 3 / 8 Conditioncond 44.4% 4 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 1 totaltotal 80.8% 93 / 115 CC 18 SCAR 18.6
CC
18
Cov
85%
mint_dist
10.0
_new_from_profile
7.3
_mint_target_dir
6.0
CRAP 6.4
« blib/lib/Dist/Zilla/Plugin/MakeMaker.pm ↑ Summary blib/lib/Dist/Zilla/App/Command/add.pm »
1 package Dist::Zilla::Dist::Minter 6.040;
2 # ABSTRACT: distribution builder; installer not included!
3  
4 50 ▶use Moose 0.92; # role composition fixes
Subroutine BEGIN: called CC=1 SCAR=0.0
5 50 extends 'Dist::Zilla';
6  
7 50 ▶use Dist::Zilla::Pragmas;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 50 ▶use File::pushd ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 50 ▶use Dist::Zilla::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 50 ▶use Module::Runtime 'require_module';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 50 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 ▶sub _setup_default_plugins {
Subroutine _setup_default_plugins: called CC=2 SCAR=7.0
16 2 my ($self) = @_;
17  
18 2 ▶ unless ($self->plugin_named(':DefaultModuleMaker')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->plugin_named(":DefaultModuleMaker")) 2 0 2
19 2 require Dist::Zilla::Plugin::TemplateModule;
20 2 my $plugin = Dist::Zilla::Plugin::TemplateModule->new({
21 plugin_name => ':DefaultModuleMaker',
22 zilla => $self,
23 });
24  
25 2 push @{ $self->plugins }, $plugin;
26 }
27 }
28  
29 2 ▶sub _new_from_profile {
Subroutine _new_from_profile: called CC=7 SCAR=19.9
30 2 my ($class, $profile_data, $arg) = @_;
31 2 ▶ $arg ||= {};
Condition50%1/2
$arg ||= {}
l!l
20
MC/DC0%0/1
$arg ||= {}
$arg
Truth table50%1/2
A
A= $arg
Aresult
11
00
32  
33 my $config_class =
34 2 ▶ $arg->{config_class} ||= 'Dist::Zilla::MVP::Reader::Finder';
Condition50%1/2
$arg->{"config_class"} ||= "Dist::Zilla::MVP::Reader::Finder"
l!l
02
MC/DC0%0/1
$arg->{"config_class"} ||= "Dist::Zilla::MVP::Reader::Finder"
$arg->{"config_class"}
Truth table50%1/2
A
A= $arg->{"config_class"}
Aresult
11
00
35 2 require_module($config_class);
36  
37 $arg->{chrome}->logger->log_debug(
38 2 { prefix => '[DZ] ' },
39 "reading configuration using $config_class"
40 );
41  
42 2 require Dist::Zilla::MVP::Assembler::Zilla;
43 2 require Dist::Zilla::MVP::Section;
44 my $assembler = Dist::Zilla::MVP::Assembler::Zilla->new({
45 chrome => $arg->{chrome},
46 2 zilla_class => $class,
47 section_class => 'Dist::Zilla::MVP::Section', # make this DZMA default
48 });
49  
50 2 for ($assembler->sequence->section_named('_')) {
51 2 $_->add_value(name => $arg->{name});
52 2 $_->add_value(chrome => $arg->{chrome});
53 $_->add_value(_global_stashes => $arg->{_global_stashes})
54 2 ▶ if $arg->{_global_stashes};
Branch: 1 branch
BranchTrueFalseTotal
if $arg->{"_global_stashes"} 2 0 2
55 }
56  
57 2 my $module = String::RewritePrefix->rewrite(
58 { '' => 'Dist::Zilla::MintingProfile::', '=', => '' },
59 $profile_data->[0],
60 );
61 2 require_module($module);
62  
63 2 my $profile_dir = $module->profile_dir($profile_data->[1]);
64  
65 2 ▶ warn "expected a string or Path::Tiny but got a Path::Class from $module\n"
Branch: 1 branch
BranchTrueFalseTotal
if ref $profile_dir and $profile_dir->isa("Path::Class") 0 2 2
Condition33%1/3
ref $profile_dir and $profile_dir->isa("Path::Class")
!ll&&!rl&&r
020
MC/DC0%0/2
ref $profile_dir and $profile_dir->isa("Path::Class")
ref $profile_dir $profile_dir->isa("Path::Class")
Truth table33%1/3
A and B
A= ref $profile_dirB= $profile_dir->isa("Path::Class")
ABresult
0X0
100
111
66 if ref $profile_dir && $profile_dir->isa('Path::Class');
67  
68 2 $profile_dir = path($profile_dir);
69  
70 2 $assembler->sequence->section_named('_')->add_value(root => $profile_dir);
71  
72 2 my $seq = $config_class->read_config(
73 $profile_dir->child('profile'),
74 {
75 assembler => $assembler
76 },
77 );
78  
79 2 my $self = $seq->section_named('_')->zilla;
80  
81 2 $self->_setup_default_plugins;
82  
83 2 return $self;
84 }
85  
86 0 ▶sub _mint_target_dir {
Subroutine _mint_target_dir: not called CC=2 SCAR=17.9
87 0 my ($self) = @_;
88  
89 0 my $name = $self->name;
90 0 my $dir = path($name);
91 0 ▶ $self->log_fatal("./$name already exists") if -e $dir;
Branch: 1 branch
BranchTrueFalseTotal
if -e $dir 0 0 0
92  
93 0 return $dir = $dir->absolute;
94 }
95  
96 1 ▶sub mint_dist {
Subroutine mint_dist: called CC=10 SCAR=23.0
Pod undocumented
97 1 my ($self, $arg) = @_;
98  
99 1 my $name = $self->name;
100 1 my $dir = $self->_mint_target_dir;
101  
102 # XXX: We should have a way to get more than one module name in, and to
103 # supply plugin names for the minter to use. -- rjbs, 2010-05-03
104 1 my @modules = (
105 { name => $name =~ s/-/::/gr }
106 );
107  
108 1 $self->log("making target dir $dir");
109 1 $dir->mkpath;
110  
111 1 my $wd = File::pushd::pushd($self->root);
112  
113 1 $_->before_mint for @{ $self->plugins_with(-BeforeMint) };
114  
115 1 for my $module (@modules) {
116 my $minter = $self->plugin_named(
117 1 ▶ $module->{minter_name} || ':DefaultModuleMaker'
Condition50%1/2
$module->{'minter_name'} || ':DefaultModuleMaker'
l!l
01
MC/DC0%0/1
$module->{'minter_name'} || ':DefaultModuleMaker'
$module->{'minter_name'}
Truth table50%1/2
A
A= $module->{'minter_name'}
Aresult
11
00
118 );
119  
120 $minter->make_module({ name => $module->{name} })
121 1 }
122  
123 1 $_->gather_files for @{ $self->plugins_with(-FileGatherer) };
124 1 $_->set_file_encodings for @{ $self->plugins_with(-EncodingProvider) };
125 1 $_->prune_files for @{ $self->plugins_with(-FilePruner) };
126 1 $_->munge_files for @{ $self->plugins_with(-FileMunger) };
127  
128 1 $self->_check_dupe_files;
129  
130 1 $self->log("writing files to $dir");
131  
132 1 for my $file (@{ $self->files }) {
133 2 $self->_write_out_file($file, $dir);
134 }
135  
136 $_->after_mint({ mint_root => $dir })
137 1 for @{ $self->plugins_with(-AfterMint) };
138  
139 1 $self->log("dist minted in ./$name");
140 }
141  
142 50 __PACKAGE__->meta->make_immutable;
143 50 1;
144  
145 __END__
« blib/lib/Dist/Zilla/Plugin/MakeMaker.pm ↑ Summary blib/lib/Dist/Zilla/App/Command/add.pm »