| 1 | 6 | ▶ | use 5.008; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 2 | 6 | ▶ | use warnings; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||
| 5 | package Class::Scaffold::App; | ||||||||||||||||||||||||
| 6 | 6 | ▶ | BEGIN { | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 7 | 6 | $Class::Scaffold::App::VERSION = '1.102280'; | |||||||||||||||||||||||
| 8 | } | ||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||
| 10 | # ABSTRACT: Base class for framework applications | ||||||||||||||||||||||||
| 11 | 6 | ▶ | use Class::Scaffold::Environment; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 12 | 6 | ▶ | use Property::Lookup; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 13 | 6 | ▶ | use Error ':try'; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 14 | 6 | ▶ | use parent 'Class::Scaffold::Storable'; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 15 | 6 | __PACKAGE__->mk_boolean_accessors(qw(initialized)); | |||||||||||||||||||||||
| 16 | 6 | ▶ | use IO::Handle; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 17 | 6 | STDOUT->autoflush; | |||||||||||||||||||||||
| 18 | 6 | STDERR->autoflush; | |||||||||||||||||||||||
| 19 | 6 | ▶ | use constant CONTEXT => 'generic/generic'; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||
| 21 | 0 | ▶ | sub app_init { | ||||||||||||||||||||||
|
Subroutine
app_init: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||
| 22 | 0 | my $self = shift; | |||||||||||||||||||||||
| 23 | 0 | ▶ | return if $self->initialized; # See POD | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 24 | 0 | $self->initialized(1); | |||||||||||||||||||||||
| 25 | 0 | my $configurator = Property::Lookup->instance; | |||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||
| 27 | # If a subclass added a getopt configurator, we can ask it for the | ||||||||||||||||||||||||
| 28 | # location of the conf file, in case the user specified '--conf' on the | ||||||||||||||||||||||||
| 29 | # command line. If a filename is given, we'll use that conf file. If the | ||||||||||||||||||||||||
| 30 | # special string "local" is given, we try to find the conf file. | ||||||||||||||||||||||||
| 31 | # Otherwise use the one given in an environment variable. | ||||||||||||||||||||||||
| 32 | 0 | ▶ | my $conf_file_spec = $configurator->conf || $ENV{CF_CONF} || ''; | ||||||||||||||||||||||
|
Condition0%0/5
$configurator->conf || $ENV{'CF_CONF'} || ''
$configurator->conf or $ENV{"CF_CONF"}
MC/DC0%0/2
$configurator->conf || $ENV{'CF_CONF'} || ''
$configurator->conf
$ENV{"CF_CONF"}
Truth table0%0/3
A or B
A= $configurator->confB= $ENV{"CF_CONF"}
| |||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||
| 34 | # make a note of the configuration file spec in the configurator | ||||||||||||||||||||||||
| 35 | 0 | $configurator->default_layer->hash(conf_file_spec => $conf_file_spec); | |||||||||||||||||||||||
| 36 | 0 | for my $conf_file (split /[:;]/, $conf_file_spec) { | |||||||||||||||||||||||
| 37 | 0 | ▶ | if ($conf_file eq 'local') { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||
| 39 | # only load if needed | ||||||||||||||||||||||||
| 40 | 0 | require Class::Scaffold::Introspect; | |||||||||||||||||||||||
| 41 | 0 | $conf_file = Class::Scaffold::Introspect::find_conf_file(); | |||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||
| 43 | 0 | $configurator->add_layer(file => $conf_file); | |||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||
| 45 | 0 | ▶ | $self->log->max_level(1 + ($configurator->verbose || 0)); | ||||||||||||||||||||||
|
Condition0%0/2
$configurator->verbose || 0
MC/DC0%0/1
$configurator->verbose || 0
$configurator->verbose
Truth table0%0/2
A
A= $configurator->verbose
| |||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||
| 47 | # Now that we have both a getopt and a file configurator, the log file | ||||||||||||||||||||||||
| 48 | # name can come from either the command line (preferred) or the conf file. | ||||||||||||||||||||||||
| 49 | 0 | ▶ | $self->log->filename($configurator->logfile) | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 50 | if defined $configurator->logfile; | ||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||
| 52 | # This class subclasses Class::Scaffold::Base, which returns | ||||||||||||||||||||||||
| 53 | # Class::Scaffold::Environment->getenv as the default delegate. So set the | ||||||||||||||||||||||||
| 54 | # proper environment here and then pass the newly formed delegate the | ||||||||||||||||||||||||
| 55 | # configurator. The environment will make use of it in its methods. | ||||||||||||||||||||||||
| 56 | 0 | Class::Scaffold::Environment->setenv($configurator->environment); | |||||||||||||||||||||||
| 57 | 0 | $self->delegate->setup; | |||||||||||||||||||||||
| 58 | 0 | $self->delegate->configurator($configurator); | |||||||||||||||||||||||
| 59 | 0 | $self->delegate->context( | |||||||||||||||||||||||
| 60 | Class::Scaffold::Context->new->parse_context($self->CONTEXT)); | ||||||||||||||||||||||||
| 61 | 0 | ▶ | if ($configurator->dryrun) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 62 | 0 | $self->log->clear_timestamp; | |||||||||||||||||||||||
| 63 | 0 | $self->delegate->set_rollback_mode; | |||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||
| 66 | 0 | ▶ | sub app_finish { 1 } | ||||||||||||||||||||||
|
Subroutine
app_finish: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||
| 67 | 0 | ▶ | sub app_code { } | ||||||||||||||||||||||
|
Subroutine
app_code: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||
| 69 | 0 | ▶ | sub run_app { | ||||||||||||||||||||||
|
Subroutine
run_app: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||
| 70 | 0 | my $self = shift; | |||||||||||||||||||||||
| 71 | 0 | $self->app_init; | |||||||||||||||||||||||
| 72 | 0 | $Error::Debug++; # to get a stacktrace | |||||||||||||||||||||||
| 73 | 0 | ▶ | try { | ||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||
| 74 | 0 | $self->app_code; | |||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||
| 76 | 0 | ▶ | catch Error with { | ||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||
| 77 | 0 | my $E = shift; | |||||||||||||||||||||||
| 78 | $self->log->info($E->{statement}) | ||||||||||||||||||||||||
| 79 | 0 | ▶ | if ref $E eq 'Error::Hierarchy::Internal::DBI::DBH'; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 80 | 0 | $self->log->info('Application exception: %s', $E); | |||||||||||||||||||||||
| 81 | 0 | $self->log->info('%s', $E->stacktrace); | |||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||
| 83 | 0 | $self->delegate->set_rollback_mode; | |||||||||||||||||||||||
| 84 | 0 | }; | |||||||||||||||||||||||
| 85 | 0 | $self->app_finish; | |||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||
| 87 | 6 | 1; | |||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||
| 90 | __END__ | ||||||||||||||||||||||||