| 1 | # ABSTRACT: Loosen a package that has been pinned | ||||||||||
| 2 | |||||||||||
| 3 | package Pinto::Action::Unpin; | ||||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use MooseX::StrictConstructor; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use MooseX::MarkAsMethods ( autoclean => 1 ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 2 | ▶ | use Pinto::Util qw(throw); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use Pinto::Types qw(TargetList); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | #------------------------------------------------------------------------------ | ||||||||||
| 13 | |||||||||||
| 14 | 2 | our $VERSION = '0.14'; # VERSION | |||||||||
| 15 | |||||||||||
| 16 | #------------------------------------------------------------------------------ | ||||||||||
| 17 | |||||||||||
| 18 | 2 | extends qw( Pinto::Action ); | |||||||||
| 19 | |||||||||||
| 20 | #------------------------------------------------------------------------------ | ||||||||||
| 21 | |||||||||||
| 22 | 2 | has targets => ( | |||||||||
| 23 | isa => TargetList, | ||||||||||
| 24 | traits => [qw(Array)], | ||||||||||
| 25 | handles => { targets => 'elements' }, | ||||||||||
| 26 | required => 1, | ||||||||||
| 27 | coerce => 1, | ||||||||||
| 28 | ); | ||||||||||
| 29 | |||||||||||
| 30 | #------------------------------------------------------------------------------ | ||||||||||
| 31 | |||||||||||
| 32 | 2 | with qw( Pinto::Role::Committable ); | |||||||||
| 33 | |||||||||||
| 34 | #------------------------------------------------------------------------------ | ||||||||||
| 35 | |||||||||||
| 36 | 1 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=5 SCAR=25.7
| |||||||||||
| 37 | 1 | my ($self) = @_; | |||||||||
| 38 | |||||||||||
| 39 | 1 | my $stack = $self->stack; | |||||||||
| 40 | |||||||||||
| 41 | 1 | for my $target ( $self->targets ) { | |||||||||
| 42 | |||||||||||
| 43 | 1 | ▶ | throw "$target is not registered on stack $stack" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | unless my $dist = $stack->get_distribution( target => $target ); | ||||||||||
| 45 | |||||||||||
| 46 | 0 | $self->notice("Unpinning distribution $dist from stack $stack"); | |||||||||
| 47 | |||||||||||
| 48 | 0 | my $did_unpin = $dist->unpin( stack => $stack ); | |||||||||
| 49 | 0 | ▶ | push @{$self->affected}, $dist if $did_unpin; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | |||||||||||
| 51 | 0 | ▶ | $self->warning("Distribution $dist is not pinned to stack $stack") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | unless $did_unpin; | ||||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 0 | return $self; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | #------------------------------------------------------------------------------ | ||||||||||
| 59 | |||||||||||
| 60 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||
| 61 | |||||||||||
| 62 | #------------------------------------------------------------------------------ | ||||||||||
| 63 | |||||||||||
| 64 | 2 | 1; | |||||||||
| 65 | |||||||||||
| 66 | __END__ | ||||||||||