File Coverage

blib/lib/Shipwright/Source/SVN.pm
Criterion Covered Total %
statement 22 44 50.0
branch 1 12 8.3
condition n/a
subroutine 7 9 77.7
pod 2 2 100.0
total 32 67 47.7


line stmt bran cond sub pod time code
1             package Shipwright::Source::SVN;
2              
3 2     2   775 use warnings;
  2         1  
  2         69  
4 2     2   11 use strict;
  2         3  
  2         52  
5 2     2   9 use Shipwright::Util;
  2         4  
  2         184  
6 2     2   9 use File::Spec::Functions qw/catdir/;
  2         3  
  2         86  
7 2     2   8 use File::Path qw/remove_tree/;
  2         4  
  2         78  
8              
9 2     2   9 use base qw/Shipwright::Source::Base/;
  2         2  
  2         704  
10              
11             =head2 new
12              
13             =cut
14              
15             sub new {
16 1     1 1 2 my $class = shift;
17 1         9 my $self = $class->SUPER::new(@_);
18              
19 1 50       19 $self->name( $self->just_name( $self->source ) ) unless $self->name;
20 1         4 return $self;
21             }
22              
23             =head2 run
24              
25             =cut
26              
27             sub run {
28 0     0 1   my $self = shift;
29 0           $self->log->info( "preparing to run source: " . $self->source );
30 0           $self->_update_url( $self->name, 'svn:' . $self->source );
31              
32 0           $self->_run;
33 0           my $s;
34 0 0         if ( $self->is_compressed ) {
35 0           require Shipwright::Source::Compressed;
36 0           $s = Shipwright::Source::Compressed->new( %$self, _no_update_url => 1 );
37             }
38             else {
39 0           require Shipwright::Source::Directory;
40 0           $s = Shipwright::Source::Directory->new( %$self, _no_update_url => 1 );
41             }
42 0           $s->run(@_);
43             }
44              
45             =head2 _run
46              
47             =cut
48              
49             sub _run {
50 0     0     my $self = shift;
51 0           my $source = $self->source;
52              
53 0           my $path = catdir( $self->download_directory, $self->name );
54 0 0         my $cmd = [
55             $ENV{'SHIPWRIGHT_SVN'}, 'export',
56             $self->source, $path,
57             $self->version ? ( '-r', $self->version ) : (),
58             ];
59              
60 0 0         unless ( $self->version ) {
61 0           my ($out) =
62             run_cmd( [ $ENV{'SHIPWRIGHT_SVN'}, 'info', $source, ] );
63              
64 0 0         if ( $out =~ /^Revision: (\d+)/m ) {
65 0           $self->version($1);
66             }
67             }
68              
69 0 0         remove_tree($path) if -e $path;
70 0           $self->source( $path );
71 0           run_cmd($cmd);
72             }
73              
74             1;
75              
76             __END__