blib/lib/VIM/Packager/Git.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 56 CC 2 SCAR 10.0
CC
2
Cov
0%
clone
6.0
rand_hash
2.0
new
2.0
CRAP 2.7
1 package VIM::Packager::Git;
2 use warnings;
3 use strict;
4 use File::Path qw(mkpath rmtree);
5  
6 use constant build_dir => ( $ENV{VIM_BUILD_DIR} || '/' . File::Spec->join( qw(tmp vim-build) ) );
7  
8 sub rand_hash { join "", map { ( 'a' .. 'z' )[ rand(26) ] } 1 .. $_[0] }
9  
10  
11 sub new {
12 return bless {} , shift;
13 }
14  
15 sub clone {
16 my ($self , $clone_path) = @_;
17  
18 mkpath [ build_dir ] unless -e build_dir;
19 chdir build_dir;
20  
21 my ($build_name) = ( $clone_path =~ m{\/([a-zA-Z0-9-_.]+?)$} );
22  
23 my $hash = rand_hash(5);
24 $build_name =~ s{\.git$}{}g;
25 $build_name .= '-' . $hash;
26  
27 $self->{build_name} = $build_name;
28 $self->{build_path} = File::Spec->join( build_dir , $build_name );
29  
30 my $ret = system(qq{git clone $clone_path $build_name});
31 chdir $build_name;
32  
33 # do install
34 # from here
35 return $build_name;
36 }
37  
38  
39 sub build_path { $_[0]->{build_path} }
40 sub build_name { $_[0]->{build_name} }
41  
42  
43 sub cleanup {
44 chdir "..";
45 my $self = shift;
46 rmtree [ $self->{build_name} ];
47 }
48  
49 1;