| 1 | 7 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 2 | 7 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | |||||||||||||||
| 4 | package Footprintless; | ||||||||||||||
| 5 | 7 | $Footprintless::VERSION = '1.29'; | |||||||||||||
| 6 | # ABSTRACT: A utility for managing systems with minimal installs | ||||||||||||||
| 7 | # PODNAME: Footprintless | ||||||||||||||
| 8 | |||||||||||||||
| 9 | 7 | ▶ | use Carp; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | 7 | ▶ | use Config::Entities; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 7 | ▶ | use Footprintless::Util qw(factory); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | 7 | ▶ | use Log::Any; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | |||||||||||||||
| 14 | 7 | our $AUTOLOAD; | |||||||||||||
| 15 | |||||||||||||||
| 16 | 7 | my $logger = Log::Any->get_logger(); | |||||||||||||
| 17 | |||||||||||||||
| 18 | 20 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 19 | 20 | return bless( {}, shift )->_init(@_); | |||||||||||||
| 20 | } | ||||||||||||||
| 21 | |||||||||||||||
| 22 | 0 | ▶ | sub agent { | ||||||||||||
|
Subroutine
agent: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 23 | 0 | my ( $self, @options ) = @_; | |||||||||||||
| 24 | 0 | $self->{factory}->agent(@options); | |||||||||||||
| 25 | } | ||||||||||||||
| 26 | |||||||||||||||
| 27 | 21 | ▶ | sub AUTOLOAD { | ||||||||||||
|
Subroutine
AUTOLOAD: called CC=2 SCAR=7.0
| |||||||||||||||
| 28 | 21 | my ( $self, @args ) = @_; | |||||||||||||
| 29 | 21 | my $method = $AUTOLOAD; | |||||||||||||
| 30 | 21 | $method =~ s/.*:://; | |||||||||||||
| 31 | 21 | ▶ | $self->{factory}->$method(@args) if ( $self->{factory} ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 32 | } | ||||||||||||||
| 33 | |||||||||||||||
| 34 | 0 | ▶ | sub command_options_factory { | ||||||||||||
|
Subroutine
command_options_factory: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 35 | 0 | my ( $self, @args ) = @_; | |||||||||||||
| 36 | 0 | $self->{factory}->command_options_factory(@args); | |||||||||||||
| 37 | } | ||||||||||||||
| 38 | |||||||||||||||
| 39 | 2 | ▶ | sub command_runner { | ||||||||||||
|
Subroutine
command_runner: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 40 | 2 | my ( $self, @args ) = @_; | |||||||||||||
| 41 | 2 | $self->{factory}->command_runner(@args); | |||||||||||||
| 42 | } | ||||||||||||||
| 43 | |||||||||||||||
| 44 | 2 | ▶ | sub deployment { | ||||||||||||
|
Subroutine
deployment: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 45 | 2 | my ( $self, @args ) = @_; | |||||||||||||
| 46 | 2 | $self->{factory}->deployment(@args); | |||||||||||||
| 47 | } | ||||||||||||||
| 48 | |||||||||||||||
| 49 | 52 | ▶ | sub entities { | ||||||||||||
|
Subroutine
entities: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 50 | 52 | my ( $self, @args ) = @_; | |||||||||||||
| 51 | 52 | $self->{factory}->entities(@args); | |||||||||||||
| 52 | } | ||||||||||||||
| 53 | |||||||||||||||
| 54 | 20 | ▶ | sub _init { | ||||||||||||
|
Subroutine
_init: called CC=14 SCAR=29.5
| |||||||||||||||
| 55 | 20 | my ( $self, %options ) = @_; | |||||||||||||
| 56 | |||||||||||||||
| 57 | 20 | $logger->debugf( 'creating new Footprintless: %s', \%options ); | |||||||||||||
| 58 | |||||||||||||||
| 59 | 20 | ▶ | if ( $options{factory} ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 60 | 1 | $self->{factory} = $options{factory}; | |||||||||||||
| 61 | } | ||||||||||||||
| 62 | else { | ||||||||||||||
| 63 | 19 | my $entities; | |||||||||||||
| 64 | 19 | ▶ | if ( $options{entities} ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 65 | 5 | ▶ | if ( ref( $options{entities} ) eq 'HASH' ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 66 | 4 | $entities = Config::Entities->new( { entity => $options{entities} } ); | |||||||||||||
| 67 | } | ||||||||||||||
| 68 | elsif ( $options{entities}->isa('Config::Entities') ) { | ||||||||||||||
| 69 | 1 | $entities = $options{entities}; | |||||||||||||
| 70 | } | ||||||||||||||
| 71 | else { | ||||||||||||||
| 72 | 0 | croak('illegal entities, must be hashref, or Config::Entities'); | |||||||||||||
| 73 | } | ||||||||||||||
| 74 | } | ||||||||||||||
| 75 | else { | ||||||||||||||
| 76 | 14 | my $fpl_home; | |||||||||||||
| 77 | 14 | ▶ | if ( $options{fpl_home} ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 78 | 0 | $fpl_home = $options{fpl_home}; | |||||||||||||
| 79 | } | ||||||||||||||
| 80 | elsif ( $ENV{FPL_HOME} ) { | ||||||||||||||
| 81 | 0 | $fpl_home = $ENV{FPL_HOME}; | |||||||||||||
| 82 | } | ||||||||||||||
| 83 | else { | ||||||||||||||
| 84 | 14 | $fpl_home = File::Spec->catdir( $ENV{HOME}, '.footprintless' ); | |||||||||||||
| 85 | } | ||||||||||||||
| 86 | |||||||||||||||
| 87 | 14 | my @config_dirs = (); | |||||||||||||
| 88 | 14 | ▶ | if ( $options{config_dirs} ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 89 | @config_dirs = | ||||||||||||||
| 90 | ref( $options{config_dirs} ) eq 'ARRAY' | ||||||||||||||
| 91 | 0 | ? @{ $options{config_dirs} } | |||||||||||||
| 92 | 1 | ▶ | : ( $options{config_dirs} ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 93 | } | ||||||||||||||
| 94 | elsif ( $ENV{FPL_CONFIG_DIRS} ) { | ||||||||||||||
| 95 | 13 | @config_dirs = _split_dirs( $ENV{FPL_CONFIG_DIRS} ); | |||||||||||||
| 96 | } | ||||||||||||||
| 97 | else { | ||||||||||||||
| 98 | 0 | my $default = File::Spec->catdir( $fpl_home, 'config' ); | |||||||||||||
| 99 | 0 | ▶ | if ( -d $default ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 100 | 0 | @config_dirs = ($default); | |||||||||||||
| 101 | } | ||||||||||||||
| 102 | } | ||||||||||||||
| 103 | |||||||||||||||
| 104 | 14 | my @config_options = (); | |||||||||||||
| 105 | 14 | ▶ | if ( $options{config_properties} ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 106 | 0 | push( @config_options, properties_file => $options{config_properties} ); | |||||||||||||
| 107 | } | ||||||||||||||
| 108 | elsif ( $ENV{FPL_CONFIG_PROPS} ) { | ||||||||||||||
| 109 | 9 | my @properties = _split_dirs( $ENV{FPL_CONFIG_PROPS} ); | |||||||||||||
| 110 | 9 | push( @config_options, properties_file => \@properties ); | |||||||||||||
| 111 | } | ||||||||||||||
| 112 | else { | ||||||||||||||
| 113 | 5 | my $default = File::Spec->catdir( $fpl_home, 'properties.pl' ); | |||||||||||||
| 114 | 5 | ▶ | if ( -f $default ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 115 | 0 | push( @config_options, properties_file => $default ); | |||||||||||||
| 116 | } | ||||||||||||||
| 117 | } | ||||||||||||||
| 118 | |||||||||||||||
| 119 | 14 | $logger->tracef( | |||||||||||||
| 120 | "constructing entities with\n\tconfig_dirs: %s\n\tconfig_options: %s)", | ||||||||||||||
| 121 | \@config_dirs, {@config_options} ); | ||||||||||||||
| 122 | 14 | $entities = Config::Entities->new( @config_dirs, {@config_options} ); | |||||||||||||
| 123 | } | ||||||||||||||
| 124 | |||||||||||||||
| 125 | 19 | $self->{factory} = factory($entities); | |||||||||||||
| 126 | } | ||||||||||||||
| 127 | |||||||||||||||
| 128 | 20 | return $self; | |||||||||||||
| 129 | } | ||||||||||||||
| 130 | |||||||||||||||
| 131 | 0 | ▶ | sub localhost { | ||||||||||||
|
Subroutine
localhost: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 132 | 0 | my ( $self, @args ) = @_; | |||||||||||||
| 133 | 0 | $self->{factory}->localhost(@args); | |||||||||||||
| 134 | } | ||||||||||||||
| 135 | |||||||||||||||
| 136 | 4 | ▶ | sub log { | ||||||||||||
|
Subroutine
log: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 137 | 4 | my ( $self, @args ) = @_; | |||||||||||||
| 138 | 4 | $self->{factory}->log(@args); | |||||||||||||
| 139 | } | ||||||||||||||
| 140 | |||||||||||||||
| 141 | 8 | ▶ | sub plugins { | ||||||||||||
|
Subroutine
plugins: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 142 | 8 | my ($self) = @_; | |||||||||||||
| 143 | 8 | $self->{factory}->plugins(); | |||||||||||||
| 144 | } | ||||||||||||||
| 145 | |||||||||||||||
| 146 | 2 | ▶ | sub overlay { | ||||||||||||
|
Subroutine
overlay: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 147 | 2 | my ( $self, @args ) = @_; | |||||||||||||
| 148 | 2 | $self->{factory}->overlay(@args); | |||||||||||||
| 149 | } | ||||||||||||||
| 150 | |||||||||||||||
| 151 | 0 | ▶ | sub resource_manager { | ||||||||||||
|
Subroutine
resource_manager: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 152 | 0 | my ( $self, @args ) = @_; | |||||||||||||
| 153 | 0 | $self->{factory}->resource_manager(@args); | |||||||||||||
| 154 | } | ||||||||||||||
| 155 | |||||||||||||||
| 156 | 4 | ▶ | sub service { | ||||||||||||
|
Subroutine
service: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 157 | 4 | my ( $self, @args ) = @_; | |||||||||||||
| 158 | 4 | $self->{factory}->service(@args); | |||||||||||||
| 159 | } | ||||||||||||||
| 160 | |||||||||||||||
| 161 | 0 | ▶ | sub tunnel { | ||||||||||||
|
Subroutine
tunnel: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 162 | 0 | my ( $self, @args ) = @_; | |||||||||||||
| 163 | 0 | $self->{factory}->tunnel(@args); | |||||||||||||
| 164 | } | ||||||||||||||
| 165 | |||||||||||||||
| 166 | 22 | ▶ | sub _split_dirs { | ||||||||||||
|
Subroutine
_split_dirs: called CC=3 SCAR=11.0
| |||||||||||||||
| 167 | 22 | my ($dirs_string) = @_; | |||||||||||||
| 168 | |||||||||||||||
| 169 | 22 | my @dirs = (); | |||||||||||||
| 170 | 22 | ▶ | my $separator = ( $^O eq 'MSWin32' ) ? ';' : ':'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 171 | 22 | foreach my $dir ( split( /$separator/, $dirs_string ) ) { | |||||||||||||
| 172 | 31 | $dir =~ s/^\s+//; | |||||||||||||
| 173 | 31 | $dir =~ s/\s+$//; | |||||||||||||
| 174 | 31 | push( @dirs, $dir ); | |||||||||||||
| 175 | } | ||||||||||||||
| 176 | |||||||||||||||
| 177 | 22 | return @dirs; | |||||||||||||
| 178 | } | ||||||||||||||
| 179 | |||||||||||||||
| 180 | 7 | 1; | |||||||||||||
| 181 | |||||||||||||||
| 182 | __END__ | ||||||||||||||