Update.pm

filter: Statementstmt 72.5% 29 / 40 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 100% 2 / 2 totaltotal 74.1% 43 / 58 CC 6 SCAR 13.2
CC
6
Cov
72%
upmake
6.0
read_files_list
5.0
BEGIN
1.0
CRAP 3.7
« Update/Bakefile0.pm ↑ Summary
1 package Makefile::Update;
2  
3 # ABSTRACT: Update make files.
4  
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 our @EXPORT = qw(read_files_list upmake);
12  
13 4 our $VERSION = '0.2'; # VERSION
14  
15  
16  
17 sub read_files_list
18 {
19 1 ▶ my ($fh) = @_;
Subroutine read_files_list: called CC=5 SCAR=16.1
Pod documented
20  
21 1 my ($var, %vars);
22 1 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 10 1 11
23 10 chomp;
24 10 s/#.*$//;
25 10 s/^\s+//;
26 10 s/\s+$//;
27 10 ▶ next if !$_;
Branch: 1 branch
BranchTrueFalseTotal
unless $_ 4 6 10
28  
29 6 ▶ if (/^(\w+)\s*=$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^(\w+)\s*=$/) { } 2 4 6
30 2 $var = $1;
31 } else {
32 4 ▶ die "Unexpected contents outside variable definition at line $.\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $var 0 4 4
33 unless defined $var;
34 4 push @{$vars{$var}}, $_;
35 }
36 }
37  
38 1 return \%vars;
39 }
40  
41  
42 sub upmake
43 {
44 0 ▶ my ($fname, $updater, @args) = @_;
Subroutine upmake: not called CC=2 SCAR=17.9
Pod documented
45  
46 0 my $fname_new = "$fname.upmake.new"; # TODO make it more unique
47  
48 0 open my $in, '<', $fname;
49 0 open my $out, '>', $fname_new;
50  
51 0 my $changed = $updater->($in, $out, @args);
52  
53 0 close $in;
54 0 close $out;
55  
56 0 ▶ if ($changed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($changed) { } 0 0 0
57 0 rename $fname_new, $fname;
58 } else {
59 0 unlink $fname_new;
60 }
61  
62 0 $changed
63 }
64  
65 4 1;
66  
67 __END__
« Update/Bakefile0.pm ↑ Summary