| 1 | package Acme::Crux; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | =encoding utf-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | Acme::Crux - The CTK::App of the next generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | use Acme::Crux; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | The CTK::App of the next generation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | my $app = Acme::Crux->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | project => 'MyApp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | moniker => 'myapp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | options => {foo => 'bar'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | plugins => { foo => 'MyApp::Foo', bar => 'MyApp::Bar' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | preload => 'Config, Log', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | cachedir => '/var/cache/myapp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | configfile => '/etc/myapp/myapp.conf', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | datadir => '/var/lib/myapp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | docdir => '/usr/share/doc/myapp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | lockdir => '/var/lock/myapp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | logdir => '/var/log/myapp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | logfile => '/var/log/myapp/myapp.log', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | pidfile => '/var/run/myapp/myapp.pid', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | root => '/etc/myapp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | rundir => '/var/run/myapp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | sharedir => '/usr/share/myapp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | spooldir => '/var/spool/myapp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | tempdir => '/tmp/myapp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | webdir => '/var/www/myapp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | debug => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | test => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | verbose => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | This class implements the following attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | =head2 cachedir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | cachedir => '/var/cache/myapp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | Cache dir for project cache files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | $app = $app->cachedir( "/path/to/cache/dir" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | my $cachedir = $app->cachedir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | Default: /var/cache/<MONIKER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | =head2 configfile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | configfile => '/etc/myapp/myapp.conf' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | Path to the configuration file of your project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | $app = $app->configfile( "/path/to/config/file.conf" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | my $configfile = $app->configfile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | Default: /etc/<MONIKER>/<MONIKER>.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | =head2 datadir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | datadir => '/var/lib/myapp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | Data dir of project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | $app = $app->datadir( "/path/to/data/dir" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | my $datadir = $app->datadir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | Default: /var/lib/<MONIKER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | =head2 debug | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | debug => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | debug => 'on' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | debug => 'yes' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | Debug mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | Default: 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | =head2 docdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | docdir => '/usr/share/doc/myapp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | Doc dir for project documentation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | $app = $app->docdir( "/path/to/docs/dir" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | my $docdir = $app->docdir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | Default: /usr/share/doc/<MONIKER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | =head2 lockdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | lockdir => '/var/lock/myapp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | Lock dir for project lock files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | $app = $app->lockdir( "/path/to/lock/dir" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | my $lockdir = $app->lockdir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | Default: /var/lock/<MONIKER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | =head2 logdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | logdir => '/var/log/myapp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | Log dir for project logging | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | $app = $app->logdir( "/path/to/log/dir" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | my $logdir = $app->logdir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | Default: /var/log/<MONIKER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | =head2 logfile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | logfile => '/var/log/myapp/myapp.log' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | Path to the log file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | $app = $app->logfile( "/path/to/file.log" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | my $logfile = $app->logfile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | Default: /var/log/<MONIKER>/<MONIKER>.log | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | =head2 moniker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | moniker => 'myapp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | This attribute sets moniker of project name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | Moniker B<SHOULD> contains only symbols: a-z, 0-9, '_', '-', '.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | $app = $app->moniker( 'myapp' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | my $moniker = $app->moniker; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | Default: decamelized version of the C<project> attribute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | =head2 options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | options => {foo => 'bar'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | Command-line options, or any hash-ref structure with options. See L<Getopt::Long> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | $app = $app->options({ foo => 'bar' }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | my $options = $app->options; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | Default: {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | =head2 pidfile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | pidfile => '/var/run/myapp/myapp.pid' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | Path to the pid file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | $app = $app->pidfile( "/path/to/file.pid" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | my $pidfile = $app->pidfile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | Default: /var/run/<MONIKER>/<MONIKER>.pid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | =head2 preload, preload_plugins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | preload => [qw/foo bar baz/] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | preload => "foo bar baz" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | preload => "foo, bar, baz" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | preload => "foo; bar; baz" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | This attribute sets list of preloading plugins. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | Each specified plugin will be loaded and registered during application creation automatically | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | Default preloading plugins: C<Config>, C<Log> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | =head2 plugins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | plugins => { foo => 'MyApp::Foo', bar => 'MyApp::Bar' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | This attribute defines specified plugins only. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | B<NOTE!> This attribute NOT performs automatic loading and register specified plugins! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | See the L</"plugin"> method below if you want to load and register a plugin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | $app = $app->plugins( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | foo => 'MyApp::Foo', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | bar => 'MyApp::Bar', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | my $plugins = $app->plugins; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | Default plugins: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | Config Acme::Crux::Plugin::Config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | Log Acme::Crux::Plugin::Log | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | =head2 project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | project => 'MyApp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | Name of project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | $app = $app->project( 'MyApp' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | my $project = $app->project; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | Default: script name (without file extension) or invocant class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | =head2 root | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | root => '/etc/myapp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | Root dir of project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | $app = $app->root( "/etc/myapp" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | my $root = $app->root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | Default: /etc/<MONIKER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | =head2 rundir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | rundir => '/var/run/myapp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | Run dir for project pid files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | $app = $app->rundir( "/path/to/run/dir" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | my $rundir = $app->rundir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | Default: /var/run/<MONIKER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | =head2 sharedir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | sharedir => '/usr/share/myapp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | Share dir for project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | $app = $app->sharedir( "/path/to/share/dir" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | my $sharedir = $app->sharedir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | Default: /usr/share/<MONIKER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | =head2 spooldir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | spooldir => '/var/spool/myapp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | Spool is the dir for project pool data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | $app = $app->spooldir( "/path/to/spool/dir" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | my $spooldir = $app->spooldir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | Default: /var/spool/<MONIKER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | =head2 tempdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | tempdir => '/tmp/myapp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | Temp dir for project temporary files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | $app = $app->tempdir( "/path/to/temp/dir" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | my $tempdir = $app->tempdir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | Default: /tmp/<MONIKER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | =head2 test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | test => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | test => 'on' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | test => 'yes' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | Test mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | Default: 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | =head2 verbose | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | verbose => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | verbose => 'on' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | verbose => 'yes' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | Verbose mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | Default: 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | =head2 webdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | webdir => '/var/www/myapp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | Web dir for project web files (DocumentRoot) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | $app = $app->webdir( "/path/to/webdoc/dir" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | my $webdirr = $app->webdir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | Default: /var/www/<MONIKER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | This class implements the following methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | =head2 begin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | my $timing_begin = $app->begin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | This method sets timestamp for L</elapsed> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | my $timing_begin = $app->begin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # ... long operations ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | my $elapsed = $app->elapsed( $timing_begin ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | =head2 debugmode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | $app->debugmode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | Returns debug flag. 1 - on, 0 - off | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | =head2 elapsed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | my $elapsed = $app->elapsed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | my $timing_begin = [gettimeofday]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | # ... long operations ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | my $elapsed = $app->elapsed( $timing_begin ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | Return fractional amount of time in seconds since unnamed timstamp has been created while start application | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | my $elapsed = $app->elapsed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | $app->log->debug("Database stuff took $elapsed seconds"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | For formatted output: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | $app->log->debug(sprintf("%+.*f sec", 4, $app->elapsed)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | =head2 error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | my $error = $app->error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | Returns error string if occurred any errors while working with application | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | $app = $app->error( "error text" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | Sets new error message and returns object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | =head2 exedir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | my $exedir = $app->exedir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | Gets exedir value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | =head2 handlers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | my @names = $app->handlers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | Returns list of names of registered handlers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | my @names_and_aliases = $app->handlers(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | Returns list of aliases and names of registered handlers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | =head2 has_handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | $app->has_handler($command) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | or die "The command not found"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | This method returns true if the specified command name is exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | =head2 lookup_handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | my $handler = $app->lookup_handler($name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | or die "Handler not found"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | Lookup handler by name or aliase. Returns handler or undef while error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | =head2 option, opt, getopt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | my $value = $app->option("key"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | Returns option value by key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | my $options = $app->option; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | Returns hash-ref structure to all options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | See L</options> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | =head2 orig | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | my $origin_args = $app->orig; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | Returns hash-ref structure to all origin arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | =head2 plugin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | $app->plugin(foo => 'MyApp::Plugin::Foo'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | $app->plugin(foo); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | $app->plugin(foo => 'MyApp::Plugin::Foo', {bar => 123, baz => 'test'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | $app->plugin(foo => 'MyApp::Plugin::Foo', bar => 123, baz => 'test'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | $app->plugin(foo, undef, {bar => 123, baz => 'test'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | Load a plugin by name or pair - name and class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | =head2 pwd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | my $pwd = $app->pwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | This method returns current/working directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | =head2 register_handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | use parent qw/Acme::Crux/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | __PACKAGE__->register_handler( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | handler => "foo", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | aliases => "one, two", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | description => "Foo handler", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | params => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | param1 => "test", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | param2 => 123, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | ### CODE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | my $self = shift; # App | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | my $meta = shift; # Meta data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | my @args = @_; # Arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | print Acrux::Util::dumper({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | meta => $meta, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | args => \@args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | Method for register new handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | Example output while running: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | $app->run('one', abc => 123, def => 456); # returns 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | "args" => ["abc", 123, "def", 456], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | "meta" => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | "aliases" => ["one", "two"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | "description" => "Foo handler", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | "name" => "foo", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | "params" => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | "param1" => "test", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | "param2" => 123 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | "name" => "foo" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | This method supports the following options: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | =item aliases, alias | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | aliases => 'foo bar baz' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | aliases => 'foo, bar, baz' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | aliases => [qw/foo bar baz/] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | alias => 'foo' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | Sets aliases list for handler lookup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | =item code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | my ($self, $meta, @args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | # . . . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | Sets code oh handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | =item description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | description => 'Short description, abstract or synopsis' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | =item handler, name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | handler => 'version' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | name => 'version' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | Sets handler name. Default to 'default' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | =item params, parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | params => { foo => 'bar' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | List of handler parameters. All handler parameters will passed to $meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | =head2 register_method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | $app->register_method($namespace, $method, sub { 1 }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | $app->register_method($method => sub { 1 }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | __PACKAGE__->register_method($namespace, $method, sub { 1 }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | This method performs register the new method in your namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | By default use current application namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | =head2 register_plugin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | $app->register_plugin('foo', 'MyApp::Plugin::Foo'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | $app->register_plugin('foo', 'MyApp::Plugin::Foo', {bar => 123}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | $app->register_plugin('foo', 'MyApp::Plugin::Foo', bar => 123); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | Load a plugin and run C<register> method, optional arguments are passed through | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | =head2 run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | By default this method is alias for L</run_handler> method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | This method meant to be overloaded in a subclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | =head2 run_handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | my $result = $app->run_handler("foo", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | foo => "one", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | bar => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | ) or die $app->error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | Runs handler by name and returns result of it handler running | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | =head2 silentmode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | $app->silentmode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | Returns the verbose flag in the opposite value. 0 - verbose, 1 - silent. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | See L</verbosemode> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | =head2 startup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | This is your main hook into the application, it will be called at application startup. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | Meant to be overloaded in a subclass. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | This method is called immediately after creating the instance and returns it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | B<NOTE:> Please use only in your subclasses! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | sub startup { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | . . . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | return $self; # REQUIRED! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | =head2 testmode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | $app->testmode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | Returns test flag. 1 - on, 0 - off | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | =head2 verbosemode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | $app->verbosemode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | Returns verbose flag. 1 - on, 0 - off | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | See L</silentmode> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | =head1 PLUGINS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | The following plugins are included in the Acrux distribution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | =item L<Acme::Crux::Plugin::Config> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | Config => Acme::Crux::Plugin::Config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | L<Acrux::Config> configuration plugin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | =item L<Acme::Crux::Plugin::Log> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | Log => Acme::Crux::Plugin::Log | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | L<Acrux::Log> logging plugin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | =head1 TO DO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | See C<TODO> file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | L<CTK>, L<CTK::App> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | Serż Minus (Sergey Lepenkov) L<https://www.serzik.com> E<lt>abalama@cpan.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | Copyright (C) 1998-2026 D&D Corporation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | This program is distributed under the terms of the Artistic License Version 2.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | See the C<LICENSE> file or L<https://opensource.org/license/artistic-2-0> for details | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 1 | ▶ | use Carp qw/carp croak/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 1 | ▶ | use Time::HiRes qw/gettimeofday tv_interval/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 1 | ▶ | use FindBin qw/$RealBin $Script/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 1 | ▶ | use File::Spec qw//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 1 | ▶ | use Cwd qw/getcwd/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 1 | ▶ | use Sub::Util qw/set_subname/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 1 | ▶ | use Acrux::RefUtil qw/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | as_hash_ref is_hash_ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | as_array_ref is_array_ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | is_value is_code_ref is_true_flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 1 | /; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 1 | ▶ | use Acrux::Const qw/:dir/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 1 | ▶ | use Acrux::Util qw/load_class trim words/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 1 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 1 | WIN => !!($^O =~ /mswin/i), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | ALOWED_MODES => [qw/debug test verbose/], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | PRELOAD_PLUGINS => [qw/Config Log/], # Order is very important! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | DEFAULT_PLUGINS => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | Config => "Acme::Crux::Plugin::Config", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | Log => "Acme::Crux::Plugin::Log", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=51 SCAR=54.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 2 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | ▶ | my $args = @_ ? @_ > 1 ? {@_} : {%{$_[0]}} : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | # Get project name and moniker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | my $project = $args->{project} || $args->{name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 2 | ▶ | || ($Script =~ /^(.+?)\.(pl|t|pm|cgi)$/ ? $1 : $Script) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition36%4/11
$args->{'project'} || $args->{'name'} || ($Acme::Crux::Script =~ /^(.+?)\.(pl|t|pm|cgi)$/ ? $1 : $Acme::Crux::Script) || $class || scalar caller 0
$args->{"project"} or $args->{"name"} or $Acme::Crux::Script =~ /^(.+?)\.(pl|t|pm|cgi)$/ ? $1 : $Acme::Crux::Script or $class
$args->{"project"} or $args->{"name"} or $Acme::Crux::Script =~ /^(.+?)\.(pl|t|pm|cgi)$/ ? $1 : $Acme::Crux::Script
$args->{"project"} or $args->{"name"}
MC/DC0%0/4
$args->{'project'} || $args->{'name'} || ($Acme::Crux::Script =~ /^(.+?)\.(pl|t|pm|cgi)$/ ? $1 : $Acme::Crux::Script) || $class || scalar caller 0
$args->{"project"}
$args->{"name"}
$Acme::Crux::Script =~ /^(.+?)\.(pl|t|pm|cgi)$/ ? $1 : $Acme::Crux::Script
$class
Truth table20%1/5
A or B or C or D
A= $args->{"project"}B= $args->{"name"}C= $Acme::Crux::Script =~ /^(.+?)\.(pl|t|pm|cgi)$/ ? $1 : $Acme::Crux::ScriptD= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | || $class || scalar(caller(0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 2 | ▶ | my $moniker = $args->{moniker} || _project2moniker($project) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition25%2/8
$args->{'moniker'} || _project2moniker($project) || _project2moniker($class || scalar caller 0)
$args->{"moniker"} or _project2moniker($project)
$class || scalar caller 0
MC/DC0%0/3
$args->{'moniker'} || _project2moniker($project) || _project2moniker($class || scalar caller 0)
$args->{"moniker"}
_project2moniker($project)
_project2moniker($class || scalar caller 0)
MC/DC0%0/1
$class || scalar caller 0
$class
Truth table25%1/4
A or B || C
A= $args->{"moniker"}B= _project2moniker($project)C= _project2moniker($class || scalar caller 0)
Truth table0%0/2
A
A= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | || _project2moniker($class || scalar(caller(0))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | # Current dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 2 | my $pwd = getcwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | # Create | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | my $self = bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | # Common | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | error => "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | script => $Script, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | invocant => scalar(caller(0)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | project => $project, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | moniker => $moniker, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | pid => $$, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | running => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | # General | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | orig => {%$args}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | created => Time::HiRes::time, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | hitime => [gettimeofday], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | options => as_hash_ref($args->{options}), # Options of command line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | plugins => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | preload_plugins => $args->{preload} || $args->{preload_plugins} || PRELOAD_PLUGINS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | # Modes (defaults) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | debugmode => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | testmode => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | verbosemode => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | # Dirs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | pwd => $pwd, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | exedir => $RealBin, # Script dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | root => $args->{root}, # Root dir of project. Default: /etc/moniker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | tempdir => $args->{tempdir}, # Temp dir of project. Default: /tmp/moniker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | datadir => $args->{datadir}, # Data dir of project. Defaut: /var/lib/moniker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | logdir => $args->{logdir}, # Log dir of project. Default: /var/log/moniker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | sharedir => $args->{sharedir}, # Share dir. Default: /usr/share/moniker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | docdir => $args->{docdir}, # Share dir. Default: /usr/share/doc/moniker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | cachedir => $args->{cachedir}, # Cache dir. Default: /var/cache/moniker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | spooldir => $args->{spooldir}, # Spool dir. Default: /var/spool/moniker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | rundir => $args->{rundir}, # Run dir. Default: /var/run/moniker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | lockdir => $args->{lockdir}, # Lock dir. Default: /var/lock/moniker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | webdir => $args->{webdir}, # Web dir. Default: /var/www/moniker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | # Files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | logfile => $args->{logfile}, # Log file of project. Default: /var/log/moniker/moniker.log | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | configfile => $args->{configfile}, # Config file of project. Default: /etc/moniker/moniker.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | pidfile => $args->{pidfile}, # PID file of project. Default: /var/run/moniker.pid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 2 | ▶ | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$args->{'preload'} || $args->{'preload_plugins'} || ['Config', 'Log']
$args->{"preload"} or $args->{"preload_plugins"}
MC/DC0%0/2
$args->{'preload'} || $args->{'preload_plugins'} || ['Config', 'Log']
$args->{"preload"}
$args->{"preload_plugins"}
Truth table33%1/3
A or B
A= $args->{"preload"}B= $args->{"preload_plugins"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | # Modes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 2 | foreach my $mode ( @{(ALOWED_MODES)}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 6 | ▶ | $self->{$mode."mode"} = 1 if is_true_flag($args->{$mode}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | # Root dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 2 | my $root = $self->{root}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 2 | ▶ | $root = $self->{root} = $pwd if defined($root) && $root eq '.'; # Set root to cwd if specified as '.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $root and $root eq "."
MC/DC0%0/2
defined $root and $root eq "."
defined $root
$root eq "."
Truth table33%1/3
A and B
A= defined $rootB= $root eq "."
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 2 | ▶ | unless (defined($root) && length($root)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $root and length $root
MC/DC0%0/2
defined $root and length $root
defined $root
length $root
Truth table33%1/3
A and B
A= defined $rootB= length $root
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 2 | $root = $self->{root} = File::Spec->catdir(SYSCONFDIR, $moniker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | # Temp dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 2 | my $temp = $self->{tempdir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 2 | ▶ | unless (defined($temp) && length($temp)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $temp and length $temp
MC/DC0%0/2
defined $temp and length $temp
defined $temp
length $temp
Truth table33%1/3
A and B
A= defined $tempB= length $temp
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 2 | $temp = $self->{tempdir} = File::Spec->catdir(File::Spec->tmpdir(), $moniker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | # Data dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 2 | my $datadir = $self->{datadir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 2 | ▶ | unless (defined($datadir) && length($datadir)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $datadir and length $datadir
MC/DC0%0/2
defined $datadir and length $datadir
defined $datadir
length $datadir
Truth table33%1/3
A and B
A= defined $datadirB= length $datadir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 2 | $datadir = $self->{datadir} = File::Spec->catdir(SHAREDSTATEDIR, $moniker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | # Log dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 2 | my $logdir = $self->{logdir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 2 | ▶ | unless (defined($logdir) && length($logdir)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $logdir and length $logdir
MC/DC0%0/2
defined $logdir and length $logdir
defined $logdir
length $logdir
Truth table33%1/3
A and B
A= defined $logdirB= length $logdir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 2 | $logdir = $self->{logdir} = File::Spec->catdir(LOGDIR, $moniker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | # Share dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 2 | my $sharedir = $self->{sharedir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 2 | ▶ | unless (defined($sharedir) && length($sharedir)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $sharedir and length $sharedir
MC/DC0%0/2
defined $sharedir and length $sharedir
defined $sharedir
length $sharedir
Truth table33%1/3
A and B
A= defined $sharedirB= length $sharedir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 2 | $self->{sharedir} = File::Spec->catdir(DATADIR, $moniker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | # Doc dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 2 | my $docdir = $self->{docdir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 2 | ▶ | unless (defined($docdir) && length($docdir)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $docdir and length $docdir
MC/DC0%0/2
defined $docdir and length $docdir
defined $docdir
length $docdir
Truth table33%1/3
A and B
A= defined $docdirB= length $docdir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 2 | $self->{docdir} = File::Spec->catdir(DOCDIR, $moniker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | # Cache dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 2 | my $cachedir = $self->{cachedir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 2 | ▶ | unless (defined($cachedir) && length($cachedir)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $cachedir and length $cachedir
MC/DC0%0/2
defined $cachedir and length $cachedir
defined $cachedir
length $cachedir
Truth table33%1/3
A and B
A= defined $cachedirB= length $cachedir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 2 | $self->{cachedir} = File::Spec->catdir(CACHEDIR, $moniker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | # Spool dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 2 | my $spooldir = $self->{spooldir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 2 | ▶ | unless (defined($spooldir) && length($spooldir)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $spooldir and length $spooldir
MC/DC0%0/2
defined $spooldir and length $spooldir
defined $spooldir
length $spooldir
Truth table33%1/3
A and B
A= defined $spooldirB= length $spooldir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 2 | $self->{spooldir} = File::Spec->catdir(SPOOLDIR, $moniker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | # Run dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 2 | my $rundir = $self->{rundir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 2 | ▶ | unless (defined($rundir) && length($rundir)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $rundir and length $rundir
MC/DC0%0/2
defined $rundir and length $rundir
defined $rundir
length $rundir
Truth table33%1/3
A and B
A= defined $rundirB= length $rundir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 2 | $rundir = $self->{rundir} = File::Spec->catdir(RUNDIR, $moniker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | # Lock dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 2 | my $lockdir = $self->{lockdir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 2 | ▶ | unless (defined($lockdir) && length($lockdir)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $lockdir and length $lockdir
MC/DC0%0/2
defined $lockdir and length $lockdir
defined $lockdir
length $lockdir
Truth table33%1/3
A and B
A= defined $lockdirB= length $lockdir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 2 | $self->{lockdir} = File::Spec->catdir(LOCKDIR, $moniker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | # Web dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 2 | my $webdir = $self->{webdir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 2 | ▶ | unless (defined($webdir) && length($webdir)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $webdir and length $webdir
MC/DC0%0/2
defined $webdir and length $webdir
defined $webdir
length $webdir
Truth table33%1/3
A and B
A= defined $webdirB= length $webdir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 2 | $self->{webdir} = File::Spec->catdir(WEBDIR, $moniker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | # Config file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 2 | my $configfile = $self->{configfile}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 2 | ▶ | unless (defined($configfile) && length($configfile)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $configfile and length $configfile
MC/DC0%0/2
defined $configfile and length $configfile
defined $configfile
length $configfile
Truth table33%1/3
A and B
A= defined $configfileB= length $configfile
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 2 | $self->{configfile} = $configfile = File::Spec->catfile($root, sprintf("%s.conf", $moniker)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 2 | ▶ | unless (File::Spec->file_name_is_absolute($configfile)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | $self->{configfile} = $configfile = File::Spec->rel2abs($configfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | # Log file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 2 | my $logfile = $self->{logfile}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 2 | ▶ | unless (defined($logfile) && length($logfile)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $logfile and length $logfile
MC/DC0%0/2
defined $logfile and length $logfile
defined $logfile
length $logfile
Truth table33%1/3
A and B
A= defined $logfileB= length $logfile
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 2 | $self->{logfile} = $logfile = File::Spec->catfile($logdir, sprintf("%s.log", $moniker)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 2 | ▶ | if ($logfile !~ /^(?:[@=-]|\:?(?:stdout|stderr|syslog)\:?)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 2 | ▶ | unless (File::Spec->file_name_is_absolute($logfile)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | $self->{logfile} = $logfile = File::Spec->rel2abs($logfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | # PID file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 2 | my $pidfile = $self->{pidfile}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 2 | ▶ | unless (defined($pidfile) && length($pidfile)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $pidfile and length $pidfile
MC/DC0%0/2
defined $pidfile and length $pidfile
defined $pidfile
length $pidfile
Truth table33%1/3
A and B
A= defined $pidfileB= length $pidfile
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 2 | $self->{pidfile} = $pidfile = File::Spec->catfile($rundir, sprintf("%s.pid", $moniker)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 2 | ▶ | unless (File::Spec->file_name_is_absolute($pidfile)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | $self->{pidfile} = $pidfile = File::Spec->rel2abs($pidfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | # Define plugins list to plugin map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 2 | $self->plugins(as_hash_ref($args->{plugins})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | # Preloading plugins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 2 | my $preload_plugins = $self->{preload_plugins}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 2 | ▶ | $preload_plugins = [$preload_plugins] unless is_array_ref($preload_plugins); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 2 | my $pplgns = words(@$preload_plugins); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 2 | $self->plugin($_) for @$pplgns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | #foreach my $p (@$preload_plugins) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | # next unless defined($p) && is_value($p); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | # $self->plugin($_) for split(/[\s;,]+/, $p); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 2 | return $self->startup(%$args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 2 | ▶ | sub startup { shift } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
startup: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | # Attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | ▶ | sub options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
options: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | $self->{options} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | return $self->{options}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | ▶ | sub project { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
project: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | $self->{project} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | return $self->{project}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | ▶ | sub moniker { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
moniker: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | $self->{moniker} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | return $self->{moniker}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | # Files and directories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | ▶ | sub pwd { shift->{pwd} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pwd: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | ▶ | sub root { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
root: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | $self->{root} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | return $self->{root}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | ▶ | sub tempdir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tempdir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | $self->{tempdir} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | return $self->{tempdir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | ▶ | sub datadir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
datadir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | $self->{datadir} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | return $self->{datadir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | ▶ | sub logdir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logdir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | $self->{logdir} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | return $self->{logdir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | ▶ | sub sharedir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sharedir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | $self->{sharedir} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | return $self->{sharedir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | ▶ | sub docdir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
docdir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | $self->{docdir} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | return $self->{docdir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | ▶ | sub cachedir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cachedir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | $self->{cachedir} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | return $self->{cachedir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | sub spooldir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spooldir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | $self->{spooldir} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | return $self->{spooldir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | ▶ | sub rundir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rundir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | $self->{rundir} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | return $self->{rundir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | ▶ | sub lockdir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lockdir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | $self->{lockdir} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | return $self->{lockdir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | ▶ | sub webdir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
webdir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | $self->{webdir} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | return $self->{webdir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | sub configfile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configfile: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | $self->{configfile} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | return $self->{configfile}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | ▶ | sub logfile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logfile: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | $self->{logfile} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | return $self->{logfile}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | ▶ | sub pidfile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pidfile: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | $self->{pidfile} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | return $self->{pidfile}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | # Modes (methods) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | ▶ | sub testmode { !! shift->{testmode} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
testmode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | ▶ | sub debugmode { !! shift->{debugmode} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debugmode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | ▶ | sub verbosemode { !! shift->{verbosemode} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verbosemode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | ▶ | sub silentmode { ! shift->{verbosemode} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
silentmode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | # Methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 1 | ▶ | sub error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=2 SCAR=8.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 1 | ▶ | if (scalar(@_) >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | $self->{error} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 1 | return $self->{error}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | ▶ | sub begin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
begin: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | $self->{hitime} = [gettimeofday]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | return $self->{hitime} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | ▶ | sub elapsed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
elapsed: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | my $timing_begin = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | ▶ | return undef unless my $started = $timing_begin || $self->{hitime}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$timing_begin || $self->{'hitime'}
MC/DC0%0/2
$timing_begin || $self->{'hitime'}
$timing_begin
$self->{'hitime'}
Truth table0%0/3
A || B
A= $timing_beginB= $self->{'hitime'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | return tv_interval($started, [gettimeofday]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | ▶ | sub exedir { shift->{exedir} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exedir: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | ▶ | sub orig { shift->{orig} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
orig: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | ▶ | sub option { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
option: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | my $opts = $self->{options}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | ▶ | return undef unless $opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | ▶ | return $opts unless defined $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | return $opts->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | ▶ | sub opt { goto &option } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
opt: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | ▶ | sub getopt { goto &option } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getopt: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | # Register method. See Mojo::Util::monkey_patch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | ▶ | sub register_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_method: not called CC=7 SCAR=35.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | ▶ | my $code = pop || sub { 1 }; # last param | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
pop() || sub {
1;
}
MC/DC0%0/2
pop() || sub {
1;
}
pop()
sub {
1;
}
Truth table0%0/3
A || B
A= pop()B= sub {
1;
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | my $method = pop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | ▶ | my $namespace = pop || ref($self) || $self || __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
pop() || ref $self || $self || __PACKAGE__
pop() or ref $self or $self
pop() or ref $self
MC/DC0%0/3
pop() || ref $self || $self || __PACKAGE__
pop()
ref $self
$self
Truth table0%0/4
A or B or C
A= pop()B= ref $selfC= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | ▶ | croak qq{Can't register method: method name is missing} unless $method; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | ▶ | croak qq{Can't register method "$method": subroutine code is not defined} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | unless is_code_ref($code); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | my $ent = sprintf("%s::%s", $namespace, $method); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | # Create new method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 1 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | *{$ent} = set_subname($ent, $code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | ### Old version from CTK::Plugin::register_method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | ### Check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | ##return if do { no strict 'refs'; defined &{$ff} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | ### Create method! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | ##do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | ## no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | ## *{$ff} = \&$callback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | ##}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | # Plugins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 2 | ▶ | sub plugins { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plugins: called CC=9 SCAR=32.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 2 | ▶ | return $self->{plugins} if scalar(@_) < 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 2 | ▶ | my $args = @_ ? @_ > 1 ? {@_} : {%{$_[0]}} : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 2 | my $plugins = $self->{plugins}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 2 | foreach my $k (keys %$args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | ▶ | next if exists($plugins->{$k}) && $plugins->{$k}->{loaded}; # Skip loaded plugins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $plugins->{$k} and $plugins->{$k}{"loaded"}
MC/DC0%0/2
exists $plugins->{$k} and $plugins->{$k}{"loaded"}
exists $plugins->{$k}
$plugins->{$k}{"loaded"}
Truth table0%0/3
A and B
A= exists $plugins->{$k}B= $plugins->{$k}{"loaded"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | ▶ | $plugins->{$k} = { class => $args->{$k}, loaded => 0 } if length($args->{$k} // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$args->{$k} // ""
MC/DC0%0/1
$args->{$k} // ""
$args->{$k}
Truth table0%0/2
A
A= $args->{$k}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | ▶ | sub plugin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plugin: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | ▶ | my $name = shift // ''; # Plugin name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | ▶ | my $class = shift // ''; # Plugin class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | my $plugins = $self->{plugins}; # Get list of plugins | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | ▶ | return unless length $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | # Lookup class by name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | ▶ | unless (length($class)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | # Lookup in existing plugins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | ▶ | $class = $plugins->{$name}->{class} // '' if exists $plugins->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$plugins->{$name}{"class"} // ""
MC/DC0%0/1
$plugins->{$name}{"class"} // ""
$plugins->{$name}{"class"}
Truth table0%0/2
A
A= $plugins->{$name}{"class"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | # Lookup in defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | ▶ | $class = DEFAULT_PLUGINS()->{$name} // '' unless length $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
{"Config" => "Acme::Crux::Plugin::Config","Log" => "Acme::Crux::Plugin::Log"}->{$name} // ""
MC/DC0%0/1
{"Config" => "Acme::Crux::Plugin::Config","Log" => "Acme::Crux::Plugin::Log"}->{$name} // ""
{"Config" => "Acme::Crux::Plugin::Config","Log" => "Acme::Crux::Plugin::Log"}->{$name}
Truth table0%0/2
A
A= {"Config" => "Acme::Crux::Plugin::Config","Log" => "Acme::Crux::Plugin::Log"}->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | ▶ | return unless length $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | # Register found plugin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | $self->register_plugin($name, $class, @args); # name, class, args | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | ▶ | sub register_plugin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_plugin: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | ▶ | my $name = shift // ''; # Plugin name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 0 | ▶ | my $class = shift // ''; # Plugin class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | ▶ | my $args = @_ ? @_ > 1 ? {@_} : {%{$_[0]}} : {}; # Plugin arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | my $plugins = $self->{plugins}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | ▶ | croak "No plugin name specified!" unless length $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | ▶ | croak "No plugin class specified!" unless length $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | # Load plugin if not exists in already loaded plugins list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | ▶ | return 1 if exists($plugins->{$name}) && $plugins->{$name}->{loaded}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $plugins->{$name} and $plugins->{$name}{"loaded"}
MC/DC0%0/2
exists $plugins->{$name} and $plugins->{$name}{"loaded"}
exists $plugins->{$name}
$plugins->{$name}{"loaded"}
Truth table0%0/3
A and B
A= exists $plugins->{$name}B= $plugins->{$name}{"loaded"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 0 | ▶ | if (my $error = load_class($class)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 0 | ▶ | $self->verbosemode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | ? die qq{Plugin "$name" missing, maybe you need to install it?\n$error\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | : die qq{Plugin "$name" missing, maybe you need to install it?\n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | # Create plugin instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 0 | ▶ | die qq{Plugin "$name" no contains required the "new" method\n} unless $class->can('new'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 0 | my $p = $class->new($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | # Register this plugin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 0 | my $ret = $p->register($self, $args); # $app, $args | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | # Fixup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | $plugins->{$name} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 'class' => $class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 'loaded' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 'time' => time, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 'something' => $ret, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | # Handlers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 3 | ▶ | sub register_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_handler: called CC=16 SCAR=28.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 3 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 3 | ▶ | $class = ref($class) if ref($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 3 | my %info = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 3 | my $k = "$class.$$"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 3 | ▶ | $Acme::Crux::Sandbox::HANDLERS{$k} = {} unless exists($Acme::Crux::Sandbox::HANDLERS{$k}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 3 | my $handlers = $Acme::Crux::Sandbox::HANDLERS{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | # Handler name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 3 | ▶ | my $name = trim($info{handler} // $info{name} // 'default'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
($info{"handler"} // $info{"name"}) // "default"
$info{"handler"} // $info{"name"}
MC/DC50%1/2
($info{"handler"} // $info{"name"}) // "default"
$info{"handler"}
$info{"name"}
Truth table66%2/3
A // B
A= $info{"handler"}B= $info{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 3 | ▶ | croak("The handler name missing") unless length($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 3 | delete $info{handler}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 3 | $info{name} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 3 | ▶ | croak("The $name duplicate handler definition") if defined($handlers->{$name}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | # Handler aliases | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 3 | ▶ | my $_aliases = $info{alias} // $info{aliases} // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
($info{"alias"} // $info{"aliases"}) // []
$info{"alias"} // $info{"aliases"}
MC/DC50%1/2
($info{"alias"} // $info{"aliases"}) // []
$info{"alias"}
$info{"aliases"}
Truth table66%2/3
A // B
A= $info{"alias"}B= $info{"aliases"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 3 | ▶ | $_aliases = [ trim($_aliases) ] unless is_array_ref($_aliases); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 3 | my $aliases = words(@$_aliases); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | #foreach my $al (@$_aliases) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | # next unless defined($al) && is_value($al); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | # foreach my $p (split(/[\s;,]+/, $al)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | # next unless defined($p) && length($p); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | # $aliases{$p} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 3 | delete $info{alias}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 3 | $info{aliases} = [grep {$_ ne $name} @$aliases]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | # Handler description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 3 | ▶ | $info{description} //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$info{"description"} //= ""
MC/DC100%1/1
$info{"description"} //= ""
$info{"description"}
Truth table100%2/2
A
A= $info{"description"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | # Handler params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 3 | ▶ | my $params = $info{parameters} || $info{params} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
$info{'parameters'} || $info{'params'} || {}
$info{"parameters"} or $info{"params"}
MC/DC50%1/2
$info{'parameters'} || $info{'params'} || {}
$info{"parameters"}
$info{"params"}
Truth table66%2/3
A or B
A= $info{"parameters"}B= $info{"params"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 3 | delete $info{parameters}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 3 | ▶ | $params = {} unless is_hash_ref($params); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 3 | $info{params} = $params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | # Handler code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 3 | ▶ | my $code = $info{code} || sub {return 1}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Condition66%2/3
$info{'code'} || sub {
return 1;
}
MC/DC0%0/2
$info{'code'} || sub {
return 1;
}
$info{'code'}
sub {
return 1;
}
Truth table66%2/3
A || B
A= $info{'code'}B= sub {
return 1;
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | ▶ | $info{code} = is_code_ref($code) ? $code : sub { $code }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | # Set info to handler data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 3 | $handlers->{$name} = {%info}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 2 | ▶ | sub lookup_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_handler: called CC=9 SCAR=24.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 2 | ▶ | my $name = trim(shift // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 2 | ▶ | return undef unless length $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 2 | ▶ | my $invocant = ref($self) || scalar(caller(0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
ref $self || scalar caller 0
MC/DC0%0/1
ref $self || scalar caller 0
ref $self
Truth table50%1/2
A
A= ref $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 2 | my $handlers = $Acme::Crux::Sandbox::HANDLERS{"$invocant.$$"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 2 | ▶ | return undef unless defined($handlers) && is_hash_ref($handlers); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $handlers and is_hash_ref($handlers)
MC/DC0%0/2
defined $handlers and is_hash_ref($handlers)
defined $handlers
is_hash_ref($handlers)
Truth table33%1/3
A and B
A= defined $handlersB= is_hash_ref($handlers)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 2 | foreach my $n (keys %$handlers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 6 | my $aliases = as_array_ref($handlers->{$n}->{aliases}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 6 | ▶ | return $handlers->{$n} if grep {defined && $_ eq $name} ($n, @$aliases); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $_ && $_ eq $name
MC/DC50%1/2
defined $_ && $_ eq $name
defined $_
$_ eq $name
Truth table66%2/3
A && B
A= defined $_B= $_ eq $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 0 | ▶ | sub handlers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handlers: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | ▶ | my $all = shift // 0; # returns aliases too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() // 0
MC/DC0%0/1
shift() // 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | ▶ | my $invocant = ref($self) || scalar(caller(0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
ref $self || scalar caller 0
MC/DC0%0/1
ref $self || scalar caller 0
ref $self
Truth table0%0/2
A
A= ref $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | my $handlers = $Acme::Crux::Sandbox::HANDLERS{"$invocant.$$"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | ▶ | return [] unless defined($handlers) && is_hash_ref($handlers); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $handlers and is_hash_ref($handlers)
MC/DC0%0/2
defined $handlers and is_hash_ref($handlers)
defined $handlers
is_hash_ref($handlers)
Truth table0%0/3
A and B
A= defined $handlersB= is_hash_ref($handlers)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 0 | ▶ | return [(sort {$a cmp $b} keys %$handlers)] unless $all; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | # All: names and aliases | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 0 | my %seen = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 0 | foreach my $n (keys %$handlers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 0 | my $aliases = as_array_ref($handlers->{$n}->{aliases}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | foreach my $_a ($n, @$aliases) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 0 | ▶ | $seen{$_a} = 1 if defined($_a) and length($_a); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_a and length $_a
MC/DC0%0/2
defined $_a and length $_a
defined $_a
length $_a
Truth table0%0/3
A and B
A= defined $_aB= length $_a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | return [(sort {$a cmp $b} keys %seen)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | ▶ | sub has_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_handler: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | ▶ | my $name = trim(shift // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | ▶ | return undef unless length $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | return !!grep { $_ eq $name } @{ $self->handlers(1) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 2 | ▶ | sub run_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_handler: called CC=9 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 2 | ▶ | my $name = shift // 'default'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // "default"
MC/DC0%0/1
shift() // "default"
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 2 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 2 | ▶ | if ($self->{running}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 0 | $self->error(sprintf(qq{The application "%s" is already runned}, $self->project)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 2 | ▶ | unless(length($name)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 0 | $self->error("Invalid handler name"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 2 | my $meta = $self->lookup_handler($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 2 | ▶ | unless ($meta) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | $self->error(sprintf("Handler %s not found", $name)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | # Run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 2 | my %info = (orig => $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 2 | my $func; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 2 | $self->{running} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 2 | foreach my $k (keys %$meta) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 10 | ▶ | next unless defined $k; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 10 | ▶ | if ($k eq 'code') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 2 | $func = $meta->{code}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 8 | $info{$k} = $meta->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 2 | ▶ | unless(is_code_ref($func)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | $self->error("Handler code not found! Maybe you need to implement it?"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | # Call function and return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 2 | my $ret = &$func($self, {%info}, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 2 | $self->{running} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 2 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 2 | ▶ | sub run { goto &run_handler } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | # Internal functions (NOT METHODS) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 2 | ▶ | sub _project2moniker { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_project2moniker: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 2 | my $prj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 2 | ▶ | return unless defined($prj); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 2 | $prj =~ s/::/-/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 2 | $prj =~ s/[^A-Za-z0-9_\-.]/_/g; # Remove incorrect chars | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 2 | $prj =~ s/([_\-.]){2,}/$1/g; # Remove dubles | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 2 | ▶ | return unless length($prj); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 2 | return lc($prj); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | package Acme::Crux::Sandbox; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 1 | our %HANDLERS = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||