Footprintless/App.pm

filter: Statementstmt 78.1% 43 / 55 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.8% 13 / 14 Podpod 57.1% 4 / 7 totaltotal 76.1% 64 / 84 CC 7 SCAR 12.0
CC
7
Cov
75%
REAL_footprintless_plugin_search_paths
12.0
_configure_logging
4.1
footprintless_plugin_search_paths
2.0
CRAP 3.3
« Footprintless/App/Action.pm ↑ Summary Footprintless/Overlay.pm »
1 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Footprintless::App;
5 5 $Footprintless::App::VERSION = '1.29';
6 # ABSTRACT: The base application class for fpl
7 # PODNAME: Footprintless::App
8  
9 5 ▶use App::Cmd::Setup -app;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use Footprintless;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use Footprintless::Util qw(dynamic_module_new);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use Log::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 5 my $logger = Log::Any->get_logger();
15  
16 # todo: remove after https://github.com/rjbs/App-Cmd/pull/60
17 5 my $pretend_self = {};
18  
19 14 ▶sub _configure_logging {
Subroutine _configure_logging: called CC=3 SCAR=14.2
20 14 my ( $self, %options ) = @_;
21  
22 14 my $log_configurator_module =
23 $self->footprintless()->entities()->get_entity('footprintless.log_configurator');
24 14 ▶ if ($log_configurator_module) {
Branch: 2 branches
BranchTrueFalseTotal
if ($log_configurator_module) { } 0 14 14
elsif ($options{'log_level'}) { } 0 14 14
25 0 dynamic_module_new($log_configurator_module)->configure(%options);
26 }
27 elsif ( $options{log_level} ) {
28 0 require Log::Any::Adapter;
29 Log::Any::Adapter->set( 'Stderr',
30 0 log_level => Log::Any::Adapter::Util::numeric_level( $options{log_level} ) );
31 }
32 }
33  
34 4 ▶sub clear_pretend_self {
Subroutine clear_pretend_self: called CC=1 SCAR=0.0
Pod undocumented
35  
36 #used by unit tests to clear out predend self hack between tests
37 4 $pretend_self = {};
38 }
39  
40 33 ▶sub footprintless {
Subroutine footprintless: called CC=2 SCAR=6.9
Pod documented
41 33 my ($self) = @_;
42  
43 33 ▶ if ( !defined( $pretend_self->{footprintless} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pretend_self->{"footprintless"}) 7 26 33
44 7 $pretend_self->{footprintless} = Footprintless->new();
45 }
46  
47 33 return $pretend_self->{footprintless};
48 }
49  
50 14 ▶sub get_command {
Subroutine get_command: called CC=1 SCAR=0.0
Pod documented
51 14 my ( $self, @args ) = @_;
52 14 my ( $command, $opt, @rest ) = $self->App::Cmd::get_command(@args);
53  
54 $self->_configure_logging(
55 command => $command,
56 opt => $opt,
57 rest => \@rest,
58 log_level => delete( $opt->{log} )
59 14 );
60  
61 14 return ( $command, $opt, @rest );
62 }
63  
64 14 ▶sub global_opt_spec {
Subroutine global_opt_spec: called CC=1 SCAR=0.0
Pod documented
65 14 my ($self) = @_;
66 14 return ( [ "log=s", "sets the log level", ], $self->App::Cmd::global_opt_spec() );
67 }
68  
69 # todo: remove after https://github.com/rjbs/App-Cmd/pull/60
70 5 ▶sub footprintless_plugin_search_paths {
Subroutine footprintless_plugin_search_paths: called CC=2 SCAR=7.1
Pod undocumented
71 5 my ($self) = @_;
72  
73 5 my @paths = ();
74 5 foreach my $plugin ( $self->footprintless()->plugins() ) {
75 0 push( @paths, $plugin->command_packages() );
76 }
77  
78 5 return @paths;
79 }
80  
81 0 ▶sub REAL_footprintless_plugin_search_paths {
Subroutine REAL_footprintless_plugin_search_paths: not called CC=3 SCAR=24.8
Pod undocumented
82 0 my ($self) = @_;
83  
84 0 ▶ unless ( $self->{plugin_search_paths} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"plugin_search_paths"}) 0 0 0
85 0 my @paths = ();
86 0 foreach my $plugin ( $self->footprintless()->plugins() ) {
87 0 push( @paths, $plugin->command_packages() );
88 }
89 0 $self->{plugin_search_paths} = \@paths;
90 }
91  
92 0 return @{ $self->{plugin_search_paths} };
93 }
94  
95 5 ▶sub plugin_search_path {
Subroutine plugin_search_path: called CC=1 SCAR=0.0
Pod documented
96 5 my ($self) = @_;
97  
98 5 my $search_path =
99 [ 'Footprintless::App::Command', $self->footprintless_plugin_search_paths() ];
100  
101 5 return $search_path;
102 }
103  
104 5 1;
105  
106 __END__
« Footprintless/App/Action.pm ↑ Summary Footprintless/Overlay.pm »