blib/lib/OrePAN2/CLI/Inject.pm

filter: Statementstmt 88.1% 52 / 59 Branchbran 45.0% 9 / 20 Conditioncond 33.3% 2 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 2 totaltotal 73.5% 75 / 102 CC 14 SCAR 27.7
CC
14
Cov
74%
run
26.5
BEGIN
1.0
BEGIN
1.0
CRAP 15.9
« blib/lib/OrePAN2/Indexer.pm ↑ Summary blib/lib/OrePAN2/Auditor.pm »
1 package OrePAN2::CLI::Inject;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Getopt::Long ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use OrePAN2;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use OrePAN2::Indexer;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use OrePAN2::Injector;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use OrePAN2::Repository;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Pod::Usage;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub new {
15 2 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
16 2 bless {}, $class;
17 }
18  
19 sub run {
20 2 ▶ my ( $self, @args ) = @_;
Subroutine run: called CC=14 SCAR=32.8
Pod undocumented
21  
22 2 my $version;
23 2 my $generate_index = 1;
24 2 my $author = 'DUMMY';
25 2 my $author_subdir = '';
26 2 my $simple;
27 my $text;
28 2 my $enable_cache = 0;
29 2 my $p = Getopt::Long::Parser->new(
30 config => [qw(posix_default no_ignore_case auto_help)] );
31 2 $p->getoptions(
32 'version!' => \$version,
33 'generate-index!' => \$generate_index,
34 'author=s' => \$author,
35 'author_subdir=s' => \$author_subdir,
36 'simple!' => \$simple,
37 'text!' => \$text,
38 'cache!' => \$enable_cache,
39 );
40  
41 2 ▶ if ($version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version) 0 2 2
42 0 print "orepan2: $OrePAN2::VERSION\n";
43 }
44 2 ▶ my $directory = pop @ARGV or pod2usage(
Branch: 1 branch
BranchTrueFalseTotal
my $directory = pop @ARGV or pod2usage("-input", $0) 0 2 2
45 -input => $0,
46 );
47  
48 2 my $repository = OrePAN2::Repository->new(
49 directory => $directory,
50 compress_index => !$text,
51 simple => $simple,
52 );
53 2 ▶ if (@ARGV) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ARGV) { } 2 0 2
54 2 for (@ARGV) {
55 2 ▶ next unless /\S/;
Branch: 1 branch
BranchTrueFalseTotal
unless /\S/ 0 2 2
56 2 ▶ next if $enable_cache && $repository->has_cache($_);
Branch: 1 branch
BranchTrueFalseTotal
if $enable_cache and $repository->has_cache($_) 1 1 2
Condition66%2/3
$enable_cache and $repository->has_cache($_)
!ll&&!rl&&r
011
MC/DC50%1/2
$enable_cache and $repository->has_cache($_)
$enable_cache $repository->has_cache($_)
Truth table66%2/3
A and B
A= $enable_cacheB= $repository->has_cache($_)
ABresult
0X0
100
111
57  
58 1 my $tarpath = $repository->inject( $_, { author => $author, author_subdir => $author_subdir } );
59 1 print "Wrote $tarpath from $_\n";
60 }
61 }
62 else {
63 0 ▶ while (<>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline ARGV)) 0 0 0
64 0 chomp;
65 0 ▶ next unless /\S/;
Branch: 1 branch
BranchTrueFalseTotal
unless /\S/ 0 0 0
66 0 ▶ next if $enable_cache && $repository->has_cache($_);
Branch: 1 branch
BranchTrueFalseTotal
if $enable_cache and $repository->has_cache($_) 0 0 0
Condition0%0/3
$enable_cache and $repository->has_cache($_)
!ll&&!rl&&r
000
MC/DC0%0/2
$enable_cache and $repository->has_cache($_)
$enable_cache $repository->has_cache($_)
Truth table0%0/3
A and B
A= $enable_cacheB= $repository->has_cache($_)
ABresult
0X0
100
111
67  
68 0 my $tarpath = $repository->inject( $_, { author => $author, author_subdir => $author_subdir } );
69 0 print "Wrote $tarpath from $_\n";
70 }
71 }
72  
73 2 ▶ return unless $repository->cache->is_dirty;
Branch: 1 branch
BranchTrueFalseTotal
unless $repository->cache->is_dirty 1 1 2
74  
75 1 $repository->save_cache;
76  
77 1 ▶ if ($generate_index) {
Branch: 1 branch
BranchTrueFalseTotal
if ($generate_index) 1 0 1
78 1 $repository->make_index();
79 }
80 }
81  
82 2 1;
83  
« blib/lib/OrePAN2/Indexer.pm ↑ Summary blib/lib/OrePAN2/Auditor.pm »