| 1 | # ABSTRACT: Delete archives from the repository | ||||||||||
| 2 | |||||||||||
| 3 | package Pinto::Action::Delete; | ||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use MooseX::StrictConstructor; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use MooseX::Types::Moose qw(Bool); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use MooseX::MarkAsMethods ( autoclean => 1 ); | ||||||||
|
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 | 1 | ▶ | use Pinto::Types qw(DistributionTargetList); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | #------------------------------------------------------------------------------ | ||||||||||
| 14 | |||||||||||
| 15 | 1 | our $VERSION = '0.14'; # VERSION | |||||||||
| 16 | |||||||||||
| 17 | #------------------------------------------------------------------------------ | ||||||||||
| 18 | |||||||||||
| 19 | 1 | extends qw( Pinto::Action ); | |||||||||
| 20 | |||||||||||
| 21 | #------------------------------------------------------------------------------ | ||||||||||
| 22 | |||||||||||
| 23 | 1 | with qw( Pinto::Role::Transactional ); | |||||||||
| 24 | |||||||||||
| 25 | #------------------------------------------------------------------------------ | ||||||||||
| 26 | |||||||||||
| 27 | 1 | has targets => ( | |||||||||
| 28 | isa => DistributionTargetList, | ||||||||||
| 29 | traits => [qw(Array)], | ||||||||||
| 30 | handles => { targets => 'elements' }, | ||||||||||
| 31 | required => 1, | ||||||||||
| 32 | coerce => 1, | ||||||||||
| 33 | ); | ||||||||||
| 34 | |||||||||||
| 35 | 1 | has force => ( | |||||||||
| 36 | is => 'ro', | ||||||||||
| 37 | isa => Bool, | ||||||||||
| 38 | default => 0, | ||||||||||
| 39 | ); | ||||||||||
| 40 | |||||||||||
| 41 | #------------------------------------------------------------------------------ | ||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: not called CC=3 SCAR=24.8
| |||||||||||
| 44 | 0 | my ($self) = @_; | |||||||||
| 45 | |||||||||||
| 46 | 0 | for my $target ( $self->targets ) { | |||||||||
| 47 | |||||||||||
| 48 | 0 | my $dist = $self->repo->get_distribution( target => $target ); | |||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | throw "Distribution $target is not in the repository" if not defined $dist; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | |||||||||||
| 52 | 0 | $self->notice("Deleting $dist from the repository"); | |||||||||
| 53 | |||||||||||
| 54 | 0 | $self->repo->delete_distribution( dist => $dist, force => $self->force ); | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 0 | return $self->result->changed; | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | #------------------------------------------------------------------------------ | ||||||||||
| 61 | |||||||||||
| 62 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 63 | |||||||||||
| 64 | #------------------------------------------------------------------------------ | ||||||||||
| 65 | |||||||||||
| 66 | 1 | 1; | |||||||||
| 67 | |||||||||||
| 68 | __END__ | ||||||||||