| 1 | package Module::Setup; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 40 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 40 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 40 | ▶ | use 5.008001; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 40 | our $VERSION = '0.06_01'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 40 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 40 | ▶ | use Class::Trigger; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 40 | ▶ | use Cwd (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 40 | ▶ | use ExtUtils::MakeMaker qw(prompt); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 40 | ▶ | use File::HomeDir; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 40 | ▶ | use File::Path; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 40 | ▶ | use File::Temp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 40 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 40 | ▶ | use Path::Class; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 40 | ▶ | use Pod::Usage; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 40 | ▶ | use Module::Setup::Devel; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 40 | ▶ | use Module::Setup::Distribute; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 40 | ▶ | use Module::Setup::Path; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 40 | ▶ | use Module::Setup::Path::Flavor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 40 | ▶ | use Module::Setup::Path::Template; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 40 | our $HAS_TERM; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 241 | ▶ | sub argv { shift->{argv} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
argv: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 139 | ▶ | sub config { shift->{config} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 1228 | ▶ | sub options { shift->{options} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
options: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 1825 | ▶ | sub base_dir { shift->{base_dir} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base_dir: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 406 | ▶ | sub distribute { shift->{distribute} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
distribute: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | ▶ | sub plugins_stash { shift->{plugins_stash} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plugins_stash: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 110 | ▶ | my($class, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 110 | ▶ | $args{options} ||= +{}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"options"} ||= {}
MC/DC100%1/1
$args{"options"} ||= {}
$args{"options"}
Truth table100%2/2
A
A= $args{"options"}
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 110 | ▶ | $args{argv} ||= +[]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"argv"} ||= []
MC/DC100%1/1
$args{"argv"} ||= []
$args{"argv"}
Truth table100%2/2
A
A= $args{"argv"}
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 110 | $args{_current_dir} = Cwd::getcwd; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 110 | my $self = bless { %args }, $class; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 110 | $self->{_current_dir} = Cwd::getcwd; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 110 | $self->{plugins_stash} = +{}; | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 110 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 84 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 84 | ▶ | chdir $self->{_current_dir} unless $self->{_current_dir} eq Cwd::getcwd; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | sub _setup_options_pod2usage { | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 3 | ▶ | pod2usage(1); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setup_options_pod2usage: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | sub _setup_options_version { | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | ▶ | print "module-setup v$VERSION\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setup_options_version: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | sub setup_options { | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 17 | ▶ | my($self, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_options: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 17 | $Module::Setup::HAS_TERM = 1; | |||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 17 | ▶ | _setup_options_pod2usage unless @ARGV; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 17 | my $options = {}; | |||||||||||||||||||||||||||||||||||||||||
| 68 | GetOptions( | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 'init' => \($options->{init}), | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 'pack' => \($options->{pack}), | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 'direct' => \($options->{direct}), | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 'flavor|flavour=s' => \($options->{flavor}), | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 'flavor-class|flavour-class=s' => \($options->{flavor_class}), | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 'additional=s' => \($options->{additional}), | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 'without-additional' => \($options->{without_additional}), | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 'executable' => \($options->{executable}), | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 'plugin=s@' => \($options->{plugins}), | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 'target' => \($options->{target}), | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 'module-setup-dir' => \($options->{module_setup_dir}), | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 'devel' => \($options->{devel}), | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 17 | ▶ | 'test' => \($options->{test}), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | version => \&_setup_options_version, | ||||||||||||||||||||||||||||||||||||||||||
| 83 | help => \&_setup_options_pod2usage, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | ) or _setup_options_pod2usage; | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 17 | $self->{options} = $options; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 17 | $self->{argv} = [ @ARGV ]; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 17 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | sub _clear_triggers { | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 130 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clear_triggers: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | # reset triggers # this is bad hack | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 130 | delete $self->{__triggers}; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 130 | delete $self->{_class_trigger_results}; | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | sub _load_argv { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 157 | ▶ | my($self, $name, $default) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_argv: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 157 | ▶ | $self->options->{$name} = @{ $self->argv } ? shift @{ $self->argv } : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 157 | ▶ | if (!$self->options->{$name} && defined $default) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $self->options->{$name} and defined $default
MC/DC100%2/2
not $self->options->{$name} and defined $default
not $self->options->{$name}
defined $default
Truth table100%3/3
not(A) and B
A= not $self->options->{$name}B= defined $default
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 75 | ▶ | $self->options->{$name} = ref($default) eq 'CODE' ? $default->() : $default; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 157 | $self->options->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | sub _load_argv_module { | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 62 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_argv_module: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 62 | $self->_load_argv( module => '' ); | |||||||||||||||||||||||||||||||||||||||||
| 111 | 62 | ▶ | Carp::croak "module name is required" unless $self->options->{module}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 61 | $self->options->{module}; | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | sub _load_argv_flavor { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 61 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_argv_flavor: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 61 | ▶ | $self->_load_argv( flavor => sub { $self->select_flavor } ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 61 | ▶ | Carp::croak "flavor name is required" unless $self->options->{flavor}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 60 | $self->options->{flavor}; | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | sub setup_base_dir { | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 95 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_base_dir: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 95 | my $path; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 95 | ▶ | if ($self->options->{direct}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | $path = File::Temp->newdir; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 94 | ▶ | $path = $self->options->{module_setup_dir} || $ENV{MODULE_SETUP_DIR} || Path::Class::Dir->new(File::HomeDir->my_home, '.module-setup'); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$self->options->{'module_setup_dir'} || $ENV{'MODULE_SETUP_DIR'} || 'Path::Class::Dir'->new('File::HomeDir'->my_home, '.module-setup')
$self->options->{"module_setup_dir"} or $ENV{"MODULE_SETUP_DIR"}
MC/DC100%3/3
$self->options->{'module_setup_dir'} || $ENV{'MODULE_SETUP_DIR'} || 'Path::Class::Dir'->new('File::HomeDir'->my_home, '.module-setup')
$self->options->{"module_setup_dir"}
$ENV{"MODULE_SETUP_DIR"}
'Path::Class::Dir'->new('File::HomeDir'->my_home, '.module-setup')
Truth table100%4/4
A or B || C
A= $self->options->{"module_setup_dir"}B= $ENV{"MODULE_SETUP_DIR"}C= 'Path::Class::Dir'->new('File::HomeDir'->my_home, '.module-setup')
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 95 | ▶ | die 'module_setup directory was not able to be discovered.' unless $path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 94 | $self->{base_dir} = Module::Setup::Path->new($path); | |||||||||||||||||||||||||||||||||||||||||
| 133 | 94 | ▶ | $self->base_dir->init_directories unless $self->base_dir->is_initialized; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | sub run { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 91 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 91 | my $options = $self->options; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 91 | $self->_clear_triggers; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 91 | ▶ | $options->{flavor_class} ||= 'Default'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options->{"flavor_class"} ||= "Default"
MC/DC100%1/1
$options->{"flavor_class"} ||= "Default"
$options->{"flavor_class"}
Truth table100%2/2
A
A= $options->{"flavor_class"}
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 91 | ▶ | return Module::Setup::Devel->new($self)->run if $options->{devel}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 91 | $self->setup_base_dir; | |||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 91 | ▶ | if ($options->{init} || (!$options->{pack} && $options->{additional})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$options->{"init"} or not $options->{"pack"} and $options->{"additional"}
not $options->{"pack"} and $options->{"additional"}
MC/DC66%2/3
$options->{"init"} or not $options->{"pack"} and $options->{"additional"}
$options->{"init"}
not $options->{"pack"}
$options->{"additional"}
Truth table75%3/4
A or not(B) and C
A= $options->{"init"}B= not $options->{"pack"}C= $options->{"additional"}
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 29 | $self->_load_argv( flavor => 'default' ); | |||||||||||||||||||||||||||||||||||||||||
| 148 | 29 | return $self->create_flavor; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 62 | $self->_load_argv_module; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 61 | $self->_load_argv_flavor; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 60 | $self->base_dir->set_flavor($options->{flavor}); | |||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 60 | ▶ | if ($options->{additional} && !-d $self->base_dir->flavor->additional->path_to($options->{additional})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$options->{"additional"} and not -d $self->base_dir->flavor->additional->path_to($options->{"additional"})
MC/DC100%2/2
$options->{"additional"} and not -d $self->base_dir->flavor->additional->path_to($options->{"additional"})
$options->{"additional"}
not -d $self->base_dir->flavor->additional->path_to($options->{"additional"})
Truth table100%3/3
A and not(B)
A= $options->{"additional"}B= not -d $self->base_dir->flavor->additional->path_to($options->{"additional"})
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | Carp::croak "additional template is no exist: $options->{additional}"; | |||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 59 | ▶ | return $self->pack_flavor if $options->{pack}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 49 | ▶ | unless ($self->base_dir->flavor->is_dir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 20 | ▶ | return unless $self->create_flavor; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 46 | $self->load_config; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 46 | $self->load_plugins; | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | # create skeleton | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 46 | $self->create_skeleton; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 46 | $self->call_trigger( 'after_create_skeleton' ); | |||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | # test | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 46 | chdir $self->distribute->dist_path; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 46 | $self->call_trigger( 'check_skeleton_directory' ); | |||||||||||||||||||||||||||||||||||||||||
| 175 | 39 | $self->call_trigger( 'finalize_create_skeleton' ); | |||||||||||||||||||||||||||||||||||||||||
| 176 | 39 | chdir $self->{_current_dir}; | |||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 39 | $self->call_trigger( 'finish_of_run' ); | |||||||||||||||||||||||||||||||||||||||||
| 179 | 37 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | sub load_config { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 46 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_config: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 46 | my $options = $self->options; | |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 46 | ▶ | my $option_plugins = delete $options->{plugins} || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $options->{'plugins'} || []
MC/DC100%1/1
delete $options->{'plugins'} || []
delete $options->{'plugins'}
Truth table100%2/2
A
A= delete $options->{'plugins'}
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 46 | my $config = $self->base_dir->flavor->config->load; | |||||||||||||||||||||||||||||||||||||||||
| 189 | $config = +{ | ||||||||||||||||||||||||||||||||||||||||||
| 190 | plugins => [], | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 46 | %{ $config }, | |||||||||||||||||||||||||||||||||||||||||
| 192 | 46 | %{ $options }, | |||||||||||||||||||||||||||||||||||||||||
| 193 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 46 | push @{ $config->{plugins} }, @{ $option_plugins }; | |||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 46 | $self->{config} = $config; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | sub plugin_collect { | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 86 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plugin_collect: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 86 | my %loaded_local_plugin; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 86 | for my $local_plugin ( $self->base_dir->global_plugins->collect, $self->base_dir->flavor->plugins->collect ) { | |||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | $local_plugin->require; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | ▶ | if ($local_plugin->package->isa('Module::Setup::Plugin')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $loaded_local_plugin{$local_plugin->package} = $local_plugin; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 86 | %loaded_local_plugin; | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | sub load_plugins { | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 86 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_plugins: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 86 | my %loaded_local_plugin = $self->plugin_collect; | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 86 | ▶ | $self->{loaded_plugin} ||= +{}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"loaded_plugin"} ||= {}
MC/DC100%1/1
$self->{"loaded_plugin"} ||= {}
$self->{"loaded_plugin"}
Truth table100%2/2
A
A= $self->{"loaded_plugin"}
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 86 | for my $plugin (@{ $self->config->{plugins} }) { | |||||||||||||||||||||||||||||||||||||||||
| 219 | 320 | my $pkg; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 320 | my $config = +{}; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 320 | ▶ | if (ref($plugin)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 4 | ▶ | if (ref($plugin) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 2 | $pkg = $plugin->{module}; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | $config = $plugin->{config}; | |||||||||||||||||||||||||||||||||||||||||
| 225 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 316 | $pkg = $plugin; | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 318 | ▶ | $pkg = "Module::Setup::Plugin::$pkg" unless $pkg =~ s/^\+//; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 318 | ▶ | unless ($loaded_local_plugin{$pkg}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 318 | eval "require $pkg"; ## no critic | |||||||||||||||||||||||||||||||||||||||||
| 235 | 318 | ▶ | Carp::croak $@ if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 317 | $self->{loaded_plugin}->{$pkg} = $pkg->new( context => $self, config => $config ); | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | sub write_file { | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 806 | ▶ | my($self, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_file: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 806 | my $path = $opts->{dist_path}; | |||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 806 | ▶ | if (-e $path) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 58 | my $ans = $self->dialog("$path exists. Override? [yN] ", 'n'); | |||||||||||||||||||||||||||||||||||||||||
| 247 | 58 | ▶ | return if $ans !~ /[Yy]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 748 | $path->dir->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 760 | my $template; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 760 | ▶ | if ($opts->{is_binary}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | $template = pack 'H*', $opts->{template}; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 759 | $template = $opts->{template}; | |||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | 760 | $self->log("Creating $path"); | |||||||||||||||||||||||||||||||||||||||||
| 260 | 760 | my $out = $path->openw; | |||||||||||||||||||||||||||||||||||||||||
| 261 | 760 | $out->print($template); | |||||||||||||||||||||||||||||||||||||||||
| 262 | 760 | $out->close; | |||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 760 | ▶ | chmod oct($opts->{chmod}), $path if $opts->{chmod}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | sub install_flavor { | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 389 | ▶ | my($self, $tmpl) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install_flavor: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 389 | my $flavor = $self->base_dir->flavor; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 389 | my $template_path = $flavor->template; | |||||||||||||||||||||||||||||||||||||||||
| 272 | 389 | ▶ | if (exists $tmpl->{additional}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 21 | $template_path = Module::Setup::Path::Template->new($flavor->additional->path, $tmpl->{additional}); | |||||||||||||||||||||||||||||||||||||||||
| 274 | 21 | $template_path->path->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 389 | my $path; | |||||||||||||||||||||||||||||||||||||||||
| 278 | 389 | ▶ | if (exists $tmpl->{file} && $tmpl->{file}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
exists $tmpl->{"file"} and $tmpl->{"file"}
MC/DC100%2/2
exists $tmpl->{"file"} and $tmpl->{"file"}
exists $tmpl->{"file"}
$tmpl->{"file"}
Truth table100%3/3
A and B
A= exists $tmpl->{"file"}B= $tmpl->{"file"}
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 366 | $path = $template_path->path_to(split '/', $tmpl->{file}); | |||||||||||||||||||||||||||||||||||||||||
| 280 | ▶ | } elsif (exists $tmpl->{dir} && $tmpl->{dir}) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
exists $tmpl->{"dir"} and $tmpl->{"dir"}
MC/DC100%2/2
exists $tmpl->{"dir"} and $tmpl->{"dir"}
exists $tmpl->{"dir"}
$tmpl->{"dir"}
Truth table100%3/3
A and B
A= exists $tmpl->{"dir"}B= $tmpl->{"dir"}
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 9 | return Module::Setup::Path::Dir->new( $template_path->path, split('/', $tmpl->{dir}) )->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 282 | ▶ | } elsif (exists $tmpl->{plugin} && $tmpl->{plugin} && !exists $tmpl->{additional}) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
exists $tmpl->{"plugin"} and $tmpl->{"plugin"} and not exists $tmpl->{"additional"}
exists $tmpl->{"plugin"} and $tmpl->{"plugin"}
MC/DC100%3/3
exists $tmpl->{"plugin"} and $tmpl->{"plugin"} and not exists $tmpl->{"additional"}
exists $tmpl->{"plugin"}
$tmpl->{"plugin"}
not exists $tmpl->{"additional"}
Truth table100%4/4
A and B and not(C)
A= exists $tmpl->{"plugin"}B= $tmpl->{"plugin"}C= not exists $tmpl->{"additional"}
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 2 | $path = $flavor->plugins->path_to(split '/', $tmpl->{plugin}); | |||||||||||||||||||||||||||||||||||||||||
| 284 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | $self->write_file(+{ | ||||||||||||||||||||||||||||||||||||||||||
| 289 | dist_path => $path, | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 368 | %{ $tmpl }, | |||||||||||||||||||||||||||||||||||||||||
| 291 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | sub _load_flavor_class { | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 49 | ▶ | my($self, $class) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_flavor_class: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 49 | ▶ | $class = "Module::Setup::Flavor::$class" unless $class =~ s/^\+//; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 49 | ▶ | eval " require $class "; Carp::croak $@ if $@; ## no critic | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 48 | $class; | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | sub create_flavor { | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 49 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_flavor: called CC=18 SCAR=28.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 49 | my $options = $self->options; | |||||||||||||||||||||||||||||||||||||||||
| 305 | 49 | my $name = $options->{flavor}; | |||||||||||||||||||||||||||||||||||||||||
| 306 | 49 | my $flavor_class = $self->_load_flavor_class($options->{flavor_class}); | |||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 48 | $self->base_dir->set_flavor($name); | |||||||||||||||||||||||||||||||||||||||||
| 309 | 48 | ▶ | Carp::croak "create flavor: $name exists " if $self->base_dir->flavor->is_exists && !exists $options->{additional}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->base_dir->flavor->is_exists and not exists $options->{"additional"}
MC/DC100%2/2
$self->base_dir->flavor->is_exists and not exists $options->{"additional"}
$self->base_dir->flavor->is_exists
not exists $options->{"additional"}
Truth table100%3/3
A and not(B)
A= $self->base_dir->flavor->is_existsB= not exists $options->{"additional"}
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 47 | my $flavor = $flavor_class->new; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 47 | ▶ | return unless $flavor->setup_flavor($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 45 | my @template = $flavor->loader; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 45 | my $config = +{}; | |||||||||||||||||||||||||||||||||||||||||
| 315 | 45 | my $additional_config = +{}; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 45 | ▶ | if ($options->{additional}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 5 | $additional_config = $self->base_dir->flavor->additional->config->load; | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 45 | for my $tmpl (@template) { | |||||||||||||||||||||||||||||||||||||||||
| 320 | 424 | ▶ | if (exists $tmpl->{config} && ref($tmpl->{config}) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $tmpl->{"config"} and ref $tmpl->{"config"} eq "HASH"
MC/DC100%2/2
exists $tmpl->{"config"} and ref $tmpl->{"config"} eq "HASH"
exists $tmpl->{"config"}
ref $tmpl->{"config"} eq "HASH"
Truth table100%3/3
A and B
A= exists $tmpl->{"config"}B= ref $tmpl->{"config"} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 35 | $config = $tmpl->{config}; | |||||||||||||||||||||||||||||||||||||||||
| 322 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 389 | my $additional; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 389 | ▶ | if (exists $tmpl->{additional}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 6 | $additional = $tmpl->{additional}; | |||||||||||||||||||||||||||||||||||||||||
| 326 | } elsif ($options->{additional}) { | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 15 | $additional = $options->{additional}; | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 389 | ▶ | local $tmpl->{additional} = $additional if $additional; ## no critic; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 389 | ▶ | if ($additional) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 21 | $additional_config->{$additional} = +{ | |||||||||||||||||||||||||||||||||||||||||
| 332 | class => $flavor_class, | ||||||||||||||||||||||||||||||||||||||||||
| 333 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 389 | $self->install_flavor($tmpl); | |||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 45 | $config->{class} = $flavor_class; | |||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | 45 | $self->base_dir->flavor->additional->path->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 341 | 45 | $self->base_dir->flavor->additional->config->dump($additional_config); | |||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 45 | ▶ | if ($options->{additional}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 5 | $flavor->setup_additional($self, $config); | |||||||||||||||||||||||||||||||||||||||||
| 345 | 5 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 40 | $self->base_dir->flavor->plugins->path->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 40 | $self->base_dir->flavor->template->path->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | 40 | ▶ | if (exists $options->{plugins} && $options->{plugins} && @{ $options->{plugins} }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
exists $options->{"plugins"} and $options->{"plugins"} and @{$options->{"plugins"};}
exists $options->{"plugins"} and $options->{"plugins"}
MC/DC100%3/3
exists $options->{"plugins"} and $options->{"plugins"} and @{$options->{"plugins"};}
exists $options->{"plugins"}
$options->{"plugins"}
@{$options->{"plugins"};}
Truth table100%4/4
A and B and C
A= exists $options->{"plugins"}B= $options->{"plugins"}C= @{$options->{"plugins"};}
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 6 | ▶ | $config->{plugins} ||= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$config->{"plugins"} ||= []
MC/DC100%1/1
$config->{"plugins"} ||= []
$config->{"plugins"}
Truth table100%2/2
A
A= $config->{"plugins"}
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 6 | push @{ $config->{plugins} }, @{ delete $options->{plugins} }; | |||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | 40 | ▶ | $config->{plugins} ||= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$config->{"plugins"} ||= []
MC/DC100%1/1
$config->{"plugins"} ||= []
$config->{"plugins"}
Truth table100%2/2
A
A= $config->{"plugins"}
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 40 | $flavor->setup_config($self, $config); | |||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | # load plugins | ||||||||||||||||||||||||||||||||||||||||||
| 360 | local $self->{config} = +{ | ||||||||||||||||||||||||||||||||||||||||||
| 361 | 40 | %{ $config }, | |||||||||||||||||||||||||||||||||||||||||
| 362 | 40 | %{ $options }, | |||||||||||||||||||||||||||||||||||||||||
| 363 | plugins => $config->{plugins}, | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 40 | }; | |||||||||||||||||||||||||||||||||||||||||
| 365 | 40 | $self->load_plugins; | |||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 39 | $self->call_trigger( before_dump_config => $config ); | |||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | 39 | $self->_clear_triggers; | |||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 39 | $self->base_dir->flavor->config->dump($config); | |||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | sub create_skeleton { | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 46 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_skeleton: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | 46 | my $config = $self->config; | |||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | $self->{distribute} = Module::Setup::Distribute->new( | ||||||||||||||||||||||||||||||||||||||||||
| 379 | $config->{module}, | ||||||||||||||||||||||||||||||||||||||||||
| 380 | target => $config->{target}, | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 46 | ); | |||||||||||||||||||||||||||||||||||||||||
| 382 | 46 | $self->call_trigger( 'after_setup_module_attribute' ); | |||||||||||||||||||||||||||||||||||||||||
| 383 | 46 | $self->distribute->dist_path->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | my $template_vars = { | ||||||||||||||||||||||||||||||||||||||||||
| 386 | module => $self->distribute->module, | ||||||||||||||||||||||||||||||||||||||||||
| 387 | dist => $self->distribute->dist_name, | ||||||||||||||||||||||||||||||||||||||||||
| 388 | module_path => $self->distribute->module_path, | ||||||||||||||||||||||||||||||||||||||||||
| 389 | 46 | module_unix_path => join('/', @{ $self->distribute->package }), | |||||||||||||||||||||||||||||||||||||||||
| 390 | config => $config, | ||||||||||||||||||||||||||||||||||||||||||
| 391 | distribute => $self->distribute, | ||||||||||||||||||||||||||||||||||||||||||
| 392 | localtime => scalar localtime, | ||||||||||||||||||||||||||||||||||||||||||
| 393 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 46 | $self->call_trigger( after_setup_template_vars => $template_vars); | |||||||||||||||||||||||||||||||||||||||||
| 395 | 46 | $self->{distribute}->set_template_vars($template_vars); | |||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 46 | for my $path ($self->base_dir->flavor->template->find_files) { | |||||||||||||||||||||||||||||||||||||||||
| 398 | 428 | $self->{distribute}->install_template($self, $path); | |||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | 46 | $self->call_trigger( 'append_template_file' ); | |||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 46 | return $template_vars; | |||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | sub _collect_flavor_files { | ||||||||||||||||||||||||||||||||||||||||||
| 406 | 24 | ▶ | my($self, $template, $path_name, $type) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_collect_flavor_files: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 24 | my $base_path = $type->path; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 24 | for my $file ($type->find_files) { | |||||||||||||||||||||||||||||||||||||||||
| 410 | 99 | ▶ | my @path = $file->is_dir ? $file->dir_list : ($file->dir->dir_list, $file->basename); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 99 | ▶ | while ($path[0] eq '.') { shift @path }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | 99 | ▶ | if ($file->is_dir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 5 | push @{ $template }, +{ | |||||||||||||||||||||||||||||||||||||||||
| 415 | dir => join('/', @path), | ||||||||||||||||||||||||||||||||||||||||||
| 416 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 417 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 94 | my $body = $type->path_to($file)->slurp; | |||||||||||||||||||||||||||||||||||||||||
| 419 | 94 | my $tmpl = +{ | |||||||||||||||||||||||||||||||||||||||||
| 420 | $path_name => join('/', @path), | ||||||||||||||||||||||||||||||||||||||||||
| 421 | template => $body, | ||||||||||||||||||||||||||||||||||||||||||
| 422 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 94 | ▶ | if (-B $type->path_to($file)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 1 | $tmpl->{template} = unpack 'H*', $body; | |||||||||||||||||||||||||||||||||||||||||
| 425 | 1 | $tmpl->{is_binary} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 427 | 94 | push @{ $template }, $tmpl; | |||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | sub pack_flavor { | ||||||||||||||||||||||||||||||||||||||||||
| 433 | 10 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack_flavor: called CC=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 10 | my $config = $self->options; | |||||||||||||||||||||||||||||||||||||||||
| 435 | 10 | my $module = $config->{module}; | |||||||||||||||||||||||||||||||||||||||||
| 436 | 10 | my $flavor = $config->{flavor}; | |||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | 10 | my $template = []; | |||||||||||||||||||||||||||||||||||||||||
| 439 | 10 | ▶ | my $flavor_dir = exists $config->{flavor_dir} ? Module::Setup::Path::Flavor->new( $config->{flavor_dir} ) : $self->base_dir->flavor; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 10 | $self->_collect_flavor_files($template, file => $flavor_dir->template); | |||||||||||||||||||||||||||||||||||||||||
| 441 | 10 | $self->_collect_flavor_files($template, plugin => $flavor_dir->plugins); | |||||||||||||||||||||||||||||||||||||||||
| 442 | 10 | push @{ $template }, +{ | |||||||||||||||||||||||||||||||||||||||||
| 443 | config => YAML::LoadFile($flavor_dir->config->path), | ||||||||||||||||||||||||||||||||||||||||||
| 444 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | 10 | ▶ | unless ($config->{without_additional}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 9 | ▶ | $template = [] if $config->{additional}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 448 | 9 | for my $additional ( $flavor_dir->additional->path->children ) { | |||||||||||||||||||||||||||||||||||||||||
| 449 | 18 | ▶ | next unless $additional->is_dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | 6 | my $name = $additional->dir_list(-1); | |||||||||||||||||||||||||||||||||||||||||
| 451 | 6 | ▶ | next if $config->{additional} && $name ne $config->{additional}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$config->{"additional"} and $name ne $config->{"additional"}
MC/DC100%2/2
$config->{"additional"} and $name ne $config->{"additional"}
$config->{"additional"}
$name ne $config->{"additional"}
Truth table100%3/3
A and B
A= $config->{"additional"}B= $name ne $config->{"additional"}
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 4 | my $base_path = Module::Setup::Path::Template->new($flavor_dir->additional->path, $name); | |||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | 4 | my $templates = []; | |||||||||||||||||||||||||||||||||||||||||
| 455 | 4 | $self->_collect_flavor_files($templates, file => $base_path); | |||||||||||||||||||||||||||||||||||||||||
| 456 | 4 | ▶ | if ($config->{additional}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | 2 | push @{ $template }, @{ $templates }; | |||||||||||||||||||||||||||||||||||||||||
| 458 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 459 | 2 | push @{ $template }, map { $_->{additional} = $name; $_ } @{ $templates }; | |||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | 10 | my $executable_code = ''; | |||||||||||||||||||||||||||||||||||||||||
| 465 | 10 | ▶ | if ($config->{executable}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | $executable_code = <<EXECUTABLE__; | |||||||||||||||||||||||||||||||||||||||||
| 467 | #!/bin/env perl | ||||||||||||||||||||||||||||||||||||||||||
| 468 | package main; | ||||||||||||||||||||||||||||||||||||||||||
| 469 | use strict; | ||||||||||||||||||||||||||||||||||||||||||
| 470 | use warnings; | ||||||||||||||||||||||||||||||||||||||||||
| 471 | use Module::Setup; | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | my \$msetup = Module::Setup->new; | ||||||||||||||||||||||||||||||||||||||||||
| 474 | \$msetup->setup_options; | ||||||||||||||||||||||||||||||||||||||||||
| 475 | \$msetup->options->{direct} = 1; | ||||||||||||||||||||||||||||||||||||||||||
| 476 | \$msetup->options->{flavor_class} = '+$config->{module}'; | ||||||||||||||||||||||||||||||||||||||||||
| 477 | { | ||||||||||||||||||||||||||||||||||||||||||
| 478 | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||
| 479 | *Module::Setup::_load_flavor_class = sub { '$config->{module}' }; | ||||||||||||||||||||||||||||||||||||||||||
| 480 | \$msetup->run; | ||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 482 | EXECUTABLE__ | ||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 10 | my $eq = '='; | |||||||||||||||||||||||||||||||||||||||||
| 486 | 10 | my $yaml = YAML::Dump(@{ $template }); | |||||||||||||||||||||||||||||||||||||||||
| 487 | 10 | $self->stdout(<<FLAVOR__); | |||||||||||||||||||||||||||||||||||||||||
| 488 | $executable_code | ||||||||||||||||||||||||||||||||||||||||||
| 489 | package $module; | ||||||||||||||||||||||||||||||||||||||||||
| 490 | use strict; | ||||||||||||||||||||||||||||||||||||||||||
| 491 | use warnings; | ||||||||||||||||||||||||||||||||||||||||||
| 492 | use base 'Module::Setup::Flavor'; | ||||||||||||||||||||||||||||||||||||||||||
| 493 | 1; | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | ${eq}head1 | ||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | $module - pack from $flavor | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | ${eq}head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | $ module-setup --init --flavor-class=+$module new_flavor | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | ${eq}cut | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | \__DATA__ | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | $yaml | ||||||||||||||||||||||||||||||||||||||||||
| 508 | FLAVOR__ | ||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | sub select_flavor { | ||||||||||||||||||||||||||||||||||||||||||
| 512 | 53 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
select_flavor: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | 53 | ▶ | return 'default' if $self->options->{direct}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 514 | 52 | ▶ | return 'default' if $self->base_dir->flavors->path->children == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | 34 | my @flavors; | |||||||||||||||||||||||||||||||||||||||||
| 517 | 34 | for my $flavor ( $self->base_dir->flavors->path->children ) { | |||||||||||||||||||||||||||||||||||||||||
| 518 | 37 | ▶ | next unless $flavor->is_dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 519 | 36 | my $name = $flavor->dir_list(-1); | |||||||||||||||||||||||||||||||||||||||||
| 520 | 36 | ▶ | ($name eq 'default') ? unshift @flavors, $name : push @flavors, $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||
| 522 | 34 | ▶ | return $flavors[0] if @flavors == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | 1 | my $num = 1; | |||||||||||||||||||||||||||||||||||||||||
| 525 | 1 | my $message; | |||||||||||||||||||||||||||||||||||||||||
| 526 | 1 | for my $flavor (@flavors) { | |||||||||||||||||||||||||||||||||||||||||
| 527 | 3 | $message .= sprintf "[%d]: %s\n", $num++, $flavor; | |||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||
| 530 | 1 | my $selected; | |||||||||||||||||||||||||||||||||||||||||
| 531 | $self->dialog( "${message}Select flavor:", 1, sub { | ||||||||||||||||||||||||||||||||||||||||||
| 532 | 5 | ▶ | my($self, $ret) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | 5 | ▶ | return unless $ret =~ /^[0-9]+$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | 2 | $selected = $flavors[ $ret - 1 ]; | |||||||||||||||||||||||||||||||||||||||||
| 535 | 1 | } ); | |||||||||||||||||||||||||||||||||||||||||
| 536 | 1 | $self->log("You chose flavor: $selected"); | |||||||||||||||||||||||||||||||||||||||||
| 537 | 1 | return $selected; | |||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | sub stdout { | ||||||||||||||||||||||||||||||||||||||||||
| 541 | 2 | ▶ | my($self, $msg) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stdout: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | 2 | ▶ | print STDOUT "$msg\n" if $HAS_TERM; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||
| 544 | sub log { | ||||||||||||||||||||||||||||||||||||||||||
| 545 | 1202 | ▶ | my($self, $msg) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | 1202 | ▶ | print STDERR "$msg\n" if $HAS_TERM; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||
| 548 | sub dialog { | ||||||||||||||||||||||||||||||||||||||||||
| 549 | 84 | ▶ | my($self, $msg, $default, $validator_callback) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dialog: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | 84 | ▶ | return $default unless $HAS_TERM; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | 4 | while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 552 | 9 | my $ret = prompt($msg, $default); | |||||||||||||||||||||||||||||||||||||||||
| 553 | 9 | ▶ | return $ret unless $validator_callback && ref($validator_callback) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$validator_callback and ref $validator_callback eq "CODE"
MC/DC100%2/2
$validator_callback and ref $validator_callback eq "CODE"
$validator_callback
ref $validator_callback eq "CODE"
Truth table100%3/3
A and B
A= $validator_callbackB= ref $validator_callback eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||
| 554 | 7 | ▶ | return $ret if $validator_callback->($self, $ret); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | sub system { | ||||||||||||||||||||||||||||||||||||||||||
| 559 | 2 | ▶ | my($self, @args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
system: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 560 | 2 | CORE::system(@args); | |||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 40 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 564 | __END__ | ||||||||||||||||||||||||||||||||||||||||||