Cfn/ResourceModules.pm

filter: Statementstmt 100% 15 / 15 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 100% 2 / 2 totaltotal 95.4% 21 / 22 CC 2 SCAR 4.1
CC
2
Cov
94%
load
2.0
list
1.0
BEGIN
1.0
CRAP 1.5
« Cfn/Resource/AWS/FSx/FileSystem.pm ↑ Summary Cfn/Resource/AWS/EC2/NetworkAclEntry.pm »
1 package Cfn::ResourceModules;
2  
3 sub list {
4 1 ▶ require Module::Find;
Subroutine list: called CC=1 SCAR=0.0
Pod documented
5 1 my @list = Module::Find::findallmod Cfn::Resource;
6 # strip off the Cfn::Resource
7 1 @list = map { $_ =~ s/^Cfn::Resource:://; $_ } @list;
8 1 return @list;
9 }
10  
11 22 ▶ use Module::Runtime qw//;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 sub load {
13 2333 ▶ my $type = shift;
Subroutine load: called CC=2 SCAR=7.0
Pod documented
14 2333 my $cfn_resource_class = "Cfn::Resource::$type";
15 2333 my $retval = Module::Runtime::require_module($cfn_resource_class);
16 2333 ▶ die "Couldn't load $cfn_resource_class" if (not $retval);
Branch: 1 branch
BranchTrueFalseTotal
unless $retval 0 2333 2333
17 2333 return $cfn_resource_class;
18 }
19  
20 22 1;
21 ### main pod documentation begin ###
22  
23 =encoding UTF-8
24  
25 =head1 NAME
26  
27 Cfn::ResourceModules - Load Cfn resource classes
28  
29 =head1 SYNOPSIS
30  
31 use Cfn::ResourceModules;
32  
33 my $perl_class = Cfn::ResourceModules::load('AWS::EC2::Instance');
34 my $ec2_instance_object = $perl_class->new(...);
35  
36 my @supported_modules = Cfn::ResourceModules::list;
37  
38 =head1 DESCRIPTION
39  
40 This module is designed to load Perl modules that respresent CloudFormation resources.
41  
42 It exposes functions for knowing what resources are available on the system (what CloudFormation
43 resource types can be loaded) and making them available to your programs. It doesn't export
44 anything into the callers namespace.
45  
46 =head1 FUNCTIONS
47  
48 =head2 list
49  
50 Returns an array of CloudFormation resource types present on the system that can be passed to C<load>
51  
52 =head2 load($resource)
53  
54 When passed a CloudFormation resource type (f.ex. C<AWS::EC2::SecurityGroup>) it loads into memory the
55 Perl modules that will later let the program instance objects of that type. Note that the Perl class
56 for the resource type will get returned (Cfn resource objects are in the C<Cfn::Resource>
57 namespace), so you will get strings of the form C<Cfn::Resource::AWS::EC2::SecurityGroup>.
58  
59 =head1 AUTHOR
60  
61 Jose Luis Martinez
62 CAPSiDE
63 jlmartinez@capside.com
64  
65 =head1 COPYRIGHT and LICENSE
66  
67 Copyright (c) 2013 by CAPSiDE
68 This code is distributed under the Apache 2 License. The full text of the
69 license can be found in the LICENSE file included with this module.
70  
71 =cut
« Cfn/Resource/AWS/FSx/FileSystem.pm ↑ Summary Cfn/Resource/AWS/EC2/NetworkAclEntry.pm »