lib/Dist/Zilla/Plugin/CSJEWELL/FTPUploadToOwnSite.pm

filter: Statementstmt 51.1% 23 / 45 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 43.0% 28 / 65 CC 7 SCAR 35.0
CC
7
Cov
40%
release
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 33.1
↑ Summary lib/Dist/Zilla/MintingProfile/CSJEWELL.pm »
1 package Dist::Zilla::Plugin::CSJEWELL::FTPUploadToOwnSite;
2  
3 1 ▶use 5.008003;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Net::Netrc;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Net::FTP;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 with 'Dist::Zilla::Role::Releaser';
8  
9 1 our $VERSION = '0.900';
10 1 $VERSION =~ s/_//sm;
11  
12 1 has site => (
13 is => 'ro',
14 isa => 'Str',
15 required => 1,
16 );
17  
18 1 has directory => (
19 is => 'ro',
20 isa => 'Str',
21 required => 1,
22 );
23  
24 1 has passive_ftp => (
25 is => 'ro',
26 isa => 'Int',
27 default => 1,
28 );
29  
30 1 has debug => (
31 is => 'ro',
32 isa => 'Int',
33 default => 0,
34 );
35  
36 0 ▶sub release {
Subroutine release: not called CC=7 SCAR=40.3
Pod undocumented
37 0 my ( $self, $archive ) = @_;
38  
39 0 my $filename = $archive->stringify();
40 0 my $site = $self->site();
41 0 my $siteinfo = Net::Netrc->lookup($site);
42 0 ▶ if ( not $siteinfo ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($siteinfo) 0 0 0
43 0 $self->log_fatal(
44 "Could not get information for $site from .netrc.");
45 }
46 0 my ( $user, $password, undef ) = $siteinfo->lpa();
47  
48 0 my $ftp = Net::FTP->new(
49 $site,
50 Debug => $self->debug(),
51 Passive => $self->passive_ftp(),
52 );
53  
54 0 ▶ $ftp->login( $user, $password )
Branch: 1 branch
BranchTrueFalseTotal
$ftp->login($user, $password) or $self->log_fatal('Could not log in to ' . $site) 0 0 0
55 or $self->log_fatal( 'Could not log in to ' . $site );
56  
57 0 $ftp->binary;
58  
59 0 ▶ $ftp->cwd( $self->directory() )
Branch: 1 branch
BranchTrueFalseTotal
$ftp->cwd($self->directory) or $self->log_fatal('Could not change remote site directory to' . $self->directory) 0 0 0
60 or $self->log_fatal(
61 'Could not change remote site directory to' . $self->directory() );
62  
63 0 my $remote_file = $ftp->put($filename);
64  
65 0 ▶ if ( $remote_file ne $filename ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($remote_file ne $filename) 0 0 0
66 0 $self->log_fatal( 'Could not upload file: ' . $ftp->message() );
67 }
68  
69 0 my $remote_size = $ftp->size($remote_file);
70 0 ▶ $remote_size ||= 0;
Condition0%0/2
$remote_size ||= 0
l!l
00
MC/DC0%0/1
$remote_size ||= 0
$remote_size
Truth table0%0/2
A
A= $remote_size
Aresult
11
00
71 0 my $local_size = -s $filename;
72  
73 0 ▶ if ( $remote_size != $local_size ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($remote_size != $local_size) 0 0 0
74 0 $self->log( "Uploaded file is $remote_size bytes, "
75 . "but local file is $local_size bytes" );
76 }
77  
78 0 $ftp->quit;
79  
80 0 $self->log( 'File uploaded to ' . $self->site() );
81  
82 0 return 1;
83 } ## end sub release
84  
85 1 __PACKAGE__->meta()->make_immutable();
86 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
87 1 1;
88  
89 __END__
↑ Summary lib/Dist/Zilla/MintingProfile/CSJEWELL.pm »