blib/lib/App/supertouch.pm

filter: Statementstmt 72.3% 34 / 47 Branchbran 46.1% 12 / 26 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 61.9% 52 / 84 CC 16 SCAR 35.0
CC
16
Cov
62%
main
41.0
BEGIN
1.0
BEGIN
1.0
CRAP 33.0
↑ Summary
1 package App::supertouch;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Path::Tiny qw( path );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # ABSTRACT: Touch with directories
9 1 our $VERSION = '0.02'; # VERSION
10  
11  
12 sub main
13 3 ▶{
Subroutine main: called CC=16 SCAR=37.1
Pod undocumented
14 3 my(undef, @args) = @_;
15  
16 3 my $verbose = 0;
17 3 my $options = 1;
18  
19 3 foreach my $arg (@args)
20 {
21 3 ▶ if($options && $arg =~ /^-/)
Branch: 1 branch
BranchTrueFalseTotal
if ($options and $arg =~ /^-/) 0 3 3
Condition33%1/3
$options and $arg =~ /^-/
!ll&&!rl&&r
030
MC/DC0%0/2
$options and $arg =~ /^-/
$options $arg =~ /^-/
Truth table33%1/3
A and B
A= $optionsB= $arg =~ /^-/
ABresult
0X0
100
111
22 {
23 0 ▶ if($arg eq '--')
Branch: 2 branches
BranchTrueFalseTotal
if ($arg eq '--') { } 0 0 0
elsif ($arg eq '-v') { } 0 0 0
24 {
25 0 $options = 0;
26 }
27 elsif($arg eq '-v')
28 {
29 0 $verbose = 1;
30 }
31 0 next;
32 }
33 3 ▶ if($arg eq '')
Branch: 1 branch
BranchTrueFalseTotal
if ($arg eq "") 0 3 3
34 {
35 0 print STDERR "'' (empty) is not a legal filename";
36 0 return 2;
37 }
38 3 ▶ if($arg =~ s{[\\/]$}{})
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ s[[\\/]$][]) { } 1 2 3
39 {
40 1 my $dir = path($arg);
41 1 ▶ if($dir->is_file)
Branch: 1 branch
BranchTrueFalseTotal
if ($dir->is_file) 0 1 1
42 {
43 0 print STDERR "$dir is a file";
44 0 return 2;
45 }
46 1 ▶ unless(-d $dir)
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $dir) 1 0 1
47 {
48 0 ▶ print "DIR @{[ $dir ]}\n" if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 1 1
49 1 $dir->mkpath;
50 }
51 }
52 else
53 {
54 2 my $file = path($arg);
55 2 ▶ if($file->is_dir)
Branch: 1 branch
BranchTrueFalseTotal
if ($file->is_dir) 0 2 2
56 {
57 0 print STDERR "$file is a directory";
58 0 return 2;
59 }
60 2 ▶ unless(-d $file->parent)
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $file->parent) 2 0 2
61 {
62 0 ▶ print "DIR @{[ $file->parent ]}\n" if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 2 2
63 2 $file->parent->mkpath;
64 }
65 2 ▶ unless(-f $file)
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $file) 2 0 2
66 {
67 0 ▶ print "FILE @{[ $file ]}\n" if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 2 2
68 2 $file->touch;
69 }
70 }
71 }
72  
73 3 return 0;
74 }
75  
76 1 1;
77  
78 __END__
↑ Summary