_build/lib/MyModuleBuilder.pm

filter: Statementstmt 60.7% 96 / 158 Branchbran 35.7% 20 / 56 Conditioncond 33.3% 3 / 9 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 81.4% 22 / 27 Podpod 0.0% 0 / 17 totaltotal 52.2% 142 / 272 CC 37 SCAR 25.3
CC
37
Cov
53%
_files_in
39.8
ACTION_debian
30.0
ACTION_redhat
30.0
CRAP 12.6
↑ Summary Build »
1 package MyModuleBuilder;
2 1 ▶use Module::Build;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 our @ISA = qw(Module::Build);
4  
5 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶ use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶ use File::Copy;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶ use File::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶ use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶ use File::Spec::Functions qw( catfile catdir rel2abs );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # override and add a few things
15  
16 sub new {
17 0 ▶ my $class = shift;
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
18  
19 0 my $self = $class->SUPER::new(@_);
20  
21 0 my $blib = $self->{properties}{blib};
22 0 my $sbin = catfile($blib, 'sbin');
23 0 $self->{properties}{sbindoc_dirs} = [ $sbin ];
24  
25 0 return $self;
26  
27 }
28  
29 # create man pages for files within sbin
30  
31 sub manify_sbin_pods {
32 1 ▶ my $self = shift;
Subroutine manify_sbin_pods: called CC=5 SCAR=19.0
Pod undocumented
33  
34 my $files = $self->_find_pods(
35 $self->{properties}{sbindoc_dirs},
36 1 exclude => [ $self->file_qr('\.bat$') ]
37 );
38  
39 1 ▶ return unless keys %$files;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %$files 0 1 1
40  
41 1 my $mandir = File::Spec->catdir( $self->blib, 'bindoc' );
42 1 File::Path::mkpath( $mandir, 0, oct(777) );
43  
44 1 require Pod::Man;
45  
46 1 foreach my $file (keys %$files) {
47  
48 # Pod::Simple based parsers only support one document per instance.
49 # This is expected to change in a future version
50 # (Pod::Simple > 3.03).
51  
52 # binaries go in section 1p
53  
54 1 my $parser = Pod::Man->new( section => '1p' );
55 1 my $manpage = $self->man1page_name( $file ) . '.' .
56 $self->config( 'man1ext' );
57  
58 1 my $outfile = File::Spec->catfile($mandir, $manpage);
59  
60 1 ▶ next if $self->up_to_date( $file, $outfile );
Branch: 1 branch
BranchTrueFalseTotal
if $self->up_to_date($file, $outfile) 1 0 1
61  
62 0 $self->log_verbose("Manifying $file -> $outfile\n");
63  
64 0 ▶ eval { $parser->parse_from_file( $file, $outfile ); 1 }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $parser->parse_from_file($file, $outfile); 1 } } or $self->log_warn("Error creating '${outfile}': $@\n") 0 0 0
65 or $self->log_warn("Error creating '$outfile': $@\n");
66
67 0 $files->{$file} = $outfile;
68  
69 }
70  
71 }
72  
73 # remove redhat stuff when installing to debian
74  
75 sub ACTION_debian {
76 0 ▶ my $self = shift;
Subroutine ACTION_debian: not called CC=5 SCAR=34.0
Pod undocumented
77  
78 # cleanup the init.d directory
79  
80 0 my $destdir = $self->destdir;
81 0 my @files = ('xas-spooler', 'xas-collector');
82 0 my @names = map { catfile($destdir, 'etc', 'init.d', $_ . '.rhel') } @files;
83  
84 0 foreach my $file (@names) {
85  
86 0 ▶ unlink $file if (-e $file);
Branch: 1 branch
BranchTrueFalseTotal
if -e $file 0 0 0
87  
88 }
89  
90 0 @names = map { catfile($destdir, 'etc', 'init.d', $_ . '.debian') } @files;
91  
92 0 foreach my $file (@names) {
93  
94 0 ▶ if ( -e $file) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $file) 0 0 0
95  
96 0 my ($name, $path, $ext) = fileparse($file, qr/\.[^.]*/);
97 0 my $new = catfile($path, $name);
98  
99 0 move($file, $new);
100  
101 }
102  
103 }
104  
105 }
106  
107 # remove debian stuff when installing to redhat
108  
109 sub ACTION_redhat {
110 0 ▶ my $self = shift;
Subroutine ACTION_redhat: not called CC=5 SCAR=34.0
Pod undocumented
111  
112 # cleanup the init.d directory
113  
114 0 my $destdir = $self->destdir;
115 0 my @files = ('xas-spooler', 'xas-collector');
116 0 my @names = map { catfile($destdir, 'etc', 'init.d', $_ . '.debian') } @files;
117  
118 0 foreach my $file (@names) {
119  
120 0 ▶ unlink $file if (-e $file);
Branch: 1 branch
BranchTrueFalseTotal
if -e $file 0 0 0
121  
122 }
123  
124 0 @names = map { catfile($destdir, 'etc', 'init.d', $_ . '.rhel') } @files;
125  
126 0 foreach my $file (@names) {
127  
128 0 ▶ if ( -e $file) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $file) 0 0 0
129  
130 0 my ($name, $path, $ext) = fileparse($file, qr/\.[^.]*/);
131 0 my $new = catfile($path, $name);
132  
133 0 move($file, $new);
134  
135 }
136  
137 }
138  
139 }
140  
141 # correctly process additional directories
142  
143 sub process_etc_files {
144 1 ▶ my $self = shift;
Subroutine process_etc_files: called CC=3 SCAR=11.0
Pod undocumented
145  
146 1 my $result;
147 1 my $dir = catfile('blib', 'etc');
148 1 my $files = $self->find_etc_files;
149  
150 1 ▶ mkdir $dir unless (-e $dir);
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dir 0 1 1
151  
152 1 ▶ while (my ($from, $to) = each %$files) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$files) 1 1 2
153  
154 1 $to = catfile('blib', $to);
155 1 $result = $self->copy_if_modified(from => $from, to => $to);
156  
157 }
158  
159 1 return $self;
160  
161 }
162  
163 sub process_sbin_files {
164 1 ▶ my $self = shift;
Subroutine process_sbin_files: called CC=5 SCAR=17.4
Pod undocumented
165  
166 1 my $result;
167 1 my $dir = catfile('blib', 'sbin');
168 1 my $files = $self->find_sbin_files;
169  
170 1 ▶ mkdir $dir unless (-e $dir);
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dir 0 1 1
171  
172 1 ▶ while (my ($from, $to) = each %$files) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$files) 1 1 2
173  
174 1 $to = catfile('blib', $to);
175 1 ▶ $result = $self->copy_if_modified(from => $from, to => $to) or next;
Branch: 1 branch
BranchTrueFalseTotal
$result = $self->copy_if_modified("from", $from, "to", $to) or next 1 0 1
176 0 ▶ $self->fix_shebang_line($result) unless $self->is_vmsish;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_vmsish 0 0 0
177 0 $self->make_executable($result);
178  
179 }
180  
181 1 $self->manify_sbin_pods();
182 1 return $self;
183  
184 }
185  
186 sub process_initd_files {
187 1 ▶ my $self = shift;
Subroutine process_initd_files: called CC=4 SCAR=14.1
Pod undocumented
188  
189 1 my $result;
190 1 my $dir = catfile('blib', 'init.d');
191 1 my $files = $self->find_initd_files;
192  
193 1 ▶ mkdir $dir unless (-e $dir);
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dir 0 1 1
194  
195 1 ▶ while (my ($from, $to) = each %$files) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$files) 2 1 3
196  
197 2 $to = catfile('blib', $to);
198 2 ▶ $result = $self->copy_if_modified(from => $from, to => $to) or next;
Branch: 1 branch
BranchTrueFalseTotal
$result = $self->copy_if_modified("from", $from, "to", $to) or next 2 0 2
199 0 $self->make_executable($result);
200  
201 }
202  
203 1 return $self;
204  
205 }
206  
207 sub process_sysconf_files {
208 1 ▶ my $self = shift;
Subroutine process_sysconf_files: called CC=3 SCAR=11.0
Pod undocumented
209  
210 1 my $result;
211 1 my $dir = catfile('blib', 'sysconfig');
212 1 my $files = $self->find_sysconf_files;
213  
214 1 ▶ mkdir $dir unless (-e $dir);
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dir 0 1 1
215  
216 1 ▶ while (my ($from, $to) = each %$files) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$files) 1 1 2
217  
218 1 $to = catfile('blib', $to);
219 1 $result = $self->copy_if_modified(from => $from, to => $to);
220  
221 }
222  
223 1 return $self;
224  
225 }
226  
227 sub process_profiled_files {
228 0 ▶ my $self = shift;
Subroutine process_profiled_files: not called CC=4 SCAR=30.0
Pod undocumented
229  
230 0 my $result;
231 0 my $dir = catfile('blib', 'profile.d');
232 0 my $files = $self->find_profiled_files;
233  
234 0 ▶ mkdir $dir unless (-e $dir);
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dir 0 0 0
235  
236 0 ▶ while (my ($from, $to) = each %$files) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$files) 0 0 0
237  
238 0 $to = catfile('blib', $to);
239 0 ▶ $result = $self->copy_if_modified(from => $from, to => $to) or next;
Branch: 1 branch
BranchTrueFalseTotal
$result = $self->copy_if_modified("from", $from, "to", $to) or next 0 0 0
240 0 $self->make_executable($result);
241  
242 }
243  
244 0 return $self;
245  
246 }
247  
248 sub process_logrotated_files {
249 1 ▶ my $self = shift;
Subroutine process_logrotated_files: called CC=3 SCAR=11.0
Pod undocumented
250  
251 1 my $result;
252 1 my $dir = catfile('blib', 'logrotate.d');
253 1 my $files = $self->find_logrotated_files;
254  
255 1 ▶ mkdir $dir unless (-e $dir);
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dir 0 1 1
256  
257 1 ▶ while (my ($from, $to) = each %$files) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$files) 1 1 2
258  
259 1 $to = catfile('blib', $to);
260 1 $result = $self->copy_if_modified(from => $from, to => $to);
261  
262 }
263  
264 1 return $self;
265  
266 }
267  
268 1 ▶ sub find_etc_files { shift->find_all_files_no_scm('etc'); }
Subroutine find_etc_files: called CC=1 SCAR=0.0
Pod undocumented
269 1 ▶ sub find_sbin_files { shift->find_all_files_no_scm('sbin'); }
Subroutine find_sbin_files: called CC=1 SCAR=0.0
Pod undocumented
270 1 ▶ sub find_initd_files { shift->find_all_files_no_scm('init.d'); }
Subroutine find_initd_files: called CC=1 SCAR=0.0
Pod undocumented
271 1 ▶ sub find_sysconf_files { shift->find_all_files_no_scm('sysconfig'); }
Subroutine find_sysconf_files: called CC=1 SCAR=0.0
Pod undocumented
272 0 ▶ sub find_profiled_files { shift->find_all_files_no_scm('profile.d'); }
Subroutine find_profiled_files: not called CC=1 SCAR=6.9
Pod undocumented
273 1 ▶ sub find_logrotated_files { shift->find_all_files_no_scm('logrotate.d'); }
Subroutine find_logrotated_files: called CC=1 SCAR=0.0
Pod undocumented
274  
275 sub find_all_files_no_scm {
276 5 ▶ my ($self, $dir) = @_;
Subroutine find_all_files_no_scm: called CC=1 SCAR=0.2
Pod undocumented
277  
278 my $sub = sub {
279 11 ▶ return ((($File::Find::name !~ /SVN/i) and
Subroutine __ANON__: called CC=3 SCAR=13.1
Condition50%3/6
!($File::Find::name =~ /SVN/i || $File::Find::name =~ /GIT/i) && -f $File::Find::name
!ll&&!rl&&r
056
$File::Find::name =~ /SVN/i || $File::Find::name =~ /GIT/i
l!l&&r!l&&!r
0011
MC/DC33%1/3
!($File::Find::name =~ /SVN/i || $File::Find::name =~ /GIT/i) && -f $File::Find::name
$File::Find::name =~ /SVN/i $File::Find::name =~ /GIT/i -f $File::Find::name
Truth table50%2/4
not(A || B) && C
A= $File::Find::name =~ /SVN/iB= $File::Find::name =~ /GIT/iC= -f $File::Find::name
ABCresult
1XX0
01X0
0000
0011
280 ($File::Find::name !~ /GIT/i)) and
281 ( -f $File::Find::name));
282 5 };
283  
284 5 return { map {$_, $_} @{ $self->rscan_dir($dir, $sub) } };
285  
286 }
287  
288 # fix for scm files in the script directory
289  
290 sub _files_in {
291 1 ▶ my ($self, $dir) = @_;
Subroutine _files_in: called CC=7 SCAR=36.8
292 1 ▶ return unless -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 1 0 1
293  
294 0 local *DH;
295 0 ▶ opendir DH, $dir or die "Can't read directory $dir: $!";
Branch: 1 branch
BranchTrueFalseTotal
opendir DH, $dir or die "Can't read directory ${dir}: $!" 0 0 0
296  
297 0 my @files;
298 0 ▶ while (defined (my $file = readdir DH)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $file = readdir DH)) 0 0 0
299 0 my $full_path = File::Spec->catfile($dir, $file);
300 0 ▶ next if -d $full_path;
Branch: 1 branch
BranchTrueFalseTotal
if -d $full_path 0 0 0
301 0 ▶ next if (($file =~ /SVN/i) or ($file =~ /GIT/i));
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ /SVN/i or $file =~ /GIT/i 0 0 0
Condition0%0/3
$file =~ /SVN/i or $file =~ /GIT/i
l!l&&r!l&&!r
000
MC/DC0%0/2
$file =~ /SVN/i or $file =~ /GIT/i
$file =~ /SVN/i $file =~ /GIT/i
Truth table0%0/3
A or B
A= $file =~ /SVN/iB= $file =~ /GIT/i
ABresult
1X1
011
000
302 0 push @files, $full_path;
303 }
304 0 return @files;
305 }
306  
307 1 1;
↑ Summary Build »