blib/lib/OrePAN2/CLI/Inject.pm

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