Juno/Role/Check.pm

filter: Statementstmt 100% 40 / 40 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 100% 1 / 1 totaltotal 100% 53 / 53 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Juno.pm ↑ Summary
1 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Juno::Role::Check;
4 # ABSTRACT: Check role for Juno
5 7 $Juno::Role::Check::VERSION = '0.010';
6 7 ▶use AnyEvent;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 7 ▶use MooX::Types::MooseLike::Base qw<Str Num CodeRef ArrayRef>;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 7 ▶use PerlX::Maybe;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 7 with 'MooseX::Role::Loggable';
13  
14 has hosts => (
15 is => 'ro',
16 isa => ArrayRef[Str],
17 2 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
18 7 );
19  
20 has interval => (
21 is => 'ro',
22 isa => Num,
23 5 ▶ default => sub {10},
Subroutine __ANON__: called CC=1 SCAR=0.0
24 7 );
25  
26 has after => (
27 is => 'ro',
28 isa => Num,
29 5 ▶ default => sub {0},
Subroutine __ANON__: called CC=1 SCAR=0.0
30 7 );
31  
32 7 has on_before => (
33 is => 'ro',
34 isa => CodeRef,
35 predicate => 1,
36 );
37  
38 7 has on_result => (
39 is => 'ro',
40 isa => CodeRef,
41 predicate => 1,
42 );
43  
44 7 has on_success => (
45 is => 'ro',
46 isa => CodeRef,
47 predicate => 1,
48 );
49  
50 7 has on_fail => (
51 is => 'ro',
52 isa => CodeRef,
53 predicate => 1,
54 );
55  
56 7 has watcher => (
57 is => 'ro',
58 writer => 'set_watcher',
59 clearer => 1,
60 );
61  
62 7 requires 'check';
63  
64 2 ▶sub run {
Subroutine run: called CC=1 SCAR=0.0
Pod documented
65 2 my $self = shift;
66  
67 # keep a watcher per check
68 $self->set_watcher( AnyEvent->timer(
69 maybe after => $self->after,
70 interval => $self->interval,
71 3 ▶ cb => sub { $self->check },
Subroutine __ANON__: called CC=1 SCAR=0.0
72 2 ) );
73  
74 2 return 1;
75 }
76  
77 7 1;
78  
79 __END__
« Juno.pm ↑ Summary