line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
24
|
|
|
24
|
|
743594
|
use strict; |
|
24
|
|
|
|
|
42
|
|
|
24
|
|
|
|
|
848
|
|
2
|
24
|
|
|
24
|
|
100
|
use warnings; |
|
24
|
|
|
|
|
33
|
|
|
24
|
|
|
|
|
1071
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package App::Embra::Role::Plugin; |
5
|
|
|
|
|
|
|
$App::Embra::Role::Plugin::VERSION = '0.001'; # TRIAL |
6
|
|
|
|
|
|
|
# ABSTRACT: something that gets plugged into App::Embra |
7
|
|
|
|
|
|
|
|
8
|
24
|
|
|
24
|
|
1020
|
use Method::Signatures; |
|
24
|
|
|
|
|
90252
|
|
|
24
|
|
|
|
|
145
|
|
9
|
24
|
|
|
24
|
|
8801
|
use Moo::Role; |
|
24
|
|
|
|
|
16059
|
|
|
24
|
|
|
|
|
163
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'App::Embra::Role::Logging'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
around '_build_log_prefix' => func( $orig, $self ) { |
15
|
|
|
|
|
|
|
return "[${ \ $self->name }] "; |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
around '_build_logger' => func( $orig, $self ) { |
19
|
|
|
|
|
|
|
$self->embra->logger; |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'embra' => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
required => 1, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has 'name' => ( |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
default => method { ref $self }, |
32
|
24
|
|
|
24
|
|
320819
|
); |
|
22
|
|
|
22
|
|
32927
|
|
|
22
|
|
|
|
|
130
|
|
33
|
22
|
|
|
|
|
83
|
|
34
|
22
|
|
|
|
|
37
|
method BUILDARGS( @args ) { |
35
|
22
|
|
|
|
|
56
|
my %args = @args; |
36
|
22
|
100
|
|
|
|
243
|
my %attrs; |
37
|
15
|
|
|
|
|
53
|
for my $attr ( qw< name > ) { |
38
|
|
|
|
|
|
|
if( not defined $args{$attr} ) { |
39
|
|
|
|
|
|
|
delete $args{$attr}; |
40
|
|
|
|
|
|
|
} |
41
|
22
|
|
|
|
|
474
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
return \%args; |
44
|
|
|
|
|
|
|
} |
45
|
24
|
100
|
66
|
24
|
|
159340
|
|
|
9
|
50
|
66
|
9
|
|
423
|
|
|
9
|
50
|
33
|
|
|
62
|
|
|
9
|
50
|
|
|
|
22
|
|
|
9
|
50
|
|
|
|
23
|
|
|
9
|
|
|
|
|
85
|
|
|
9
|
|
|
|
|
93
|
|
|
9
|
|
|
|
|
727151
|
|
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
115
|
|
|
9
|
|
|
|
|
1416
|
|
|
9
|
|
|
|
|
38
|
|
|
9
|
|
|
|
|
36
|
|
46
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
65
|
|
47
|
9
|
|
|
|
|
484
|
method register_plugin( $class:, :$name, HashRef :$args = {}, App::Embra :$embra ) { |
48
|
9
|
|
|
|
|
57
|
my $self = $class->new( embra => $embra, name => $name, %{ $args } ); |
49
|
9
|
|
|
|
|
57
|
$self->logger->debugf( '%sregistered with %s', $self->log_prefix, $args ); |
50
|
|
|
|
|
|
|
$embra->add_plugin( $self ); |
51
|
|
|
|
|
|
|
return $self; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=pod |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=encoding UTF-8 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
App::Embra::Role::Plugin - something that gets plugged into App::Embra |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 VERSION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
version 0.001 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This role provides a few key methods and attributes which all plugins for App::Embra should implement. It consumes the L<Logging role|App::Embra::Role::Logging>, altering L<C<log prefix>|App::Embra::Role::Logging/log_prefix> to include the plugin's name, and L<C<logger>|App::Embra::Role::Logging/logger> to reuse the C<logger> from the instance of App::Embra being plugged into. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 embra |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
The instance of L<App::Embra> into which the plugin was plugged. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 name |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
The name of the plugin, generally set to the name used in the configuration file when read by L<App::Embra::MVP::Assembler>. Defaults to the class name of the implementer. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 METHODS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 register_plugin |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
App::Embra::Role::Plugin->register_plugin( $class, $name, $args, $embra ); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Static method which creates a new instance of the implementing plugin with its C<name> set to C<$name>, C<embra> set to C<$embra>, and each entry of the C<$args> hash ref passed as an argument to the constructor. It then plugs new instance into C<$embra>. Returns the created instance. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 AUTHOR |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Daniel Holz <dgholz@gmail.com> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Daniel Holz. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
101
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |