blib/lib/Pinto/Remote/Action/Add.pm

filter: Statementstmt 54.5% 18 / 33 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 1 totaltotal 41.5% 22 / 53 CC 5 SCAR 19.6
CC
5
Cov
43%
__ANON__
12.0
BUILD
12.0
__ANON__
2.0
CRAP 7.1
« blib/lib/Pinto/Schema/Result/Registration.pm ↑ Summary blib/lib/Pinto/Repository.pm »
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
BranchTrueFalseTotal
if $ENV{"PINTO_AUTHOR_ID"} 0 0 0
Condition0%0/3
$args->{"args"}{"author"} ||= $ENV{"PINTO_AUTHOR_ID"}
l!l&&r!l&&!r
000
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"}
ABresult
1X1
011
000
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
BranchTrueFalseTotal
if @{$self->args->{"archives"} or [];} > 1 0 0 0
Condition0%0/2
$self->args->{'archives'} || []
l!l
00
MC/DC0%0/1
$self->args->{'archives'} || []
$self->args->{'archives'}
Truth table0%0/2
A
A= $self->args->{'archives'}
Aresult
11
00
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__
« blib/lib/Pinto/Schema/Result/Registration.pm ↑ Summary blib/lib/Pinto/Repository.pm »