line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
6
|
use Map::Metro::Standard; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
2
|
1
|
|
|
1
|
|
2371
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
73
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.2300'; # VERSION |
6
|
|
|
|
|
|
|
# ABSTRACT: Event emitter for hooks |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Map::Metro::Emitter { |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
7
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
11
|
1
|
|
|
1
|
|
6660
|
use Kavorka; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
12
|
1
|
|
|
1
|
|
1815
|
use List::Util 1.33 'none'; |
|
1
|
|
|
|
|
35
|
|
|
1
|
|
|
|
|
85
|
|
13
|
1
|
|
|
1
|
|
5
|
use Types::Standard -types; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
14
|
1
|
|
|
1
|
|
5468
|
use Map::Metro::Hook; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
54
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
9
|
use Module::Pluggable search_path => ['Map::Metro::Plugin::Hook'], require => 1, sub_name => 'found_plugins'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has wanted_hook_plugins => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
isa => ArrayRef[ Str ], |
21
|
|
|
|
|
|
|
traits => ['Array'], |
22
|
|
|
|
|
|
|
handles => { |
23
|
|
|
|
|
|
|
all_wanted_hook_plugins => 'elements', |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
has registered_hooks => ( |
27
|
|
|
|
|
|
|
is => 'rw', |
28
|
|
|
|
|
|
|
isa => ArrayRef, |
29
|
|
|
|
|
|
|
traits => ['Array'], |
30
|
|
|
|
|
|
|
handles => { |
31
|
|
|
|
|
|
|
add_registered_hook => 'push', |
32
|
|
|
|
|
|
|
all_registered_hooks => 'elements', |
33
|
|
|
|
|
|
|
filter_registered_hooks => 'grep', |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
has plugins => ( |
37
|
|
|
|
|
|
|
is => 'rw', |
38
|
|
|
|
|
|
|
isa => HashRef, |
39
|
|
|
|
|
|
|
traits => ['Hash'], |
40
|
|
|
|
|
|
|
handles => { |
41
|
|
|
|
|
|
|
add_plugin => 'set', |
42
|
|
|
|
|
|
|
get_plugin => 'get', |
43
|
|
|
|
|
|
|
plugin_names => 'keys', |
44
|
|
|
|
|
|
|
}, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub BUILD { |
48
|
1
|
|
|
1
|
0
|
1737
|
my $self = shift; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
PLUGIN: |
51
|
1
|
|
|
|
|
7
|
foreach my $pluginname ($self->found_plugins) { |
52
|
2
|
|
|
|
|
1911
|
my $actual = $pluginname =~ s{^Map::Metro::Plugin::Hook::}{}r; |
53
|
2
|
50
|
|
0
|
|
111
|
next PLUGIN if none { $_ eq $actual } $self->all_wanted_hook_plugins; |
|
0
|
|
|
|
|
0
|
|
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
0
|
my $plugin = $pluginname->new; |
56
|
0
|
|
|
|
|
0
|
$self->register($plugin); |
57
|
0
|
|
|
|
|
0
|
$self->add_plugin($actual => $plugin); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
1
|
0
|
|
1
|
|
2457
|
method register($plugin) { |
|
1
|
0
|
|
0
|
|
3
|
|
|
1
|
0
|
|
|
|
257
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
61
|
0
|
|
|
|
|
0
|
my %hooks_list = $plugin->register; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
0
|
foreach my $event (keys %hooks_list) { |
64
|
0
|
|
|
|
|
0
|
my $hook = Map::Metro::Hook->new(event => $event, action => $hooks_list{ $event }, plugin => $plugin); |
65
|
0
|
|
|
|
|
0
|
$self->add_registered_hook($hook); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
1
|
50
|
|
1
|
|
1751
|
method before_add_station($station) { |
|
1
|
50
|
|
20
|
|
1
|
|
|
1
|
50
|
|
|
|
142
|
|
|
20
|
|
|
|
|
304
|
|
|
20
|
|
|
|
|
60
|
|
|
20
|
|
|
|
|
49
|
|
|
20
|
|
|
|
|
28
|
|
70
|
20
|
|
|
|
|
62
|
$self->emit('before_add_station', $station); |
71
|
|
|
|
|
|
|
} |
72
|
1
|
0
|
|
1
|
|
1773
|
method before_add_routing($routing) { |
|
1
|
0
|
|
0
|
|
3
|
|
|
1
|
0
|
|
|
|
139
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
73
|
0
|
|
|
|
|
0
|
$self->emit('before_add_routing', $routing); |
74
|
|
|
|
|
|
|
} |
75
|
1
|
0
|
|
1
|
|
1238
|
method before_start_routing { |
|
1
|
|
|
0
|
|
2
|
|
|
1
|
|
|
|
|
90
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
76
|
0
|
|
|
|
|
0
|
$self->emit('before_start_routing'); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
1
|
50
|
|
1
|
|
2183
|
method emit($event, @args) { |
|
1
|
50
|
|
20
|
|
2
|
|
|
1
|
50
|
|
|
|
413
|
|
|
20
|
50
|
|
|
|
50
|
|
|
20
|
|
|
|
|
50
|
|
|
20
|
|
|
|
|
49
|
|
|
20
|
|
|
|
|
78
|
|
|
20
|
|
|
|
|
36
|
|
80
|
20
|
|
|
0
|
|
1138
|
my @hooks = $self->filter_registered_hooks(sub { $_->event eq $event }); |
|
0
|
|
|
|
|
0
|
|
81
|
|
|
|
|
|
|
|
82
|
20
|
|
|
|
|
166
|
foreach my $hook (@hooks) { |
83
|
0
|
|
|
|
|
|
$hook->action->($hook->plugin, @args); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=pod |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=encoding UTF-8 |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 NAME |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Map::Metro::Emitter - Event emitter for hooks |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 VERSION |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Version 0.2300, released 2016-01-14. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SOURCE |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L<https://github.com/Csson/p5-Map-Metro> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 HOMEPAGE |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
L<https://metacpan.org/release/Map-Metro> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Erik Carlsson <info@code301.com> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Erik Carlsson. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
121
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |