File Coverage

blib/lib/CCfnX/Deployment.pm
Criterion Covered Total %
statement 6 21 28.5
branch 0 4 0.0
condition 0 9 0.0
subroutine 2 8 25.0
pod 0 6 0.0
total 8 48 16.6


line stmt bran cond sub pod time code
1             package CCfnX::Deployment {
2 14     14   252 use Moose;
  14         34  
  14         97  
3 14     14   84099 use Module::Runtime qw/use_module/;
  14         36  
  14         100  
4              
5             has origin => (is => 'rw', isa => 'CCfn');
6             has name => (is => 'rw', isa => 'Str', required => 1, lazy => 1, default => sub { $_[0]->origin->params->name });
7             has type => (
8             is => 'rw',
9             isa => 'Str',
10             required => 1,
11             lazy => 1,
12             clearer => 'clear_type',
13             default => sub { $_[0]->origin->meta->name }
14             );
15             has account => (is => 'rw', isa => 'Str', required => 1, lazy => 1, default => sub { (defined $_[0]->origin)?$_[0]->origin->params->account:$ENV{CPSD_AWS_ACCOUNT} });
16             has outputs => (is => 'rw', isa => 'HashRef');
17             has params => (is => 'rw', isa => 'HashRef', lazy => 1, default => sub { $_[0]->get_params_from_origin });
18              
19             sub get_params_from_origin {
20 0     0 0   my $params = $_[0]->origin->params;
21 0           my @attrs = map { $_->name } $params->meta->get_all_attributes;
  0            
22 0           my %p = map { $_ => $params->$_ } grep {
23 0 0 0       $_ ne 'ARGV'
  0   0        
24             and $_ ne 'extra_argv'
25             and $_ ne 'help_flag'
26             and $_ ne 'usage'
27             } @attrs;
28 0           return \%p;
29             }
30              
31             sub output {
32 0     0 0   my ($self, $name) = @_;
33 0 0 0       die "Output $name not found in " . $self->name if (not defined $self->outputs or not defined $self->outputs->{ $name });
34 0           return $self->outputs->{ $name };
35             }
36              
37       0 0   sub undeploy { }
38              
39       0 0   sub redeploy { }
40              
41       0 0   sub deploy { }
42              
43             sub new_with_roles {
44 0     0 0   my ($class, $params, @roles) = @_;
45 0           use_module($_) for (@roles);
46 0           my $new_class = Moose::Util::with_traits('CCfnX::Deployment', @roles);
47 0           my $dep = $new_class->new(%$params);
48 0           return $dep;
49             }
50             }
51              
52             1;