Minilla/CLI/New.pm

filter: Statementstmt 37.2% 22 / 59 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 1 totaltotal 33.7% 29 / 86 CC 7 SCAR 33.5
CC
7
Cov
30%
run
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 28.5
« Minilla/Release/UploadToCPAN.pm ↑ Summary Minilla/ModuleMaker/ModuleBuildTiny.pm »
1 package Minilla::CLI::New;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use File::pushd;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use File::Path qw(mkpath);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Minilla::Util qw(check_git cmd parse_options);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Minilla::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub run {
Subroutine run: not called CC=7 SCAR=40.3
Pod undocumented
12 0 my ($self, @args) = @_;
13  
14 0 my $username;
15 my $email;
16 0 my $profile = 'Default';
17 0 parse_options(
18 \@args,
19 'username=s' => \$username,
20 'email=s' => \$email,
21 'p|profile=s' => \$profile,
22 );
23  
24 0 ▶ my $module = shift @args or errorf("Missing module name\n");
Branch: 1 branch
BranchTrueFalseTotal
my $module = shift @args or errorf("Missing module name\n") 0 0 0
25 0 $module =~ s!-!::!g;
26  
27 0 check_git;
28  
29 0 ▶ $username ||= `git config user.name`;
Condition0%0/3
$username ||= `git config user.name`
l!l&&r!l&&!r
000
MC/DC0%0/2
$username ||= `git config user.name`
$username `git config user.name`
Truth table0%0/3
A ||= B
A= $usernameB= `git config user.name`
ABresult
1X1
011
000
30 0 $username =~ s/\n$//;
31  
32 0 ▶ $email ||= `git config user.email`;
Condition0%0/3
$email ||= `git config user.email`
l!l&&r!l&&!r
000
MC/DC0%0/2
$email ||= `git config user.email`
$email `git config user.email`
Truth table0%0/3
A ||= B
A= $emailB= `git config user.email`
ABresult
1X1
011
000
33 0 $email =~ s/\n$//;
34  
35 0 my $version = '0.01';
36  
37 0 ▶ unless ($username) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($username) 0 0 0
38 0 errorf("Please set user.name in git, or use `--username` option.\n");
39 }
40  
41 # $module = "Foo::Bar"
42 # $suffix = "Bar"
43 # $dist = "Foo-Bar"
44 # $path = "Foo/Bar.pm"
45 0 my @pkg = split /::/, $module;
46 0 my $suffix = $pkg[ @pkg - 1 ];
47 0 my $dist = join "-", @pkg;
48 0 my $path = join( "/", @pkg ) . ".pm";
49 0 ( my $dir = $dist ) =~ s/^App-//;
50  
51 0 ▶ if (-d $dist) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $dist) 0 0 0
52 0 errorf("There is %s/\n", $dist);
53 }
54  
55 0 my $author = $username;
56  
57 0 my $profile_klass = "Minilla::Profile::${profile}";
58 0 ▶ eval "require $profile_klass; 1;" or die $@;
Branch: 1 branch
BranchTrueFalseTotal
eval "require $profile_klass; 1;" or die $@ 0 0 0
59 0 my $skelton = $profile_klass->new(
60 dist => $dist,
61 path => $path,
62 author => $username,
63 suffix => $suffix,
64 module => $module,
65 version => $version,
66 email => $email,
67 );
68 {
69 0 mkpath($dist);
70 0 my $guard = pushd($dist);
71 0 $skelton->generate();
72  
73 # init git repo
74 0 infof("Initializing git $module\n");
75 0 cmd('git', 'init');
76  
77 # generate project after initialize git repo
78 0 my $project = Minilla::Project->new();
79 0 $project->generate_minil_toml($profile);
80 0 cmd('git', 'add', '.');
81 0 $project->regenerate_files();
82  
83 # and git add all things
84 0 cmd('git', 'add', '.');
85 }
86  
87 0 infof("Finished to create $module\n");
88 }
89  
90 1 1;
91 __END__
« Minilla/Release/UploadToCPAN.pm ↑ Summary Minilla/ModuleMaker/ModuleBuildTiny.pm »