line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::RPCPlugin::DispatchMethodList; |
2
|
8
|
|
|
8
|
|
115915
|
use warnings; |
|
8
|
|
|
|
|
32
|
|
|
8
|
|
|
|
|
301
|
|
3
|
8
|
|
|
8
|
|
47
|
use strict; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
171
|
|
4
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
40
|
use Exporter 'import'; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
316
|
|
6
|
|
|
|
|
|
|
our @EXPORT = ('list_methods'); |
7
|
|
|
|
|
|
|
|
8
|
8
|
|
|
8
|
|
330
|
use Dancer::RPCPlugin::PluginNames; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
206
|
|
9
|
8
|
|
|
8
|
|
40
|
use Scalar::Util 'blessed'; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
404
|
|
10
|
8
|
|
|
8
|
|
449
|
use Types::Standard qw/ StrMatch ArrayRef /; |
|
8
|
|
|
|
|
78707
|
|
|
8
|
|
|
|
|
124
|
|
11
|
8
|
|
|
8
|
|
6321
|
use Params::ValidationCompiler 'validation_for'; |
|
8
|
|
|
|
|
18090
|
|
|
8
|
|
|
|
|
2533
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Dancer::RPCPlugin::DispatchMethodList - Class for maintaining a global methodlist. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Dancer::RPCPlugin::DispatchMethodList; |
20
|
|
|
|
|
|
|
my $methods = Dancer::RPCPlugin::DispatchMethodList->new(); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$methods->set_partial( |
23
|
|
|
|
|
|
|
protocol => <jsonrpc|restrpc|xmlrpc>, |
24
|
|
|
|
|
|
|
endpoint => </configured>, |
25
|
|
|
|
|
|
|
methods => [ @method_names ], |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# .... |
29
|
|
|
|
|
|
|
my $method_list = $methods->list_methods(protocol => <any|jsonrpc|restrpc|xmlrpc>); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
This class implements a singleton that can hold the collection of all method names. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 my $dml = Dancer::RPCPlugin::DispatchMethodList->new() |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head3 Parameters |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
None! |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head3 Responses |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$_singleton = bless $parameters, $class; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $_singleton; |
48
|
|
|
|
|
|
|
sub new { |
49
|
46
|
100
|
|
46
|
1
|
5945
|
return $_singleton if $_singleton; |
50
|
|
|
|
|
|
|
|
51
|
8
|
|
|
|
|
33
|
my $class = shift; |
52
|
8
|
|
|
|
|
49
|
$_singleton = bless {protocol => {}}, $class; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 $dml->set_partial(%parameters) |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head3 Parameters |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Named, list: |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=over |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item protocol => <jsonrpc|restrpc|xmlrpc> (required) |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item endpoint => $endpoint (required) |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item methods => \@method_list |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=back |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head3 Responses |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$self |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub set_partial { |
78
|
45
|
|
|
45
|
1
|
15082
|
my $self = shift; |
79
|
45
|
|
|
|
|
317
|
my $pn_re = Dancer::RPCPlugin::PluginNames->new->regex; |
80
|
45
|
|
|
|
|
603
|
my %args = validation_for( |
81
|
|
|
|
|
|
|
params => { |
82
|
|
|
|
|
|
|
protocol => {type => StrMatch[ qr/^$pn_re$/ ], optional => 0}, |
83
|
|
|
|
|
|
|
endpoint => {type => StrMatch[ qr/^.*$/] , optional => 0}, |
84
|
|
|
|
|
|
|
methods => {type => ArrayRef}, |
85
|
|
|
|
|
|
|
}, |
86
|
|
|
|
|
|
|
)->(@_); |
87
|
45
|
|
|
|
|
114103
|
$self->{protocols}{$args{protocol}}{$args{endpoint}} = $args{methods}; |
88
|
45
|
|
|
|
|
4200
|
return $self; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 list_methods(@parameters) |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Method that returns information about the dispatch-table. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head3 Parameters |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Positional, list |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item 1. $protocol => undef || <any|jsonrpc|restrpc|xmlrpc> (optional) |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=back |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head3 Responses |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
In case of no C<$protocol>: |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
{ |
110
|
|
|
|
|
|
|
xmlrpc => { |
111
|
|
|
|
|
|
|
$endpoint1 => [ list ], |
112
|
|
|
|
|
|
|
$endpoint2 => [ list ], |
113
|
|
|
|
|
|
|
}, |
114
|
|
|
|
|
|
|
jsonrpc => { |
115
|
|
|
|
|
|
|
$endpoint1 => [ list ], |
116
|
|
|
|
|
|
|
$endpoint2 => [ list ], |
117
|
|
|
|
|
|
|
}, |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
In case of specified C<$protocol>: |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
{ |
123
|
|
|
|
|
|
|
$endpoint1 => [ list ], |
124
|
|
|
|
|
|
|
$endpoint2 => [ list ], |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub list_methods { |
130
|
6
|
|
|
6
|
1
|
21737
|
my $self; |
131
|
6
|
100
|
|
|
|
56
|
if (blessed($_[0])) { |
132
|
5
|
|
|
|
|
16
|
$self = shift; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
else { |
135
|
1
|
|
|
|
|
4
|
$self = $_singleton; |
136
|
|
|
|
|
|
|
} |
137
|
6
|
|
|
|
|
60
|
my $pn_re = Dancer::RPCPlugin::PluginNames->new->regex; |
138
|
6
|
|
|
|
|
165
|
my ($protocol) = validation_for( |
139
|
|
|
|
|
|
|
params => [ |
140
|
|
|
|
|
|
|
{ |
141
|
|
|
|
|
|
|
type => StrMatch [qr/^(?:any|$pn_re)$/], |
142
|
|
|
|
|
|
|
default => 'any', |
143
|
|
|
|
|
|
|
}, |
144
|
|
|
|
|
|
|
], |
145
|
|
|
|
|
|
|
)->(@_); |
146
|
|
|
|
|
|
|
|
147
|
6
|
100
|
|
|
|
12833
|
if ($protocol eq 'any') { |
148
|
4
|
|
|
|
|
363
|
return $self->{protocols}; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
else { |
151
|
2
|
|
|
|
|
144
|
return $self->{protocols}{$protocol}; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
1; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 COPYRIGHT |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
(c) MMXVI - Abe Timmerman <abeltje@cpan.org> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |