Midgen/Role/Output/MI.pm

filter: Statementstmt 25.5% 23 / 90 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 66.6% 6 / 9 Podpod 100% 3 / 3 totaltotal 22.0% 32 / 145 CC 21 SCAR 43.9
CC
21
Cov
18%
body_mi
156.0
footer_mi
56.0
header_mi
20.0
CRAP 81.0
« Midgen/Role/UseModule.pm ↑ Summary Midgen/Role/Output/MIdsl.pm »
1 package App::Midgen::Role::Output::MI;
2  
3 2 ▶use constant {NONE => q{},};
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 requires qw( no_index verbose );
7  
8 # Load time and dependencies negate execution time
9 # use namespace::clean -except => 'meta';
10  
11 2 our $VERSION = '0.34';
12 2 $VERSION = eval $VERSION; ## no critic
13  
14 2 ▶use English qw( -no_match_vars ); # Avoids reg-ex performance penalty
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 local $OUTPUT_AUTOFLUSH = 1;
16  
17 2 ▶use Term::ANSIColor qw( :constants colored );
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21 #######
22 # header_mi
23 #######
24 0 ▶sub header_mi {
Subroutine header_mi: not called CC=4 SCAR=30.0
Pod documented
25 0 my $self = shift;
26 0 ▶ my $package_name = shift || NONE;
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
27 0 ▶ my $mi_ver = shift || NONE;
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
28  
29 0 print "\nuse strict;\n";
30 0 print "use warnings;\n";
31 0 print "use inc::Module::Install " . colored($mi_ver, 'yellow') . ";\n";
32  
33 0 ▶ if ($package_name ne NONE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($package_name ne "") 0 0 0
34 0 $package_name =~ s{::}{-}g;
35 0 print "name '$package_name';\n";
36 0 $package_name =~ tr{-}{/};
37 0 print "all_from 'lib/$package_name.pm';\n";
38 }
39  
40 0 print BRIGHT_BLACK . "license 'perl';" . CLEAR . "\n";
41 0 return;
42 }
43 #######
44 # body_mi
45 #######
46 0 ▶sub body_mi {
Subroutine body_mi: not called CC=12 SCAR=50.5
Pod documented
47 0 my $self = shift;
48 0 my $title = shift;
49 0 ▶ my $required_ref = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
50  
51 0 ▶ return if not %{$required_ref};
Branch: 1 branch
BranchTrueFalseTotal
unless %{$required_ref;} 0 0 0
52  
53 0 my $pm_length = 0;
54 0 foreach my $module_name (sort keys %{$required_ref}) {
55 0 ▶ if (length $module_name > $pm_length) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $module_name > $pm_length) 0 0 0
56 0 $pm_length = length $module_name;
57 }
58 }
59  
60 0 ▶ print "perl_version '$App::Midgen::Min_Version';\n" if $title eq 'RuntimeRequires';
Branch: 1 branch
BranchTrueFalseTotal
if $title eq "RuntimeRequires" 0 0 0
61 0 print "\n";
62  
63 0 $title =~ s/^RuntimeRequires/requires/;
64 0 $title =~ s/^TestRequires/test_requires/;
65  
66 0 foreach my $module_name (sort keys %{$required_ref}) {
67  
68 next
69 if $title eq 'test_requires'
70 0 ▶ && $required_ref->{$module_name} =~ m/mcpan/;
Branch: 1 branch
BranchTrueFalseTotal
if $title eq "test_requires" and $required_ref->{$module_name} =~ /mcpan/ 0 0 0
Condition0%0/3
$title eq "test_requires" and $required_ref->{$module_name} =~ /mcpan/
!ll&&!rl&&r
000
MC/DC0%0/2
$title eq "test_requires" and $required_ref->{$module_name} =~ /mcpan/
$title eq "test_requires" $required_ref->{$module_name} =~ /mcpan/
Truth table0%0/3
A and B
A= $title eq "test_requires"B= $required_ref->{$module_name} =~ /mcpan/
ABresult
0X0
100
111
71  
72 0 ▶ if ($module_name =~ /^Win32/sxm) {
Branch: 3 branches
BranchTrueFalseTotal
if ($module_name =~ /^Win32/msx) { } 0 0 0
elsif ($module_name =~ /XS/msx) { } 0 0 0
elsif ($module_name eq 'MRO::Compat') { } 0 0 0
73 0 my $sq_key = "'$module_name'";
74 printf "%s %-*s => '%s' %s;\n", $title, $pm_length + 2, $sq_key,
75 0 $required_ref->{$module_name}, colored('if win32', 'bright_green');
76 }
77 elsif ($module_name =~ /XS/sxm) {
78 0 my $sq_key = "'$module_name'";
79 printf "%s %-*s => '%s' %s;\n", $title, $pm_length + 2, $sq_key,
80 0 $required_ref->{$module_name}, colored('if can_xs', 'bright_blue');
81 }
82 elsif ($module_name eq 'MRO::Compat') {
83 0 my $sq_key = "'$module_name'";
84 printf "%s %-*s => '%s' %s;\n", $title, $pm_length + 2, $sq_key,
85 0 $required_ref->{$module_name},
86 colored('if $] < 5.009005', 'bright_blue');
87 }
88 else {
89 0 my $sq_key = "'$module_name'";
90 printf "%s %-*s => '%s';\n", lc $title, $pm_length + 2, $sq_key,
91 0 $required_ref->{$module_name};
92 }
93  
94 }
95  
96 0 return;
97 }
98 #######
99 # footer_mi
100 #######
101 0 ▶sub footer_mi {
Subroutine footer_mi: not called CC=7 SCAR=40.3
Pod documented
102 0 my $self = shift;
103 0 ▶ my $package_name = shift || NONE;
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
104 0 $package_name =~ s{::}{-}g;
105  
106 0 ▶ if ($self->verbose > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->verbose > 0) 0 0 0
107 0 print BRIGHT_BLACK "\n";
108 0 print "homepage 'https://github.com/.../$package_name';\n";
109 0 print "bugtracker 'https://github.com/.../$package_name/issues';\n";
110 0 print "repository 'git://github.com/.../$package_name.git';\n";
111 0 print "\n";
112 0 print "Meta->add_metadata(\n";
113 0 print "\tx_contributors => [\n";
114 0 print "\t\t'brian d foy (ADOPTME) <brian.d.foy\@gmail.com>',\n";
115 0 print "\t\t'Fred Bloggs <fred\@bloggs.org>',\n";
116 0 print "\t],\n";
117 0 print ");\n";
118 0 print CLEAR;
119 }
120  
121 0 print "\n";
122  
123 0 ▶ if (defined -d File::Spec->catdir($App::Midgen::Working_Dir, 'share')) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined -d "File::Spec"->catdir($App::Midgen::Working_Dir, "share")) 0 0 0
124 0 print "install_share;\n\n";
125 }
126  
127 0 ▶ if (defined -d File::Spec->catdir($App::Midgen::Working_Dir, 'script')) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined -d 'File::Spec'->catdir($App::Midgen::Working_Dir, 'script')) { } 0 0 0
elsif (defined -d 'File::Spec'->catdir($App::Midgen::Working_Dir, 'bin')) { } 0 0 0
128 0 print "install_script 'script/...';\n\n";
129 }
130 elsif (defined -d File::Spec->catdir($App::Midgen::Working_Dir, 'bin')) {
131 0 print "install_script 'bin/...';\n\n";
132 }
133  
134 0 my @no_index = $self->no_index;
135 0 ▶ if (@no_index) {
Branch: 1 branch
BranchTrueFalseTotal
if (@no_index) 0 0 0
136 0 print "no_index 'directory' => qw{ @no_index };\n\n";
137 }
138  
139 0 print "WriteAll\n\n";
140  
141 0 return;
142 }
143  
144 2 ▶no Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
145  
146 2 1;
147  
148 __END__
« Midgen/Role/UseModule.pm ↑ Summary Midgen/Role/Output/MIdsl.pm »