| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Run::Base::PlugHelpers; |
|
2
|
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
14161
|
use strict; |
|
|
17
|
|
|
|
|
64
|
|
|
|
17
|
|
|
|
|
500
|
|
|
4
|
17
|
|
|
17
|
|
94
|
use warnings; |
|
|
17
|
|
|
|
|
36
|
|
|
|
17
|
|
|
|
|
593
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Test::Run::Base::PlugHelpers - base class for Test::Run's classes with |
|
9
|
|
|
|
|
|
|
pluggable helpers. |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
|
12
|
|
|
|
|
|
|
|
|
13
|
17
|
|
|
17
|
|
129
|
use MRO::Compat; |
|
|
17
|
|
|
|
|
31
|
|
|
|
17
|
|
|
|
|
455
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
17
|
|
|
17
|
|
196
|
use Carp; |
|
|
17
|
|
|
|
|
41
|
|
|
|
17
|
|
|
|
|
1254
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
17
|
|
|
17
|
|
92
|
use Moose; |
|
|
17
|
|
|
|
|
33
|
|
|
|
17
|
|
|
|
|
120
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
extends('Test::Run::Base'); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
17
|
|
|
17
|
|
122025
|
use Test::Run::Base::Plugger; |
|
|
17
|
|
|
|
|
63
|
|
|
|
17
|
|
|
|
|
212
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has '_plug_helpers' => (is => "rw", isa => "HashRef", |
|
25
|
|
|
|
|
|
|
lazy => 1, default => sub { +{} }, |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 $self->register_pluggable_helper( { %args } ) |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Registers a pluggable helper class (commonly done during initialisation). |
|
31
|
|
|
|
|
|
|
%args contain the following keys: |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=over 4 |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item * 'id' |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
The 'id' identifying this class type. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item * 'base' |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
The base class to use as the ultimate primary class of the plugin-based class. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item * 'collect_plugins_method' |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
The method from which to collect the plugins. It should be defined for every |
|
46
|
|
|
|
|
|
|
base class in the hierarchy of the main class (that instantiates the helpers) |
|
47
|
|
|
|
|
|
|
and is traversed there. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=back |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub register_pluggable_helper |
|
54
|
|
|
|
|
|
|
{ |
|
55
|
265
|
|
|
265
|
1
|
3463
|
my ($self, $args) = @_; |
|
56
|
|
|
|
|
|
|
|
|
57
|
265
|
|
|
|
|
395
|
my %plug_helper_struct; |
|
58
|
|
|
|
|
|
|
|
|
59
|
265
|
|
|
|
|
597
|
foreach my $key (qw(id base collect_plugins_method)) |
|
60
|
|
|
|
|
|
|
{ |
|
61
|
792
|
100
|
|
|
|
2582
|
my $value = $args->{$key} |
|
62
|
|
|
|
|
|
|
or confess "\"$key\" not specified for register_pluggable_helper"; |
|
63
|
|
|
|
|
|
|
|
|
64
|
789
|
|
|
|
|
1983
|
$plug_helper_struct{$key} = $value; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
262
|
|
|
|
|
10394
|
$self->_plug_helpers()->{$plug_helper_struct{'id'}} |
|
68
|
|
|
|
|
|
|
= \%plug_helper_struct; |
|
69
|
|
|
|
|
|
|
|
|
70
|
262
|
|
|
|
|
677
|
return; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 $self->calc_helpers_namespace($id) |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Calc the namespace to put the helper with the ID C<$id> in. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub calc_helpers_namespace |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
203
|
|
|
203
|
1
|
663
|
my ($self, $id) = @_; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
return |
|
84
|
203
|
|
|
|
|
1114
|
$self->helpers_base_namespace() . "::Helpers::" . ucfirst($id) |
|
85
|
|
|
|
|
|
|
; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 $self->create_pluggable_helper_obj({ id => $id, args => $args }) |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Instantiates a new pluggable helper object of the ID $id and with $args |
|
91
|
|
|
|
|
|
|
passed to the constructor. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub create_pluggable_helper_obj |
|
96
|
|
|
|
|
|
|
{ |
|
97
|
203
|
|
|
203
|
1
|
487
|
my ($self, $args) = @_; |
|
98
|
|
|
|
|
|
|
|
|
99
|
203
|
|
|
|
|
576
|
my $id = $args->{id}; |
|
100
|
|
|
|
|
|
|
|
|
101
|
203
|
|
|
|
|
8534
|
my $plug_struct = $self->_plug_helpers()->{$id}; |
|
102
|
203
|
100
|
|
|
|
619
|
if (!defined($plug_struct)) |
|
103
|
|
|
|
|
|
|
{ |
|
104
|
1
|
|
|
|
|
124
|
confess "Unknown Pluggable Helper ID \"$id\"!"; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my $plugger = Test::Run::Base::Plugger->new( |
|
108
|
|
|
|
|
|
|
{ |
|
109
|
|
|
|
|
|
|
base => $plug_struct->{base}, |
|
110
|
202
|
|
|
|
|
1020
|
into => $self->calc_helpers_namespace($id), |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
$plugger->add_plugins( |
|
115
|
|
|
|
|
|
|
$self->accum_array( |
|
116
|
|
|
|
|
|
|
{ |
|
117
|
|
|
|
|
|
|
method => $plug_struct->{collect_plugins_method} |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
) |
|
120
|
202
|
|
|
|
|
3515
|
); |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
return |
|
123
|
|
|
|
|
|
|
$plugger->create_new( |
|
124
|
|
|
|
|
|
|
$args->{args}, |
|
125
|
202
|
|
|
|
|
1113
|
); |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 $self->helpers_base_namespace() |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
B<TO OVERRIDE>: this method determines the base namespace used as the |
|
131
|
|
|
|
|
|
|
base for the pluggable helpers classes. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1; |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
__END__ |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L<Test::Run::Base>, L<Test::Run::Obj>, L<Test::Run::Core> |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 LICENSE |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This file is freely distributable under the MIT X11 license. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
L<http://www.opensource.org/licenses/mit-license.php> |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 AUTHOR |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Shlomi Fish, L<http://www.shlomifish.org/>. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
|
155
|
|
|
|
|
|
|
|