| 1 | 14 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 14 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | package Footprintless::Factory; | ||||||||||
| 5 | 14 | $Footprintless::Factory::VERSION = '1.29'; | |||||||||
| 6 | # ABSTRACT: The default factory for footprintless modules | ||||||||||
| 7 | # PODNAME: Footprintless::Factory | ||||||||||
| 8 | |||||||||||
| 9 | 14 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 14 | ▶ | use Footprintless::Util; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 14 | ▶ | use Log::Any; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 14 | our $AUTOLOAD; | |||||||||
| 14 | 14 | my $logger = Log::Any->get_logger(); | |||||||||
| 15 | |||||||||||
| 16 | 52 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 17 | 52 | return bless( {}, shift )->_init(@_); | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 24 | ▶ | sub agent { | ||||||||
|
Subroutine
agent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 21 | 24 | my ( $self, @options ) = @_; | |||||||||
| 22 | |||||||||||
| 23 | 24 | return Footprintless::Util::agent(@options); | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 4 | ▶ | sub AUTOLOAD { | ||||||||
|
Subroutine
AUTOLOAD: called CC=3 SCAR=11.2
| |||||||||||
| 27 | 4 | my ( $self, @args ) = @_; | |||||||||
| 28 | 4 | my $method_name = $AUTOLOAD; | |||||||||
| 29 | 4 | $method_name =~ s/.*:://; | |||||||||
| 30 | 4 | foreach my $plugin ( $self->plugins() ) { | |||||||||
| 31 | 4 | my $method = $plugin->factory_methods()->{$method_name}; | |||||||||
| 32 | 4 | ▶ | if ($method) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 4 | return &$method( $self, @args ); | |||||||||
| 34 | } | ||||||||||
| 35 | } | ||||||||||
| 36 | 0 | croak("unsupported factory method: [$method_name]"); | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 33 | ▶ | sub command_options { | ||||||||
|
Subroutine
command_options: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 40 | 33 | my ( $self, @spec ) = @_; | |||||||||
| 41 | 33 | return $self->command_options_factory()->command_options(@spec); | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 33 | ▶ | sub command_options_factory { | ||||||||
|
Subroutine
command_options_factory: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 45 | 33 | my ($self) = @_; | |||||||||
| 46 | |||||||||||
| 47 | 33 | ▶ | unless ( $self->{command_options_factory} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 22 | require Footprintless::CommandOptionsFactory; | |||||||||
| 49 | $self->{command_options_factory} = | ||||||||||
| 50 | 22 | Footprintless::CommandOptionsFactory->new( localhost => $self->localhost() ); | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 33 | return $self->{command_options_factory}; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 39 | ▶ | sub command_runner { | ||||||||
|
Subroutine
command_runner: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 57 | 39 | my ($self) = @_; | |||||||||
| 58 | |||||||||||
| 59 | 39 | ▶ | unless ( $self->{command_runner} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | 11 | require Footprintless::Util; | |||||||||
| 61 | 11 | $self->{command_runner} = Footprintless::Util::default_command_runner(); | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 39 | return $self->{command_runner}; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 2 | ▶ | sub deployment { | ||||||||
|
Subroutine
deployment: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 68 | 2 | my ( $self, $coordinate, %options ) = @_; | |||||||||
| 69 | |||||||||||
| 70 | 2 | require Footprintless::Deployment; | |||||||||
| 71 | 2 | return Footprintless::Deployment->new( $self, $coordinate, %options ); | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | 15 | ▶ | sub DESTROY { } | ||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||
| 75 | |||||||||||
| 76 | 304 | ▶ | sub entities { | ||||||||
|
Subroutine
entities: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 77 | 304 | return $_[0]->{entities}; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | 52 | ▶ | sub _init { | ||||||||
|
Subroutine
_init: called CC=4 SCAR=13.9
| |||||||||||
| 81 | 52 | my ( $self, $entities, %options ) = @_; | |||||||||
| 82 | |||||||||||
| 83 | 52 | $self->{entities} = $entities; | |||||||||
| 84 | 52 | $self->{agent} = $options{agent}; | |||||||||
| 85 | 52 | $self->{command_options_factory} = $options{command_options_factory}; | |||||||||
| 86 | 52 | $self->{command_runner} = $options{command_runner}; | |||||||||
| 87 | 52 | $self->{localhost} = $options{localhost}; | |||||||||
| 88 | 52 | $self->{resource_manager} = $options{resource_manager}; | |||||||||
| 89 | |||||||||||
| 90 | 52 | $self->{plugins} = []; | |||||||||
| 91 | 52 | ▶ | if ( $self->{entities}{'footprintless'} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 92 | 14 | my $plugin_modules = $self->{entities}{'footprintless'}{plugins}; | |||||||||
| 93 | 14 | ▶ | if ($plugin_modules) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 94 | 2 | foreach my $plugin_module (@$plugin_modules) { | |||||||||
| 95 | 2 | $logger->debugf( 'registering plugin %s', $plugin_module ); | |||||||||
| 96 | $self->register_plugin( | ||||||||||
| 97 | Footprintless::Util::dynamic_module_new( | ||||||||||
| 98 | 2 | $plugin_module, $self->{entities}{'footprintless'}{$plugin_module} | |||||||||
| 99 | ) | ||||||||||
| 100 | ); | ||||||||||
| 101 | } | ||||||||||
| 102 | } | ||||||||||
| 103 | } | ||||||||||
| 104 | |||||||||||
| 105 | 52 | return $self; | |||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | 38 | ▶ | sub localhost { | ||||||||
|
Subroutine
localhost: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 109 | 38 | my ($self) = @_; | |||||||||
| 110 | |||||||||||
| 111 | 38 | ▶ | unless ( $self->{localhost} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 112 | 28 | require Footprintless::Localhost; | |||||||||
| 113 | 28 | $self->{localhost} = Footprintless::Localhost->new()->load_all(); | |||||||||
| 114 | } | ||||||||||
| 115 | |||||||||||
| 116 | 38 | return $self->{localhost}; | |||||||||
| 117 | } | ||||||||||
| 118 | |||||||||||
| 119 | 4 | ▶ | sub log { | ||||||||
|
Subroutine
log: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 120 | 4 | my ( $self, $coordinate, %options ) = @_; | |||||||||
| 121 | |||||||||||
| 122 | 4 | require Footprintless::Log; | |||||||||
| 123 | 4 | return Footprintless::Log->new( $self, $coordinate, %options ); | |||||||||
| 124 | } | ||||||||||
| 125 | |||||||||||
| 126 | 2 | ▶ | sub overlay { | ||||||||
|
Subroutine
overlay: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 127 | 2 | my ( $self, $coordinate, %options ) = @_; | |||||||||
| 128 | |||||||||||
| 129 | 2 | require Footprintless::Overlay; | |||||||||
| 130 | 2 | return Footprintless::Overlay->new( $self, $coordinate, %options ); | |||||||||
| 131 | } | ||||||||||
| 132 | |||||||||||
| 133 | 12 | ▶ | sub plugins { | ||||||||
|
Subroutine
plugins: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 134 | 12 | return @{ $_[0]->{plugins} }; | |||||||||
| 135 | } | ||||||||||
| 136 | |||||||||||
| 137 | 2 | ▶ | sub register_plugin { | ||||||||
|
Subroutine
register_plugin: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 138 | 2 | my ( $self, $plugin ) = @_; | |||||||||
| 139 | |||||||||||
| 140 | 2 | push( @{ $self->{plugins} }, $plugin ); | |||||||||
| 141 | } | ||||||||||
| 142 | |||||||||||
| 143 | 19 | ▶ | sub resource_manager { | ||||||||
|
Subroutine
resource_manager: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 144 | 19 | my ( $self, $coordinate, %options ) = @_; | |||||||||
| 145 | |||||||||||
| 146 | 19 | ▶ | unless ( $self->{resource_manager} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 147 | $self->{resource_manager} = | ||||||||||
| 148 | 9 | Footprintless::Util::dynamic_module_new( 'Footprintless::ResourceManager', | |||||||||
| 149 | $self, $coordinate ); | ||||||||||
| 150 | } | ||||||||||
| 151 | |||||||||||
| 152 | 19 | return $self->{resource_manager}; | |||||||||
| 153 | } | ||||||||||
| 154 | |||||||||||
| 155 | 4 | ▶ | sub service { | ||||||||
|
Subroutine
service: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 156 | 4 | my ( $self, $coordinate, %options ) = @_; | |||||||||
| 157 | |||||||||||
| 158 | 4 | require Footprintless::Service; | |||||||||
| 159 | 4 | return Footprintless::Service->new( $self, $coordinate, %options ); | |||||||||
| 160 | } | ||||||||||
| 161 | |||||||||||
| 162 | 0 | ▶ | sub tunnel { | ||||||||
|
Subroutine
tunnel: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 163 | 0 | my ( $self, $coordinate, %options ) = @_; | |||||||||
| 164 | |||||||||||
| 165 | 0 | require Footprintless::Tunnel; | |||||||||
| 166 | 0 | return Footprintless::Tunnel->new( $self, $coordinate, %options ); | |||||||||
| 167 | } | ||||||||||
| 168 | |||||||||||
| 169 | 14 | 1; | |||||||||
| 170 | |||||||||||
| 171 | __END__ | ||||||||||