line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Anansi::ScriptComponent; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Anansi::ScriptComponent - A manager template for Perl script interface interactions. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Anansi::Script::Example; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use base qw(Anansi::ScriptComponent); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub validate { |
15
|
|
|
|
|
|
|
my ($self, $channel, %parameters) = @_; |
16
|
|
|
|
|
|
|
return $self->SUPER::validate(undef); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Anansi::Component::addChannel('Anansi::Script::Example', 'VALIDATE_AS_APPROPRIATE' => 'validate'); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
1; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Manages a Perl script's interface interactions with the user providing generic |
26
|
|
|
|
|
|
|
processes to co-ordinate execution argument access and verification and the |
27
|
|
|
|
|
|
|
correct output of concurrent script responses. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
70243
|
use base qw(Anansi::Component); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
592
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 INHERITED METHODS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 addChannel |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Declared in L. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 channel |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Declared in L. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 componentManagers |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Declared in L. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 finalise |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$OBJECT->SUPER::finalise(); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$OBJECT->Anansi::Class::finalise(); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Declared as a virtual method in L. Overridden by this module. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub finalise { |
75
|
0
|
|
|
0
|
1
|
|
my ($self, %parameters) = @_; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 implicate |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Declared as a virtual method in L. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 import |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Declared in L. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 initialise |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$OBJECT->SUPER::initialise(); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Declared as a virtual method in L. Overridden by this module. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub initialise { |
103
|
0
|
|
|
0
|
1
|
|
my ($self, %parameters) = @_; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 old |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Declared in L. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 removeChannel |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Declared in L. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 used |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Declared in L. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 uses |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Declared in L. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 METHODS |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 validate |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
if(1 == Anansi::ScriptComponent::validate($OBJECT, undef)); |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
if(1 == Anansi::ScriptComponent::channel($OBJECT, 'VALIDATE_AS_APPROPRIATE')); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
if(1 == Anansi::ScriptComponent->validate(undef)); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
if(1 == Anansi::ScriptComponent->channel('VALIDATE_AS_APPROPRIATE')); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
if(1 == $OBJECT->validate(undef)); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
if(1 == $OBJECT->channel('VALIDATE_AS_APPROPRIATE')); |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=over 4 |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item self I<(Blessed Hash B String, Required)> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Either an object or a string of this namespace. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item channel I<(String, Required)> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
The abstract identifier of a subroutine. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item parameters I<(Hash, Optional)> |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Named parameters. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=back |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Generic validation for whether a Perl script should be handled by a component. |
171
|
|
|
|
|
|
|
Returns B<1> I<(one)> for yes and B<0> I<(zero)> for no. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub validate { |
177
|
0
|
|
|
0
|
1
|
|
my ($self, $channel, %parameters) = @_; |
178
|
0
|
|
|
|
|
|
my $package = $self; |
179
|
0
|
0
|
|
|
|
|
$package = ref($self) if(ref($self) !~ /^$/); |
180
|
0
|
|
|
|
|
|
return 1; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Anansi::Component::addChannel('Anansi::ScriptComponent', 'VALIDATE_AS_APPROPRIATE' => 'validate'); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 METHODS |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 NOTES |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
This module is designed to make it simple, easy and quite fast to code your |
194
|
|
|
|
|
|
|
design in perl. If for any reason you feel that it doesn't achieve these goals |
195
|
|
|
|
|
|
|
then please let me know. I am here to help. All constructive criticisms are |
196
|
|
|
|
|
|
|
also welcomed. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 AUTHOR |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Kevin Treleaven treleaven I net> |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=cut |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
1; |
209
|
|
|
|
|
|
|
|