File Coverage

blib/lib/Shipwright.pm
Criterion Covered Total %
statement 38 38 100.0
branch 8 8 100.0
condition n/a
subroutine 9 9 100.0
pod 1 1 100.0
total 56 56 100.0


line stmt bran cond sub pod time code
1             package Shipwright;
2              
3 15     15   97122 use warnings;
  15         23  
  15         519  
4 15     15   59 use strict;
  15         19  
  15         360  
5 15     15   5216 use version; our $VERSION = qv('2.4.40');
  15         18266  
  15         84  
6              
7 15     15   1149 use base qw/Shipwright::Base/;
  15         19  
  15         5786  
8              
9             __PACKAGE__->mk_accessors(qw/backend source build log_level log_file/);
10              
11 15     15   4915 use Shipwright::Logger;
  15         43  
  15         538  
12 15     15   85 use File::Spec::Functions qw/catfile tmpdir/;
  15         25  
  15         799  
13 15     15   68 use Shipwright::Util;
  15         22  
  15         836  
14             # strawberry perl's build make is 'dmake'
15 15     15   8166 use File::Which 'which';
  15         12748  
  15         4651  
16             $ENV{SHIPWRIGHT_MAKE} ||= which('make') || which('dmake') || which( 'nmake' ) || 'make';
17             $ENV{SHIPWRIGHT_SVK} ||= which('svk') || 'svk';
18             $ENV{SHIPWRIGHT_SVN} ||= which('svn') || 'svn';
19             $ENV{SHIPWRIGHT_GIT} ||= which('git') || 'git';
20             $ENV{SHIPWRIGHT_DZIL} ||= which('dzil') || 'dzil';
21             $ENV{SHIPWRIGHT_LWP_TIMEOUT} ||= 1200;
22              
23             $ENV{PERL_MM_USE_DEFAULT} = 1; # always true
24              
25             # FTP_PASSIVE is true by default,
26             # since many sites use this nowadays.
27             unless ( defined $ENV{FTP_PASSIVE} ) {
28             $ENV{FTP_PASSIVE} = 1;
29             }
30              
31             =head2 new
32              
33             =cut
34              
35             sub new {
36 5     5 1 3903 my $class = shift;
37              
38 5         35 my %args = (
39             log_level => undef,
40             log_file => undef,
41             repository => undef,
42             source => undef,
43             @_
44             );
45 5 100       30 $args{log_level} = $args{log_level} ? uc $args{log_level} : 'FATAL';
46              
47 5 100       33 $args{log_file} = '-' unless $args{log_file};
48              
49 5         20 my $self = {
50             log_level => $args{log_level},
51             log_file => $args{log_file},
52             };
53              
54 5         12 bless $self, $class;
55              
56 5         32 Shipwright::Logger->new($self);
57              
58 5 100       15 if ( $args{repository} ) {
59 4         1523 require Shipwright::Backend;
60 4         47 $self->backend( Shipwright::Backend->new(%args) );
61             }
62              
63 5 100       23 if ( $args{source} ) {
64 1         445 require Shipwright::Source;
65 1         9 $self->source( Shipwright::Source->new(%args) );
66             }
67              
68 5         32 return $self;
69             }
70              
71             1;
72              
73             __END__