| 1 | # ABSTRACT: Add a distribution to a the repository | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package Pinto::Remote::Action::Add; | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use MooseX::MarkAsMethods ( autoclean => 1 ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use JSON; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Pinto::Util qw(throw); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | our $VERSION = '0.14'; # VERSION | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | extends qw( Pinto::Remote::Action ); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 23 | 0 | my $orig = shift; | |||||||||||||||||||||||||||
| 24 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | my $args = $class->$orig(@_); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # I don't have a separate attribute for each action argument, | ||||||||||||||||||||||||||||
| 29 | # so I need to wedge in the default author identity somehow. | ||||||||||||||||||||||||||||
| 30 | # And if PINTO_AUTHOR_ID isn't defined either, then the server | ||||||||||||||||||||||||||||
| 31 | # will fall back to using the username. Perhaps I could also | ||||||||||||||||||||||||||||
| 32 | # do the same thing here just to make it clear what's going on. | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $args->{args}->{author} ||= $ENV{PINTO_AUTHOR_ID} if $ENV{PINTO_AUTHOR_ID}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"args"}{"author"} ||= $ENV{"PINTO_AUTHOR_ID"}
MC/DC0%0/2
$args->{"args"}{"author"} ||= $ENV{"PINTO_AUTHOR_ID"}
$args->{"args"}{"author"}
$ENV{"PINTO_AUTHOR_ID"}
Truth table0%0/3
A ||= B
A= $args->{"args"}{"author"}B= $ENV{"PINTO_AUTHOR_ID"}
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | return $args; | |||||||||||||||||||||||||||
| 37 | 1 | }; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 42 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | throw 'Only one archive can be remotely added at a time' | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if @{ $self->args->{archives} || [] } > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->args->{'archives'} || []
MC/DC0%0/1
$self->args->{'archives'} || []
$self->args->{'archives'}
Truth table0%0/2
A
A= $self->args->{'archives'}
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | return $self; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | override _make_request_body => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 53 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | my $body = super; | |||||||||||||||||||||||||||
| 56 | 0 | my $archive = ( delete $self->args->{archives} )->[0]; | |||||||||||||||||||||||||||
| 57 | 0 | push @{$body}, ( archives => [$archive] ); | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | return $body; | |||||||||||||||||||||||||||
| 60 | 1 | }; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 67 | 1 | 1; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | __END__ | ||||||||||||||||||||||||||||