File Coverage

blib/lib/Pinto/Action/Delete.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 24 24 100.0


line stmt bran cond sub pod time code
1             # ABSTRACT: Delete archives from the repository
2              
3             package Pinto::Action::Delete;
4              
5 1     1   564 use Moose;
  1         3  
  1         10  
6 1     1   7088 use MooseX::StrictConstructor;
  1         3  
  1         12  
7 1     1   3557 use MooseX::Types::Moose qw(Bool);
  1         2  
  1         26  
8 1     1   5289 use MooseX::MarkAsMethods ( autoclean => 1 );
  1         2  
  1         9  
9              
10 1     1   4084 use Pinto::Util qw(throw);
  1         3  
  1         104  
11 1     1   9 use Pinto::Types qw(DistributionTargetList);
  1         4  
  1         11  
12              
13             #------------------------------------------------------------------------------
14              
15             our $VERSION = '0.13'; # VERSION
16              
17             #------------------------------------------------------------------------------
18              
19             extends qw( Pinto::Action );
20              
21             #------------------------------------------------------------------------------
22              
23             with qw( Pinto::Role::Transactional );
24              
25             #------------------------------------------------------------------------------
26              
27             has targets => (
28             isa => DistributionTargetList,
29             traits => [qw(Array)],
30             handles => { targets => 'elements' },
31             required => 1,
32             coerce => 1,
33             );
34              
35             has force => (
36             is => 'ro',
37             isa => Bool,
38             default => 0,
39             );
40              
41             #------------------------------------------------------------------------------
42              
43             sub execute {
44             my ($self) = @_;
45              
46             for my $target ( $self->targets ) {
47              
48             my $dist = $self->repo->get_distribution( target => $target );
49              
50             throw "Distribution $target is not in the repository" if not defined $dist;
51              
52             $self->notice("Deleting $dist from the repository");
53              
54             $self->repo->delete_distribution( dist => $dist, force => $self->force );
55             }
56              
57             return $self->result->changed;
58             }
59              
60             #------------------------------------------------------------------------------
61              
62             __PACKAGE__->meta->make_immutable;
63              
64             #------------------------------------------------------------------------------
65              
66             1;
67              
68             __END__
69              
70             =pod
71              
72             =encoding UTF-8
73              
74             =for :stopwords Jeffrey Ryan Thalhammer
75              
76             =head1 NAME
77              
78             Pinto::Action::Delete - Delete archives from the repository
79              
80             =head1 VERSION
81              
82             version 0.13
83              
84             =head1 AUTHOR
85              
86             Jeffrey Ryan Thalhammer <jeff@stratopan.com>
87              
88             =head1 COPYRIGHT AND LICENSE
89              
90             This software is copyright (c) 2015 by Jeffrey Ryan Thalhammer.
91              
92             This is free software; you can redistribute it and/or modify it under
93             the same terms as the Perl 5 programming language system itself.
94              
95             =cut