File Coverage

blib/lib/Pinto/Action/Unpin.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


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