| 1 | package Mojolicious::Plugin::Minion::Notifier; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Mojo::Base 'Mojolicious::Plugin'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Minion::Notifier; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Mojo::IOLoop; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | my $isa = sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||
| 10 | 1 | my ($obj, $class) = @_; | |||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | return $obj && Scalar::Util::blessed($obj) && $obj->isa($class); | ||||||||||||||||||||||||||||||||
|
Condition33%2/6
$obj && builtin::blessed($obj) && $obj->isa($class)
$obj and builtin::blessed($obj)
MC/DC0%0/3
$obj && builtin::blessed($obj) && $obj->isa($class)
$obj
builtin::blessed($obj)
$obj->isa($class)
Truth table25%1/4
A and B && C
A= $objB= builtin::blessed($obj)C= $obj->isa($class)
| |||||||||||||||||||||||||||||||||||
| 12 | 1 | }; | |||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | sub register { | ||||||||||||||||||||||||||||||||
|
Subroutine
register: called CC=8 SCAR=26.1
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 15 | 1 | my ($plugin, $app, $config) = @_; | |||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | $config->{minion} ||= eval { $app->minion } || die 'A minion instance is required'; | ||||||||||||||||||||||||||||||||
|
Condition40%2/5
$config->{"minion"} ||= eval {
do {
$app->minion
}
} || die("A minion instance is required")
eval {
do {
$app->minion
}
} || die('A minion instance is required')
MC/DC0%0/2
$config->{"minion"} ||= eval {
do {
$app->minion
}
} || die("A minion instance is required")
$config->{"minion"}
eval {
do {
$app->minion
}
}
Truth table33%1/3
A ||= B
A= $config->{"minion"}B= eval {
do {
$app->minion
}
}
| |||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | my $transport = $config->{transport} || ''; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{'transport'} || ''
MC/DC0%0/1
$config->{'transport'} || ''
$config->{'transport'}
Truth table50%1/2
A
A= $config->{'transport'}
| |||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | unless ($transport->$isa('Minion::Notifier::Transport')) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | if($transport =~ /^wss?:/) { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 21 | 1 | require Minion::Notifier::Transport::WebSocket; | |||||||||||||||||||||||||||||||||
| 22 | 1 | $config->{transport} = Minion::Notifier::Transport::WebSocket->new(url => $transport); | |||||||||||||||||||||||||||||||||
| 23 | } elsif ($transport =~ /^redis:/) { | ||||||||||||||||||||||||||||||||||
| 24 | 0 | require Mojo::Redis2; | |||||||||||||||||||||||||||||||||
| 25 | 0 | require Minion::Notifier::Transport::Redis; | |||||||||||||||||||||||||||||||||
| 26 | 0 | my $redis = Mojo::Redis2->new(url => $transport); | |||||||||||||||||||||||||||||||||
| 27 | 0 | $config->{transport} = Minion::Notifier::Transport::Redis->new(redis => $redis); | |||||||||||||||||||||||||||||||||
| 28 | } elsif ($config->{minion}->backend->isa('Minion::Backend::Pg')) { | ||||||||||||||||||||||||||||||||||
| 29 | 0 | require Minion::Notifier::Transport::Pg; | |||||||||||||||||||||||||||||||||
| 30 | 0 | $config->{transport} = Minion::Notifier::Transport::Pg->new(pg => $config->{minion}->backend->pg); | |||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||
| 34 | 1 | my $notifier = Minion::Notifier->new($config); | |||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | $app->helper(minion_notifier => sub { $notifier }); | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | 1 | $notifier->setup_worker; | |||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | Mojo::IOLoop->next_tick(sub{ $notifier->setup_listener }); | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | 1 | return $notifier; | |||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||
| 43 | 1 | 1; | |||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||