File Coverage

blib/lib/Pinto/Action/Install.pm
Criterion Covered Total %
statement 20 20 100.0
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod n/a
total 27 28 96.4


line stmt bran cond sub pod time code
1             # ABSTRACT: Install packages from the repository
2              
3             package Pinto::Action::Install;
4              
5 2     2   1628 use Moose;
  2         911  
  2         38  
6 2     2   16519 use MooseX::StrictConstructor;
  2         5  
  2         27  
7 2     2   6908 use MooseX::Types::Moose qw(Bool ArrayRef Str);
  2         7  
  2         42  
8 2     2   10223 use MooseX::MarkAsMethods ( autoclean => 1 );
  2         6  
  2         25  
9              
10 2     2   8193 use Pinto::Target;
  2         5  
  2         34  
11              
12             #------------------------------------------------------------------------------
13              
14             our $VERSION = '0.14'; # VERSION
15              
16             #------------------------------------------------------------------------------
17              
18             extends qw( Pinto::Action );
19              
20             #------------------------------------------------------------------------------
21              
22             has targets => (
23             isa => ArrayRef [Str],
24             traits => ['Array'],
25             handles => { targets => 'elements' },
26             required => 1,
27             );
28              
29             has do_pull => (
30             is => 'ro',
31             isa => Bool,
32             default => 0,
33             );
34              
35             has mirror_uri => (
36             is => 'ro',
37             isa => Str,
38             builder => '_build_mirror_uri',
39             lazy => 1,
40             );
41              
42             #------------------------------------------------------------------------------
43              
44             with qw( Pinto::Role::Committable Pinto::Role::Puller Pinto::Role::Installer);
45              
46             #------------------------------------------------------------------------------
47              
48             sub _build_mirror_uri {
49 8     8   29 my ($self) = @_;
50              
51 8         266 my $stack = $self->stack;
52 8 50       64 my $stack_dir = defined $stack ? "/stacks/$stack" : '';
53 8         596 my $mirror_uri = 'file://' . $self->repo->root->absolute . $stack_dir;
54              
55 8         623 return $mirror_uri;
56             }
57              
58             #------------------------------------------------------------------------------
59              
60             sub execute {
61             my ($self) = @_;
62              
63             my @dists;
64             if ( $self->do_pull ) {
65              
66             for my $target ( $self->targets ) {
67             next if -d $target or -f $target;
68              
69             require Pinto::Target;
70             $target = Pinto::Target->new($target);
71              
72             my $dist = $self->pull( target => $target );
73             push @dists, $dist ? $dist : ();
74             }
75             }
76              
77             return @dists;
78             }
79              
80             #------------------------------------------------------------------------------
81              
82             __PACKAGE__->meta->make_immutable;
83              
84             #-----------------------------------------------------------------------------
85             1;
86              
87             __END__
88              
89             =pod
90              
91             =encoding UTF-8
92              
93             =for :stopwords Jeffrey Ryan Thalhammer
94              
95             =head1 NAME
96              
97             Pinto::Action::Install - Install packages from the repository
98              
99             =head1 VERSION
100              
101             version 0.14
102              
103             =head1 AUTHOR
104              
105             Jeffrey Ryan Thalhammer <jeff@stratopan.com>
106              
107             =head1 COPYRIGHT AND LICENSE
108              
109             This software is copyright (c) 2015 by Jeffrey Ryan Thalhammer.
110              
111             This is free software; you can redistribute it and/or modify it under
112             the same terms as the Perl 5 programming language system itself.
113              
114             =cut