| 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
| |||||||||||||||||||||||||||||
| 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
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
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 8 | ▶ | if ($merge_mode) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 21 | 6 | ▶ | die "--orepan and --cpan must be given together\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $orepan_file and defined $cpan_file
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
| |||||||||||||||||||||||||||||
| 22 | unless defined $orepan_file && defined $cpan_file; | ||||||||||||||||||||||||||||
| 23 | 5 | ▶ | die "stray positional arguments not allowed with --orepan/--cpan: @ARGV\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | if @ARGV; | ||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | ▶ | elsif ($protected_authors && @$protected_authors) { | |||||||||||||||||||||||||||
|
Condition66%2/3
$protected_authors and @$protected_authors
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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 || []
MC/DC100%1/1
$protected_authors || []
$protected_authors
Truth table100%2/2
A
A= $protected_authors
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 48 | 4 | ▶ | open $outfh, '>', $outfilename | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | or die "Cannot open $outfilename for writing: $!"; | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 4 | ▶ | my $outname = defined $outfilename ? $outfilename : 'STDOUT'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 4 | ▶ | print {$outfh} $index->as_string({simple => $simple}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | or die "Cannot write to $outname: $!\n"; | ||||||||||||||||||||||||||||
| 55 | 4 | ▶ | close $outfh | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | or die "Cannot close $outname: $!\n"; | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||||||||||