Build/PPK.pm untested

filter: Statementstmt 0.0% 0 / 57 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 74 CC 2 SCAR 9.4
CC
2
Cov
0%
build
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.6
1 package Build::PPK;
2  
3 # Copyright (c) 2018, cPanel, L.L.C.
4 # All rights reserved.
5 # http://cpanel.net/
6 #
7 # This is free software; you can redistribute it and/or modify it under the same
8 # terms as Perl itself. See the LICENSE file for further details.
9  
10 use strict;
11 use warnings;
12  
13 use Fcntl ();
14  
15 use MIME::Base64 ();
16 use File::ShareDir ();
17 use Filesys::POSIX::IO::Handle ();
18  
19 use Build::PPK::Bundle ();
20 use Build::PPK::Dist ();
21  
22 use Carp;
23  
24 BEGIN {
25 use Exporter ();
26 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
27  
28 our $VERSION = '0.08';
29 our @ISA = qw(Exporter);
30  
31 our @EXPORT = ();
32 our @EXPORT_OK = ();
33 our %EXPORT_TAGS = ();
34 }
35  
36 sub build {
37 my ( $class, $main, $args ) = @_;
38 my @dists;
39  
40 my $bundle = Build::PPK::Bundle->new( $main, $args );
41  
42 #
43 # First, go through each of the distributions passed, crack them open,
44 # and add them to the bundle.
45 #
46 foreach my $path ( @{ $args->{'dists'} } ) {
47 my $dist = Build::PPK::Dist->new($path)->prepare;
48  
49 $bundle->add_dist($dist);
50  
51 #
52 # Retain this distribution for later usage and cleanup.
53 #
54 push @dists, $dist;
55 }
56  
57 #
58 # Second, go through each of the explicit module dependencies passed,
59 # and add them to the bundle as well.
60 #
61 foreach my $module ( keys %{ $args->{'modules'} } ) {
62 my $file = $args->{'modules'}->{$module};
63  
64 $bundle->add_module( $file, $module );
65 }
66  
67 #
68 # Verify the bundle contents prior to preparing it.
69 #
70 $bundle->check;
71  
72 #
73 # If the '-c' flag is passed, then skip the bundle preparation
74 # phase and only perform a sanity check.
75 #
76 return if $args->{'check'};
77  
78 #
79 # Prepare the bundle for assembly, and receive a filesystem object
80 # that represents the prepared result.
81 #
82 my $fs = $bundle->prepare();
83  
84 #
85 # Assemble the bundle!
86 #
87 $bundle->assemble($fs);
88  
89 #
90 # Clean up any distributions previously opened.
91 #
92 foreach my $dist (@dists) {
93 $dist->cleanup;
94 }
95  
96 return;
97 }
98  
99 1;