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   94440 use warnings;
  15         22  
  15         459  
4 15     15   54 use strict;
  15         18  
  15         359  
5 15     15   5443 use version; our $VERSION = qv('2.4.41');
  15         18442  
  15         83  
6              
7 15     15   1109 use base qw/Shipwright::Base/;
  15         23  
  15         5854  
8              
9             __PACKAGE__->mk_accessors(qw/backend source build log_level log_file/);
10              
11 15     15   4836 use Shipwright::Logger;
  15         45  
  15         498  
12 15     15   77 use File::Spec::Functions qw/catfile tmpdir/;
  15         23  
  15         724  
13 15     15   69 use Shipwright::Util;
  15         25  
  15         845  
14             # strawberry perl's build make is 'dmake'
15 15     15   7908 use File::Which 'which';
  15         11870  
  15         4466  
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 3547 my $class = shift;
37              
38 5         30 my %args = (
39             log_level => undef,
40             log_file => undef,
41             repository => undef,
42             source => undef,
43             @_
44             );
45 5 100       25 $args{log_level} = $args{log_level} ? uc $args{log_level} : 'FATAL';
46              
47 5 100       28 $args{log_file} = '-' unless $args{log_file};
48              
49 5         16 my $self = {
50             log_level => $args{log_level},
51             log_file => $args{log_file},
52             };
53              
54 5         11 bless $self, $class;
55              
56 5         28 Shipwright::Logger->new($self);
57              
58 5 100       13 if ( $args{repository} ) {
59 4         1166 require Shipwright::Backend;
60 4         35 $self->backend( Shipwright::Backend->new(%args) );
61             }
62              
63 5 100       21 if ( $args{source} ) {
64 1         385 require Shipwright::Source;
65 1         9 $self->source( Shipwright::Source->new(%args) );
66             }
67              
68 5         31 return $self;
69             }
70              
71             1;
72              
73             __END__