blib/lib/VCS/Lite/Common.pm

filter: Statementstmt 90.9% 40 / 44 Branchbran 63.6% 14 / 22 Conditioncond 35.7% 5 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 92.3% 12 / 13 Podpod 100% 9 / 9 totaltotal 72.0% 80 / 111 CC 16 SCAR 14.4
CC
16
Cov
74%
up_generation
12.0
latest
7.1
_mumble
3.2
CRAP 4.2
« blib/lib/VCS/Lite/Shell.pm ↑ Summary blib/lib/VCS/Lite/Element/Binary.pm »
1 package VCS::Lite::Common;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 our $VERSION = '0.11';
7  
8 #----------------------------------------------------------------------------
9  
10 11 ▶our $username = $ENV{VCSLITE_USER} || $ENV{USER};
Condition33%1/3
$ENV{'VCSLITE_USER'} || $ENV{'USER'}
l!l&&r!l&&!r
0011
MC/DC0%0/2
$ENV{'VCSLITE_USER'} || $ENV{'USER'}
$ENV{'VCSLITE_USER'} $ENV{'USER'}
Truth table33%1/3
A || B
A= $ENV{'VCSLITE_USER'}B= $ENV{'USER'}
ABresult
1X1
011
000
11 11 our $default_store = 'Storable';
12  
13 11 ▶use File::Spec::Functions qw(splitpath splitdir);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 #----------------------------------------------------------------------------
16  
17 sub path {
18 592 ▶ my $self = shift;
Subroutine path: called CC=3 SCAR=11.0
Pod documented
19  
20 592 ▶ return $self->{path} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 403 189 592
21  
22 189 my $newpath = shift;
23  
24 189 ▶ if ($self->{path} ne $newpath) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"path"} ne $newpath) 6 183 189
25 6 $self->{path} = $newpath;
26 6 $self->save;
27 }
28 }
29  
30 sub name {
31 22 ▶ my $self = shift;
Subroutine name: called CC=2 SCAR=7.1
Pod documented
32 22 my ($vol, $dir, $fil) = splitpath($self->path);
33  
34 22 ▶ $fil || (splitdir $dir)[-1];
Branch: 1 branch
BranchTrueFalseTotal
$fil or (splitdir($dir))[-1] 0 22 22
35 }
36  
37 sub store {
38 140 ▶ my $self = shift;
Subroutine store: called CC=1 SCAR=0.0
Pod documented
39  
40 140 $self->{store};
41 }
42  
43 sub save {
44 130 ▶ my ($self) = @_;
Subroutine save: called CC=1 SCAR=0.0
Pod documented
45  
46 130 $self->store->save($self);
47 }
48  
49 sub _mumble {
50 115 ▶ my ($self,$msg) = @_;
Subroutine _mumble: called CC=3 SCAR=11.7
51  
52 115 ▶ print $msg,"\n" if exists($self->{verbose}) && $self->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"verbose"} and $self->{"verbose"} 0 115 115
Condition66%2/3
exists $self->{"verbose"} and $self->{"verbose"}
!ll&&!rl&&r
48670
MC/DC0%0/2
exists $self->{"verbose"} and $self->{"verbose"}
exists $self->{"verbose"} $self->{"verbose"}
Truth table66%2/3
A and B
A= exists $self->{"verbose"}B= $self->{"verbose"}
ABresult
0X0
100
111
53 }
54  
55 sub latest {
56 174 ▶ my ($self,$base) = @_;
Subroutine latest: called CC=6 SCAR=19.6
Pod documented
57  
58 174 ▶ $base .= '.' if $base && $base =~ /\d$/;
Branch: 1 branch
BranchTrueFalseTotal
if $base and $base =~ /\d$/ 0 174 174
Condition33%1/3
$base and $base =~ /\d$/
!ll&&!rl&&r
17400
MC/DC0%0/2
$base and $base =~ /\d$/
$base $base =~ /\d$/
Truth table33%1/3
A and B
A= $baseB= $base =~ /\d$/
ABresult
0X0
100
111
59 174 ▶ $base ||= '';
Condition50%1/2
$base ||= ""
l!l
0174
MC/DC0%0/1
$base ||= ""
$base
Truth table50%1/2
A
A= $base
Aresult
11
00
60 174 ▶ return 0 if !exists($self->{latest});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"latest"} 121 53 174
61 53 ▶ $self->{latest}{$base} || 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"latest"}{$base} or 0 0 53 53
62 }
63  
64 sub up_generation {
65 0 ▶ my ($self,$gen) = @_;
Subroutine up_generation: not called CC=3 SCAR=24.8
Pod documented
66  
67 0 ▶ $gen =~ s/\.0$// or $gen =~ s/([1-9]\d*)$/$1-1/e or return;
Branch: 1 branch
BranchTrueFalseTotal
$gen =~ s/\.0$// or $gen =~ s/([1-9]\d*)$/$1 - 1;/e or return 0 0 0
Condition0%0/3
$gen =~ s/\.0$// or $gen =~ s/([1-9]\d*)$/$1 - 1;/e
l!l&&r!l&&!r
000
MC/DC0%0/2
$gen =~ s/\.0$// or $gen =~ s/([1-9]\d*)$/$1 - 1;/e
$gen =~ s/\.0$// $gen =~ s/([1-9]\d*)$/$1 - 1;/e
Truth table0%0/3
A or B
A= $gen =~ s/\.0$//B= $gen =~ s/([1-9]\d*)$/$1 - 1;/e
ABresult
1X1
011
000
68 0 $gen;
69 }
70  
71 sub user {
72 162 ▶ my $obj = shift;
Subroutine user: called CC=2 SCAR=6.9
Pod documented
73 162 ▶ @_ ? ($username = shift) : $username;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 6 156 162
74 }
75  
76 sub default_store {
77 218 ▶ my $obj = shift;
Subroutine default_store: called CC=2 SCAR=7.2
Pod documented
78 218 ▶ @_ ? ($default_store = shift) : $default_store;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 218 218
79 }
80  
81 sub parent {
82 2 ▶ my $self = shift;
Subroutine parent: called CC=2 SCAR=7.1
Pod documented
83  
84 2 ▶ return unless exists $self->{parent};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"parent"} 0 2 2
85  
86 2 $self->{parent_store}->retrieve($self->{parent});
87 }
88  
89 11 1;
90  
91 __END__
« blib/lib/VCS/Lite/Shell.pm ↑ Summary blib/lib/VCS/Lite/Element/Binary.pm »