BundleDeps.pm

filter: Statementstmt 28.5% 20 / 70 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 40.0% 6 / 15 Podpod 0.0% 0 / 9 totaltotal 21.1% 26 / 123 CC 12 SCAR 29.1
CC
12
Cov
22%
bundle_from_meta
56.0
bundle_deps
12.0
extlib
6.0
CRAP 18.4
↑ Summary BundleDeps/Platypus.pm »
1 package App::BundleDeps;
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 local::lib ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Cwd ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use ExtUtils::MakeMaker;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our $VERSION = '0.00006';
10  
11 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
12 0 my ($class, @args) = @_;
13 0 return bless {
14 extlib => File::Spec->catdir(File::Spec->curdir, 'extlib'),
15 notest => 1,
16 @args
17 }, $class;
18 }
19  
20 # XXX - accessors inlined for minimal setup
21 0 ▶sub extlib {
Subroutine extlib: not called CC=2 SCAR=17.9
Pod undocumented
22 0 my $self = shift;
23 0 ▶ $self->{extlib} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
24 0 return $self->{extlib};
25 }
26  
27 0 ▶sub notest {
Subroutine notest: not called CC=2 SCAR=17.9
Pod undocumented
28 0 my $self = shift;
29 0 ▶ $self->{notest} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
30 0 return $self->{notest};
31 }
32  
33 0 ▶sub deps {
Subroutine deps: not called CC=2 SCAR=17.9
Pod undocumented
34 0 my $self = shift;
35 0 ▶ $self->{deps} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
36 0 return $self->{deps};
37 }
38  
39 # given a META.yml file (if no arguments, looks for a META.yml in the current
40 # directory), does the proper dep bundling
41 0 ▶sub bundle_from_meta {
Subroutine bundle_from_meta: not called CC=7 SCAR=40.3
Pod undocumented
42 0 my ($self, $file) = @_;
43 0 ▶ $file ||= 'META.yml';
Condition0%0/2
$file ||= "META.yml"
l!l
00
MC/DC0%0/1
$file ||= "META.yml"
$file
Truth table0%0/2
A
A= $file
Aresult
11
00
44  
45 0 require YAML;
46 0 require YAML::Dumper; # yeah, really, wtf
47 0 my $meta = eval {
48 0 YAML::LoadFile($file)
49 };
50 0 ▶ if (! $meta || $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $meta or $@) 0 0 0
Condition0%0/3
not $meta or $@
l!l&&r!l&&!r
000
MC/DC0%0/2
not $meta or $@
not $meta $@
Truth table0%0/3
not(A) or B
A= not $metaB= $@
ABresult
1X1
011
000
51 0 ▶ $@ ||= 'Unknown reason';
Condition0%0/2
$@ ||= "Unknown reason"
l!l
00
MC/DC0%0/1
$@ ||= "Unknown reason"
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
52 0 die "Failed to load file $file: $@."
53 }
54  
55 0 ▶ my $requires = $meta->{requires} || {};
Condition0%0/2
$meta->{'requires'} || {}
l!l
00
MC/DC0%0/1
$meta->{'requires'} || {}
$meta->{'requires'}
Truth table0%0/2
A
A= $meta->{'requires'}
Aresult
11
00
56 0 ▶ my $build_requires = $meta->{build_requires} || {};
Condition0%0/2
$meta->{'build_requires'} || {}
l!l
00
MC/DC0%0/1
$meta->{'build_requires'} || {}
$meta->{'build_requires'}
Truth table0%0/2
A
A= $meta->{'build_requires'}
Aresult
11
00
57 0 my %deps = (%{ $requires }, %{ $build_requires });
58 0 $self->setup_deps(keys %deps);
59  
60 0 $self->bundle();
61 }
62  
63 0 ▶sub bundle_modules {
Subroutine bundle_modules: not called CC=1 SCAR=6.9
Pod undocumented
64 0 my($self, @modules) = @_;
65  
66 0 $self->setup_deps(@modules);
67 0 $self->bundle();
68 }
69  
70 0 ▶sub setup_deps {
Subroutine setup_deps: not called CC=1 SCAR=6.9
Pod undocumented
71 0 my ($self, @deps) = @_;
72  
73 0 @deps = grep { $_ ne 'perl' } sort @deps;
74 0 $self->deps(\@deps);
75 }
76  
77 0 ▶sub bundle {
Subroutine bundle: not called CC=1 SCAR=6.9
Pod undocumented
78 0 my $self = shift;
79 0 $self->bundle_deps();
80 }
81  
82 0 ▶sub bundle_deps {
Subroutine bundle_deps: not called CC=3 SCAR=24.8
Pod undocumented
83 0 my $self = shift;
84  
85 0 $ENV{PERL5LIB} = ''; # detach existent local::lib
86 0 local::lib->setup_local_lib_for( Cwd::abs_path( $self->extlib ) );
87  
88 # wtf: ExtUtils::MakeMaker shipped with Leopard is old
89 0 ▶ if ($ExtUtils::MakeMaker::VERSION < 6.31) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ExtUtils::MakeMaker::VERSION < "6.31") 0 0 0
90 0 $ENV{PERL_MM_OPT} =~ s/INSTALL_BASE=(.*)/$& INSTALLBASE=$1/;
91 }
92  
93 # no man pages TODO: do the same with Module::Build
94 0 $ENV{PERL_MM_OPT} .= " INSTALLMAN1DIR=none INSTALLMAN3DIR=none";
95 0 $ENV{PERL_MM_USE_DEFAULT} = 1;
96  
97 # Remove /opt from PATH: end users won't have ports
98 0 $ENV{PATH} = join ":", grep !/^\/opt/, split /:/, $ENV{PATH};
99  
100 0 my @cmd = ('cpanm', '--skip-installed');
101 0 ▶ if ($self->notest) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->notest) 0 0 0
102 0 push @cmd, '--notest';
103 }
104 0 push @cmd, @{ $self->deps };
105  
106 0 system(@cmd);
107 }
108  
109 1 1;
110  
111  
112 __END__
↑ Summary BundleDeps/Platypus.pm »