blib/lib/App/palien.pm

filter: Statementstmt 15.3% 20 / 130 Branchbran 0.0% 0 / 44 Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 40.0% 6 / 15 Podpod 0.0% 0 / 1 totaltotal 12.3% 26 / 211 CC 35 SCAR 56.4
CC
35
Cov
11%
main
552.0
_find
110.0
_modversion
12.0
CRAP 282.9
↑ Summary bin/af »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 package App::palien 0.18 {
6  
7 1 ▶use Getopt::Long qw( GetOptions );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Pod::Usage qw( pod2usage );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Path::Tiny qw( path );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # ABSTRACT: Command line interface to Alien::Base
12 # VERSION
13  
14  
15 sub _version ($)
16 0 ▶{
Subroutine _version: not called CC=1 SCAR=6.9
17 0 my($alien) = @_;
18 0 my $class = ref $alien;
19 0 eval { $class->VERSION };
20 }
21  
22 sub _modversion ($)
23 0 ▶{
Subroutine _modversion: not called CC=3 SCAR=24.8
24 0 my($alien) = @_;
25 0 ▶ return $alien->version if $alien->can('version');
Branch: 1 branch
BranchTrueFalseTotal
if $alien->can("version") 0 0 0
26 0 ▶ return 'unknown' unless $alien->can('config');
Branch: 1 branch
BranchTrueFalseTotal
unless $alien->can("config") 0 0 0
27 0 my $ver = $alien->config('version');
28 0 chomp $ver;
29 0 $ver;
30 }
31  
32 sub _bin_dir
33 0 ▶{
Subroutine _bin_dir: not called CC=1 SCAR=6.9
34 0 my($dir_sep, $alien) = @_;
35  
36 0 join( $dir_sep, $alien->bin_dir );
37 }
38  
39 sub _cflags ($)
40 0 ▶{
Subroutine _cflags: not called CC=1 SCAR=6.9
41 0 my($alien) = @_;
42 0 scalar $alien->cflags;
43 }
44  
45 sub _libs ($)
46 0 ▶{
Subroutine _libs: not called CC=1 SCAR=6.9
47 0 my($alien) = @_;
48 0 scalar $alien->libs;
49 }
50  
51 sub main
52 0 ▶{
Subroutine main: not called CC=23 SCAR=63.1
Pod undocumented
53 0 local(undef, @ARGV) = @_;
54  
55 0 my $bin_dir;
56 0 my $dir_sep = ' ';
57 0 my $cflags;
58 my $libs;
59 0 my $dll;
60 0 my $modversion;
61 0 my $detail;
62 0 my $status = 0;
63  
64 GetOptions(
65 "bin-dir" => \$bin_dir,
66 "dir-sep" => \$dir_sep,
67 "cflags" => \$cflags,
68 "libs" => \$libs,
69 "dll" => \$dll,
70 "modversion" => \$modversion,
71 "detail|d" => \$detail,
72 0 ▶ "help|h" => sub { pod2usage({ -verbose => 2}) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
73 0 ▶ "version" => sub { print "App::palien version " . ($App::palien::VERSION || 'dev') . "\n"; exit 1; },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$App::palien::VERSION || 'dev'
l!l
00
MC/DC0%0/1
$App::palien::VERSION || 'dev'
$App::palien::VERSION
Truth table0%0/2
A
A= $App::palien::VERSION
Aresult
11
00
74 0 ▶ ) || pod2usage(1);
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions("bin-dir", \$bin_dir, "dir-sep", \$dir_sep, "cflags", \$cflags, "libs", \$libs, "dll", \$dll, "modversion", \$modversion, "detail|d", \$detail, "help|h", sub { pod2usage({"-verbose", 2}); } , "version", sub { print 'App::palien version ' . ($App::palien::VERSION || "dev") . "\n"; exit 1; } ) or pod2usage(1) 0 0 0
75  
76 0 ▶ unless(@ARGV)
Branch: 1 branch
BranchTrueFalseTotal
unless (@ARGV) 0 0 0
77 {
78 0 my %mods;
79 0 foreach my $inc (@INC)
80 {
81 0 my $dir = path( "$inc/Alien" );
82 0 ▶ next unless -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 0 0 0
83 0 foreach my $pm (grep /\.pm$/, map { $_->basename } grep { -f $_ } $dir->children)
84 {
85 0 $pm =~ s/\.pm$//;
86 0 ▶ next if $pm =~ /^(Base|Packages|Builder|MSYS)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $pm =~ /^(Base|Packages|Builder|MSYS)$/u 0 0 0
87 0 print "$pm = $pm\n";
88 0 $mods{"Alien::$pm"} = 1;
89 }
90  
91 0 my $share_root = path("$inc/auto/share/dist");
92 0 ▶ next unless -d $share_root;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $share_root 0 0 0
93 0 foreach my $share (sort { $a->basename cmp $b->basename } $share_root->children)
94 {
95 0 my $readme = $share->child('README');
96 0 ▶ next unless (-r $readme) && ($readme->slurp =~ /This README file is autogenerated by Alien::Base/);
Branch: 1 branch
BranchTrueFalseTotal
unless -r $readme and $readme->slurp =~ /This README file is autogenerated by Alien::Base/u 0 0 0
Condition0%0/3
-r $readme and $readme->slurp =~ /This README file is autogenerated by Alien::Base/u
!ll&&!rl&&r
000
MC/DC0%0/2
-r $readme and $readme->slurp =~ /This README file is autogenerated by Alien::Base/u
-r $readme $readme->slurp =~ /This README file is autogenerated by Alien::Base/u
Truth table0%0/3
A and B
A= -r $readmeB= $readme->slurp =~ /This README file is autogenerated by Alien::Base/u
ABresult
0X0
100
111
97 0 my $module = $share->basename;
98 0 $module =~ s/-/::/g;
99 0 $mods{$module} = 1;
100 }
101  
102 }
103  
104 0 @ARGV = sort keys %mods;
105 }
106  
107 0 foreach my $module (@ARGV)
108 {
109 0 my $alien;
110  
111 0 ▶ if($module =~ /::/)
Branch: 1 branch
BranchTrueFalseTotal
if ($module =~ /::/u) { } 0 0 0
112 {
113 0 $alien = eval {
114 0 my $pm = $module . ".pm";
115 0 $pm =~ s/::/\\/g;
116 0 require $pm;
117 0 $module->new;
118 };
119 0 ▶ if($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
120 {
121 0 warn "unable to load $module: $@";
122 0 $status = 2;
123 0 next;
124 }
125 }
126 else
127 {
128 0 $alien = _find($module);
129 0 ▶ next unless $alien;
Branch: 1 branch
BranchTrueFalseTotal
unless $alien 0 0 0
130 }
131  
132 0 ▶ if($detail)
Branch: 1 branch
BranchTrueFalseTotal
if ($detail) 0 0 0
133 {
134 0 my $class = ref $alien;
135 0 printf "=============================================\n";
136 0 printf "class: %s\n", ref $alien;
137 0 printf "version: %s\n", _version $alien;
138 0 printf "modversion: %s\n", _modversion $alien;
139 0 ▶ printf "dist: %s\n", $alien->dist_dir if eval { $alien->dist_dir };
Branch: 1 branch
BranchTrueFalseTotal
if eval { do { $alien->dist_dir } } 0 0 0
140 0 printf "cflags: %s\n", _cflags $alien;
141 0 printf "libs: %s\n", _libs $alien;
142 }
143  
144 0 ▶ if( defined $bin_dir)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $bin_dir) 0 0 0
145 {
146 0 print _bin_dir ( $dir_sep, $alien) , "\n";
147 }
148  
149 0 ▶ if($cflags)
Branch: 1 branch
BranchTrueFalseTotal
if ($cflags) 0 0 0
150 {
151 0 print _cflags $alien, "\n";
152 }
153  
154 0 ▶ if($libs)
Branch: 1 branch
BranchTrueFalseTotal
if ($libs) 0 0 0
155 {
156 0 print _libs $alien, "\n";
157 }
158  
159 0 ▶ if($modversion)
Branch: 1 branch
BranchTrueFalseTotal
if ($modversion) 0 0 0
160 {
161 0 print _modversion $alien, "\n";
162 }
163  
164 0 ▶ if($dll)
Branch: 1 branch
BranchTrueFalseTotal
if ($dll) 0 0 0
165 {
166 0 print $_, "\n" for $alien->dynamic_libs;
167 }
168 }
169  
170 0 $status;
171 }
172  
173 1 my $byname;
174  
175 sub _find
176 0 ▶{
Subroutine _find: not called CC=10 SCAR=47.0
177 0 my($q) = @_;
178  
179 0 ▶ unless($byname)
Branch: 1 branch
BranchTrueFalseTotal
unless ($byname) 0 0 0
180 {
181 0 $byname->{libarchive} = 'Alien::Libarchive';
182 0 $byname->{bz2} = 'Alien::bz2';
183 0 foreach my $inc (@INC)
184 {
185 0 my $share_root = path("$inc/auto/share/dist");
186 0 ▶ next unless -d $share_root;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $share_root 0 0 0
187 0 foreach my $share ($share_root->children)
188 {
189 0 my $readme = $share->child('README');
190 0 ▶ next unless (-r $readme) && ($readme->slurp =~ /This README file is autogenerated by Alien::Base/);
Branch: 1 branch
BranchTrueFalseTotal
unless -r $readme and $readme->slurp =~ /This README file is autogenerated by Alien::Base/u 0 0 0
Condition0%0/3
-r $readme and $readme->slurp =~ /This README file is autogenerated by Alien::Base/u
!ll&&!rl&&r
000
MC/DC0%0/2
-r $readme and $readme->slurp =~ /This README file is autogenerated by Alien::Base/u
-r $readme $readme->slurp =~ /This README file is autogenerated by Alien::Base/u
Truth table0%0/3
A and B
A= -r $readmeB= $readme->slurp =~ /This README file is autogenerated by Alien::Base/u
ABresult
0X0
100
111
191 0 my $module = $share->basename;
192 0 $module =~ s/-/::/g;
193 0 my $name = eval {
194 0 my $module = "$module::ConfigData";
195 0 my $pm = "$module.pm";
196 0 $pm =~ s/::/\\/g;
197 0 require $pm;
198 0 $module->config('name');
199 };
200 0 $byname->{$name} = $module;
201 }
202 }
203 }
204  
205 0 my $module = $byname->{$q};
206  
207 defined $module
208 0 ▶ ? eval {
Branch: 1 branch
BranchTrueFalseTotal
defined $module ? : 0 0 0
Condition0%0/2
eval { do { my $pm = "$module.pm"; $pm =~ s/::/\\/gu; require $pm; $module->new } } or warn "unable to load ${module}: $@" && ()
l!l
00
MC/DC0%0/1
eval { do { my $pm = "$module.pm"; $pm =~ s/::/\\/gu; require $pm; $module->new } } or warn "unable to load ${module}: $@" && ()
eval { do { my $pm = "$module.pm"; $pm =~ s/::/\\/gu; require $pm; $module->new } }
Truth table0%0/2
A
A= eval { do { my $pm = "$module.pm"; $pm =~ s/::/\\/gu; require $pm; $module->new } }
Aresult
11
00
209 0 my $pm = "$module.pm";
210 0 $pm =~ s/::/\\/g;
211 0 require $pm;
212 0 ▶ $module->new;
Condition0%0/3
"unable to load ${module}: $@" && ()
!ll&&!rl&&r
000
MC/DC0%0/2
"unable to load ${module}: $@" && ()
"unable to load ${module}: $@" ()
Truth table0%0/3
A && B
A= "unable to load ${module}: $@"B= ()
ABresult
0X0
100
111
213 } || warn "unable to load $module: $@" && ()
214 : ();
215 }
216  
217 }
218  
219 1 1;
220  
221 __END__
↑ Summary bin/af »