blib/lib/OS/Package/Role/Prune.pm

filter: Statementstmt 46.3% 19 / 41 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 45.6% 26 / 57 SCAR 29.0
CC
7
Cov
39%
prune
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 18.2
« blib/lib/OS/Package/Artifact/Role/Validate.pm ↑ Summary blib/lib/OS/Package/Role/Build.pm »
1 5 ▶use v5.14.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package OS::Package::Role::Prune;
5  
6 # ABSTRACT: Provides prune method for OS::Package object.
7 5 our $VERSION = '0.2.6'; # VERSION
8  
9 5 ▶use OS::Package::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub prune {
15  
16 0 ▶ my $self = shift;
Subroutine prune: not called CC=7 SCAR=40.3
Pod documented
17  
18 0 ▶ if ( !defined $self->fakeroot ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->fakeroot) 0 0 0
19 0 $LOGGER->warn('fakeroot is not defined');
20 0 return;
21 }
22  
23 0 ▶ if ( !-d $self->fakeroot ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $self->fakeroot) 0 0 0
24 0 $LOGGER->warn('fakeroot does not exist');
25 0 return 1;
26 }
27  
28 0 ▶ if ( defined $self->prune_files ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->prune_files) 0 0 0
29  
30 0 $LOGGER->info( sprintf 'prune files: %s', $self->name );
31  
32 0 foreach my $file ( @{ $self->prune_files } ) {
33  
34 0 my $pfile =
35 sprintf( '%s/%s/%s', $self->fakeroot, $self->prefix, $file );
36 0 $LOGGER->debug( sprintf 'removing file: %s', $pfile );
37  
38 0 unlink path($pfile)->stringify;
39 }
40 }
41  
42 0 ▶ if ( defined $self->prune_dirs ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->prune_dirs) 0 0 0
43  
44 0 $LOGGER->info( sprintf 'prune directories: %s', $self->name );
45  
46 0 foreach my $dir ( @{ $self->prune_dirs } ) {
47  
48 0 my $pdir =
49 sprintf( '%s/%s/%s', $self->fakeroot, $self->prefix, $dir );
50 0 $LOGGER->debug( sprintf 'removing directory: %s', $pdir );
51  
52 0 path($pdir)->remove_tree( { safe => 0 } );
53 }
54 }
55  
56 0 return 1;
57 }
58  
59 5 1;
60  
61 __END__
62  
63 =pod
64  
65 =encoding UTF-8
66  
67 =head1 NAME
68  
69 OS::Package::Role::Prune - Provides prune method for OS::Package object.
70  
71 =head1 VERSION
72  
73 version 0.2.6
74  
75 =head1 METHODS
76  
77 =head2 prune
78  
79 Deletes files and directories from the fakeroot.
80  
81 =head1 AUTHOR
82  
83 James F Wilkus <jfwilkus@cpan.org>
84  
85 =head1 COPYRIGHT AND LICENSE
86  
87 This software is Copyright (c) 2014 by James F Wilkus.
88  
89 This is free software, licensed under:
90  
91 The (three-clause) BSD License
92  
93 =cut
« blib/lib/OS/Package/Artifact/Role/Validate.pm ↑ Summary blib/lib/OS/Package/Role/Build.pm »