VCI.pm

filter: Statementstmt 83.1% 64 / 77 Branchbran 80.0% 8 / 10 Conditioncond 81.8% 9 / 11 MC/DCmcdc 66.6% 4 / 6 Subroutinesub 54.5% 12 / 22 Podpod 100% 3 / 3 totaltotal 77.5% 100 / 129 CC 10 SCAR 12.0
CC
10
Cov
83%
_check_api
8.0
connect
3.0
missing_requirements
2.0
CRAP 3.3
« VCI/VCS/Hg/Committable.pm ↑ Summary VCI/VCS/Cvs/Commit.pm »
1 package VCI;
2 9 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 our $VERSION = '0.7.1';
5  
6 9 ▶use Class::MOP;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 ▶use VCI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 9 ▶use constant CLASS_BASE => 'VCI::VCS::';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 9 ▶use constant revisions_are_universal => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 9 ▶use constant revisions_are_global => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # Will also need a write_repo in the future, if we add commit support,
15 # for things like Hg that read from hgweb but have to write through the
16 # actual hg client.
17  
18 9 has 'repo' => (is => 'ro', isa => 'Str', required => 1);
19 9 has 'type' => (is => 'ro', isa => 'Str', required => 1);
20 has 'debug' => (is => 'ro', isa => 'VCI::Type::IntBool', coerce => 1,
21 4 ▶ default => sub { 0 });
Subroutine __ANON__: called CC=1 SCAR=0.0
22  
23 9 has 'repository' => (is => 'ro', isa => 'VCI::Abstract::Repository',
24 lazy_build => 1);
25  
26 9 has 'vci_class' => (is => 'ro', isa => 'ClassName', lazy_build => 1);
27 9 has 'commit_class' => (is => 'ro', isa => 'ClassName', lazy_build => 1);
28 9 has 'diff_class' => (is => 'ro', isa => 'ClassName', lazy_build => 1);
29 9 has 'directory_class' => (is => 'ro', isa => 'ClassName', lazy_build => 1);
30 9 has 'file_class' => (is => 'ro', isa => 'ClassName', lazy_build => 1);
31 9 has 'history_class' => (is => 'ro', isa => 'ClassName', lazy_build => 1);
32 9 has 'project_class' => (is => 'ro', isa => 'ClassName', lazy_build => 1);
33 9 has 'repository_class' => (is => 'ro', isa => 'ClassName', lazy_build => 1);
34  
35 5 ▶sub connect {
Subroutine connect: called CC=3 SCAR=11.1
Pod documented
36 5 my $class = shift;
37 5 my %params = @_;
38 5 my $type = $params{type};
39 5 ▶ my $vci_class = $params{vci_class} || CLASS_BASE . $type;
Condition50%1/2
$params{'vci_class'} || 'VCI::VCS::' . $type
l!l
05
MC/DC0%0/1
$params{'vci_class'} || 'VCI::VCS::' . $type
$params{'vci_class'}
Truth table50%1/2
A
A= $params{'vci_class'}
Aresult
11
00
40 5 ▶ eval { Class::MOP::load_class($vci_class) }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { Class::MOP::load_class($vci_class) } } or confess("$type is not a valid VCI driver: $@") 5 0 5
41 || confess("$type is not a valid VCI driver: $@");
42 5 my $vci = $vci_class->new(@_);
43 5 $vci->_check_api();
44 2 my $repo = $vci->repository;
45 2 return $repo;
46 }
47  
48 0 ▶sub missing_requirements { () }
Subroutine missing_requirements: not called CC=1 SCAR=6.9
Pod documented
49  
50 10 ▶sub api_version {
Subroutine api_version: called CC=1 SCAR=0.0
Pod documented
51 10 my $invocant = shift;
52 10 my $version = $invocant->VERSION;
53 10 $version =~ /^(\d+)\.(\d+)/;
54 10 return { major => int($1), api => int($2) };
55 }
56  
57 # Note that this default build_repository doesn't do anything about
58 # authentication.
59 2 ▶sub _build_repository {
Subroutine _build_repository: called CC=1 SCAR=0.0
60 2 my $self = shift;
61 2 return $self->repository_class->new(root => $self->repo, vci => $self);
62 }
63  
64 5 ▶sub _check_api {
Subroutine _check_api: called CC=8 SCAR=20.8
65 5 my $self = shift;
66 5 my $package = blessed $self;
67 5 my $driver = $self->api_version;
68 5 my $vci = __PACKAGE__->api_version;
69 5 my $driver_ver = "$driver->{major}.$driver->{api}";
70 5 my $vci_ver = "$vci->{major}.$vci->{api}";
71 5 ▶ if ($driver->{major} > $vci->{major}
Branch: 1 branch
BranchTrueFalseTotal
if ($driver->{"major"} > $vci->{"major"} or $driver->{"major"} == $vci->{"major"} and $driver->{"api"} > $vci->{"api"}) 2 3 5
Condition100%6/6
$driver->{"major"} > $vci->{"major"} or $driver->{"major"} == $vci->{"major"} and $driver->{"api"} > $vci->{"api"}
l!l&&r!l&&!r
113
$driver->{"major"} == $vci->{"major"} and $driver->{"api"} > $vci->{"api"}
!ll&&!rl&&r
121
MC/DC100%3/3
$driver->{"major"} > $vci->{"major"} or $driver->{"major"} == $vci->{"major"} and $driver->{"api"} > $vci->{"api"}
$driver->{"major"} > $vci->{"major"} $driver->{"major"} == $vci->{"major"} $driver->{"api"} > $vci->{"api"}
Truth table100%4/4
A or B and C
A= $driver->{"major"} > $vci->{"major"}B= $driver->{"major"} == $vci->{"major"}C= $driver->{"api"} > $vci->{"api"}
ABCresult
1XX1
0111
00X0
0100
72 || ($driver->{major} == $vci->{major} && $driver->{api} > $vci->{api}))
73 {
74 2 confess("This driver implements VCI $driver_ver but you only have"
75 . " VCI $vci_ver installed. You probably need to update VCI.");
76 }
77
78 3 ▶ if ($driver->{major} < $vci->{major}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($driver->{"major"} < $vci->{"major"}) 1 2 3
79 1 confess("VCI has a major version of $vci->{major} but your $package"
80 . " only implements VCI $driver->{major}. You probably need"
81 . " to upgrade $package.");
82 }
83
84 2 ▶ if ($driver->{major} == $vci->{major} && $driver->{api} < $vci->{api}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($driver->{"major"} == $vci->{"major"} and $driver->{"api"} < $vci->{"api"}) 1 1 2
Condition66%2/3
$driver->{"major"} == $vci->{"major"} and $driver->{"api"} < $vci->{"api"}
!ll&&!rl&&r
011
MC/DC50%1/2
$driver->{"major"} == $vci->{"major"} and $driver->{"api"} < $vci->{"api"}
$driver->{"major"} == $vci->{"major"} $driver->{"api"} < $vci->{"api"}
Truth table66%2/3
A and B
A= $driver->{"major"} == $vci->{"major"}B= $driver->{"api"} < $vci->{"api"}
ABresult
0X0
100
111
85 1 ▶ warn "$package only implements VCI $driver_ver but you have VCI"
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 1 0 1
86 . " $vci_ver installed. You probably need to upgrade $package."
87 if $self->debug;
88 }
89 }
90  
91 0 ▶sub _build_vci_class { CLASS_BASE . shift->type }
Subroutine _build_vci_class: not called CC=1 SCAR=6.9
92 0 ▶sub _build_commit_class { return shift->_class('Commit') }
Subroutine _build_commit_class: not called CC=1 SCAR=6.9
93 0 ▶sub _build_diff_class { return shift->_class('Diff') }
Subroutine _build_diff_class: not called CC=1 SCAR=6.9
94 0 ▶sub _build_directory_class { return shift->_class('Directory') }
Subroutine _build_directory_class: not called CC=1 SCAR=6.9
95 0 ▶sub _build_file_class { return shift->_class('File') }
Subroutine _build_file_class: not called CC=1 SCAR=6.9
96 0 ▶sub _build_history_class { return shift->_class('History') }
Subroutine _build_history_class: not called CC=1 SCAR=6.9
97 0 ▶sub _build_project_class { return shift->_class('Project') }
Subroutine _build_project_class: not called CC=1 SCAR=6.9
98 0 ▶sub _build_repository_class { return shift->_class('Repository') }
Subroutine _build_repository_class: not called CC=1 SCAR=6.9
99  
100 0 ▶sub _class {
Subroutine _class: not called CC=1 SCAR=6.9
101 0 my ($self, $class) = @_;
102 0 my $module = $self->vci_class . '::' . $class;
103 0 Class::MOP::load_class($module);
104 0 return $module;
105 }
106  
107 9 __PACKAGE__->meta->make_immutable;
108  
109 9 1;
110  
111 __END__
« VCI/VCS/Hg/Committable.pm ↑ Summary VCI/VCS/Cvs/Commit.pm »