script/orepan2-merge-index

filter: Statementstmt 100% 36 / 36 Branchbran 81.8% 18 / 22 Conditioncond 72.7% 8 / 11 MC/DCmcdc 57.1% 4 / 7 Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 87.5% 70 / 80 CC 1 SCAR 0.0
CC
1
Cov
90%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/OrePAN2/Logger.pm ↑ Summary script/orepan2-gc »
1 #!perl
2 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use OrePAN2::Index;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 9 my $p = Getopt::Long::Parser->new(
8 config => [qw(posix_default no_ignore_case auto_help)]
9 );
10 9 ▶$p->getoptions(
Branch: 1 branch
BranchTrueFalseTotal
$p->getoptions("o=s", \my $outfilename, "simple!", \my $simple, "orepan=s", \my $orepan_file, "cpan=s", \my $cpan_file, "protect-orepan-author=s\@", \my $protected_authors) or die "Usage error\n" 8 1 9
11 'o=s' => \my $outfilename,
12 'simple!' => \my $simple,
13 'orepan=s' => \my $orepan_file,
14 'cpan=s' => \my $cpan_file,
15 'protect-orepan-author=s@' => \my $protected_authors,
16 ) or die "Usage error\n";
17  
18 8 ▶my $merge_mode = defined $orepan_file || defined $cpan_file;
Condition66%2/3
defined $orepan_file || defined $cpan_file
l!l&&r!l&&!r
602
MC/DC50%1/2
defined $orepan_file || defined $cpan_file
defined $orepan_file defined $cpan_file
Truth table66%2/3
A || B
A= defined $orepan_fileB= defined $cpan_file
ABresult
1X1
011
000
19  
20 8 ▶if ($merge_mode) {
Branch: 2 branches
BranchTrueFalseTotal
if ($merge_mode) { } 6 2 8
elsif ($protected_authors and @$protected_authors) { } 1 2 3
21 6 ▶ die "--orepan and --cpan must be given together\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $orepan_file and defined $cpan_file 1 5 6
Condition66%2/3
defined $orepan_file and defined $cpan_file
!ll&&!rl&&r
015
MC/DC50%1/2
defined $orepan_file and defined $cpan_file
defined $orepan_file defined $cpan_file
Truth table66%2/3
A and B
A= defined $orepan_fileB= defined $cpan_file
ABresult
0X0
100
111
22 unless defined $orepan_file && defined $cpan_file;
23 5 ▶ die "stray positional arguments not allowed with --orepan/--cpan: @ARGV\n"
Branch: 1 branch
BranchTrueFalseTotal
if @ARGV 1 4 5
24 if @ARGV;
25 }
26 ▶elsif ($protected_authors && @$protected_authors) {
Condition66%2/3
$protected_authors and @$protected_authors
!ll&&!rl&&r
101
MC/DC50%1/2
$protected_authors and @$protected_authors
$protected_authors @$protected_authors
Truth table66%2/3
A and B
A= $protected_authorsB= @$protected_authors
ABresult
0X0
100
111
27 1 die "--protect-orepan-author only works with --orepan and --cpan\n";
28 }
29  
30 5 my $index;
31 5 ▶if ($merge_mode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($merge_mode) { } 4 1 5
32 4 $index = OrePAN2::Index->new();
33 4 $index->load($orepan_file, {replace => 1});
34  
35 4 my $cpan_index = OrePAN2::Index->new();
36 4 $cpan_index->load($cpan_file, {replace => 1});
37 3 ▶ $index->merge($cpan_index, protect_author => $protected_authors || []);
Condition100%2/2
$protected_authors || []
l!l
21
MC/DC100%1/1
$protected_authors || []
$protected_authors
Truth table100%2/2
A
A= $protected_authors
Aresult
11
00
38 }
39 else {
40 1 $index = OrePAN2::Index->new();
41 1 for my $filename (@ARGV) {
42 2 $index->load($filename, {replace => 1});
43 }
44 }
45  
46 4 my $outfh = *STDOUT;
47 4 ▶if (defined $outfilename) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $outfilename) 4 0 4
48 4 ▶ open $outfh, '>', $outfilename
Branch: 1 branch
BranchTrueFalseTotal
open $outfh, ">", $outfilename or die "Cannot open $outfilename for writing: $!" 4 0 4
49 or die "Cannot open $outfilename for writing: $!";
50 }
51  
52 4 ▶my $outname = defined $outfilename ? $outfilename : 'STDOUT';
Branch: 1 branch
BranchTrueFalseTotal
defined $outfilename ? : 4 0 4
53 4 ▶print {$outfh} $index->as_string({simple => $simple})
Branch: 1 branch
BranchTrueFalseTotal
print {$outfh;} $index->as_string({"simple", $simple}) or die "Cannot write to ${outname}: $!\n" 4 0 4
54 or die "Cannot write to $outname: $!\n";
55 4 ▶close $outfh
Branch: 1 branch
BranchTrueFalseTotal
close $outfh or die "Cannot close ${outname}: $!\n" 3 1 4
56 or die "Cannot close $outname: $!\n";
57  
58 __END__
« blib/lib/OrePAN2/Logger.pm ↑ Summary script/orepan2-gc »