| 1 | package | ||
| 2 | Pinto::Remote::SelfContained::Action::Add; # hide from PAUSE | ||
| 3 | # ABSTRACT: add a distribution to a the repository | ||
| 4 | |||
| 5 | use v5.10; | ||
| 6 | use Moo; | ||
| 7 | |||
| 8 | use Carp qw(croak); | ||
| 9 | use Pinto::Remote::SelfContained::Types qw(SingleBodyPart); | ||
| 10 | |||
| 11 | use namespace::clean; | ||
| 12 | |||
| 13 | our $VERSION = '1.999'; # TRIAL VERSION | ||
| 14 | |||
| 15 | extends qw(Pinto::Remote::SelfContained::Action); | ||
| 16 | |||
| 17 | has archives => (is => 'ro', isa => SingleBodyPart, required => 1); | ||
| 18 | |||
| 19 | around BUILDARGS => sub { | ||
| 20 | my ($orig, $class, @rest) = @_; | ||
| 21 | |||
| 22 | my $args = $class->$orig(@rest); | ||
| 23 | |||
| 24 | $args->{args}{author} //= $ENV{PINTO_AUTHOR_ID} | ||
| 25 | if defined $ENV{PINTO_AUTHOR_ID}; | ||
| 26 | |||
| 27 | $args->{archives} //= delete $args->{args}{archives}; | ||
| 28 | |||
| 29 | return $args; | ||
| 30 | }; | ||
| 31 | |||
| 32 | around _make_body_parts => sub { | ||
| 33 | my ($orig, $self) = @_; | ||
| 34 | |||
| 35 | my $body = $self->$orig; | ||
| 36 | my $archives = $self->archives; | ||
| 37 | push @$body, @$archives; | ||
| 38 | |||
| 39 | return $body; | ||
| 40 | }; | ||
| 41 | |||
| 42 | 1; | ||
| 43 | |||
| 44 | __END__ |