Which/Plugin.pm

filter: Statementstmt 50.0% 37 / 74 Branchbran 5.5% 1 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 52.3% 11 / 21 Podpod 100% 11 / 11 totaltotal 48.3% 60 / 124 CC 12 SCAR 23.7
CC
12
Cov
41%
exec
42.0
versions
12.0
cat
6.0
CRAP 10.7
« Which/Plugin/Bazaar.pm ↑ Summary Which/Plugin/CVS.pm »
1 package VCS::Which::Plugin;
2  
3 # Created on: 2009-05-16 17:50:07
4 # Create by: ivan
5 # $Id$
6 # $Revision$, $HeadURL$, $Date$
7 # $Revision$, $Source$, $Date$
8  
9 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Data::Dumper qw/Dumper/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use English qw/ -no_match_vars /;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use File::chdir;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 2 our $VERSION = version->new('0.6.9');
19  
20 2 has [qw/_installed _base/] => (
21 is => 'rw',
22 );
23  
24 55 ▶sub name {
Subroutine name: called CC=2 SCAR=7.0
Pod documented
25 55 my ($self) = @_;
26 55 ▶ my $package = ref $self ? ref $self : $self;
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 55 0 55
27  
28 2 ▶ no strict qw/refs/; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
29 55 return ${"$package\::name"};
30 }
31  
32 0 ▶sub exe {
Subroutine exe: not called CC=2 SCAR=11.6
Pod documented
33 0 my ($self) = @_;
34 0 ▶ my $package = ref $self ? ref $self : $self;
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 0 0 0
35  
36 2 ▶ no strict qw/refs/; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
37 0 return ${"$package\::exe"};
38 }
39  
40 0 ▶sub installed {
Subroutine installed: not called CC=1 SCAR=6.9
Pod documented
41 0 my ($self) = @_;
42  
43 0 return die $self->name . ' does not currently implement installed!';
44 }
45  
46 0 ▶sub used {
Subroutine used: not called CC=1 SCAR=6.9
Pod documented
47 0 my ($self) = @_;
48  
49 0 return die $self->name . ' does not currently implement used!';
50 }
51  
52 0 ▶sub uptodate {
Subroutine uptodate: not called CC=1 SCAR=6.9
Pod documented
53 0 my ($self) = @_;
54  
55 0 return die $self->name . ' does not currently implement uptodate!';
56 }
57  
58 0 ▶sub exec {
Subroutine exec: not called CC=6 SCAR=37.4
Pod documented
59 0 my ($self, $dir, @args) = @_;
60  
61 0 ▶ die $self->name . " not installed\n" if !$self->installed();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->installed 0 0 0
62  
63 0 local $CWD = $dir;
64  
65 0 ▶ if ($CWD ne $dir) {
Branch: 1 branch
BranchTrueFalseTotal
if ($VCS::Which::Plugin::CWD ne $dir) 0 0 0
66 0 for my $arg (@args) {
67 0 ▶ $arg = $CWD if $arg eq $dir;
Branch: 1 branch
BranchTrueFalseTotal
if $arg eq $dir 0 0 0
68 }
69 }
70  
71 0 my $cmd = $self->exe;
72 0 my $run = join ' ', $cmd, @args;
73 0 ▶ return defined wantarray ? `$run` : CORE::exec($run);
Branch: 1 branch
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
74 }
75  
76 0 ▶sub cat {
Subroutine cat: not called CC=2 SCAR=17.9
Pod documented
77 0 my ($self, $file, $revision) = @_;
78  
79 0 my $exe = $self->exe;
80 0 ▶ my $rev = $revision ? "-r$revision " : '';
Branch: 1 branch
BranchTrueFalseTotal
$revision ? : 0 0 0
81  
82 0 return `$exe cat $rev$file`;
83 }
84  
85 0 ▶sub pull {
Subroutine pull: not called CC=1 SCAR=6.9
Pod documented
86 0 die '"pull" not implemented for this Version Controll System!';
87 }
88  
89 0 ▶sub push {
Subroutine push: not called CC=1 SCAR=6.9
Pod documented
90 0 die '"push" not implemented for this Version Controll System!';
91 }
92  
93 0 ▶sub versions {
Subroutine versions: not called CC=3 SCAR=24.8
Pod documented
94 0 my ($self, $file, $oldest, $newest, $max) = @_;
95  
96 0 ▶ my %logs = %{ $self->log($file, $max ? "--limit $max" : '') };
Branch: 1 branch
BranchTrueFalseTotal
$max ? : 0 0 0
97 0 my @versions;
98  
99 0 for my $log (sort {$a <=> $b} keys %logs) {
100 0 CORE::push @versions, $logs{$log}{rev};# if $oldest && $logs{$log}{rev} <= $oldest;
101 }
102  
103 0 return @versions;
104 }
105  
106 0 ▶sub add {
Subroutine add: not called CC=2 SCAR=17.9
Pod documented
107 0 my ($self, $file, $revision) = @_;
108  
109 0 my $exe = $self->exe;
110 0 ▶ my $rev = $revision ? "-r$revision " : '';
Branch: 1 branch
BranchTrueFalseTotal
$revision ? : 0 0 0
111  
112 0 return `$exe add $rev$file`;
113 }
114  
115 2 1;
116  
117 __END__
« Which/Plugin/Bazaar.pm ↑ Summary Which/Plugin/CVS.pm »