| 1 | package Dist::Zilla::Plugin::UploadToCpanSite; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use common::sense; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use English '-no_match_vars'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use File::Spec; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Net::SCP qw(scp); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Net::SSH qw(ssh); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 1 | ▶ | use MooseX::Has::Sugar; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use MooseX::Types::Moose qw(Str); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 1 | ▶ | use Try::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | 1 | with 'Dist::Zilla::Role::Releaser'; | |||||||||
| 20 | |||||||||||
| 21 | 1 | has 'host' => ( isa => Str, ro, required ); | |||||||||
| 22 | 1 | has 'site' => ( isa => Str, ro, required ); | |||||||||
| 23 | 1 | has 'author' => ( isa => Str, ro, required ); | |||||||||
| 24 | 1 | has 'directory' => ( isa => Str, ro, lazy_build ); | |||||||||
| 25 | 1 | has 'cpan' => ( isa => Str, ro, required, default => | |||||||||
| 26 | 'http://ftp.easynet.be/pub/CPAN/' ); | ||||||||||
| 27 | |||||||||||
| 28 | # | ||||||||||
| 29 | # Version set by dist.ini; do not change here. | ||||||||||
| 30 | 1 | our $VERSION = '1.132210'; # VERSION | |||||||||
| 31 | # | ||||||||||
| 32 | |||||||||||
| 33 | |||||||||||
| 34 | sub _build_directory | ||||||||||
| 35 | 0 | ▶ | { | ||||||||
|
Subroutine
_build_directory: not called CC=1 SCAR=6.9
| |||||||||||
| 36 | 0 | my $self = shift; | |||||||||
| 37 | |||||||||||
| 38 | my @args = | ||||||||||
| 39 | map { | ||||||||||
| 40 | 0 | substr( $self->author,0,$_ ) | |||||||||
| 41 | } ( 1, 2, length($self->author) ); | ||||||||||
| 42 | |||||||||||
| 43 | 0 | return File::Spec->catdir( | |||||||||
| 44 | $self->site, authors => id => @args ); | ||||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | |||||||||||
| 48 | sub release | ||||||||||
| 49 | 0 | ▶ | { | ||||||||
|
Subroutine
release: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 50 | 0 | my($self,$archive) = @_; | |||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 53 | 0 | ssh( | |||||||||
| 54 | $self->host, | ||||||||||
| 55 | sprintf( | ||||||||||
| 56 | 'mkdir -p %s', | ||||||||||
| 57 | $self->directory ) ) } | ||||||||||
| 58 | 0 | ▶ | catch { $self->log_fatal($ARG) }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 59 | |||||||||||
| 60 | 0 | my $scp = Net::SCP->new( { host => $self->host } ); | |||||||||
| 61 | |||||||||||
| 62 | my $rc = | ||||||||||
| 63 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 64 | 0 | $scp->put( | |||||||||
| 65 | $archive, $self->directory ); } | ||||||||||
| 66 | 0 | ▶ | catch { $self->log_fatal($ARG) }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 67 | |||||||||||
| 68 | 0 | ▶ | if(!$rc) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | 0 | $self->log_fatal( $scp->{errstr} ); | |||||||||
| 70 | } else { | ||||||||||
| 71 | my $rc = | ||||||||||
| 72 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 73 | 0 | ssh( | |||||||||
| 74 | $self->host, | ||||||||||
| 75 | sprintf( | ||||||||||
| 76 | '/usr/bin/env cpansite --site %s --cpan %s index', | ||||||||||
| 77 | $self->site, | ||||||||||
| 78 | $self->cpan ) ); } | ||||||||||
| 79 | 0 | ▶ | catch { $self->log_fatal($ARG) }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 80 | |||||||||||
| 81 | 0 | $self->log( "$archive uploaded to " . $self->directory ); | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | 0 | return; | |||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | 1 | __PACKAGE__->meta->make_immutable(); | |||||||||
| 88 | 1 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 89 | |||||||||||
| 90 | 1 | 1; | |||||||||
| 91 | |||||||||||
| 92 | |||||||||||
| 93 | # ABSTRACT: Dist::Zilla Releaser plugin for uploading to CPAN::Site mirror. | ||||||||||
| 94 | |||||||||||
| 95 | __END__ | ||||||||||