Mojolicious/Che.pm

filter: Statementstmt 11.7% 15 / 128 Branchbran 0.0% 0 / 52 Conditioncond 0.0% 0 / 187 MC/DCmcdc 0.0% 0 / 76 Subroutinesub 25.0% 4 / 16 Podpod 22.2% 2 / 9 totaltotal 4.4% 21 / 468 CC 97 SCAR 57.9
CC
97
Cov
4%
new
992.0
сессия
132.0
маршруты
110.0
CRAP 326.8
↑ Summary Mojo/Base/Che.pm »
1 package Mojolicious::Che;
2 1 ▶use Mojo::Base::Che;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Mojo::Base 'Mojolicious';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Mojo::Log::Che;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Mojo::Loader qw(load_class);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 #~ use Mojo::Util qw(url_unescape);
7 #~ use Scalar::Util 'weaken';
8  
9 0 ▶sub new {
Subroutine new: not called CC=31 SCAR=69.0
Pod documented
10 0 my ($class, %args) = @_;
11 0 ▶ my $config = delete($args{config}) || 'Config.pm';
Condition0%0/2
delete $args{'config'} || 'Config.pm'
l!l
00
MC/DC0%0/1
delete $args{'config'} || 'Config.pm'
delete $args{'config'}
Truth table0%0/2
A
A= delete $args{'config'}
Aresult
11
00
12 0 my $app = $class->SUPER::new(%args);
13
14 0 $app->plugin(Config =>{file => $config});
15
16 #~ return $app # остановка или двойной перезапуск kill -USR2
17 #~ if $ENV{HYPNOTOAD_PID} || $ENV{HYPNOTOAD_STOP};
18
19 0 my $conf = $app->config;
20 0 ▶ $conf->{mojo} ||= {};
Condition0%0/2
$conf->{"mojo"} ||= {}
l!l
00
MC/DC0%0/1
$conf->{"mojo"} ||= {}
$conf->{"mojo"}
Truth table0%0/2
A
A= $conf->{"mojo"}
Aresult
11
00
21
22 0 ▶ my $defaults = $conf->{'mojo_defaults'} || $conf->{'mojo'}{'defaults'} || $conf->{'mojo.defaults'};
Condition0%0/6
$conf->{'mojo_defaults'} || $conf->{'mojo'}{'defaults'} || $conf->{'mojo.defaults'}
l!l&&r!l&&!r
000
$conf->{"mojo_defaults"} or $conf->{"mojo"}{"defaults"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$conf->{'mojo_defaults'} || $conf->{'mojo'}{'defaults'} || $conf->{'mojo.defaults'}
$conf->{"mojo_defaults"} $conf->{"mojo"}{"defaults"} $conf->{'mojo.defaults'}
Truth table0%0/4
A or B || C
A= $conf->{"mojo_defaults"}B= $conf->{"mojo"}{"defaults"}C= $conf->{'mojo.defaults'}
ABCresult
1XX1
01X1
0011
0000
23 0 ▶ $app->defaults($defaults)
Branch: 1 branch
BranchTrueFalseTotal
if $defaults 0 0 0
24 if $defaults;
25
26 0 ▶ my $secret = $conf->{'mojo_secret'} || $conf->{'mojo_secrets'} || $conf->{'mojo'}{'secret'} || $conf->{'mojo'}{'secrets'} || $conf->{'mojo.secret'} || $conf->{'mojo.secrets'} || $conf->{'шифры'} || [rand];
Condition0%0/20
$conf->{'mojo_secret'} || $conf->{'mojo_secrets'} || $conf->{'mojo'}{'secret'} || $conf->{'mojo'}{'secrets'} || $conf->{'mojo.secret'} || $conf->{'mojo.secrets'} || $conf->{"\x{448}\x{438}\x{444}\x{440}\x{44b}"} || [rand]
l!l
00
$conf->{"mojo_secret"} or $conf->{"mojo_secrets"} or $conf->{"mojo"}{"secret"} or $conf->{"mojo"}{"secrets"} or $conf->{"mojo.secret"} or $conf->{"mojo.secrets"} or $conf->{"\x{448}\x{438}\x{444}\x{440}\x{44b}"}
l!l&&r!l&&!r
000
$conf->{"mojo_secret"} or $conf->{"mojo_secrets"} or $conf->{"mojo"}{"secret"} or $conf->{"mojo"}{"secrets"} or $conf->{"mojo.secret"} or $conf->{"mojo.secrets"}
l!l&&r!l&&!r
000
$conf->{"mojo_secret"} or $conf->{"mojo_secrets"} or $conf->{"mojo"}{"secret"} or $conf->{"mojo"}{"secrets"} or $conf->{"mojo.secret"}
l!l&&r!l&&!r
000
$conf->{"mojo_secret"} or $conf->{"mojo_secrets"} or $conf->{"mojo"}{"secret"} or $conf->{"mojo"}{"secrets"}
l!l&&r!l&&!r
000
$conf->{"mojo_secret"} or $conf->{"mojo_secrets"} or $conf->{"mojo"}{"secret"}
l!l&&r!l&&!r
000
$conf->{"mojo_secret"} or $conf->{"mojo_secrets"}
l!l&&r!l&&!r
000
MC/DC0%0/7
$conf->{'mojo_secret'} || $conf->{'mojo_secrets'} || $conf->{'mojo'}{'secret'} || $conf->{'mojo'}{'secrets'} || $conf->{'mojo.secret'} || $conf->{'mojo.secrets'} || $conf->{"\x{448}\x{438}\x{444}\x{440}\x{44b}"} || [rand]
$conf->{"mojo_secret"} $conf->{"mojo_secrets"} $conf->{"mojo"}{"secret"} $conf->{"mojo"}{"secrets"} $conf->{"mojo.secret"} $conf->{"mojo.secrets"} $conf->{"\x{448}\x{438}\x{444}\x{440}\x{44b}"}
Truth table0%0/8
A or B or C or D or E or F or G
A= $conf->{"mojo_secret"}B= $conf->{"mojo_secrets"}C= $conf->{"mojo"}{"secret"}D= $conf->{"mojo"}{"secrets"}E= $conf->{"mojo.secret"}F= $conf->{"mojo.secrets"}G= $conf->{"\x{448}\x{438}\x{444}\x{440}\x{44b}"}
ABCDEFGresult
1XXXXXX1
01XXXXX1
001XXXX1
0001XXX1
00001XX1
000001X1
00000011
00000000
27 0 $app->secrets($secret);
28
29 0 ▶ my $mode = $conf->{'mojo_mode'} || $conf->{'mojo'}{'mode'} || $conf->{'mojo.mode'};
Condition0%0/6
$conf->{'mojo_mode'} || $conf->{'mojo'}{'mode'} || $conf->{'mojo.mode'}
l!l&&r!l&&!r
000
$conf->{"mojo_mode"} or $conf->{"mojo"}{"mode"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$conf->{'mojo_mode'} || $conf->{'mojo'}{'mode'} || $conf->{'mojo.mode'}
$conf->{"mojo_mode"} $conf->{"mojo"}{"mode"} $conf->{'mojo.mode'}
Truth table0%0/4
A or B || C
A= $conf->{"mojo_mode"}B= $conf->{"mojo"}{"mode"}C= $conf->{'mojo.mode'}
ABCresult
1XX1
01X1
0011
0000
30 0 ▶ $app->mode($mode) # Файл лога уже не переключишь
Branch: 1 branch
BranchTrueFalseTotal
if $mode 0 0 0
31 if $mode;
32 #~ $app->log->level( $conf->{'mojo_log_level'} || $conf->{'mojo'}{'log_level'} || 'debug');
33 0 ▶ my $log = $conf->{'mojo_log'} || $conf->{'mojo.log'} || $conf->{'mojo'}{'log'};
Condition0%0/6
$conf->{'mojo_log'} || $conf->{'mojo.log'} || $conf->{'mojo'}{'log'}
l!l&&r!l&&!r
000
$conf->{"mojo_log"} or $conf->{"mojo.log"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$conf->{'mojo_log'} || $conf->{'mojo.log'} || $conf->{'mojo'}{'log'}
$conf->{"mojo_log"} $conf->{"mojo.log"} $conf->{'mojo'}{'log'}
Truth table0%0/4
A or B || C
A= $conf->{"mojo_log"}B= $conf->{"mojo.log"}C= $conf->{'mojo'}{'log'}
ABCresult
1XX1
01X1
0011
0000
34 0 ▶ $app->log(Mojo::Log::Che->new(%$log))
Branch: 1 branch
BranchTrueFalseTotal
if $log 0 0 0
35 if $log;
36 #~ warn "Mode: ", $app->mode, "; log level: ", $app->log->level;
37
38 0 my $home = $app->home;
39 0 ▶ my $statics = $conf->{'mojo_static_paths'} || $conf->{'mojo.static.paths'} || $conf->{'mojo'}{'static'}{'paths'} || [];
Condition0%0/8
$conf->{'mojo_static_paths'} || $conf->{'mojo.static.paths'} || $conf->{'mojo'}{'static'}{'paths'} || []
l!l
00
$conf->{"mojo_static_paths"} or $conf->{"mojo.static.paths"} or $conf->{"mojo"}{"static"}{"paths"}
l!l&&r!l&&!r
000
$conf->{"mojo_static_paths"} or $conf->{"mojo.static.paths"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$conf->{'mojo_static_paths'} || $conf->{'mojo.static.paths'} || $conf->{'mojo'}{'static'}{'paths'} || []
$conf->{"mojo_static_paths"} $conf->{"mojo.static.paths"} $conf->{"mojo"}{"static"}{"paths"}
Truth table0%0/4
A or B or C
A= $conf->{"mojo_static_paths"}B= $conf->{"mojo.static.paths"}C= $conf->{"mojo"}{"static"}{"paths"}
ABCresult
1XX1
01X1
0011
0000
40 #~ push @{$app->static->paths}, @{$paths} if $paths;
41 0 push @{$app->static->paths}, $home->rel_file($_)
42 0 for @$statics;
43
44 0 ▶ my $templates_paths = $conf->{'mojo_renderer_paths'} || $conf->{'mojo.renderer.paths'} || $conf->{'mojo'}{'renderer'}{'paths'} || [];
Condition0%0/8
$conf->{'mojo_renderer_paths'} || $conf->{'mojo.renderer.paths'} || $conf->{'mojo'}{'renderer'}{'paths'} || []
l!l
00
$conf->{"mojo_renderer_paths"} or $conf->{"mojo.renderer.paths"} or $conf->{"mojo"}{"renderer"}{"paths"}
l!l&&r!l&&!r
000
$conf->{"mojo_renderer_paths"} or $conf->{"mojo.renderer.paths"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$conf->{'mojo_renderer_paths'} || $conf->{'mojo.renderer.paths'} || $conf->{'mojo'}{'renderer'}{'paths'} || []
$conf->{"mojo_renderer_paths"} $conf->{"mojo.renderer.paths"} $conf->{"mojo"}{"renderer"}{"paths"}
Truth table0%0/4
A or B or C
A= $conf->{"mojo_renderer_paths"}B= $conf->{"mojo.renderer.paths"}C= $conf->{"mojo"}{"renderer"}{"paths"}
ABCresult
1XX1
01X1
0011
0000
45 0 push @{$app->renderer->paths}, $home->rel_dir($_)
46 0 for @$templates_paths;
47
48 0 ▶ my $renderer_classes = $conf->{'mojo_renderer_classes'} || $conf->{'mojo.renderer.classes'} || $conf->{'mojo'}{'renderer'}{'classes'} || [];
Condition0%0/8
$conf->{'mojo_renderer_classes'} || $conf->{'mojo.renderer.classes'} || $conf->{'mojo'}{'renderer'}{'classes'} || []
l!l
00
$conf->{"mojo_renderer_classes"} or $conf->{"mojo.renderer.classes"} or $conf->{"mojo"}{"renderer"}{"classes"}
l!l&&r!l&&!r
000
$conf->{"mojo_renderer_classes"} or $conf->{"mojo.renderer.classes"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$conf->{'mojo_renderer_classes'} || $conf->{'mojo.renderer.classes'} || $conf->{'mojo'}{'renderer'}{'classes'} || []
$conf->{"mojo_renderer_classes"} $conf->{"mojo.renderer.classes"} $conf->{"mojo"}{"renderer"}{"classes"}
Truth table0%0/4
A or B or C
A= $conf->{"mojo_renderer_classes"}B= $conf->{"mojo.renderer.classes"}C= $conf->{"mojo"}{"renderer"}{"classes"}
ABCresult
1XX1
01X1
0011
0000
49 0 push @{$app->renderer->classes}, $_
50 0 for grep ! load_class($_), @$renderer_classes;
51
52 0 $app->сессия();
53 0 $app->хазы();
54 0 $app->плугины();
55 0 $app->хуки();
56 0 $app->спейсы();
57 0 $app->маршруты();
58 0 $app->задачи();
59 0 $app->типы();
60 #~ $app->minion_worker();
61  
62 0 return $app;
63  
64 }
65  
66 0 ▶sub хазы { # Хазы из конфига
Subroutine хазы: not called CC=4 SCAR=30.0
Pod undocumented
67 0 my $app = shift;
68 0 my $conf = $app->config;
69 0 ▶ my $h = $conf->{'mojo_has'} || $conf->{'mojo.has'} || $conf->{'mojo'}{'has'} || $conf->{'хазы'};
Condition0%0/9
$conf->{'mojo_has'} || $conf->{'mojo.has'} || $conf->{'mojo'}{'has'} || $conf->{"\x{445}\x{430}\x{437}\x{44b}"}
l!l&&r!l&&!r
000
$conf->{"mojo_has"} or $conf->{"mojo.has"} or $conf->{"mojo"}{"has"}
l!l&&r!l&&!r
000
$conf->{"mojo_has"} or $conf->{"mojo.has"}
l!l&&r!l&&!r
000
MC/DC0%0/4
$conf->{'mojo_has'} || $conf->{'mojo.has'} || $conf->{'mojo'}{'has'} || $conf->{"\x{445}\x{430}\x{437}\x{44b}"}
$conf->{"mojo_has"} $conf->{"mojo.has"} $conf->{"mojo"}{"has"} $conf->{"\x{445}\x{430}\x{437}\x{44b}"}
Truth table0%0/5
A or B or C || D
A= $conf->{"mojo_has"}B= $conf->{"mojo.has"}C= $conf->{"mojo"}{"has"}D= $conf->{"\x{445}\x{430}\x{437}\x{44b}"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
70 map {
71 0 $app->log->debug("Make the app->has('$_')");
72 0 has $_ => $h->{$_};
73 } keys %$h;
74 }
75  
76 #~ sub плугины {# Плугины из конфига
77 0 ▶has плугины => sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
78 0 my $app = shift;
79 0 my $conf = $app->config;
80 0 my $плугины = {};
81 0 ▶ my $plugins = $conf->{'mojo_plugins'} || $conf->{'mojo.plugins'} || $conf->{'mojo'}{'plugins'} || $conf->{'плугины'}
Condition0%0/11
$conf->{'mojo_plugins'} || $conf->{'mojo.plugins'} || $conf->{'mojo'}{'plugins'} || $conf->{"\x{43f}\x{43b}\x{443}\x{433}\x{438}\x{43d}\x{44b}"} || (return)
l!l
00
$conf->{"mojo_plugins"} or $conf->{"mojo.plugins"} or $conf->{"mojo"}{"plugins"} or $conf->{"\x{43f}\x{43b}\x{443}\x{433}\x{438}\x{43d}\x{44b}"}
l!l&&r!l&&!r
000
$conf->{"mojo_plugins"} or $conf->{"mojo.plugins"} or $conf->{"mojo"}{"plugins"}
l!l&&r!l&&!r
000
$conf->{"mojo_plugins"} or $conf->{"mojo.plugins"}
l!l&&r!l&&!r
000
MC/DC0%0/4
$conf->{'mojo_plugins'} || $conf->{'mojo.plugins'} || $conf->{'mojo'}{'plugins'} || $conf->{"\x{43f}\x{43b}\x{443}\x{433}\x{438}\x{43d}\x{44b}"} || (return)
$conf->{"mojo_plugins"} $conf->{"mojo.plugins"} $conf->{"mojo"}{"plugins"} $conf->{"\x{43f}\x{43b}\x{443}\x{433}\x{438}\x{43d}\x{44b}"}
Truth table0%0/5
A or B or C or D
A= $conf->{"mojo_plugins"}B= $conf->{"mojo.plugins"}C= $conf->{"mojo"}{"plugins"}D= $conf->{"\x{43f}\x{43b}\x{443}\x{433}\x{438}\x{43d}\x{44b}"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
82 || return;
83 map {
84 0 ▶ push @{ $плугины->{$_->[0]} ||= [] }, [ref $_->[1] eq 'CODE' ? $app->plugin($_->[0] => $app->${ \$_->[1] }) : $app->plugin(@$_)];
Branch: 1 branch
BranchTrueFalseTotal
ref $_->[1] eq 'CODE' ? : 0 0 0
Condition0%0/2
$$плугины{$_->[0]} ||= []
l!l
00
MC/DC0%0/1
$$плугины{$_->[0]} ||= []
$$плугины{$_->[0]}
Truth table0%0/2
A
A= $$плугины{$_->[0]}
Aresult
11
00
85 0 $app->log->debug("Enable plugin [$_->[0]]");
86 } @$plugins;
87 0 return $плугины;
88 1 };
89  
90
91 0 ▶sub хуки {# Хуки из конфига
Subroutine хуки: not called CC=9 SCAR=45.0
Pod undocumented
92 0 my $app = shift;
93 0 my $conf = $app->config;
94 0 ▶ my $hooks = $conf->{'mojo_hooks'} || $conf->{'mojo.hooks'} || $conf->{'mojo'}{'hooks'} || $conf->{'хуки'}
Condition0%0/11
$conf->{'mojo_hooks'} || $conf->{'mojo.hooks'} || $conf->{'mojo'}{'hooks'} || $conf->{"\x{445}\x{443}\x{43a}\x{438}"} || (return)
l!l
00
$conf->{"mojo_hooks"} or $conf->{"mojo.hooks"} or $conf->{"mojo"}{"hooks"} or $conf->{"\x{445}\x{443}\x{43a}\x{438}"}
l!l&&r!l&&!r
000
$conf->{"mojo_hooks"} or $conf->{"mojo.hooks"} or $conf->{"mojo"}{"hooks"}
l!l&&r!l&&!r
000
$conf->{"mojo_hooks"} or $conf->{"mojo.hooks"}
l!l&&r!l&&!r
000
MC/DC0%0/4
$conf->{'mojo_hooks'} || $conf->{'mojo.hooks'} || $conf->{'mojo'}{'hooks'} || $conf->{"\x{445}\x{443}\x{43a}\x{438}"} || (return)
$conf->{"mojo_hooks"} $conf->{"mojo.hooks"} $conf->{"mojo"}{"hooks"} $conf->{"\x{445}\x{443}\x{43a}\x{438}"}
Truth table0%0/5
A or B or C or D
A= $conf->{"mojo_hooks"}B= $conf->{"mojo.hooks"}C= $conf->{"mojo"}{"hooks"}D= $conf->{"\x{445}\x{443}\x{43a}\x{438}"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
95 || return;
96 0 ▶ while (my ($name, $sub) = each %$hooks) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$hooks) 0 0 0
97 0 ▶ if (ref $sub eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $sub eq 'ARRAY') { } 0 0 0
98 $app->hook($name => $_)
99 0 for @$sub;
100 } else {
101 0 $app->hook($name => $sub);
102 }
103
104 0 ▶ $app->log->debug(sprintf("Applied hook%s [%s] from config", ref $sub eq 'ARRAY' ? "s (@{[ scalar @$sub]})" : '', $name));
Branch: 1 branch
BranchTrueFalseTotal
ref $sub eq 'ARRAY' ? : 0 0 0
105 }
106  
107 }
108  
109 0 ▶sub сессия {
Subroutine сессия: not called CC=11 SCAR=48.8
Pod undocumented
110 0 my $app = shift;
111 0 my $conf = $app->config;
112 0 ▶ my $session = $conf->{'mojo_session'} || $conf->{'mojo_sessions'} || $conf->{'mojo.session'} || $conf->{'mojo.sessions'} || $conf->{'mojo'}{'session'} || $conf->{'mojo'}{'sessions'} || $conf->{'сессии'} || $conf->{'сессия'}
Condition0%0/23
$conf->{'mojo_session'} || $conf->{'mojo_sessions'} || $conf->{'mojo.session'} || $conf->{'mojo.sessions'} || $conf->{'mojo'}{'session'} || $conf->{'mojo'}{'sessions'} || $conf->{"\x{441}\x{435}\x{441}\x{441}\x{438}\x{438}"} || $conf->{"\x{441}\x{435}\x{441}\x{441}\x{438}\x{44f}"} || (return)
l!l
00
$conf->{"mojo_session"} or $conf->{"mojo_sessions"} or $conf->{"mojo.session"} or $conf->{"mojo.sessions"} or $conf->{"mojo"}{"session"} or $conf->{"mojo"}{"sessions"} or $conf->{"\x{441}\x{435}\x{441}\x{441}\x{438}\x{438}"} or $conf->{"\x{441}\x{435}\x{441}\x{441}\x{438}\x{44f}"}
l!l&&r!l&&!r
000
$conf->{"mojo_session"} or $conf->{"mojo_sessions"} or $conf->{"mojo.session"} or $conf->{"mojo.sessions"} or $conf->{"mojo"}{"session"} or $conf->{"mojo"}{"sessions"} or $conf->{"\x{441}\x{435}\x{441}\x{441}\x{438}\x{438}"}
l!l&&r!l&&!r
000
$conf->{"mojo_session"} or $conf->{"mojo_sessions"} or $conf->{"mojo.session"} or $conf->{"mojo.sessions"} or $conf->{"mojo"}{"session"} or $conf->{"mojo"}{"sessions"}
l!l&&r!l&&!r
000
$conf->{"mojo_session"} or $conf->{"mojo_sessions"} or $conf->{"mojo.session"} or $conf->{"mojo.sessions"} or $conf->{"mojo"}{"session"}
l!l&&r!l&&!r
000
$conf->{"mojo_session"} or $conf->{"mojo_sessions"} or $conf->{"mojo.session"} or $conf->{"mojo.sessions"}
l!l&&r!l&&!r
000
$conf->{"mojo_session"} or $conf->{"mojo_sessions"} or $conf->{"mojo.session"}
l!l&&r!l&&!r
000
$conf->{"mojo_session"} or $conf->{"mojo_sessions"}
l!l&&r!l&&!r
000
MC/DC0%0/8
$conf->{'mojo_session'} || $conf->{'mojo_sessions'} || $conf->{'mojo.session'} || $conf->{'mojo.sessions'} || $conf->{'mojo'}{'session'} || $conf->{'mojo'}{'sessions'} || $conf->{"\x{441}\x{435}\x{441}\x{441}\x{438}\x{438}"} || $conf->{"\x{441}\x{435}\x{441}\x{441}\x{438}\x{44f}"} || (return)
$conf->{"mojo_session"} $conf->{"mojo_sessions"} $conf->{"mojo.session"} $conf->{"mojo.sessions"} $conf->{"mojo"}{"session"} $conf->{"mojo"}{"sessions"} $conf->{"\x{441}\x{435}\x{441}\x{441}\x{438}\x{438}"} $conf->{"\x{441}\x{435}\x{441}\x{441}\x{438}\x{44f}"}
Truth table0%0/9
A or B or C or D or E or F or G or H
A= $conf->{"mojo_session"}B= $conf->{"mojo_sessions"}C= $conf->{"mojo.session"}D= $conf->{"mojo.sessions"}E= $conf->{"mojo"}{"session"}F= $conf->{"mojo"}{"sessions"}G= $conf->{"\x{441}\x{435}\x{441}\x{441}\x{438}\x{438}"}H= $conf->{"\x{441}\x{435}\x{441}\x{441}\x{438}\x{44f}"}
ABCDEFGHresult
1XXXXXXX1
01XXXXXX1
001XXXXX1
0001XXXX1
00001XXX1
000001XX1
0000001X1
000000011
000000000
113 || return;
114
115 #~ $app->sessions->cookie_name($session->{'cookie_name'})
116 #~ if $session->{'cookie_name'};
117
118 #~ $app->sessions->default_expiration($session->{'default_expiration'}) # set expiry
119 #~ if defined $session->{'default_expiration'};
120
121 0 ▶ while (my ($meth, $val) = each %$session) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$session) 0 0 0
122 next
123 0 ▶ unless $app->sessions->can($meth);
Branch: 1 branch
BranchTrueFalseTotal
unless $app->sessions->can($meth) 0 0 0
124 0 $app->sessions->$meth($val);
125 }
126 }
127  
128 0 ▶sub маршруты {
Subroutine маршруты: not called CC=10 SCAR=47.0
Pod undocumented
129 0 my $app = shift;
130 0 my $conf = $app->config;
131 0 ▶ my $routes = $conf->{'mojo_routes'} || $conf->{'mojo.routes'} || $conf->{'mojo'}{'routes'} || $conf->{'routes'} || $conf->{'маршруты'}
Branch: 1 branch
BranchTrueFalseTotal
my $routes = $conf->{"mojo_routes"} || $conf->{"mojo.routes"} || $conf->{"mojo"}{"routes"} || $conf->{"routes"} || $conf->{"\x{43c}\x{430}\x{440}\x{448}\x{440}\x{443}\x{442}\x{44b}"} or return 0 0 0
Condition0%0/12
$conf->{'mojo_routes'} || $conf->{'mojo.routes'} || $conf->{'mojo'}{'routes'} || $conf->{'routes'} || $conf->{"\x{43c}\x{430}\x{440}\x{448}\x{440}\x{443}\x{442}\x{44b}"}
l!l&&r!l&&!r
000
$conf->{"mojo_routes"} or $conf->{"mojo.routes"} or $conf->{"mojo"}{"routes"} or $conf->{"routes"}
l!l&&r!l&&!r
000
$conf->{"mojo_routes"} or $conf->{"mojo.routes"} or $conf->{"mojo"}{"routes"}
l!l&&r!l&&!r
000
$conf->{"mojo_routes"} or $conf->{"mojo.routes"}
l!l&&r!l&&!r
000
MC/DC0%0/5
$conf->{'mojo_routes'} || $conf->{'mojo.routes'} || $conf->{'mojo'}{'routes'} || $conf->{'routes'} || $conf->{"\x{43c}\x{430}\x{440}\x{448}\x{440}\x{443}\x{442}\x{44b}"}
$conf->{"mojo_routes"} $conf->{"mojo.routes"} $conf->{"mojo"}{"routes"} $conf->{"routes"} $conf->{"\x{43c}\x{430}\x{440}\x{448}\x{440}\x{443}\x{442}\x{44b}"}
Truth table0%0/6
A or B or C or D || E
A= $conf->{"mojo_routes"}B= $conf->{"mojo.routes"}C= $conf->{"mojo"}{"routes"}D= $conf->{"routes"}E= $conf->{"\x{43c}\x{430}\x{440}\x{448}\x{440}\x{443}\x{442}\x{44b}"}
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
132 or return;
133 0 my $app_routes = $app->routes;
134 0 ▶ my $apply_route = sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
135 0 ▶ my $r = shift || $app_routes;
Condition0%0/3
shift() || $app_routes
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || $app_routes
shift() $app_routes
Truth table0%0/3
A || B
A= shift()B= $app_routes
ABresult
1X1
011
000
136 0 my ($meth, $arg) = @_;
137 0 my $nr;
138 0 ▶ if (my $m = $r->can($meth)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $m = $r->can($meth)) { } 0 0 0
139 0 ▶ $nr = $r->$m($arg) unless ref($arg);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $arg 0 0 0
140 0 ▶ $nr = $r->$m(cb => $arg) if ref($arg) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $arg eq "CODE" 0 0 0
141 0 ▶ $nr = $r->$m(@$arg) if ref($arg) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $arg eq "ARRAY" 0 0 0
142 0 ▶ $nr = $r->$m(%$arg) if ref($arg) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $arg eq "HASH" 0 0 0
143
144 } else {
145 0 $app->log->warn("Can't method [$meth] for route",);
146 }
147 0 return $nr;
148 0 };
149
150 0 for my $r (@$routes) {
151 0 ▶ my $nr = $apply_route->($app_routes, @$r[0,1])
Branch: 1 branch
BranchTrueFalseTotal
my $nr = &$apply_route($app_routes, @$r[0, 1]) or next 0 0 0
152 or next;
153 0 $app->log->debug("Apply route [$r->[0] $r->[1]]");
154 0 ▶ for( my $i = 2; $i < @$r; $i += 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$r) 0 0 0
155 0 ▶ $nr = $apply_route->($nr, @$r[$i, $i+1])
Branch: 1 branch
BranchTrueFalseTotal
$nr = &$apply_route($nr, @$r[$i, $i + 1]) or next 0 0 0
156 or next;
157 }
158 }
159 }
160  
161 0 ▶sub спейсы {
Subroutine спейсы: not called CC=7 SCAR=40.3
Pod undocumented
162 0 my $app = shift;
163 0 my $conf = $app->config;
164 0 ▶ my $ns = $conf->{'mojo_namespaces'} || $conf->{'mojo.namespaces'} || $conf->{'mojo'}{'namespaces'} || $conf->{'namespaces'} || $conf->{'ns'} || $conf->{'спейсы'}
Condition0%0/17
$conf->{'mojo_namespaces'} || $conf->{'mojo.namespaces'} || $conf->{'mojo'}{'namespaces'} || $conf->{'namespaces'} || $conf->{'ns'} || $conf->{"\x{441}\x{43f}\x{435}\x{439}\x{441}\x{44b}"} || (return)
l!l
00
$conf->{"mojo_namespaces"} or $conf->{"mojo.namespaces"} or $conf->{"mojo"}{"namespaces"} or $conf->{"namespaces"} or $conf->{"ns"} or $conf->{"\x{441}\x{43f}\x{435}\x{439}\x{441}\x{44b}"}
l!l&&r!l&&!r
000
$conf->{"mojo_namespaces"} or $conf->{"mojo.namespaces"} or $conf->{"mojo"}{"namespaces"} or $conf->{"namespaces"} or $conf->{"ns"}
l!l&&r!l&&!r
000
$conf->{"mojo_namespaces"} or $conf->{"mojo.namespaces"} or $conf->{"mojo"}{"namespaces"} or $conf->{"namespaces"}
l!l&&r!l&&!r
000
$conf->{"mojo_namespaces"} or $conf->{"mojo.namespaces"} or $conf->{"mojo"}{"namespaces"}
l!l&&r!l&&!r
000
$conf->{"mojo_namespaces"} or $conf->{"mojo.namespaces"}
l!l&&r!l&&!r
000
MC/DC0%0/6
$conf->{'mojo_namespaces'} || $conf->{'mojo.namespaces'} || $conf->{'mojo'}{'namespaces'} || $conf->{'namespaces'} || $conf->{'ns'} || $conf->{"\x{441}\x{43f}\x{435}\x{439}\x{441}\x{44b}"} || (return)
$conf->{"mojo_namespaces"} $conf->{"mojo.namespaces"} $conf->{"mojo"}{"namespaces"} $conf->{"namespaces"} $conf->{"ns"} $conf->{"\x{441}\x{43f}\x{435}\x{439}\x{441}\x{44b}"}
Truth table0%0/7
A or B or C or D or E or F
A= $conf->{"mojo_namespaces"}B= $conf->{"mojo.namespaces"}C= $conf->{"mojo"}{"namespaces"}D= $conf->{"namespaces"}E= $conf->{"ns"}F= $conf->{"\x{441}\x{43f}\x{435}\x{439}\x{441}\x{44b}"}
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
165 || return;
166 0 push @{$app->routes->namespaces}, @$ns;
167 }
168  
169 0 ▶sub задачи {
Subroutine задачи: not called CC=6 SCAR=37.4
Pod undocumented
170 0 my $app = shift;
171 0 my $conf = $app->config;
172 0 ▶ my $tasks = $conf->{'jobs'} || $conf->{'tasks'} || $conf->{'задачи'}
Branch: 1 branch
BranchTrueFalseTotal
my $tasks = $conf->{"jobs"} || $conf->{"tasks"} || $conf->{"\x{437}\x{430}\x{434}\x{430}\x{447}\x{438}"} or return 0 0 0
Condition0%0/6
$conf->{'jobs'} || $conf->{'tasks'} || $conf->{"\x{437}\x{430}\x{434}\x{430}\x{447}\x{438}"}
l!l&&r!l&&!r
000
$conf->{"jobs"} or $conf->{"tasks"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$conf->{'jobs'} || $conf->{'tasks'} || $conf->{"\x{437}\x{430}\x{434}\x{430}\x{447}\x{438}"}
$conf->{"jobs"} $conf->{"tasks"} $conf->{"\x{437}\x{430}\x{434}\x{430}\x{447}\x{438}"}
Truth table0%0/4
A or B || C
A= $conf->{"jobs"}B= $conf->{"tasks"}C= $conf->{"\x{437}\x{430}\x{434}\x{430}\x{447}\x{438}"}
ABCresult
1XX1
01X1
0011
0000
173 or return;
174
175 0 ▶ die "You have jobs and first enable plugin Minion"
Branch: 1 branch
BranchTrueFalseTotal
unless $app->renderer->get_helper("minion") 0 0 0
176 unless $app->renderer->get_helper('minion');
177
178 0 ▶ while (my ($name, $sub) = each %$tasks) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$tasks) 0 0 0
179 0 $app->log->debug(sprintf("Applied task [%s] in [%s] from config", $name, $app->minion->add_task($name => $sub)));
180 }
181 #~ $app->minion->reset;
182 }
183  
184  
185 0 ▶sub типы {#MIME
Subroutine типы: not called CC=7 SCAR=40.3
Pod undocumented
186 0 my $app = shift;
187 0 my $conf = $app->config;
188 0 ▶ my $types = $conf->{'mojo_types'} || $conf->{'mojo.types'} || $conf->{'mojo'}{'types'} || $conf->{'types'} || $conf->{'типы'}
Branch: 1 branch
BranchTrueFalseTotal
my $types = $conf->{"mojo_types"} || $conf->{"mojo.types"} || $conf->{"mojo"}{"types"} || $conf->{"types"} || $conf->{"\x{442}\x{438}\x{43f}\x{44b}"} or return 0 0 0
Condition0%0/12
$conf->{'mojo_types'} || $conf->{'mojo.types'} || $conf->{'mojo'}{'types'} || $conf->{'types'} || $conf->{"\x{442}\x{438}\x{43f}\x{44b}"}
l!l&&r!l&&!r
000
$conf->{"mojo_types"} or $conf->{"mojo.types"} or $conf->{"mojo"}{"types"} or $conf->{"types"}
l!l&&r!l&&!r
000
$conf->{"mojo_types"} or $conf->{"mojo.types"} or $conf->{"mojo"}{"types"}
l!l&&r!l&&!r
000
$conf->{"mojo_types"} or $conf->{"mojo.types"}
l!l&&r!l&&!r
000
MC/DC0%0/5
$conf->{'mojo_types'} || $conf->{'mojo.types'} || $conf->{'mojo'}{'types'} || $conf->{'types'} || $conf->{"\x{442}\x{438}\x{43f}\x{44b}"}
$conf->{"mojo_types"} $conf->{"mojo.types"} $conf->{"mojo"}{"types"} $conf->{"types"} $conf->{"\x{442}\x{438}\x{43f}\x{44b}"}
Truth table0%0/6
A or B or C or D || E
A= $conf->{"mojo_types"}B= $conf->{"mojo.types"}C= $conf->{"mojo"}{"types"}D= $conf->{"types"}E= $conf->{"\x{442}\x{438}\x{43f}\x{44b}"}
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
189 or return;
190 0 ▶ while (my ($name, $val) = each %$types) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$types) 0 0 0
191 0 $app->types->type($name => $val);
192 0 $app->log->debug(sprintf("Applied type [%s] from config", $name));
193 }
194 }
195  
196 # overide only on my $path = $req->url->path->to_abs_string;
197 0 ▶sub Mojolicious::dispatch {
Subroutine dispatch: not called CC=8 SCAR=42.8
Pod documented
198 0 my ($self, $c) = @_;
199  
200 0 my $plugins = $self->plugins->emit_hook(before_dispatch => $c);
201  
202 # Try to find a static file
203 0 my $tx = $c->tx;
204 0 ▶ $self->static->dispatch($c) and $plugins->emit_hook(after_static => $c)
Branch: 1 branch
BranchTrueFalseTotal
unless $tx->res->code 0 0 0
Condition0%0/6
$tx->res->code || $self->static->dispatch($c) && $plugins->emit_hook('after_static', $c)
l!l&&r!l&&!r
000
$self->static->dispatch($c) and $plugins->emit_hook("after_static", $c)
!ll&&!rl&&r
000
MC/DC0%0/3
$tx->res->code || $self->static->dispatch($c) && $plugins->emit_hook('after_static', $c)
$tx->res->code $self->static->dispatch($c) $plugins->emit_hook("after_static", $c)
Truth table0%0/4
A || B and C
A= $tx->res->codeB= $self->static->dispatch($c)C= $plugins->emit_hook("after_static", $c)
ABCresult
1XX1
0111
00X0
0100
205 unless $tx->res->code;
206  
207 # Start timer (ignore static files)
208 0 my $stash = $c->stash;
209 0 ▶ $c->helpers->log->debug(sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
210 0 my $req = $c->req;
211 0 my $url = $req->url->to_abs;
212 0 $c->helpers->timing->begin('mojo.timer');
213 #~ return sprintf qq{[%s] %s "%s://%s%s%s"},
214 #~ $req->request_id, $req->method, $url->scheme, $url->host, $url->port ? ":".$url->port : '', $url->path->to_route;
215 0 return sprintf qq{%s "%s"}, $req->method, Mojo::Util::decode('UTF-8', Mojo::Util::url_unescape($url));
216 0 ▶ }) unless $stash->{'mojo.static'};
Branch: 1 branch
BranchTrueFalseTotal
unless $stash->{"mojo.static"} 0 0 0
217  
218 # Routes
219 0 $plugins->emit_hook(before_routes => $c);
220 $c->helpers->reply->not_found
221 0 ▶ unless $tx->res->code || $self->routes->dispatch($c) || $tx->res->code || $stash->{'mojo.rendered'};
Branch: 1 branch
BranchTrueFalseTotal
unless $tx->res->code or $self->routes->dispatch($c) or $tx->res->code or $stash->{"mojo.rendered"} 0 0 0
Condition0%0/9
$tx->res->code or $self->routes->dispatch($c) or $tx->res->code or $stash->{"mojo.rendered"}
l!l&&r!l&&!r
000
$tx->res->code or $self->routes->dispatch($c) or $tx->res->code
l!l&&r!l&&!r
000
$tx->res->code or $self->routes->dispatch($c)
l!l&&r!l&&!r
000
MC/DC0%0/4
$tx->res->code or $self->routes->dispatch($c) or $tx->res->code or $stash->{"mojo.rendered"}
$tx->res->code $self->routes->dispatch($c) $tx->res->code $stash->{"mojo.rendered"}
Truth table0%0/5
A or B or C or D
A= $tx->res->codeB= $self->routes->dispatch($c)C= $tx->res->codeD= $stash->{"mojo.rendered"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
222 }
223  
224  
225 1 our $VERSION = '0.09191';# as to Mojolicious/100+0.000<minor>
226  
227 =pod
228  
229 =encoding utf8
230  
231 =head1 Mojolicious::Che
232  
233 Доброго всем
234  
235 ¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !
236  
237 =head1 VERSION
238  
239 0.09191
240  
241 =head1 NAME
242  
243 Mojolicious::Che - Мой базовый модуль для приложений Mojolicious. Нужен только развернутый конфиг.
244  
245 =head1 SYNOPSIS
246  
247 # app.pl
248 use lib 'lib';
249 use Mojo::Base 'Mojolicious::Che';
250 __PACKAGE__->new(config => 'lib/Config.pm')->start();
251  
252  
253 =head1 Config file
254  
255 Порядок строк в этом конфиге соответствует исполнению в модуле!
256  
257 {
258 'Проект'=>'Тест-проект',
259 # mojo => {
260 # defaults =>
261 # secrets =>
262 # mode=>
263 # log => {level=>...}
264 # static => {paths => [...]},
265 # renderer => {paths => [...], classes => [...], },
266 # session[s] =>
267 # has =>
268 # plugins =>
269 # hooks =>
270 # namespaces =>
271 # routes =>
272 # jobs =>
273 # types =>
274 # },
275 # or with prefix mojo_
276 # Default values for "stash" in Mojolicious::Controller, assigned for every new request.
277 mojo_defaults => {layout=>'default',},
278 # 'шифры' => [
279 mojo_secrets => ['true 123 my app',],
280 mojo_mode=> 'development',
281 mojo_log=>{level => 'error'},
282 mojo_static_paths => ["static"],
283 mojo_renderer_classes => ["Mojolicious::Foo::Fun"],
284 # 'сессия'(или сессии) =>
285 mojo_session[s] => {cookie_name => 'EXX', default_expiration => 86400},
286
287 # 'хазы' => 'Лет 500-700 назад был такой дикий степной торговый жадный народ ХАЗАРЫ. Столицей их "государства" был город Тьмутаракань, где-то на берегу моря Каспия. Потомки этих людей рассыпаны по странам России, Средней Азии, Европы. Есть мнение, что хазары присвоили себе название ЕВРЕИ, но это не те библейские кроткие евреи, а жадные потомки кроманьонцев'
288 mojo_has => {
289 foo => sub {my $app = shift; return 'is a bar';},
290 },
291
292 # 'плугины'=> [
293 mojo_plugins=>[
294 ['Foo::Bar'],
295 [Foo::Bar::Plugin => opt1 => ..., opt2 => ...],
296 ['Foo::Plugin' => sub {<...returns config data list...>}],
297 ],
298 # 'хуки' =>
299 mojo_hooks=>{
300 #~ before_dispatch => sub {1;},
301 },
302 # 'спейсы' => [...]
303 namespaces => ['Space::Shattle'],
304 # 'маршруты' => [...]
305 routes => [
306 [get=>'/', to=> {cb=>sub{shift->render(format=>'txt', text=>'Hello friend!');},}],
307 ]
308 #~ 'задачи'=> {#first enable plugin Minion
309 jobs => {
310 slow_log => sub {
311 my ($job, $msg) = @_;
312 sleep 5;
313 $job->app->log->error(qq{slow_log "$msg"});
314 },
315 },
316 # или 'типы'=>{...}
317 types => {
318 docx => ['application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
319 ...
320 },
321 };
322  
323 =head1 ATTRIBUTES
324  
325 B<Mojolicious::Che> inherits all attributes from L<Mojolicious> and implements the
326 following new ones.
327  
328 =head2 плугины
329  
330 Apply the plugins. See L<Mojolicious#plugins>, L<Mojolicious::Plugins>.
331  
332 =head1 METHODS
333  
334 B<Mojolicious::Che> inherits all methods from L<Mojolicious> and implements the following new ones.
335  
336 =head2 сессия()
337  
338 Session object config apply. See L<Mojolicious#sessions>, L<Mojolicious::Sessions>.
339  
340 =head2 хазы()
341  
342 Apply the has's. UTF names allow.
343  
344 =head2 хуки()
345  
346 Apply the hooks. See L<Mojolicious#HOOKS>.
347  
348 =head2 спейсы()
349  
350 Apply the namespaces. Push @{$app->routes->namespaces} your namespaces. See L<Mojolicious#routes>.
351  
352 namespaces => ['Space::Shattle'],
353  
354 =head2 маршруты()
355  
356 Apply the routes. See L<Mojolicious#routes>, L<Mojolicious::Guides::Routing>.
357  
358 #~ 'маршруты' => [
359 'routes'=>[
360 [get=>'/', to=> {cb=>sub{shift->render(format=>'txt', text=>'Welcome!');},}],
361 ],
362  
363 =head2 задачи()
364  
365 Apply the jobs. See L<Minion>.
366  
367 #~ 'задачи'=> {#first enable plugin Minion
368 'jobs'=> { # or tasks
369 slow_log => sub {
370 my ($job, $msg) = @_;
371 sleep 5;
372 $job->app->log->error(qq{slow_log "$msg"});
373 },
374
375 },
376  
377 =head типы()
378  
379 Apply the new types. See L<Mojolicious#types>, L<Mojolicious::Types>.
380  
381 =head1 SEE ALSO
382  
383 L<Mojolicious>
384  
385 L<Ado>
386  
387 =head1 AUTHOR
388  
389 Михаил Че (Mikhail Che), C<< <mche[-at-]cpan.org> >>
390  
391 =head1 BUGS / CONTRIBUTING
392  
393 Please report any bugs or feature requests at L<https://github.com/mche/Mojolicious-Che/issues>.
394 Pull requests also welcome.
395  
396 =head1 COPYRIGHT
397  
398 Copyright 2016+ Mikhail Che.
399  
400 This library is free software; you can redistribute it and/or modify
401 it under the same terms as Perl itself.
402  
403 =cut
404  
405 1 1;
↑ Summary Mojo/Base/Che.pm »